# Does EEPROM data survive upload?

**URL:** <https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287>\
**Category:** Programming\
**Created:** [October 18, 2022, 9:54am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287 "2022-10-18T09:54:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![daba](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/daba/32/243479_2.png) [@daba](https://forum.arduino.cc/u/daba)\
**Post date:** [October 18, 2022, 9:54am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/1 "2022-10-18T09:54:40Z")

</div>

Hi, I suppose I could write a sketch to test this, but someone will know.

Does the data in the EEPROM area survive an upload to the board.

I've got some data (e.g. the number of EEPROM write cycles performed, and ongoing calibration data), that I'd like to maintain between uploads. I'm using an Arduino Nano.

If I make those data fields the first in the struct I declare for EEPROM data, will they get overwritten on upload.

TIA

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [October 18, 2022, 9:55am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/2 "2022-10-18T09:55:56Z")

</div>

yes. it's not cleared when you change the code

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [October 18, 2022, 9:56am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/3 "2022-10-18T09:56:46Z")

</div>

> [@daba](#):
>
> Does the data in the EEPROM area survive an upload to the board.

Yes, if you do the upload in the conventional way using the IDE

---

<div class="post-metadata">

**Author:** ![daba](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/daba/32/243479_2.png) [@daba](https://forum.arduino.cc/u/daba)\
**Post date:** [October 18, 2022, 10:01am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/4 "2022-10-18T10:01:55Z")

</div>

Thanks, that's what I thought.

I've got a mechanism for initialising the data, using an "ID" variable which I place last in the structure. I #define an "id" value which can force initialisation if needed, either by changing the EEPROM struct, or by changing the "id" define value. After that, persistent data is needed.

Thanks for the swift replies, guys.

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [October 18, 2022, 10:34am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/5 "2022-10-18T10:34:01Z")

</div>

On an AVR (Uno, Nano etc.) the fuse bits control whether or not the EEPROM is cleared on upload of a sketch. The default in the Arduino IDE is to preserve the EEPROM contents.

---

<div class="post-metadata">

**Author:** ![daba](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/daba/32/243479_2.png) [@daba](https://forum.arduino.cc/u/daba)\
**Post date:** [October 18, 2022, 10:36am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/6 "2022-10-18T10:36:30Z")

</div>

Ah, not learnt about fuse bits yet, haven't seen the need to, lol.

I'm happy to go with defaults on this project.....

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [October 19, 2022, 7:55am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/7 "2022-10-19T07:55:48Z")

</div>

> [@6v6gt](#):
>
> On an AVR (Uno, Nano etc.) the fuse bits control whether or not the EEPROM is cleared on upload of a sketch.

Actually…. Not when you’re using the bootloader. The bootloader doesn’t understand eeprom at all, and doesn’t touch it. Nor does it look at fuses.

---

<div class="post-metadata">

**Author:** ![6v6gt](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/6v6gt/32/225488_2.png) [@6v6gt](https://forum.arduino.cc/u/6v6gt)\
**Post date:** [October 19, 2022, 9:15am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/8 "2022-10-19T09:15:51Z")

</div>

> [@westfw](#):
>
> Actually…. Not when you’re using the bootloader. The bootloader doesn’t understand eeprom at all, and doesn’t touch it. Nor does it look at fuses.

OK. Maybe it was a bit loosley worded in that I used the term Arduino IDE to generally refer to an 'Arduinoized' MCU, that is one with the typical Arduino fuse settings and the bootloader etc.

Hopefully this is unambiguous:

The fuse is the EESAVE bit in the high fuse byte. By default it is un-programmed (has the value 1) which means that the contents of the EEPROM are erased when the Chip Erase command is executed, typically when the device enters programming mode. In an 'Arduinoized' MCU, the EESAVE fuse bit is cleared (has the value (0) meaning that the contents of the EEPROM are preserved across programming operations. The initiation of programming mode differs slightly depending on whether the chip is being programmed by a parallel or serial method. See the data sheet chapter "Memory Programming".

---

<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:** [April 17, 2023, 9:16am UTC](https://forum.arduino.cc/t/does-eeprom-data-survive-upload/1043287/9 "2023-04-17T09:16:14Z")

</div>

Closed on April 17, 2023, 9:16am UTC

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