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

Thread: Teensy 3.0/3.1 Lock Bits and Reprogramming

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    2

    Teensy 3.0/3.1 Lock Bits and Reprogramming

    Are there lock bits on the Teensy 3.0/3.1 like with the Teensy++ 2.0?

    Is there a way to require pressing the reset button in order to reprogram?

    I noticed that there is no 72 MHz for Teensy 3.1 (see image). I'm running Teensyduino 1.18 with Arduino 1.0.5-r2 on Windows 7. Am I missing something?

    Click image for larger version. 

Name:	teensy31.png 
Views:	204 
Size:	10.3 KB 
ID:	1706

  2. #2
    Senior Member
    Join Date
    Jun 2013
    Location
    So. Calif
    Posts
    2,828
    The 96MHz mode is used on Teensy 3.x

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    2
    The standard clock rate for the Teensy 3.1 is 72 MHz, but is not listed as an option. 96 MHz is overclocked. Bad things happen when you overclock a chip I want to avoid those problems.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,942
    Quote Originally Posted by Sc00bz View Post
    Are there lock bits on the Teensy 3.0/3.1
    No. This is planned for a future release, but for now it's not supported.

    Is there a way to require pressing the reset button in order to reprogram?
    You can edit the core library. Just remove the call to _teensyduino_reboot().

    I noticed that there is no 72 MHz for Teensy 3.1
    This too is planned, but not for some time. There's a lot of code which depends on a 48 or 24 MHz I/O clock.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,942
    Quote Originally Posted by Sc00bz View Post
    Bad things happen when you overclock a chip I want to avoid those problems.
    All the Freescale Kinetis K20 chips are made with the same 90 nm silicon process using exactly the same ARM CPU core and different mixes of same peripherals and memory. The higher end chips have slightly different bus structure. The 72 MHz part is the lowest spec part with that tightly coupled RAM structure. They all have the same flash memory, but faster parts have bigger caches and wider paths from the flash to the cache.

    Yeah, technically it's overclocking. But in this particular case, it really is the same silicon as the parts officially specified at 100 and even 120 MHz. The 48 MHz part on Teensy 3.0 is too, but on 3.0 the simpler bus structure and narrow/slower path to the flash caused a lot of wait states when running some code at 96 MHz. Teensy 3.1 really runs very well at 96 MHz.

    I personally do almost all my testing of Teensy 3.1 and every library running at 96 MHz. It really does work.

    Eventually I'm going to add 72 MHz support in Teensyduino, but it's a lower priority than more features in the audio library, CAN bus, porting other libraries, and better documentation.

    If you *really* want to try 72 MHz, you could edit the code in mk20dx128.c to configure the PLL to generate 72 MHz, and boards.txt to add 72 MHz to the menu.
    Last edited by PaulStoffregen; 03-21-2014 at 10:52 PM.

  6. #6
    Junior Member
    Join Date
    Sep 2014
    Posts
    14
    Quote Originally Posted by PaulStoffregen View Post
    No. This is planned for a future release, but for now it's not supported.

    Hello Paul,

    too bad I have to read that lock bits are not supported for Teensy 3.1. Does it mean that they are just not supported by default, or that it is completely not possible to write protect the code I'm putting onto the teensy?

    I use the teensy 3.1 as platform for our new measuring devices and I would like to make it as difficult as possible for outsiders to read the code containing all the special tricks that makes our device unique.

    I would be glad if you could help me with that issue.

    Thanks,

    Clemi

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,942
    Today the lock bit is not supported at all. The Teensy Loader won't let you set it.

    Lock bit support was originally planned for 1.20, but got delayed when the audio library too much more work than originally anticipated.

    I've put lock bit support on the feature list for 1.21.

    When this does become supported, one consequence will be complete chip erasure when you press the pushbutton. Today, pressing the button causes the chip to go into bootloader mode, but the chip is erased only at the moment you begin actually loading code. If you go into bootloader mode but don't upload code, and then reboot by the button in Teensy Loader or by power cycling, your old code is still there. Once the lock bits are set, going into bootloader mode will requires complete chip erasure. In other words, if somebody accidentally presses the button but doesn't run Teensy Loader to upload code, the board will be completely erased and not run your code anymore. With the lock bit set, special care will be need to guard against accidental pressing of the button!
    Last edited by PaulStoffregen; 10-13-2014 at 12:17 PM.

  8. #8
    Junior Member
    Join Date
    Sep 2014
    Posts
    14
    Thank you for the fast reply.

    That means it's a software thing, not hardware related? And it will probably be solved in approx. 4 month?

    I could live with that.

    If it's only disallowed to push the button on the teensy I'm okay with it. (Sounds like a booby trap at the entrance door). Our customers will not be allowed to open the devices, without spoiling warranty.

  9. #9
    Junior Member
    Join Date
    Jan 2016
    Posts
    1
    Quote Originally Posted by PaulStoffregen View Post
    Today the lock bit is not supported at all. The Teensy Loader won't let you set it.

    Lock bit support was originally planned for 1.20, but got delayed when the audio library too much more work than originally anticipated.

    I've put lock bit support on the feature list for 1.21.

    When this does become supported, one consequence will be complete chip erasure when you press the pushbutton. Today, pressing the button causes the chip to go into bootloader mode, but the chip is erased only at the moment you begin actually loading code. If you go into bootloader mode but don't upload code, and then reboot by the button in Teensy Loader or by power cycling, your old code is still there. Once the lock bits are set, going into bootloader mode will requires complete chip erasure. In other words, if somebody accidentally presses the button but doesn't run Teensy Loader to upload code, the board will be completely erased and not run your code anymore. With the lock bit set, special care will be need to guard against accidental pressing of the button!
    Has there been any progress in the addition of lock bit control? I am extremely interested in this and don't mind the consequence. Thanks!

  10. #10
    Junior Member
    Join Date
    May 2015
    Posts
    11
    I wanted to bump this as I too am looking for lock bit control for my Teensy 3.1 and 3.2 projects.

    Any word on this?

Posting Permissions

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