Update firmware over usb/serial, without dfu-util

Hi,

This will be my first topic on this community, but I have been working on my spark cores for a few months. This community has helped me quiet a few times, so I figured it is time to start contributing.

I have been wondering wether it would be possible to update the core firmware without the use of dfu-util, and found out it is actually not that difficult. The only change required in the core-firmware was creating 3 public functions with the same functionality as Spark_Prepare_For_Firmware_Update, Spark_Finish_Firmware_Update and Spark_Save_Firmware_Chunk.

After that I could call these functions from my own application firmware, which holds the code to communicate over the usb serial connection. From the connected computer I used some nodejs code that chunks the core-firmware.bin file and sends it.

I can imagine this could be very useful for the spark-cli, because it wouldn’t require dfu-util to flash the core. For this to be possible, some small changes to the bootloader firmware would be required.

My c++ skills are very basic, and as a new-comer, I feel out-of-place to be proposing changes to the core bootloader, but I would love to contribute to this wonderful product if anyone is interested. I haven’t looked at any of the code of the spark-cli, but I am positive I could made the changes required once the boot loader has been updated.

2 Likes

Ymodem protocol has been ported to the core and available in the feature/hal branch. This should work via USB as well so there’s no need to rewrite except for getting into the mode :wink:

Hi Kenneth, thanks for your fast reply. I haven’t yet taken the time to compile and flash the new hal branch, but I am very interested to see what you guys have achieved so far. I will give it a go in the near future. Good to hear there are some new features to be expected once it is released.
To be honest, I hadn’t heard of the Ymodem protocol, and I also can’t find much in combination with nodejs, but do I understand correctly that it will allow updating the firmware without the use of external tools like dfu-util?

(In my case, I want to be able to update my core from the config utility (using node-webkit) I am writing, without the requirement of installing anything. The solution I created now works fine, but naturally I’d rather not change to much in the core-firmware.
Thanks again, also for all your posts regarding the udp issues, it helped me a lot!
)

Hey @kennethlimcp @mdma

Any update about the Ymodem firmware update support? Is it already supported in the latest 0.4.3 develop firmware for the Photon?

And, will it work by using the RX/TX lines AND also the USB port? or only one of these two options?.

Apologies for the delay, only just saw this. ymodem works over the Serial port only for the time being.