Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By mvdbro
#30119 Giving this calculation inside EEPROM class and the documentation stating that EEPROM start right after SPIFFS:

EEPROMClass EEPROM((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE);)

is it true that _SPIFFS_end points to the first sector after SPIFFS area?

Or is EEPROM emulation actually using the last sector of SPIFFS area?

I'm planning to use the 32kB SPiFFS area for custom purposes and i'm not sure about the proper calculations...

Would this be safe:

uint32_t _firstsector = ((uint32_t)&_SPIFFS_start - 0x40200000) / SPI_FLASH_SEC_SIZE;
uint32_t _lastsector = ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE;

Or would it wipe EEPROM emulation area?
User avatar
By igrr
#30141 SPIFFS resides in the address range from _SPIFFS_start to _SPIFFS_end, last address not included.
So if _SPIFFS_start is 0x40300000 and _SPIFFS_end is 0x40400000, the final dword used by spiffs would be located at 0x403ffffc.

With _firstsector and _lastsector calculated as in your post, you would iterate over them as follows:

for (uint32_t sector = _firstsector; sector < _lastsector; ++sector) { ...

i.e. as in an open-ended range.
User avatar
By mvdbro
#30179 Thanks for your reply! It's clear to me now.

Just finished the code and I can now save and load a bunch of data structs to 32kB flash area without using EEPROM emulation and without using SPIFFS. Saves a lot of valuable RAM and program storage!