Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

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

  1. #1
    Junior Member
    Join Date
    Apr 2015
    Posts
    4

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

    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

  2. #2
    Senior Member
    Join Date
    Aug 2013
    Location
    Gothenburg, Sweden
    Posts
    295
    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.

  3. #3
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    Search this forum for posts from uTasker.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    6,874
    ...or alternatives which are not "ready to use" but possible ;-)

  5. #5
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,925
    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.

  6. #6
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •