EEPROM and Backup Ram available to use in P1 module?

Hi,

I am trying to store a block of data into the EEPROM or the backup RAM, prefer EEPROM if the size fits. I am trying to find out what is the available size that I have to work with. According to the documents, the P1 module have 4KB of backup RAM and 2047 bytes of emulated EEPROM. Are this available for the user to use? If not what is the size I could use? Thanks.

@sheng, There is only 3KB of back RAM and it only retains data if Vbat power is maintained. The EEPROM size is correct. The P1 has a 1MB external SPI flash chip which you can use as well.

@peekay123, the 1MB external SPI flash chip seem like the option for me. If I remember correctly, the 1MB external SPI flash chip is non-volatile. Please correctly if I am wrong. Is there document/example on how to access the 1MB SPI flash chip? I was trying to find some information on the reference docs, it point to the core.

@sheng, flash is non-volatile by design so yes, the external SPI flash is non-volatile. You will need to search the forum for details as the documentation on this flash is poor (ie non-existent!)

@peekay123, ok I will go fishing in the forum. lol :smile:

1 Like

Hi @peekay123 , Do you know what’s the start address of EEPROM (ie 2048 bytes) in memory? Thank you

@Arjun, do you mean the address of internal flash which emulates EEPROM?

yes @peekay123 as I read in particle API reference, for Photon and Electron there is 2048 bytes of emulated EEPROM available, I assumed P1 could also have 2048 bytes of emulated EEPROM. But exactly at what address this emulated EEPROM (2048 bytes) starts for P1? thanks

@Arjun, why do you need the address? I ask because in order to reduce wear on flash, the emulation firmware does wear-leveling, using 32KB (with another 32KB left unused) of flash to do this. The P1 datasheet shows:

MEMORY MAP (COMMON)

Region	    Start Address	End Address	Size
Bootloader	0x8000000	    0x8004000	16 KB
DCT1	    0x8004000  	    0x8008000	16 KB
DCT2	    0x8008000	    0x800C000	16 KB
EEPROM1  	0x800C000 	    0x8010000	16 KB
EEPROM2 	0x8010000	    0x8020000	64 KB

@peekay123 I read this but I am facing some issues with my P1, it’s not working. Even after giving power it’s offline. (It was online before I did hardfault by incorrect use of SPI.transfer function), I tried to flash code offline using STM32 workbench that’s getting failed. I have STM32 ST link utility. I am able to flash code with that. So after writing to EEPROM i want to check from ST link utility if my P1 is working or not. So is there any fix start address for emulated EEPROM? so i can see if my P1 is working or not. Thanks

@Arjun, due to the way that wear-leveling is done to emulate EEPROM, there is no simple way to check if EEPROM emulation is working or not with an ST-Link.

I would start by reflashing the latest system firmware via DFU if possible, if not via STLink being very careful with the addresses you write to. Then flash Tinker to the device and test connectivity. After all that, you can start testing the EEPROM. What confuses me is whether you are referring to the INTERNAL STM32 flash or the EXTERNAL SPI flash. Can you clarify?

@peekay123, I am sorry, I am not sure, what internal and external stm flash you are talking about.

@Arjun, I think it’s time to step back and review. The P1 contains a P0 module which is the STM32F205 MCU and the Broadcom (Cypress now) wifi chip. The board also has an external SPI flash of 1MB in size. The STM32 MCU has 1MB of onboard flash, most of which is used by the Particle firmware AND a small amount for emulating EEPROM. The external SPI flash is commonly used with the flash-eeprom library to simplify the use of the external flash.

Flash memory supports a limited number of erase cycles before it wears out. As such EEPROM emulation software uses extra flash memory in order to support “wear leveling” and extend the life of the flash.

Now, back to your question. On the P1, the 2047 bytes of EEPROM is emulated from onboard (not external) flash. The EEPROM emulation uses two 16KB pages of flash to emulate 2KB of EEPROM with wear leveling. Accessing the external SPI is not documented and a forum search may be necessary. This external flash is not accessible via DFU (that I know of).

Which flash memory are you wanting to use?

@peekay123 I just want to use the onboard(not external) flash.

@Arjun, what you are calling EEPROM is really internal flash. It sounds like you are trying to reflash the system firmware to your P1. There are several ways to do that if you follow these instructions. Be sure to follow those specific to the P1:

https://docs.particle.io/reference/firmware/photon/?fw_ver=0.6.2&cli_ver=1.22.0&electron_parts=3#programming-and-debugging-notes

I suggest that once the firmware has been flashed over, you flash over the Tinker app to test everything.