How to recover from Teensy 4.1 flash memory chip failure without pushing PROGRAM button

lincolnwang

New member
Hi,

I have a Teensy 4.1 was unplugged during code uploading. When it is plugged again, I can see the RED LED is having a 4 quick blink pattern. According to Paul here, it indicates failure with the flash memory chip. Normally when I upload program, I can see "Found HalfKay Bootloader" and the board automatically enters bootloader mode. But this time all my upload attempt failed until I physically push the PROGRAM button, then the RED LED turns solid again and the upload is successful. But what if I don't have access of the Teensy, let's say a power failure during remote firmware upload. Is there way to recover it?

Thanks

Lincoln
 
For automatic uploading (no button press required) to work, the Teensy has to be running a program based on the Teensyduino core library. This is because it includes special background code to detect when the host PC want to upload a new program. If the program has crashed or the flash memory is corrupted and there's no program to run, that's when you have to use the PROGRAM button. But once you've uploaded a new program (and it works without crashing) you shouldn't need to use the button again.
 
I see. So when we integrate Teensy into an embedded system and attempt to upload firmware update to it remotely, we will have to connect the PROGRAM pin to a GPIO so the host can control it in case of flash memory corruption. Make sense?
 
you can also put Teensy into 'original' state by pressing the program button until red light shows up (around 15 s). you release the program button and teensy wipes out all memory and installs original blink program.
 
I see. So when we integrate Teensy into an embedded system and attempt to upload firmware update to it remotely, we will have to connect the PROGRAM pin to a GPIO so the host can control it in case of flash memory corruption. Make sense?
No? As long as it's actively running a program auto-uploading should work. If it doesn't work the program has crashed, in which case it won't be able to trigger a GPIO anyway.
 
No? As long as it's actively running a program auto-uploading should work. If it doesn't work the program has crashed, in which case it won't be able to trigger a GPIO anyway.
Sorry for the confusion, I meant the GPIO from a single board computer that runs the uploading program.
 
I see. So when we integrate Teensy into an embedded system and attempt to upload firmware update to it remotely, we will have to connect the PROGRAM pin to a GPIO so the host can control it in case of flash memory corruption. Make sense?
Not when the Teensy is properly executing an uploaded program with active USB as it will respond to the bootloader request signal over USB.

However, if the Teensy ever fails to be in that active state - then Yes, access to the Button, or the Program pin would be required to activate the bootloader. If the PCB Button won't be accessible - then an auxiliary button to wire the Program pin to GND would be needed to recover for upload
 
Sorry for the confusion, I meant the GPIO from a single board computer that runs the uploading program.
Probably a good idea "just in case", I would suggest some sort of open-drain driver or an optocoupler rather than directly connecting it to a GPIO though (the PROGRAM pin is active low).
 
Back
Top