Go Down

Topic: setting the initial state of the EEPROM (Read 921 times) previous topic - next topic

eighthave

Apr 10, 2007, 12:45 am Last Edit: Apr 10, 2007, 12:45 am by eighthave Reason: 1
I am starting to mess with the EEPROM library to store the state of Firmata.  I have run into a question that I can't seem to find the answer to.  Basically, I need to find a way to set the initial state of the EEPROM so that I can set the initial state of Firmata.  I imagine that by default the EEPROM has gibberish in it, like reading unallocated memory.  Ideally, there would be some way to init the EEPROM to 0.

This thread says
Quote
I think if I read the bootloader correctly the EEPROM is erased when you upload a sketch
.  That would work quite nicely if that was true.  But it does not seem to be.  According to my tests, the EEPROM remains untouched when burning a new firmware.

This thread means that there is code in the bootloader for reseting the EEPROM.  Any chance of this getting activated?  

Or are there other options for reseting the EEPROM? Maybe this would work best as a menu option in the Arduino IDE.


jims

Perhaps you could use some sort of signature? Say, if the the EEPROM begins 0xdeadbeef or whatever you choose then you will believe that you have initialized it and it has your data in it. Otherwise, initialize it in your code. You probably want a version number in there too so you know when it is initialized with old format data after you inevitably change formats.

eighthave

#2
Apr 10, 2007, 02:02 am Last Edit: Apr 10, 2007, 02:02 am by eighthave Reason: 1
Yeah, that's a good hack for that.  I thought of another: adding a function to the Firmata firmware that zeros the EEPROM and make it part of the SYSTEM_RESET functionality.


But now I can't seem to undo my EEPROM writes... hmm...

brianbr

Quote
I am starting to mess with the EEPROM library to store the state of Firmata.  I have run into a question that I can't seem to find the answer to.  Basically, I need to find a way to set the initial state of the EEPROM so that I can set the initial state of Firmata.  I imagine that by default the EEPROM has gibberish in it, like reading unallocated memory.  Ideally, there would be some way to init the EEPROM to 0.

This thread says
Quote
I think if I read the bootloader correctly the EEPROM is erased when you upload a sketch
.  That would work quite nicely if that was true.  But it does not seem to be.  According to my tests, the EEPROM remains untouched when burning a new firmware.

This thread means that there is code in the bootloader for reseting the EEPROM.  Any chance of this getting activated?  

Or are there other options for reseting the EEPROM? Maybe this would work best as a menu option in the Arduino IDE.



I am not so usre that erasing EEPROM with each sketch upload would be such a good idea.

 (1) the whole write cycle thing, although flash is getting rewritten each time a sketch is loaded I am wondering about the write-cycle life of the EEPROM.

 (2) on a more personal basis I want to use EEPROM in a simple program to read to store and EEPROM 1-Wire device IDs, then load a different sketch to make use of the 1-Wire devices.

cheers ... BBR

Go Up