Teensy 3.6 and FSEC security register

LuisHS

Well-known member
Hi.

Is there any possibility to change the security of the FSEC registry on the Teensy 3.6?
I have seen that there is a file for the MK20, but not the same for the MK66.

I would like to protect against reading a program created for Teensy 3.6 that is then loaded onto a board with the MK66, I would also like to disable the mass erase option so that another program cannot be loaded on the same microcontroller. I have read the documentation for the MK66 and see that all of this can be done by setting the FSEC register.

Regards
 
In searching and reading the old thread it wasn't clearly noted the same works - except in ref to a T_3.5.

In spite of the name : cores\teensy3\mk20dx128.c

That file has code and #ifdef for all the kinetis ( T_3.x ) family of MCU's and that applies to them all as KINETISK and even the T_LC as KINETISL

The T_3.6 in that file is for example :: #if defined(__MK66FX1M0__)

If that is indeed the case as it seems then an update to this comment block would be appropriate:
Code:
// Flash Security Setting. On Teensy 3.2, you can lock the MK20 chip to prevent
// anyone from reading your code.  You CAN still reprogram your Teensy while
// security is set, but the bootloader will be unable to respond to auto-reboot
// requests from Arduino. Pressing the program button will cause a full chip
// erase to gain access, because the bootloader chip is locked out.  Normally,
// erase occurs when uploading begins, so if you press the Program button
// accidentally, simply power cycling will run your program again.  When
// security is locked, any Program button press causes immediate full erase.
// Special care must be used with the Program button, because it must be made
// accessible to initiate reprogramming, but it must not be accidentally
// pressed when Teensy Loader is not being used to reprogram.  To set lock the
// security change this to 0xDC.  Teensy 3.0 and 3.1 do not support security lock.
#define FSEC 0xDE
 
Yes, Defragster is correct, you can set the security lock by just editing that file.

But you can't disable mass erase that way. No matter what you set in that file, the bootloader will always program one of the FSEC bits to 0 to prevent accidentally disabling mass erase.

It is still possible, but difficult, to disable mass erase. To do so, you would need to write code in your program to erase the flash sector with FSEC, and then write it to the data you want. If you do this, the bootloader will be permanently locked out of access. Well, unless your code has some provision for again erasing FSEC so mass erase becomes possible again.
 
Back
Top