Particle Electron - Internal Flash storage for large data-sets

Hi,

I’m planning to use the Particle Electron to store a large number of data points in Internal Flash. I realize that there is a emulated EEPROM library but the limits mentioned in the documentation is 4096 bytes, I need closer to 64Kbytes.

I have enough space to spare, the compiler shows the below,
Flash used 4840 / 110592 4.4 %
RAM used 1608 / 20480 7.9 %

My primary question being, how do I access this space through the particle IDE? Normally, I would just declare a cost uint8[] array and the linker will place/reserve the array in Flash.

After that, usually there is a low level call through which I can rewrite the Flash array row-by-row(unsure of row-size of STM32 so any info there helps too).

Is there a library to help support operations like this?

Cheers,
Sree Harsha

This is not possible. The flash memory works such that bits are initialized to 1 and can only be cleared to 0 on a bit-by-bit (or byte) basis. The only way to reset a bit back to 1 is to erase the sector (all 128 Kbytes). This would erase all your code, which is not allowed because the STM32 processor does execute in place (XIP). The binary is read out of flash as it’s being executed, so if you erase the running binary, it would crash.

Also, there’s protection to prevent overwriting the user firmware binary.

There are several ways to add additional data storage to a Particle Photon/P1/Electron.

The most common is to add a micro SD card. For prototyping, you can purchase an adapter, though it you are making your own printed circuit board, you can just add the socket directly to your own board.

The SDFAT library provides the software to read and write the SD card. The data written is also compatible with computers, and you can move the card between computer and Particle devices as needed.

If you are building your own circuit board, an even less expensive option is something like the IS25LQ080 SPI flash. It holds 1 Mbyte of data in a tiny 8-SOIC surface mount package and costs US$0.31 in single unit quantities. Winbond is another manufacturer that makes chips up to 16 Mbytes. The SPIFFS library can be used to store files on it.

If you have up to 32K bytes of data that changes frequently but you need non-volatile storage, you could also use a MB85RC256V FRAM device.

1 Like

I appreciate the quick answer. Odd that STM32 has such a difficult flash map to work with. Most other vendors do have a 128/256 byte pages within sectors for this purpose. Much sadness :frowning:

As a super quick follow-up, I’m assuming if I used Boron 2G/3G this wouldn’t be an issue? The NRF chip has 4096 byte boundaries which I can probably use easily.

Is there a planned Boron 2G/3G SOM module release for mass-manufacturing?

There isn’t an API to use the internal or external flash from user firmware, so you’d have to modify Device OS to make that possible. Also a lot of the flash is reserved, so you have to be a bit careful about which parts you use.

There will be both 2G/3G and LTE Cat M1 B series (Boron-like) SoMs available in the second quarter of 2019, I believe.

1 Like