PlatformIO Community

Change ESP8266 SPIFFS size


#1

Hi

in order to be able to use OTA after my firmware grows beyond the ~500K size, I’d like to make SPIFFS on my ESP8266 smaller (or even remove it) so the sketch space will be greater than 1M.
I’m using the Robotdyn NodeMCUs with 2Mbyte (16Mbit) of flash.

Currently, after compiling, platformio shows me this:
PROGRAM: [==== ] 38.1% (used 397504 bytes from 1044464 bytes)

how do I change the 1MB to 2MB? Is this even necessary or is the second megabyte already reserved for OTA (and eeprom and stuff)?

I don’t epect my firmware to grow to 1 Meg but it might grow slightly beyond 512K.

Thanks.


#2

Which board = X are you using in your platformio.ini? You can change the linker script to change SPIFFS usage. see https://docs.platformio.org/en/latest/platforms/espressif8266.html#flash-size


#3

I’m using board = nodemcuv2 because I only recently discovered that the flash chip on this particular board I’m using is only 2 meg and not 4 meg as it is supposed to be on a nodemcuv2.

currently I’m doing
build_flags = -Wl,-Teagle.flash.2m.ld
in the platformio.ini, would that be ok for a 2meg flash chip?

somewhere else I did read that i can’t use more than 1 meg for my program anyway, so I’d have to put const char arrays to SPIFFS anyway, if my software will grow beyond that size.


#4

Have you found that out by doing a esptool.py flash_id from esptool.py repo? For my NodeMCU:

python esptool.py -p COM7 flash_id
esptool.py v2.6
Serial port COM7
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 2c:3a:e8:XX:XX:XX
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4016
Detected flash size: 4MB

Absolutely correct. The ESP8266 can only map a 1 MB address space at a time. See here.

This config would give you 1MB for your sketch, ~1MB empty space (used by OTA update), 0 bytes for SPIFFS and some 22K SDK needed stuff. With this config you can use the maximum size of 1MB for the sketch and the OTA upgrade, as you seem to want it.

Keep in mind that you can create your own linker file with own needs for special cases (e.g., <1MB sketch, <1MB OTA, 64 KB for SPIFFS,…).

For flash layout and OTA process see here, here and here.


#5

Thanks!

I found out about the flash chip size by looking up the flash chip’s datasheet, the robotdyn nodemcu modules don’t have a metal can :wink:

edit: also, they say it on their aliexpress page, there are 16m and 32m modules and I’ve accidentaly bought some 16m modules.