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

Moderator: igrr

User avatar
By HiperDoo
#89498 Hello, I have a problem about the memory that the ESP8266 can use, and I know that many have spoken and asked about it, but I can not find a solution (with the Arduino IDE)...

I have planned to do a somewhat complex project, I already did it on an Arduino as a test, but now I want to do it on the ESP8266 because supposedly I can use up to 4MB of flash memory. But loading an empty sketch says that I can only use almost 1MB (on top of that it uses 24% of that memory even when there is nothing). And with the RAM I can only use 82KB and also it uses 33% even with the sketch empty (I don't need a lot of RAM for my project, but it would be good not to waste it meaninglessly).

I have seen in some publications things about SPIFFS, OTA, SPI memory, etc. but Im something new in the world of ESP8266 and I DONT UNDERSTAND why SO MUCH memory disappears. I also saw that most solutions only gave for 2MB or having to replace the SPI flash chip with a bigger one (at most 16MB to only be able to use 8MB).

I would be very grateful if someone explained to me:
1. How to use the maximum capacity of flash memory (if its possible to use 4MB, but Im satisfied with 2MB).
2. If possible, change the SPI flash chip to a 16MB one.
3. If possible don't waste those 24% and 33% of flash and RAM memory.

User avatar
By btidey
#89561 The maximum executable program size for the esp8266 is 1MB. This I believe is a consequence of the way flash memory is cached.

Larger flash memory is useful in two ways. First it can be used as a filing system, originally SPIFFS but now LittleFS is preferred. This is actually good for many applications either to hold large static data, web pages etc, or for storing captured data. Secondly, it allows for OTA firmware updates where a second code image is first downloaded into spare flash space before being activated. So for example a 4MB Flash can be split into a 2MB program space and a 2MB filing system. The 2MB program space then allows the maximum 1MB executable plus its OTA download region.

As to why there is a 'high' basic footprint even with a minimal sketch that is down to the underlying code loaded to support kernel and wifi operations. Although it starts high it will then grow quite slowly with your application so you can build quite complex applications within the 1MB space.

It is possible in some cases to work around the 1MB limit by partitioning the application into several pieces and then switching the base working space but you want to avoid this complication if at all possible.

Similar considerations on usage apply to RAM, buffers for wifi etc.