Page 1 of 1

ESP32-C6 Flash consumption for WiFi + NimBLE

Posted: Thu Jun 26, 2025 2:54 pm
by tomatosoup
Hello

Just want to check if this is expected. I have combined the WiFi station example (https://github.com/espressif/esp-idf/tr ... ed/station) and NimBLE power save example (https://github.com/espressif/esp-idf/tr ... power_save) into one Application.

Interestingly, this doesn't fit into 1MB. When extending the factory partition to 2MB, there is about 33% free. So it needs ~1.5MB Flash.
Comparing this with the total 4MB in ESP32-C6FH4, this is quite a tight Flash budget. Especially when thinking to also integrate Zigbee and User logic code.

Are there any chances to drastically optimize this, or is this just reality that such an application needs 2-3MB Flash partition to be adequately future proof?

I have already implemented these parameters in a try to reduce NimBLE Flash usage:

Code: Select all

CONFIG_BT_NIMBLE_MAX_CONNECTIONS=1
CONFIG_BT_NIMBLE_MAX_BONDS=1
CONFIG_BT_NIMBLE_MAX_CCCDS=1
CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n
CONFIG_BT_NIMBLE_LOG_LEVEL_NONE=y
Components Flash usage:

Code: Select all

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━┓
┃ Archive File                    ┃ Total Size ┃ DIRAM ┃  .bss ┃ .data ┃ .text ┃ Flash Code ┃ .rodata ┃ .appdesc ┃  .text ┃ LP SRAM ┃ .rtc_reserved ┃ .force_fast ┃ .text ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━┩
│ libble_app.a                    │     214099 │ 19213 │   229 │   272 │ 18712 │     194886 │    7186 │        0 │ 187700 │       0 │             0 │           0 │     0 │
│ libnet80211.a                   │     186657 │ 19557 │ 10446 │  1793 │  7318 │     167100 │   18944 │        0 │ 148156 │       0 │             0 │           0 │     0 │
│ libpp.a                         │     112196 │ 45453 │  2746 │  3201 │ 39506 │      66743 │   10517 │        0 │  56226 │       0 │             0 │           0 │     0 │
│ liblwip.a                       │     102615 │  2482 │  2470 │    12 │     0 │     100133 │    3455 │        0 │  96678 │       0 │             0 │           0 │     0 │
│ libbt.a                         │      97369 │ 10365 │  5952 │   617 │  3796 │      87004 │    2418 │        0 │  84586 │       0 │             0 │           0 │     0 │
│ libmbedcrypto.a                 │      80483 │   470 │   268 │   116 │    86 │      80013 │    6569 │        0 │  73444 │       0 │             0 │           0 │     0 │
│ libwpa_supplicant.a             │      78931 │  1329 │  1321 │     8 │     0 │      77602 │    1608 │        0 │  75994 │       0 │             0 │           0 │     0 │
│ libesp_app_format.a             │      72145 │    10 │    10 │     0 │     0 │      72135 │   71349 │      256 │    530 │       0 │             0 │           0 │     0 │
│ libesp_hw_support.a             │      57638 │ 17281 │   165 │  1682 │ 15434 │      40221 │    4205 │        0 │  36016 │     136 │            24 │          32 │    80 │

Re: ESP32-C6 Flash consumption for WiFi + NimBLE

Posted: Thu Jun 26, 2025 3:22 pm
by MicroController
Try setting the compiler optimization level to "Performance" (or "Size") instead of "Debug" (via menuconfig, or "CONFIG_COMPILER_OPTIMIZATION_..." in sdkconfig).

Re: ESP32-C6 Flash consumption for WiFi + NimBLE

Posted: Thu Jun 26, 2025 4:19 pm
by tomatosoup
Seems to make just a marginal difference

Code: Select all

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━┓
┃ Archive File                    ┃ Total Size ┃ DIRAM ┃  .bss ┃ .data ┃ .text ┃ Flash Code ┃ .rodata ┃ .appdesc ┃  .text ┃ LP SRAM ┃ .rtc_reserved ┃ .force_fast ┃ .text ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━┩
│ libble_app.a                    │     213947 │ 19213 │   229 │   272 │ 18712 │     194734 │    7186 │        0 │ 187548 │       0 │             0 │           0 │     0 │
│ libnet80211.a                   │     186657 │ 19557 │ 10446 │  1793 │  7318 │     167100 │   18944 │        0 │ 148156 │       0 │             0 │           0 │     0 │
│ libpp.a                         │     112196 │ 45453 │  2746 │  3201 │ 39506 │      66743 │   10517 │        0 │  56226 │       0 │             0 │           0 │     0 │
│ liblwip.a                       │      84535 │  2482 │  2470 │    12 │     0 │      82053 │    3085 │        0 │  78968 │       0 │             0 │           0 │     0 │
│ libbt.a                         │      79561 │ 10644 │  6405 │   617 │  3622 │      68917 │    2391 │        0 │  66526 │       0 │             0 │           0 │     0 │
│ libmbedcrypto.a                 │      72783 │   466 │   268 │   116 │    82 │      72317 │    6569 │        0 │  65748 │       0 │             0 │           0 │     0 │
│ libesp_app_format.a             │      69145 │    10 │    10 │     0 │     0 │      69135 │   68381 │      256 │    498 │       0 │             0 │           0 │     0 │
│ libwpa_supplicant.a             │      65343 │  1329 │  1321 │     8 │     0 │      64014 │    1608 │        0 │  62406 │       0 │             0 │           0 │     0 │
│ libesp_hw_support.a             │      46640 │ 15173 │   165 │  1682 │ 13326 │      31349 │    3703 │        0 │  27646 │     118 │            24 │          32 │    62 │

Code: Select all

cat sdkconfig | grep OPTIMIZATION_SIZ  
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y