# Programming over ICSP seems to whipe EEPROM

**URL:** <https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227>\
**Category:** Uploading\
**Created:** [May 7, 2022, 9:09am UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227 "2022-05-07T09:09:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bask185](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bask185/32/1013044_2.png) [@bask185](https://forum.arduino.cc/u/bask185)\
**Post date:** [May 7, 2022, 9:09am UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/1 "2022-05-07T09:09:48Z")

</div>

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:

```cpp
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

```cpp
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.

```cpp
$ 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

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [May 7, 2022, 9:26am UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/2 "2022-05-07T09:26:06Z")

</div>

> [@bask185](#):
>
> Then there are the two hex files with or without bootloader. I am using the one without the bootloader. Does this matter?

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).

---

<div class="post-metadata">

**Author:** ![bask185](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bask185/32/1013044_2.png) [@bask185](https://forum.arduino.cc/u/bask185)\
**Post date:** [May 7, 2022, 10:28am UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/3 "2022-05-07T10:28:46Z")

</div>

I enabled verbose again.

```cpp
"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??

```cpp
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

---

<div class="post-metadata">

**Author:** ![bask185](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/bask185/32/1013044_2.png) [@bask185](https://forum.arduino.cc/u/bask185)\
**Post date:** [May 7, 2022, 10:37am UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/4 "2022-05-07T10:37:36Z")

</div>

IDE also wipes EEPROM. Upload output is the same 🥲

---

<div class="post-metadata">

**Author:** ![jfjlaros](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jfjlaros/32/716915_2.png) [@jfjlaros](https://forum.arduino.cc/u/jfjlaros)\
**Post date:** [May 7, 2022, 4:09pm UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/5 "2022-05-07T16:09:37Z")

</div>

[This](http://www.martyncurrey.com/arduino-atmega-328p-fuse-settings/) looks like it could be relevant.

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [May 7, 2022, 4:22pm UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/6 "2022-05-07T16:22:04Z")

</div>

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](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](https://github.com/arduino/arduino-cli/releases/tag/0.22.0), which came out yesterday, there is [a new](https://github.com/arduino/arduino-cli/pull/1688) `--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"`

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [November 3, 2022, 4:22pm UTC](https://forum.arduino.cc/t/programming-over-icsp-seems-to-whipe-eeprom/989227/7 "2022-11-03T16:22:47Z")

</div>

Closed on November 3, 2022, 4:22pm UTC

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