Can a Teensy re-flash itself from an SD card?

Status
Not open for further replies.

twpayne

New member
The device I'm working on is based on a Teensy 3.1 and has an SD card reader. We'll be releasing new firmware for the device over time as we fix problems and make improvements. It would be really really nice if the Teensy could read a firmware file off the SD card and re-flash itself.

Is this realistically possible? I suspect it is not, but I wanted to make sure.

Cheers,
Tom
 
Its possible to write code that programs flash, main restriction is it must run from RAM.
This code can read new firmware from sdcard and program it into flash.

I dont think there are any libraries available for what you want, but as far as I can see
it should definetly be possible without any modifications to the basic Teensy 3 setup.
 
Loading code from SD card is do-able, my understanding is that most people actually doing it are using http://www.utasker.com/index.html, though there are a couple of 'roll your own' projects floating around. Key element is how likely the unit is to be bricked if something happens after it's lobotomised itself but before new code is written. My understanding is that utasker handles that by not touching the core boot area and keeping part of itself there, impacting boot speed and total program space. Other choice is to work in only half the memory space at a time, which is safe but wastes half the flash space the rest of the time.

Teensy handles it by having an offboard chip, but that currently only expects data via USB, with expansion to support RF and SD card loading being a requested feature on Paul's to-do list but not anywhere near the top unfortunately. Current user update method people are using is to leave the USB port accessible and provide the users with a software package that uses https://www.pjrc.com/teensy/loader_cli.html to send a hex file to the teensy. While not complex for the end user does have multiple steps and mean drivers needs to be installed. Also leaves things vulnerable to OS changes crippling you without warning so not at all a perfect solution.
 
The concept, I think, is to compile for run-in-RAM and execute the SD-to-flash copy out of RAM. If the SD-to-flash code is in sector n of flash, one should be able to run code out of flash not RAM for altering other sectors. I've done that with sector 0 for boot and network download code, and all apps always link for sector 1 and up.
 
Status
Not open for further replies.
Back
Top