How to burn program into EEPROM without flashing the Arduino ?

So i am working on this project where i want to store few variables into the eeprom provided on atmge 328p but also want to update them when user wants to change the value of the variable for that i will need to flash the arduino so that i can update the value of the variable in the eeprom but in that case i need to upload the whole program again is there a solution to this problem where i can store the variable data in eeprom and can update them without flashing the arduino?

(deleted)

Using AVRdude, you can essentially read or write any part of the uC.
This article shows how.

Specifically for EEPROM:
avrdude -c arduino -P com4 -p ATMEGA328P -b 19200 -U eeprom:r:%temp%\backup_eeprom.hex:i

and

avrdude -c arduino -P com4 -p ATMEGA328P -b 19200 -U eeprom:w:\Users\owner\AppData\Local\Temp\backup_eeprom.hex

The first command uses ISP on com4 to create a backup file of the EEPROM contents.
The second command uses ISP on com4 to write the file "backup_eeprom" to the uC

Make changes in the script files to suit your environment.

Ray

(deleted)

spycatcher2k:
Nice one mrburnette. Been using AVR-DUDE for years and didn't know that one. Might program an EEPROM editor in C# and use that for uploading to the chip.

Yes, it would be a nice tool for newbies and those who do not like to drop to the command prompt to have a GUI that did the work and just manipulated AVRdude in the background! I think the effort would be most useful.

What I think is happening is that Arduino has been around long enough that many of us early old dudes are off in other playgrounds and many of the common shell commands are being forgotten and the ArduinoIDE is evolving to support so many boards. I have tried over time to capture a few basic concepts in my little corner of the web but there is so much more that could be done. Fortunately, Nick has his pages and many of the older members have decent pages, too. So, as long as we can keep all those pages on the web, I think the bulk of the knowledge is preserved.

Ray

spycatcher2k:
Nice one mrburnette. Been using AVR-DUDE for years and didn't know that one. Might program an EEPROM editor in C# and use that for uploading to the chip.

One proviso, This only works when using ISP programming. (I don't know if the ArduinoAsISP support it either?) The bootloaders do not support the EEPROM protocol, They just accept it and discard. Since they don't store to data, when avrdude does its readback verification, the verification fails.

Chuck.

@ray regarding your "AVR Firmware Duplicator" page. Your avrdude examples are showing the "-c arduino" communication option which works well with optiboot, but I don't think optiboot can read the eeprom (perhaps the new optiboot or one of the forks can). I'm also fairly sure optiboot reports fake fuses. I am able to read and set fuses with the ArduinoISP sketch in examples, but that uses the "-c stk500v1" communication option. I've not tried to read the eeprom with it.

You can build Optiboot with support for EEPROM, but then it doesn't fit in 512 bytes - have to move to 1024.

ron_sutherland:
@ray regarding your "AVR Firmware Duplicator" page. Your avrdude examples are showing the "-c arduino" communication option which works well with optiboot, but I don't think optiboot can read the eeprom (perhaps the new optiboot or one of the forks can). I'm also fairly sure optiboot reports fake fuses. I am able to read and set fuses with the ArduinoISP sketch in examples, but that uses the "-c stk500v1" communication option. I've not tried to read the eeprom with it.

-c arduino
is in reality the ArduinoISP sketch which I typically run on an old UNO with an Adafruit ZIF shield.

-U flash
This command is "bootloader indifferent" - that is, reading of writing works whether there is of is not a bootloader.

Ray

I guess there are too many variables, "-c arduino" caused me problems when I tried to load firmware into an AVR with the ISP tool (ArduinoISP sketch on an Uno) from a Linux host (I hope to try a Pi Zero soon) on the other hand stk500v1 is working fine.

ron_sutherland:
I guess there are too many variables, "-c arduino" caused me problems when I tried to load firmware into an AVR with the ISP tool (ArduinoISP sketch on an Uno) from a Linux host (I hope to try a Pi Zero soon) on the other hand stk500v1 is working fine.

@Ron,

I wrote the script and articles many years back, originally it was on Instructables and also in the forum in abbreviated format. But those were "windows" days and on XP. Later, the Hackster article, I was using Win8.1 but when Microsoft started the insane Windows 10 crap, I threw my MCSE title and Windows Anything into the round-file and moved 2 servers, 4 workstations, my backup development notebook, and two traveling HP Mini notebooks to Linux.

Since running Linux, I have not tested the individual components of the Windows batch script. There may be some issue in how Linux enumerates the USB that interferes with the documentation.

Thanks for mentioning your issue. Definitely something to make a note of ...

Ray

spycatcher2k:
Might program an EEPROM editor in C# and use that for uploading to the chip.

This may be of interest...

If you tag data with EEMEM...

uint32_t NumberOfWidgets EEMEM = 0x12345678;

...the Arduino IDE creates an image (named sketch_aug25a.ino.eep in my case)...

:0400000078563412E8
:00000001FF

...that can be burned to EEPROM with the correct incantation of AVRDUDE.

Which makes assigning EEPROM addresses and initializing EEPROM values a breeze (other than having to fiddle with the command line).