LittleFS & EEPROM

I’m interested in using the 2MB of QSPI memory using LittleFS on my Argon. I’d like to use it to store sensor data that the Argon collects when the cloud connection is not available. Each grouping of data is 25 bytes, which means I could potentially have a whopping 80,000 data points in the QSPI memory. I’ve read through the File System in the docs, and because I’m a total noob to it, using it looks very intimidating to use. I’m very comfortable using the EEPROM functions - is there any way to utilize the full 2MB using something akin to the EEPROM functions (i.e put(), get(), etc.)?
If not, does anyone have any really simplified examples of utilizing the QSPI memory for data storage like I’m suggesting?
Thanks in advance for any suggestions!

Hi @tommy_boy, There exists the possibility to use the flash memory like an EEPROM memory, on this device, the EEPROM emulation is stored as a file on the flash file system. Maybe you can consult this documentation about this https://docs.particle.io/reference/device-os/firmware/boron/#eeprom.

In this documentation exist some methods (put,read,get,write ) to work the flash memory like an EEPROM memory.

Thanks @ismaelSB, there’s some differences in the write/read capability between using the File System API and the EEPROM functions. The put() and get() EEPROM functions auto-detect the type of variable being written/read while the File System seems to require c-style strings or have I misunderstood the reference documentation? After creating a new file on the File System, is it necessary to convert all the data to be saved to the file into a string before writing it?

Can you point us to the documents that may produce that misconception?
The LittleFS system does of course also support binary data (e.g. indicated by void* buf in read() and write())

BTW, for EEPROM.put() and EEPROM.get() you also need to be careful to only use datatypes they can handle correctly. String objects for instance are not stored correctly, instead you need to use C-strings instead.

Sure thing @ScruffR. I misunderstood the documentation by interpreting the example of…

int fd = open("/FileSystemTest/test1.txt", O_RDWR | O_CREAT | O_TRUNC);

being a .txt file and the read and write functions of the File System using pointers on the data to manipulate. This reminded me of how to manipulate c-style strings so that’s where my confusion began. I’ll experiment with various data types using the File System functions instead of only using strings.

Thanks very much for the responses!

1 Like