Remote code update


Is there any way to have the running Teensy code (on 4.1) update its own code. in other words looking for a fielded unit to get new firmware from the network, then store that and run the new downloaded code on a reboot. EG remote update?

I am guessing no, but curios if anyone has ideas on how to accomplish this.
The standard FlasherX library is designed for an SD card or serial data source but ultimately all it really needs is a copy of the new firmware somere in memory. If you look around there are examples of how to use flasherX to perform an update via a web page upload button. Using a raw TCP socket should also be fairly easy to do.

The default for a T4.1 is to create a temporary buffer for the new firmware towards the top of flash, once all the firmware file has arrived and been verified this is then copied to the boot location. This is good because there is normally lots of flash free but it is also slow. Also if you use the EEPROM library you may need to change the address it uses, the check to find a free part of flash gets confused by the eeprom data.

The library has an option to use RAM2 / DMAMEM for the buffer but depending on the application and image size that may not be an option.
If you have psram fitted then modifying the code to use that is simple enough and will give a significant speed up to the update process in comparison to using flash.

If you want to be paranoid I did also post a while back how to set up a basic bootloader. If you use flasherX in the normal way and power fails or something else goes wrong half way through an upgrade then you end up with a dead system and need to use the USB port to recover.
It's not fun but it is possible to set up a bootloader system so that in the event of an update failure the system falls back to a bare bones upgrade application that allows you to upload the firmware again and recover. For a commercial system system that supports upgrades in the field this is a must have feature, for any other application it's normally not worth the hassle.