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

Status
Not open for further replies.

bigpilot

Well-known member
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:
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
Yes, but the IV is not sensitive info, it can be transmitted in the clear. Point is never to use it more than once.
 
Status
Not open for further replies.
Back
Top