I am working with the Artemis Dev Kit and writing software in Arduino. I have a simple test that maintains a count in EEPROM and the value is preserved through a reset or power cycle but when I download an update to the firmware the EERPOM value is lost. I suspect that this has something to do with the EEPROM being simulated with flash and the flash being updated by the firmware update.
Is there any way to avoid having the EEPROM wiped by programming? Would I have the same issue if programming the Artemis via the serial interface (I think the Artemis Red Board uses serial) vs the Dev Kit’s drag and drop method?
Yellowdog is correct that there is no protection on the EEPROM writen into flash. BUT there is also a huge difference depending on the bootloader being used.
When using the Ambiq Secure Bootloader (ASB) the complete data in the flash seems to be erased. After it has loaded the compiled sketch it will call Apollo3-ROM functions to handle the security / decoding of compiled program into a place in the flash before executing. What those ROM functions exactly do… I don’t know… I only know by using EEPROM example1 for the ATP, what has been writen before is changed after loading a new upload.
The Sparkfun Variable Loader (SVL) is working a bit differently. The code is open source. It does not try to create a ‘secure’ binary from the sketch , but loads the binary code starting 0XF000 (60KB). It will only erase the flash needed (in blocks of 256KB) before writing new bytes from the uploaded binary.
EEPROM location is starting by default on 0xFE000 (1016KB) and thus the maximum size is 8K, before it reaches 0xFFFFF ( 1024KB / 1MB) which is defined as the maximum flash memory on Apollo3.
So using SVL and as long as your binary is not more than (1016Kb – 60KB) 956KB, say 900KB to be save, you could use EEPROM.
When using library V2 the binary is 122K to 125K as a starting point (due to MBED) but I have NEVER got to more than 130K. Even Openlog, which has a lot of code and drivers is around 198K.
I’m just getting back to this and I wanted to confirm that you are correct. Now that I am using the Artemis module in my own design with a simple serial interface and SVL (similar to the Artemis Redboard) I no longer see EEPROM being wiped when I download new code. So it must just be the way the Dev Kit does the programming with its drag and drop interface that clears the EEPROM.