🛠 Récupération, sécurisation du code et gestion de la fin de vie (EOL)
Objectives
Three production-level skills for using a Teensy 3.2: (1) recovering a board that refuses to reprogram, (2) securing your code against reading (FSEC mode), (3) living with a discontinued board — understanding why, anticipating failures, and knowing when to migrate to Teensy 4.0.
1) Recovery: why the Teensy is almost impossible to brick
The HalfKay bootloader lives in a physically separate chip from the MK20DX256: a failed flash, a buffer overflow, or code that disables interrupts cannot destroy the bootloader. Recovery scales, from the gentlest to the most radical:
- Program Button: hold it down (or connect the Program pin to GND) then replug/restart the upload — Teensy Loader enters programming mode.
- teensy_reboot: from the command line,
teensy_rebootasks the running program to enter programming mode via USB — useful in continuous integration scripts. - Teensy Loader CLI (<https://www.pjrc.com/teensy/loader_cli.html>): flash without an IDE, in a Makefile pipeline.
- FSEC Secure Mode: if you had enabled flash locking (anti-read protection), the Program button becomes a complete chip erase — the board becomes programmable again, but the code is lost. This is the intended behavior: security has a price.
# Chaine de compilation 100 % en ligne de commande (livree avec Teensyduino) :
# Makefile : {Arduino}/hardware/teensy/avr/cores/teensy3/Makefile
make -C build -f makefile.mk # compile
teensy_post_compile -file=firmware -path=. -tools=/path/to/arduino/hardware/teensy
teensy_reboot # redemarre la carte en mode prog
# Alternative : PlatformIO ou Visual Micro (Visual Studio, commercial)
2) Securing your code
The FSEC secure mode bit of the MK20DX256 locks flash reading via the debug interface — your algorithms are not extractable. Assumed consequence: no more soft reprogramming, the Program button erases everything. Test first on a demo board, never on the only board in the field.
3) Living with an EOL board
The facts, from the PJRC shop page: the last batch sold in October 2023 after an 11-year career — NXP could not help maintain the supply of the MK20DX256; status "Out Of Stock" with a physical stock recount on April 22, 2026, and limited occasional restocks (July 7, 2025, October 13, 2025 — limit 5 pieces/person). Strategy:
- Buy your spare parts now: every unit in stock is the last generation.
- Migrate if you are designing new hardware: PJRC recommends Teensy 4.0; same Teensyduino ecosystem, much faster Cortex-M7.
- Keep the build environment: keep a copy of the Teensyduino version that compiled your project — boards in circulation will live longer than download mirrors.
- Memory: PJRC itself warns that the 3.2 "does not have enough memory for all applications and O_C applets" (Ornament and Crime, the iconic open-source Eurorack synthesizer/sequencer for the board, moved to Teensy 4.x with the Phazerville fork) — if your firmware is close to 256 KB of flash or 64 KB of RAM, that is the migration signal.
Expected Verification
Complete exercise on a test board: upload code that disables everything (infinite loop disabling interrupts) → the Program button puts the board back into flashing mode in 2 seconds, proof of HalfKay isolation. Enable FSEC → re-uploading is refused until you press Program (complete erase) → the board returns blank and programmable. Compile your project via the Makefile + loader_cli chain without opening the IDE.
Common Errors
- Believing the board is dead when the cable is charge-only or the wrong board type is selected — before any heavy diagnostic, change the cable and port.
- Enabling FSEC on the only copy of a finished project without saving the firmware: erasing via the Program button is irreversible.
- Expecting unlimited restocking: the 3.2 is EOL; drops limited to 5 pieces do not fund a production fleet.
- Reprogramming a fleet with a recent Teensyduino version without reviewing breaking changes (MIDI pitch bend 1.41, etc.) on a pilot board.
- Confusing the Program and Reset pins: the Teensy 3.2 has no reset button — it is Program, and the corresponding pin on the board edge.
Other tutorials for this board
- Premiers pas sur la Teensy 3.2 : Teensyduino, HalfKay et premier Blink
- Broches, ADC 13 bits, DAC 12 bits et PWM : dompter les E/S de la Teensy 3.2
- Un instrument MIDI USB en 10 minutes : Bounce, boutons et règle d'or du drain
- Audio Shield SGTL5000 : boucle stéréo 44,1 kHz et outil de conception graphique
- OctoWS2811 : piloter 8 rubans WS2812 en parallèle par DMA (presque zéro CPU)
- Timers matériels, interruptions imbriquées et FASTRUN : la vitesse Cortex-M4
Code examples for this board
clignotante.inoArduinotouche-capacitive.inoArduinoanalogique-12-bits.inoArduinomidi-piano.inoArduinopwm-respiration.inoArduinoservo-angle.inoArduino