ICACHE and RAM size not being set

I am compiling code for NodeMCU v1.0 ESP12E. In arduino IDE, there are MMU options that allow me to divide the available instruction memory (64KB) into ICACHE and IRAM. Reference here: MMU - Adjust the Ratio of ICACHE to IRAM — ESP8266 Arduino Core 3.1.1-12-g6dfebec8 documentation
By default the 64KB memory is divided into 32KB IRAM and 32KB ICACHE. However, using the MMU option I can divide it into 16KB IRAM and 48KB ICACHE.

In the arduino cli, I tried to achieve the same by using build flags such as the following:

arduino-cli compile -b esp8266:esp8266:nodemcuv2 --build-path /app/build -
build-property "build.extra_flags=-DMMU_IRAM_SIZE=0xC000 -DMMU_ICACHE_SIZE=0x4000 -DMMU_IRAM_HEAP" <sketch-name>

But during compilation, I get a warning saying that the ICACHE size and IRAM size are reassigned. After compilation, however, the size of ICACHE remains 32KB.

Could someone point me in the right direction? I want to be able to adjust the MMU options provided in the arduino IDE via the CLI.

The IDE has MMU options so if you compile even the BareMinimum sketch you should be able to see how the options are set during the compilation and you could then use them with arduino-cli if that is what you want to do

1 Like

While it may appear that the docs and core are "Arduino" they are not, rather you are dealing with 3rd-party core and docs;nothing Official.

Proof is in the JSON:

 "packages": [
    {
      "name": "esp8266",
      "maintainer": "ESP8266 Community",
      "websiteURL": "https://github.com/esp8266/Arduino",
      "email": "ivan@esp8266.com",
      "help": {
        "online": "https://esp8266.com/arduino"
      },
      "platforms": [
        {
          "category": "ESP8266",
          "name": "esp8266",
          "url": "https://github.com/esp8266/Arduino/releases/download/3.1.1/esp8266-3.1.1.zip",
          "version": "3.1.1",

Maybe start by reviewing "issues" known:

You could also ask on
Everything ESP8266

You could also submit an "issue" on GitHub.

As you probably know, both ESP8266 and ESP32 "Arduino cores" are really wrappers around ESP-IDF code base:
Get Started - ESP32 - — ESP-IDF Programming Guide latest documentation (espressif.com)

There may be mismatches in the documentation that may only be specific to the pure IDF environment.

Just saying...

1 Like

Hi @amitash

These are called "custom board options".

Just as you can set custom board options from a menu in Arduino IDE. Arduino CLI allows you to set them in the command line. In order to do this, you must know two things:

  • The "menu ID" of the custom board option you want to configure.
  • The "option ID" of the value you want to set that custom board option to.

You can learn all the available menu IDs and option IDs for a given board by running the following arduino-cli command:

arduino-cli board details --fqbn <FQBN>

(where <FQBN> is replaced by the fully qualified board name of the board you are using)

For example:

$ arduino-cli board details -b esp8266:esp8266:nodemcuv2

Board name:                NodeMCU 1.0 (ESP-12E Module)
FQBN:                      esp8266:esp8266:nodemcuv2
Board version:             3.1.1

Identification properties: board=nodemcuv2

Package name:              esp8266
Package maintainer:        ESP8266 Community
Package URL:               https://arduino.esp8266.com/stable/package_esp8266com_index.json
Package website:           https://github.com/esp8266/Arduino
Package online help:       https://esp8266.com/arduino

Platform name:             esp8266
Platform category:         ESP8266
Platform architecture:     esp8266
Platform URL:              https://github.com/esp8266/Arduino/releases/download/3.1.1/esp8266-3.1.1.zip
Platform file name:        esp8266-3.1.1.zip
Platform size (bytes):     39264710
Platform checksum:         SHA-256:d080c4f754ad5f39a232164e4b534214d042d049b73da5908d0efaf3331db487  

Required tool:             esp8266:xtensa-lx106-elf-gcc                                               3.1.0-gcc10.3-e5f9fec

Required tool:             esp8266:mkspiffs                                                           3.1.0-gcc10.3-e5f9fec

Required tool:             esp8266:mklittlefs                                                         3.1.0-gcc10.3-e5f9fec

Required tool:             esp8266:python3                                                            3.7.2-post1

Option:                    CPU Frequency                                                                                    xtal
                           80 MHz                                                                     ✔                     xtal=80
                           160 MHz                                                                                          xtal=160
Option:                    VTables                                                                                          vt
                           Flash                                                                      ✔                     vt=flash
                           Heap                                                                                             vt=heap
                           IRAM                                                                                             vt=iram
Option:                    C++ Exceptions                                                                                   exception
                           Disabled (new aborts on oom)                                               ✔                     exception=disabled
                           Enabled                                                                                          exception=enabled
Option:                    Stack Protection                                                                                 stacksmash
                           Disabled                                                                   ✔                     stacksmash=disabled
                           Enabled                                                                                          stacksmash=enabled
Option:                    SSL Support                                                                                      ssl
                           All SSL ciphers (most compatible)                                          ✔                     ssl=all
                           Basic SSL ciphers (lower ROM use)                                                                ssl=basic
Option:                    MMU                                                                                              mmu
                           32KB cache + 32KB IRAM (balanced)                                          ✔                     mmu=3232
                           16KB cache + 48KB IRAM (IRAM)                                                                    mmu=4816
                           16KB cache + 48KB IRAM and 2nd Heap (shared)                                                     mmu=4816H
                           16KB cache + 32KB IRAM + 16KB 2nd Heap (not shared)                                              mmu=3216
                           128K Heap External 23LC1024                                                                      mmu=ext128k
                           8M w/256K Heap External 64 MBit PSRAM                                                            mmu=ext8192k
Option:                    Non-32-Bit Access                                                                                non32xfer
                           Use pgm_read macros for IRAM/PROGMEM                                       ✔                     non32xfer=fast
                           Byte/Word access to IRAM/PROGMEM (very slow)                                                     non32xfer=safe
Option:                    Flash Size                                                                                       eesz
                           4MB (FS:2MB OTA:~1019KB)                                                   ✔                     eesz=4M2M
                           4MB (FS:3MB OTA:~512KB)                                                                          eesz=4M3M
                           4MB (FS:1MB OTA:~1019KB)                                                                         eesz=4M1M
                           4MB (FS:none OTA:~1019KB)                                                                        eesz=4M
                           Mapping defined by Hardware and Sketch                                                           eesz=autoflash
Option:                    Builtin Led                                                                                      led
                           2                                                                          ✔                     led=2
                           16                                                                                               led=16
Option:                    lwIP Variant                                                                                     ip
                           v2 Lower Memory                                                            ✔                     ip=lm2f
                           v2 Higher Bandwidth                                                                              ip=hb2f
                           v2 Lower Memory (no features)                                                                    ip=lm2n
                           v2 Higher Bandwidth (no features)                                                                ip=hb2n
                           v2 IPv6 Lower Memory                                                                             ip=lm6f
                           v2 IPv6 Higher Bandwidth                                                                         ip=hb6f
Option:                    Debug port                                                                                       dbg
                           Disabled                                                                   ✔                     dbg=Disabled
                           Serial                                                                                           dbg=Serial
                           Serial1                                                                                          dbg=Serial1
Option:                    Debug Level                                                                                      lvl
                           None                                                                       ✔                     lvl=None____
                           SSL                                                                                              lvl=SSL
                           TLS_MEM                                                                                          lvl=TLS_MEM
                           HTTP_CLIENT                                                                                      lvl=HTTP_CLIENT
                           HTTP_SERVER                                                                                      lvl=HTTP_SERVER
                           SSL+TLS_MEM                                                                                      lvl=SSLTLS_MEM
                           SSL+HTTP_CLIENT                                                                                  lvl=SSLHTTP_CLIENT
                           SSL+HTTP_SERVER                                                                                  lvl=SSLHTTP_SERVER
                           TLS_MEM+HTTP_CLIENT                                                                              lvl=TLS_MEMHTTP_CLIENT
                           TLS_MEM+HTTP_SERVER                                                                              lvl=TLS_MEMHTTP_SERVER
                           HTTP_CLIENT+HTTP_SERVER                                                                          lvl=HTTP_CLIENTHTTP_SERVER
                           SSL+TLS_MEM+HTTP_CLIENT                                                                          lvl=SSLTLS_MEMHTTP_CLIENT
                           SSL+TLS_MEM+HTTP_SERVER                                                                          lvl=SSLTLS_MEMHTTP_SERVER
                           SSL+HTTP_CLIENT+HTTP_SERVER                                                                      lvl=SSLHTTP_CLIENTHTTP_SERVER
                           TLS_MEM+HTTP_CLIENT+HTTP_SERVER                                                                  lvl=TLS_MEMHTTP_CLIENTHTTP_SERVER
                           SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER                                                              lvl=SSLTLS_MEMHTTP_CLIENTHTTP_SERVER
                           CORE                                                                                             lvl=CORE
                           WIFI                                                                                             lvl=WIFI
                           HTTP_UPDATE                                                                                      lvl=HTTP_UPDATE
                           UPDATER                                                                                          lvl=UPDATER
                           OTA                                                                                              lvl=OTA
                           OOM                                                                                              lvl=OOM
                           MDNS                                                                                             lvl=MDNS
                           HWDT                                                                                             lvl=HWDT
                           HWDT_NOEXTRA4K                                                                                   lvl=HWDT_NOEXTRA4K
                           CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS                                                       lvl=COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS
                           CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT                                                  lvl=COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT
                           CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT_NOEXTRA4K                                        lvl=COREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K
                           SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS                       lvl=SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNS
                           SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT                       lvl=SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT      

                           SSL+TLS_MEM+HTTP_CLIENT+HTTP_SERVER+CORE+WIFI+HTTP_UPDATE+UPDATER+OTA+OOM+MDNS+HWDT_NOEXTRA4K                       lvl=SSLTLS_MEMHTTP_CLIENTHTTP_SERVERCOREWIFIHTTP_UPDATEUPDATEROTAOOMMDNSHWDT_NOEXTRA4K
                           NoAssert-NDEBUG                                                                                  lvl=NoAssert-NDEBUG
Option:                    Erase Flash                                                                                      wipe
                           Only Sketch                                                                ✔                     wipe=none
                           Sketch + WiFi Settings                                                                           wipe=sdk
                           All Flash Contents                                                                               wipe=all
Option:                    Upload Speed                                                                                     baud
                           115200                                                                     ✔                     baud=115200
                           57600                                                                                            baud=57600
                           256000                                                                                           baud=256000
                           512000                                                                                           baud=512000
                           921600                                                                                           baud=921600
                           3000000                                                                                          baud=3000000
Programmers:               Id                                                                         Name

Here we can see that the ID for the "MMU" menu is mmu and the ID for the "**16KB cache + 48KB IRAM (IRAM) **" option is 4816.

Now how to specify the custom board option in the arduino-cli commands?

The traditional way to do this is via the FQBN (the -b flag in your command). The format of the FQBN is like this:

<vendor ID>:<architecture>:<board ID>[:<menu ID>=<option ID>[,<menu ID>=<option ID>]...]

So instead of your current command:

arduino-cli compile -b esp8266:esp8266:nodemcuv2 ...

, which uses all default values for board options, you can set your desired configuration like so:

arduino-cli compile -b esp8266:esp8266:nodemcuv2:mmu=4816 ...

In case you prefer to set the board options separately from the FQBN in your command, you can use the --board-options flag:

https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_compile/

--board-options strings        List of board options separated by commas. Or can be used multiple times for multiple options.

This combination of flags is equivalent to the previous command:

arduino-cli compile -b esp8266:esp8266:nodemcuv2 --board-options "mmu=4816" ...

Please give it a try and let me know if you have any questions or problems.

The "extra flags" properties like build.extra_flags are useful in cases where you need to add arbitrary additional flags to the compilation commands, but in cases like this where you have a dedicated formal API provided by the Arduino boards platform author and framework, using that property instead of setting the custom board option is super hacky. The --build-property flag is a powerful and advanced feature of Arduino CLI that requires a good deal of understanding of the internal configuration of the boards platform you are using.

Hello ptillisch : are you able to help me ?
I have an issue that is close to what you have solved. My issue is available at :

Could you help me ?

Basically : when trying to load my sketch on NodeMCU, I have an error message -please refer to the link I gave), and I don't know how/where to change the value of the eesz parameter.

Thanks in advance.
CH

Hi @christophe782. I saw that topic but I'm not involved in the development of Arduino Cloud so I am not able to assist with that. I see that the people who are involved with the development are aware of your report.

Even though you can certainly set the "custom board options" such as eesz when using Arduino CLI, the same is not possible when using Arduino Cloud because it automatically generates and runs the arduino-cli command for you, so the information I shared here isn't directly relevant to your problem (though it might help you to understand the subject in general a bit better).

Thanks a lot. Do you have any idea hox to Be sûre I will receive an answer ? I have no news about my pb for several days...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.