AVR: Uploading EEPROM also erases chip

Yes with a custom piece of python code, as generally explained in the docs. Modifying the platformio.ini to

[env:attiny13]
platform = atmelavr
board = attiny44
upload_protocol = usbasp
board_build.f_cpu = 1000000L
upload_flags =
  -v
  -B 70
board_upload.extra_flags = 
extra_scripts = post:fix_uploadflags.py

and adding the file fix_uploadflags.py to the project with the content

Import("env", "projenv")

def before_upload(source, target, env):
    if "upload" == str(target[0]):
        env.Append(UPLOADERFLAGS=["-e"])

env.AddPreAction("upload", before_upload)
env.AddPreAction("uploadeep", before_upload)

will cause the Upload (firmware) command to include -e (added by script) but the upload EEPROM command not.

In my case the pio run -v -t upload (upload firmware) gives

avrdude -v “-B 70” -v -p attiny44 -C C:\Users\Max.platformio\packages\tool-avrdude\avrdude.conf -c usbasp -e -D -U flash:w:.pio\build\attiny13\firmware.hex:i

And pio run -v -t uploadeep gives

avrdude -v “-B 70” -v -p attiny44 -C C:\Users\Max.platformio\packages\tool-avrdude\avrdude.conf -c usbasp -D -U eeprom:w:.pio\build\attiny13\firmware.eep:i

2 Likes