I, too, am interested in performing 'Over the Air' firmware updates of the Teensy - except replace 'Over the Air' with CANBus, since I am placing the Teensy 3.6 in an automotive environment.
I began with the flash code provided by Jon Zeeff for Teensy 3.0/3.1/3.2. Thank you Jon! Refer to:
https://forum.pjrc.com/threads/29607-Over-the-air-updates
However, this code did not run on the Teensy 3.5 or 3.6.
After pouring over the Kinetis manuals, I discovered the Teensy 3.5/3.6 use a different flash type (FTFE, not FTFA), and require the flash to be programmed in 8 byte chunks,
represented by a different flash command code. After making this change, the example flash code attached here seems to be working on the Teensy 3.5.
However, more challenges ahead for the Teensy 3.6. As is the case when writing to EEPROM, the T3.6 has issues writing to program flash whenever it runs at > 120MHz.
Thankfully, Paul has added core routines kinetis_hsrun_enable/kinetis_hsrun_disable, which are easily called before issuing flash commands. Thanks Paul!
This got the flash write to, uh, sort of work on the Teensy 3.6. If the bytes written into program flash are read back using the 'Program Check' command, all seems well. However, if read back using simple reads via the processor, as you might read a data variable, the results are -usually- incorrect.
Some reasons why this might happen (though I have not figured out why they might be the case in the example):
1) The cache is not being cleared.
2) It is illegal to read while flashing/erasing the same section.
3) The sector is in execute only mode.
Has anyone else successfully re-flashed the program flash on the Teensy 3.6?
Does anyone see an issue with the code or have other suggestions? I'd be happy to try them out. And, I will continue to try to figure out what's going on...
WARNING: FLASHING YOUR PROGRAM CODE CAN BRICK YOUR TEENSY. ESPECIALLY addresses 0x400-0x40F.
The test program attempts to write at the program memory midpoint.
Thanks!
I began with the flash code provided by Jon Zeeff for Teensy 3.0/3.1/3.2. Thank you Jon! Refer to:
https://forum.pjrc.com/threads/29607-Over-the-air-updates
However, this code did not run on the Teensy 3.5 or 3.6.
After pouring over the Kinetis manuals, I discovered the Teensy 3.5/3.6 use a different flash type (FTFE, not FTFA), and require the flash to be programmed in 8 byte chunks,
represented by a different flash command code. After making this change, the example flash code attached here seems to be working on the Teensy 3.5.
However, more challenges ahead for the Teensy 3.6. As is the case when writing to EEPROM, the T3.6 has issues writing to program flash whenever it runs at > 120MHz.
Thankfully, Paul has added core routines kinetis_hsrun_enable/kinetis_hsrun_disable, which are easily called before issuing flash commands. Thanks Paul!
This got the flash write to, uh, sort of work on the Teensy 3.6. If the bytes written into program flash are read back using the 'Program Check' command, all seems well. However, if read back using simple reads via the processor, as you might read a data variable, the results are -usually- incorrect.
Some reasons why this might happen (though I have not figured out why they might be the case in the example):
1) The cache is not being cleared.
2) It is illegal to read while flashing/erasing the same section.
3) The sector is in execute only mode.
Has anyone else successfully re-flashed the program flash on the Teensy 3.6?
Does anyone see an issue with the code or have other suggestions? I'd be happy to try them out. And, I will continue to try to figure out what's going on...
WARNING: FLASHING YOUR PROGRAM CODE CAN BRICK YOUR TEENSY. ESPECIALLY addresses 0x400-0x40F.
The test program attempts to write at the program memory midpoint.
Thanks!