PDA

View Full Version : Can you overwrite a preinitialized DAT value in the EEPROM copy of a spin program?



andrewsi
10-31-2011, 09:55 PM
I have a simple app that displays a text string which is pre-initialized in a DAT String buffer. The hardware in question doesn't have anything in the way of additional onboard EEPROM to store persistent program data in beyond the existing 32K program storage on the standard Propeller Proto Board.

This is just fine as long as you don't want to change the message very often, as then you can just recompile/re-download. However, I had this thought that if I knew the offset in memory of the text from the @ operator, I could potentially use that to rewrite the string in the EEPROM itself at will, without having to rewrite the entire app. Then it occurred to me that perhaps there is checksumming of the application during the boot process, or something like that, such that changing the string in the EEPROM would invalidate the integrity of the app and cause future boots to fail... Haven't tried it, but I was curious if anyone else had ever used this technique, or is using extra EEPROM (or RAM on a clock chip, or whatever) really mandatory for any non-volatile storage of data created after compilation?

(Obviously manipulating your program's storage has some inherent dangers from the perspective of robustness, but I'm willing to put up with that if there are no barriers to selective rewriting of the built-in EEPROM via I2C.)

MagIO2
10-31-2011, 10:18 PM
There is no checksum to worry about! This idea pops up once in a while here in the forum, so a lot of people have tried this so far ;o)

Depending on the program, the biggest problem could be that you loose the actual settings when writing a newer software-version to EEPROM.

If you write to EEPROM very frequently, you could also think about replacing the EEPROM with a FRAM. FRAMs have much more R/W cycles. And when you're at it, you can also replace it with a 64k version ;o)

andrewsi
10-31-2011, 10:20 PM
No, that's great! The message is still infrequently written so I'm not too worried about wearing it out, but I'd like to be able to change the message from a serial terminal and have it stick beyond the current boot cycle.

Thanks for the confirmation!

Rayman
10-31-2011, 10:23 PM
Maybe something like this is what you want:
http://forums.parallax.com/showthread.php?97625-PE-Kit-Lab-Applications-%96-EEPROM-Datalogging-and-I2C

andrewsi
10-31-2011, 10:24 PM
Ooh, yeah, that looks like exactly what I want! I'll investigate further.

localroger
10-31-2011, 11:21 PM
Yes, I've done this for several projects. The neat thing is that you don't need to explicitly load updates; you just use the EEPROM library to write the DAT block to its Hub RAM address in EEPROM, and it will be automatically loaded for you when the Prop reboots. The only problem is, as MagIO2 suggests, if you need to download a change to your program you'll default those settings.