Why --target program erases eeprom?

Hello all,

Why I need run pio run -t uploadeep after each pio run -t program?

From terminal I usualy use avrdude -pt45 -cstk500v2 -P/dev/stk500-programmer0 -u -Uflash:r:firmware.hex:i and it did not erase eeprom.

You can control upload flags with Redirecting...

I’m not sure if this is the right thread to raise my topic… Currently I have a small test program for Arduino for EEPROM write and read. I use the upload feature to program the device. So after first run data were written into EEPROM and read out with my code. Everything worked as expected. Then I removed the EEPROM.write from my code and flashed once again. Normally I would expect that the EEPROM content is not touched at all, but the EEPROM was “empty”. So it seems to be that the EEPROM has been cleared too. How can I avoid this, so I woud like to be able to program flash only without affecting the EEPROM content?

Furthermore how can I write default data into EEPROM e.g. save some default configuration or other data. As I can remember with plain AVR GCC there was the possibility to do so.

Regards Andreas

Hm, according to the code this should not happen.

Since only $UPLOADCMD is executed it invokes avrdude with with -p $BOARD_MCU -C <config path> -c arduino -U flash:w:firmware.hex:i, which shouldn’t touch EEPROM content. Are you sure you’re running the most recent Atmel AVR Platform version? (VSCode Update GUI or pio platform update)

Refer to the documentation, uploadeep. It will upload the "${PROGNAME}.eep" to the EEPROM. Use it in conjuction with the EEMEM attribute (refer here) of avr-gcc to place data into that file.

1 Like