05-02-2020, 12:51 PM
Quote:For now, I'm doing some researches on another options : The application is responsible for the download of the new firmware image and for storing it in the memory. Then, the bootloader (which does not embed the ble stack) can detect that a new image is available, swap it with the current one and provide a way to rollback the update if it fails.
The advantage is that the firmware is free to use the BLE stack of its choice, but of course, it is still possible to 'brick' the watch if you flash a firmware that does not allow to OTA another firmware...
Hi @JF002
At work we use mbed-os. ARM has an open source bootloader that does exactly that what you described.
The app can pull in a new firmware image by any means (cellular, bluetooth, CAN, ...) and write it to internal flash or some kind of "external" storage such as SPI flash, etc.
The bootloader is rather basic in that it doesn't rely on any kind data carrier, but only on storage.
This way the bootloader is compatible with a wide range of apps, only minimal configuration is needed plus maybe some tweaking as you would like to have it. It also helps keeping bugs away from the bootloader.
The bootloader does have a few tricks to make sure everything goes wrong. During fwupdate, it always checks the active application for legibility. Next it runs over all fwupdate candidates and checks for the one with highest timestamp. If the timestamp is higher than that of the active application, the candidate is selected. Note that the timestamp is something you have completely control over when you "download" the fwupdate candidate into your device. It's not the application version, so it actually allows to flash older firmware as long as you download it with a newer timestamp. Before the candidate is actually being flashed, t bootloader will perform SHA check on the full firmware candidate data. This takes a few seconds depending on the size of the application.
My experience so far is that we've used it for hundreds of OTA updates without a problem. The binary size is about 30k, that leaves enough for complex applications. However I know that not everyone is keen on ARM's mbed-os due to "vendor lock-in".
Here is the repo: https://github.com/ARMmbed/mbed-bootloader