Programming over ICSP seems to whipe EEPROM

I am programming an atmega328P using an arduino nano as ICSP programmer. I do this with the cli tool.

To upload I run this line:

arduino-cli upload -b arduino:avr:uno --programmer arduinoasisp -p COM3 -i ./build/arduino.avr.uno/handController.ino.hex

Every time I do an upload it seems to erase EEPROM. If I just power down my device and turn it on again, I can tell that EEPROM is not affected, so it is not my software that is whiping the EEPROM.

I tried with

arduino-cli board details --fqbn arduino:avr:uno

To see if there is an upload option, I used below lines to find one. But unlike with my attiny cores I am not seeing any reference to retain EEPROM.

$ arduino-cli board details --fqbn arduino:avr:uno
Board name:                Arduino Uno
FQBN:                      arduino:avr:uno
Board version:             1.8.3

Official Arduino board:    ←[32m✔←[0m

Identification properties: VID:0x2341 PID:0x0001
                           VID:0x2A03 PID:0x0043
                           VID:0x2341 PID:0x0243
                           VID:0x2341 PID:0x0043

Package name:              arduino
Package maintainer:        Arduino
Package URL:               https://downloads.arduino.cc/packages/package_index.json
Package website:           http://www.arduino.cc/
Package online help:       http://www.arduino.cc/en/Reference/HomePage

Platform name:             Arduino AVR Boards
Platform category:         Arduino
Platform architecture:     avr
Platform URL:              http://downloads.arduino.cc/cores/avr-1.8.3.tar.bz2
Platform file name:        avr-1.8.3.tar.bz2
Platform size (bytes):     4941548
Platform checksum:         SHA-256:de8a9b982477762d3d3e52fc2b682cdd8ff194dc3f1d46f4debdea6a01b33c14

Required tool:             arduino:avr-gcc                                                                             7.3.0-atmel3.6.1-arduino7

Required tool:             arduino:avrdude                                                                             6.3.0-arduino17

Required tool:             arduino:arduinoOTA                                                                          1.3.0

Programmers:               Id                                                           Name
                           parallel                                                     Parallel Programmer
                           jtag3isp                                                     Atmel JTAGICE3 (ISP mode)
                           jtag3                                                        Atmel JTAGICE3 (JTAG mode)
                           buspirate                                                    BusPirate as ISP
                           usbasp                                                       USBasp
                           arduinoasispatmega32u4                                       Arduino as ISP (ATmega32U4)
                           usbGemma                                                     Arduino Gemma
                           stk500                                                       Atmel STK500 development board
                           atmel_ice                                                    Atmel-ICE (AVR)
                           arduinoisp                                                   ArduinoISP
                           arduinoasisp                                                 Arduino as ISP
                           avrisp                                                       AVR ISP
                           usbtinyisp                                                   USBtinyISP
                           arduinoisporg                                                ArduinoISP.org
                           avrispmkii                                                   AVRISP mkII

Then there are the two hex files with or without bootloader. I am using the one without the bootloader. Does this matter?

It is not a huge dealbreaker just slightly annoying. How can I solve this?

Kind regards,

Bas

No, one just contains (as the name implies) your sketch and the bootloader.

I'm not familiar with CLI, maybe it gives additional information if you run arduino-cli upload or with /? (or similar).

I enabled verbose again.

"C:\Users\Gebruiker\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Gebruiker\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -cstk500v1 -PCOM3 -b19200 "-Uflash:w:build\arduino.avr.uno/handController.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Gebruiker\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us   
         PAGEL                         : PD7       
         BS2                           : PC2       
         RESET disposition             : dedicated 
         RETRY pulse                   : SCK       
         serial program mode           : yes       
         parallel program mode         : yes       
         Timeout                       : 200       
         StabDelay                     : 100       
         CmdexeDelay                   : 25        
         SyncLoops                     : 32        
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53      
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 Version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "build\arduino.avr.uno/handController.ino.hex"
avrdude: writing flash (19904 bytes):

Writing | ################################################## | 100% 22.63s

avrdude: 19904 bytes of flash written

avrdude done.  Thank you.

UPLOADING SUCCES!!!

Would this 'erase cycle' be affecting eeprom as well??

avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip

I am goint to try if the IDE also does this...

Bas

IDE also wipes EEPROM. Upload output is the same :smiling_face_with_tear:

This looks like it could be relevant.

The easiest solution is to use MiniCore, which allows the user to control the EESAVE configuration fuse setting via a custom board option:

https://github.com/MCUdude/MiniCore#eeprom-option

When using Arduino CLI, the options are traditionally set as part of the FQBN. With MiniCore, that would look something like this: --fqbn MiniCore:avr:328:eeprom=keep

Or if you are using the latest 0.22.0 release of Arduino CLI, which came out yesterday, there is a new --board-options flag you can use to specify the custom board options separately from the FQBN if you like (the all in one FQBN system will always be supported as well): --fqbn MiniCore:avr:328 --board-options "eeprom=keep"

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.