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

Thread: How do I prevent EEPROM from being overwritten bij Teensy Loader?

  1. #1

    How do I prevent EEPROM from being overwritten bij Teensy Loader?

    Is there a way to prevent the Teensy Loader from overwriting EEPROM memory when burning in a new program?

    I'm storing an IV (initialization vector) in EEPROM and when I burn in a new program the IV becomes 0 again. For security reasons one does not want to reuse an IV, so I don't want the IV to be overwritten.

    There's currently no option in Teensy Loader to prevent it from overwriting EEPROM during programming.
    Last edited by bigpilot; 11-28-2018 at 11:57 AM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,655
    Unless you've edited FSEC in mk20dx128.c, Teensy Loader does not erase EEPROM when uploading. Or at least it's not supposed to erase it.

    But let's just take a step back and maybe look at the problem. For starters, we don't even know from your message which Teensy you're using.

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,745
    Maybe a problem in your program? I use eeprom, it works fine, and nothing gets overwritten. Its default value is 0xff so a 0x00 is not normal anyway..

    Edit:I think, *very* old Versions erased it. Years ago.

  4. #4
    I'm using a Teensy 2.0 (Atmel AVR Mega32U4).

    My .eep file looks like this:

    Code:
    :080000000000000000000000F8
    :00000001FF
    In code I have this:

    Code:
    uint32_t EEMEM eepromIV_H;
    uint32_t EEMEM eepromIV_L;
    I originally had this

    Code:
    uint32_t EEMEM eepromIV_H = 0;
    uint32_t EEMEM eepromIV_L = 0;
    Thinking that might be the problem, but to no avail.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,655
    On the older Teensy models, if your .elf file has EEPROM data compiled, Teensy Loader will recognize it and write it to the chip's EEPROM memory. If finds this from the .elf file, not your .eep file.

  6. #6
    Is there a way to prevent this?

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,655
    Simplest way would be the just delete or move the .elf file before using Teensy Loader. Then it will have only access to your .hex file.

    There are lots of ways to do custom stuff with the avr-gcc toolchain, but can turn into a deep rabbit hole of gcc & ld command line stuff and linker script files.

  8. #8
    Thanks, that worked.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,655
    Might also be worth mentioning the EEPROM is not meant for storage of sensitive info. The flash can be erased without erasing the EEPROM. Anyone who wishes to capture the data from the EEPROM can simply program the flash with code which prints the EEPROM data to USB serial.

  10. #10
    Yes, but the IV is not sensitive info, it can be transmitted in the clear. Point is never to use it more than once.

Posting Permissions

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