My own bootloader

Status
Not open for further replies.

Remz

New member
Hi guy's.

I am planning to try to reprogram my teensy through an IR port. My real goal is to program quickly over 500 teensy with only one IR source that will "broadcast" the .hex file instead of having to plug each of them individually to upload my code each time i found a new bug in the system..

To do so, i was planning to write my own software bootloader that could be right on my main teensy sketch.

So: in my main teensy sketch i will write a code that receive the .hex file through a serial port or an IR lib or any where else, and write this program in the user-writable zone of the flash, compute and check the a CRC, and after that jump to that code.

Normally this should work, but i dont know enough the teensy (i am quite new using the Teensy and there is some things with that "hardware bootloader" that i am unsure about) and i would like to have your advise on this. Are the linker files available to put a function on a precise address in the flash to hardcode the jump? Do my concept can work? what about the "double declaration" of all the "teensy" header when i am loading the bootloader and after jumping to the new "code" and there the serial.begin() is called again?

Thank you :)
 
There are plenty of topics on thsi forum reagarding different ways to program Teensy, none are supported by pjrc and can brick your teensy.

Writing your own bootloader is a hugeeee effort, I don't know what do you mean with hardware bootloader and you might be confused on how Teensys work....

Check this topics:

https://forum.pjrc.com/threads/29607-Over-the-air-updates?highlight=card+flash

https://forum.pjrc.com/threads/24385-Flash-Teensy-3-0-from-sd-card

I would think that IR is pretty unreliable for transfering data, you may consider using a pi zero on each teensy and having the pi zero flash the firmware....
 
Remz: You do know that the Teensy 2 and Teensy 3 (and LC) have different bootloading techniques?

With AVRs, I did an en-masse flash program boards - no special boot needed. Just serial TX to all boards and RX from just one. All boards were identical, and didn't get errors.

But Teensy 3 uses a special protocol via USB. This same scheme could be done with Teensy, by using a hardware serial port on each Teensy board. There is a small microprocessor on the Teensy 3 runs a reset/power-on and copies bootloader code to the main ARM CPU and causes that to run.

IR is typically a 64KHz carrier in IR, and an NRC serial data stream on-off keys the IR carrier, and that stream is 1Kbps in say, TV remotes. Custom work to go faster and the key is the IR receiver which is a chip/die with optics and a bandpass filter and amplifier - essential to a practical solution.

As noted in post #2, some folks have done Teensy 3 remote bootloaders, usually wireless. The concept is that the boot loader is code in an application, not a classic bootloader in a special place. The USB port isn't normally used.
There are several techniques to do this. The concept can be that an in-app bootloader (reflasher) erases and puts new code in different flash sectors and leaves a non-volatile marker in flash as to whether A or B should run. The exception vectors have to be in the new code, and the ARM's register pointing to the vectors has to be altered. This stuff is very hard to learn and easy to implement! I've done this A/B scheme for an ARM but not Teensy.

A more brute force is to put the new code in a uSD card or an SPI flash chip added to the hardware.
 
Last edited:
Status
Not open for further replies.
Back
Top