Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Teensy 3.6 and FSEC security register

  1. #1

    Teensy 3.6 and FSEC security register

    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

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,932
    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

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,098
    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.

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,932
    Quote Originally Posted by PaulStoffregen View Post
    Yes, Defragster is correct, you can set the security lock by just editing that file.
    ...
    Did a /PaulStoffregen/cores/pull/520 to add comment wording to cover 3.5 and 3.6

    Code:
    // Flash Security Setting. On Teensy 3.2, you can lock the MK20 chip to prevent
    // ( The same applies to the Teensy 3.5 and Teensy 3.6 for their processors )

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,932
    @Paul - saw github update on PR #520 - Cool

    Does the same FSEC exist in and work on T_LC?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •