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.