Write to 32k boot EEPROM without harming 32k boot image at next startup ?
Greg P
Posts: 58
The PropStick USB has a built-in 32k EEPROM. I would like, if possible, to store some application variables to its existing EEPROM, for readback at the next system power-up. The danger, or course, in doing such a thing is that I might easily overwrite critical firmware stored in the EEPROM.
OK, Here's my thoughts:
What if a one-to-one correspondence exists between EEPROM memory and Propeller internal RAM ? If I set aside an array of longs in some object, executing spin code could obtained the hub memory start address for this array. Now, if indeed, a 1-to-1 correspondence exists (?) to external EEPROM memory, I could use this hub array address to identify the EEPROM address set aside for this array, and safely write to ONLY those corresponding EEPROM addresses, thus avoiding the risk of overwriting boot code. At next power up, the array should contain the values written to it previously. CAN SUCH A SCHEME WORK ? Has this topic already been addressed ? Does anyone have example code ?
OK, Here's my thoughts:
What if a one-to-one correspondence exists between EEPROM memory and Propeller internal RAM ? If I set aside an array of longs in some object, executing spin code could obtained the hub memory start address for this array. Now, if indeed, a 1-to-1 correspondence exists (?) to external EEPROM memory, I could use this hub array address to identify the EEPROM address set aside for this array, and safely write to ONLY those corresponding EEPROM addresses, thus avoiding the risk of overwriting boot code. At next power up, the array should contain the values written to it previously. CAN SUCH A SCHEME WORK ? Has this topic already been addressed ? Does anyone have example code ?
Comments
One solution would be to replace the existing EEPROM with a 64K variant. Another solution is to add another EEPROM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheers,
Simon
www.norfolkhelicopterclub.com
“Before you criticize someone, you should walk a mile in their shoes. That way when you criticize them, you are a mile away from them and you have their shoes.” - Jack Handey.
Yes, it's been discussed before
If you were to use Basic_I2C_Driver (defining it as i2c) from the object exchange and wanted to store the current value of a LONG variable called HERE so that HERE would have that value when you start up your program, you'd do
If you wanted to save the value of HERE for use on a reboot, you'd call "saveItForLater(@HERE)". Remember that downloading a new copy of your program using the Propeller Tool will erase any saved values. You can also modify this to write only 2 bytes for word variables or only 1 byte for byte variables.
Post Edited (Mike Green) : 5/7/2009 5:10:02 PM GMT
I don't have code handy, but it was pretty trivial to code up using the I2C EEPROM object in the Obex.
Jason
Never heard of a checksum.
PS: Thank's Mike for giving me the answer before I finshed the question ;o)
Post Edited (MagIO2) : 5/7/2009 7:35:33 PM GMT
It contains things like the start of the stack area, a pointer to the beginning of the program, CLKFREQ and CLKMODE
values to be used, a checksum, etc.
File: Propeller Eeprom.spin
Version: 0.6
Developed for forthcoming Propeller Education Kit Lab: EEPROM Datalogging and I2C
Here's an example where I use it:
·Just use the VarBackup function with start and end addresses you want to save
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm