3 ms·
Saving the entry where the bootloader should jump in some fixed location is not necessary. In a firmware update solution that I have written many years ago, th
by adrian_b 5y ago
Saving the entry where the bootloader should jump in some fixed location is not necessary.
In a firmware update solution that I have written many years ago, there were multiple flash sectors where the firmware could be located.
In each flash sector there was a word reserved for a counter that counted how many firmware updates had been done to the device, i.e. every time when the device received a new firmware image that was written in the flash, the counter was incremented from the value written in the flash sector for the current firmware version.
The bootloader verified the sectors that could contain a firmware image for integrity by computing a hash, then among the valid firmware images it chose the one with the highest counter, i.e. the most recent update. The firmware entry address was stored at a fixed offset from the start of the flash sector.
So there were no flash writes, except for the single sector written by each firmware update, and the counters that stored the number of flash sector writes could also be used to check whether the flash endurance limit might be reached.
Because there were multiple addresses in the flash where the firmware could be located, it might have been useful if the firmware images could have been relocatable.
Without such an option, every time when the firmware was built, multiple binary images were created with the appropriate linker scripts, each linked for one of the possible flash sectors.
The multiple images were concatenated into a single fat binary. When a device received a command for firmware update, it chose an available flash sector and then, while receiving the firmware file, it ignored the parts of the file intended for other flash sectors and it wrote in the flash only the parts intended for the locally chosen sector.
Because the devices were controlled over a relatively fast communication link, sending a fat binary did not cause any visible delay, because writing the flash was slower than the speed at which the firmware image could be sent.
If an extremely slow serial interface would have been used instead, it is likely that a more complex communication protocol would have been required, to interrogate the device about available flash sectors and then send only the suitable firmware image.