Offline
Newbie
Karma: 0
Posts: 6
|
 |
« on: May 21, 2012, 11:45:49 am » |
Hi All,
New Arduino user here... Been making a ton of progress on my project (guitar pedalboard controller)...
I'm using the extended DB library to keep "presets" stored on eeprom. I was hoping to have one sketch to store the presets in eeprom, and then my regular sketch to run the pedalboard and simply read them. However, when I upload a new sketch, eeprom seems to be cleared... is there any way to tell Arduino not to clear the eeprom upon sketch upload?
I've searched with no luck.
Thanks!!
Tim
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #1 on: May 21, 2012, 11:50:00 am » |
The ATmega328P processor has an EESAVE fuse which controls this behavior. To change the value of this fuse you will need an ICSP (in-circuit serial programmer) which connects to the 2x3 pin header next to the microprocessor. I like Atmel's ATAVRISP2 programmer which, at $35, is not the least expensive solution but it's never let me down across all types of Atmel's processors. You would then use Atmel's AVR Studio (or AVRDUDE by itself if you're comfortable mucking with fuses at the command line) to connect to the processor using the ATAVRISP2, change the EESAVE fuse, and then you should be all set. -- The Rugged Audio Shield: Line In, Mic In, Headphone Out, microSD socket, potentiometer, play/record WAV files
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #2 on: May 21, 2012, 11:56:14 am » |
Thank you for this info! I am using your Flexible Midi Shield for this project and it's working great!
I'm curious - if I were to use external eeprom or SD to store these presets would they require the fuse change, or would they retain their data by default? Wondering if it's more efficient for me to go that route than to purchase this programmer just to change one setting? Maybe the programmer would be useful for me down the line...? Maybe the SD would slow things down?
Questions, questions....
Thanks!
Tim
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Faraday Member
Karma: 12
Posts: 2857
ruggedcircuits.com
|
 |
« Reply #3 on: May 21, 2012, 12:00:05 pm » |
External EEPROM or SD would store anything you write to it -- uploading sketches wouldn't affect that. Whether it's more efficient for you to go that route....it wouldn't be for me  Doing a little surgery on an Arduino with a $35 programmer makes more sense to me personally than adding extra hardware and complexity. And the programmer is definitely useful down the line if you plan to work with other devices. If you are really cost conscious you can use another Arduino board as an ICSP programmer. It just takes a lot of reading, experimenting, and patience  For me, the AVR ISP is one of the tools I always have on the bench, next to the FTDI serial cable, a couple of screwdrivers, two DMM's, and a cup warmer. -- The Basic Motor Driver: simple, inexpensive motor driver for 1 stepper motor or 2 DC motors
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25508
Solder is electric glue
|
 |
« Reply #4 on: May 21, 2012, 12:05:30 pm » |
The standard arduino does not erase EEPROM memory when uploading a new sketch.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #5 on: May 21, 2012, 01:03:09 pm » |
Hrm... is that right? I have a Mega 2560 R3. As far as I can tell eeprom gets hosed upon upload.
Unless I can discover otherwise I think I'll be picking up one of those programmers!
Thx for the help!
Tim
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25508
Solder is electric glue
|
 |
« Reply #6 on: May 21, 2012, 09:03:24 pm » |
As far as I can tell So how are you testing it. This does not happen on my Uno nor my Mega 1280.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 314
Posts: 35518
Seattle, WA USA
|
 |
« Reply #7 on: May 22, 2012, 06:23:53 am » |
This does not happen on my Uno nor my Mega 1280. Nor on my Duemilanove or Mega 2560.
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay area
Offline
Full Member
Karma: 0
Posts: 156
|
 |
« Reply #8 on: May 29, 2012, 03:18:41 pm » |
are you sure the eeprom contents are preserved when a new sketch is uploaded? according to boards.txt file for UNO, the fuse settings are (low, high and extended fuse) 0xFF 0xDE 0x05 and if you enter those numbers in http://www.engbedded.com/fusecalc/for atmega328p it shows preserve eeprom memory through chip erase cycle as disabled. If I check that box, the fuse setting is changed to 0xFF 0xD6 0xFD the extended fuse value of 0xFD is equivalent to 0x05, so the only thing that changed is the EESAVE value of high fuse. same for atmega2560 boards.txt fuse setting says 0xFF 0xD8 0xFD if I check preserve eeprom, the fuse settings change to 0xFF 0xD0 0xFD if you have another uno or mega, you can use arduino as isp sketch to change the fuse setting. just change the value in boards.txt and burn the bootloader on the target. if you want to get a programmer, you can get a usbasp for under $4 on ebay.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 118
Posts: 10167
|
 |
« Reply #9 on: May 29, 2012, 03:32:14 pm » |
are you sure the eeprom contents are preserved when a new sketch is uploaded? When using a bootloader, yes. The fuses are irrelevant. In the case of Optiboot, it does not have any EEPROM code. When using serial programming, maybe. The fuses are important. @timedgar never indicated which method he was using to program.
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay area
Offline
Full Member
Karma: 0
Posts: 156
|
 |
« Reply #10 on: May 29, 2012, 04:19:05 pm » |
that's right. thanks for the correction. if uploading sketch via bootloader, the avrdude command is like avrdude -CE:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\\.\COM1 -b115200 -D -Uflash:w:C:\TEMP\build3958906321873940373.tmp\Blink.cpp.hex:i which is independent of the fuse setting as you said. if you say burn the bootloader, the avrdude command is avrdude -CE:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM1 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m the fuse values are obtained from board.txt, so you can either change it in boards.txt or just run avrdude from command line with the fuse values needed. now come to think of it, I think the OP problem is not due to fuse setting. I think the db library may be clearing the eeprom. 
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 6
|
 |
« Reply #11 on: June 12, 2012, 07:48:26 am » |
Thanks guys for this information! I didn't get notifications on these replies so apologies for my absence  I will look into the DB library, perhaps there is a setting I can adjust. I've been more focused on the hardware side of things and getting the thing up and running in a state where at least I can play music with it...
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 43
Creating futuristic, interactive installations which merge design, art and technology.
|
 |
« Reply #12 on: November 05, 2012, 10:05:36 am » |
Dear all,
Just spend a few hours on a 328p-au chip to upload sketches via ISP and 'remembering' EEPROM.
One thing to keep in mind using ISP, it seems the fuses are only set while burning a bootloader, and not while uploading a sketch with a programmer. After changing the fuse settings in boards.txt (as explained by doughboy) and burning a bootloader it works.
Thanks you for the information to figure this one out!
|
|
|
|
|
Logged
|
My best Arduino project: Bench. Interactive transformable furniture.
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #13 on: November 05, 2012, 10:52:22 am » |
I have a question somewhat related to this topic. My bog standard arduino (2009 flavor) with bootloader uploads just fine with the normal IDE upload command via USB serial. However if I then take my TinyUSB ICSP programmer and use the IDE's file menu "upload using programmer" option then it too burns the sketch fine into the board, however the bootloader gets erased (I checked after burning the sketch by reading flash content with a AVRDUDE standalone GUI program). So how did the fuse setting get changed such that the bootloader code was not protected as it normally gets protected using the standard USB serial uploading?
Lefty
|
|
|
|
|
Logged
|
|
|
|
|
|