So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By dlx
#74997 I have read as much information as I could on the ESP822 memory map.
https://github.com/esp8266/esp8266-wiki/wiki/Memory-Map
https://circuits4you.com/2018/01/31/exa ... em-spiffs/
and many more.
But still I don't understand the mapping.

I read the spi flash is mapped at 40200000h . But I don't understand what that means.

I would like to know how many sectors I can use with the EEPROM contructor.

In the eeprom class there is this constructor:
EEPROMClass::EEPROMClass(void)
: _sector((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))
, _data(0)
, _size(0)
, _dirty(false)
{
}

I found in the eagle.flash.4M.ld /* spiffs 3052KB */
PROVIDE ( _SPIFFS_start = 0x40300000 );
PROVIDE ( _SPIFFS_end = 0x405FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );

And in the eagle.flash.4M1M.ld /* empty 2048KB - spiffs 1004KB */
PROVIDE ( _SPIFFS_start = 0x40500000 );
PROVIDE ( _SPIFFS_end = 0x405FB000 );
PROVIDE ( _SPIFFS_page = 0x100 );
PROVIDE ( _SPIFFS_block = 0x2000 );

Here are my questions:
1/ Where is the empty memory? After the 1019KB of space reserved for the sketch and before the spiffs?
2/ I don't understand this line _sector((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))
3/ How can I know how many sectors are available in the empty memory?

Thanks for your help
User avatar
By Pablo2048
#75004 1) "free" (AKA unused for now) flash memory begin after current sketch and end @ SPIFFS_start, but beware of OTA (do some study/research how OTA work).
2) It's just physical address -> SPI Flash sector number convert (because you need sector # for SDK flash functions)
3) Oh come on - dig deeper into arduino Core files and take inspiration for example from EspClass::getFreeSketchSpace()