Shop OBEX P1 Docs P2 Docs Learn Events
Can you overwrite a preinitialized DAT value in the EEPROM copy of a spin program? — Parallax Forums

Can you overwrite a preinitialized DAT value in the EEPROM copy of a spin program?

andrewsiandrewsi Posts: 59
edited 2011-10-31 16:21 in Propeller 1
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.)

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-10-31 15:18
    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)
  • andrewsiandrewsi Posts: 59
    edited 2011-10-31 15:20
    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!
  • RaymanRayman Posts: 14,864
    edited 2011-10-31 15:23
  • andrewsiandrewsi Posts: 59
    edited 2011-10-31 15:24
    Ooh, yeah, that looks like exactly what I want! I'll investigate further.
  • localrogerlocalroger Posts: 3,452
    edited 2011-10-31 16:21
    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.
Sign In or Register to comment.