I am using an Arduino Uno, and I use the EEPROM to store some presets. It works fine. But, when I reprogram the Arduino, the EEPROM gets wiped out. Is there a way to prevent this, and have the EEPROM not change after the Arduino is programmed?
I am using a USBtinyISP programmer.
Thank you very much for your help, and advance.
Here is the verbose result of my programming:
Sketch uses 5,298 bytes (16%) of program storage space. Maximum is 32,256 bytes.
Global variables use 286 bytes (13%) of dynamic memory, leaving 1,762 bytes for local variables. Maximum is 2,048 bytes.
/Users/fed/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/Users/fed/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -cusbtiny -Uflash:w:/var/folders/lb/5zdjdm6153jcx_5nq32tt7gw0000gn/T/buildb926e4430d002b65d0ca44bda9d693e2.tmp/LED_strip_08.ino.hex:i
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/Users/fed/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"
User configuration file is "/Users/fed/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : usb
Using Programmer : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: 006:003
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 : USBtiny
Description : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported
avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
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: Using SCK period of 10 usec
avrdude: reading input file "/var/folders/lb/5zdjdm6153jcx_5nq32tt7gw0000gn/T/buildb926e4430d002b65d0ca44bda9d693e2.tmp/LED_strip_08.ino.hex"
avrdude: writing flash (5298 bytes):
Writing | ################################################## | 100% 7.80s
avrdude: 5298 bytes of flash written
avrdude: verifying flash memory against /var/folders/lb/5zdjdm6153jcx_5nq32tt7gw0000gn/T/buildb926e4430d002b65d0ca44bda9d693e2.tmp/LED_strip_08.ino.hex:
avrdude: load data flash data from input file /var/folders/lb/5zdjdm6153jcx_5nq32tt7gw0000gn/T/buildb926e4430d002b65d0ca44bda9d693e2.tmp/LED_strip_08.ino.hex:
avrdude: input file /var/folders/lb/5zdjdm6153jcx_5nq32tt7gw0000gn/T/buildb926e4430d002b65d0ca44bda9d693e2.tmp/LED_strip_08.ino.hex contains 5298 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 4.98s
avrdude: verifying ...
avrdude: 5298 bytes of flash verified
avrdude done. Thank you.
-
I believe avrdude allows access to each type of memory independently, so this is probably an issue with the commands the IDE issues. Another option is to use avrdude to backup the eeprom and then re-write it after. Basically you need to become familiar with avrdude and figure out how you can change the way the IDE uses it. Or else only have the IDE build your sketch, and use avrdude manually to load it.Chris Stratton– Chris Stratton2017年07月20日 15:32:51 +00:00Commented Jul 20, 2017 at 15:32
-
I should clarify my previous comment was more about using avrdude for ISP; off the top of my head, I'm not sure what subset of this the bootloader supports.Chris Stratton– Chris Stratton2017年07月20日 16:07:49 +00:00Commented Jul 20, 2017 at 16:07
1 Answer 1
You can change the fuses for Atmega328
to preserve EEPROM
during chip erase (for ISP
programming). Basically, if you are using USBTiny
connected to the UNO
by 3x2
pin header, you are using ISP programming
. Which means chip erase erases also EEPROM
if fuse EESAVE
is 1
(unprogrammed).
Uploading over the Arduino bootloader
(it means you have the UNO
connected directly into the computer and there is no other device like USBTiny
). The EEPROM
should be preserved then.
-
So, are you saying that changing fuses (I have no idea how to do that) may or may not work. But not using Arduino IDE, but rather using AVRdude in command line should work?Fed– Fed2017年07月20日 15:40:05 +00:00Commented Jul 20, 2017 at 15:40
-
@Fed EEPROM can be changed by avrdude but Arduino usually won't do anything with it (you can see whole command in the Arduino IDE if you enable verbose upload).KIIV– KIIV2017年07月20日 19:31:03 +00:00Commented Jul 20, 2017 at 19:31
-
I updated the verbose output of Arduino IDE when I program the Arduino. Any suggestions?Fed– Fed2017年07月20日 21:19:40 +00:00Commented Jul 20, 2017 at 21:19
-
@fed The most important thing is USBTiny - it performs chip erase and without EESAVE fuse programmed to 0, it erases EEPROM too.KIIV– KIIV2017年07月21日 07:05:44 +00:00Commented Jul 21, 2017 at 7:05