From d5f3f73f51ed0718fdd56789848eed9c2f151444 Mon Sep 17 00:00:00 2001 From: Xu Si Yu Date: Tue, 12 Sep 2023 10:45:20 +0800 Subject: [PATCH 1/2] fix(openthread): copy the networkname with a null terminator --- components/openthread/src/esp_openthread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/openthread/src/esp_openthread.cpp b/components/openthread/src/esp_openthread.cpp index 5c35003da9..14a9aa43ca 100644 --- a/components/openthread/src/esp_openthread.cpp +++ b/components/openthread/src/esp_openthread.cpp @@ -112,7 +112,7 @@ esp_err_t esp_openthread_auto_start(otOperationalDatasetTlvs *datasetTlvs) dataset.mComponents.mIsPanIdPresent = true; len = strlen(CONFIG_OPENTHREAD_NETWORK_NAME); assert(len <= OT_NETWORK_NAME_MAX_SIZE); - memcpy(dataset.mNetworkName.m8, CONFIG_OPENTHREAD_NETWORK_NAME, len); + memcpy(dataset.mNetworkName.m8, CONFIG_OPENTHREAD_NETWORK_NAME, len + 1); dataset.mComponents.mIsNetworkNamePresent = true; // Extended Pan ID From 614024106e5cd683c717296549cea966953e1470 Mon Sep 17 00:00:00 2001 From: Xu Si Yu Date: Fri, 8 Sep 2023 12:16:24 +0800 Subject: [PATCH 2/2] feat(openthread): rcp size optimization configurations --- .../openthread/ot_br/main/idf_component.yml | 2 +- examples/openthread/ot_br/partitions.csv | 2 +- examples/openthread/ot_rcp/README.md | 28 +++++++++++++++++++ examples/openthread/ot_rcp/sdkconfig.defaults | 18 +++++++++++- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/examples/openthread/ot_br/main/idf_component.yml b/examples/openthread/ot_br/main/idf_component.yml index 6567df8d22..947edba2dd 100644 --- a/examples/openthread/ot_br/main/idf_component.yml +++ b/examples/openthread/ot_br/main/idf_component.yml @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: espressif/esp_ot_cli_extension: - version: "~0.4.0" + version: "~1.0.0" espressif/mdns: "^1.0.3" ## Required IDF version idf: diff --git a/examples/openthread/ot_br/partitions.csv b/examples/openthread/ot_br/partitions.csv index 4305c74725..1da5005fac 100644 --- a/examples/openthread/ot_br/partitions.csv +++ b/examples/openthread/ot_br/partitions.csv @@ -2,4 +2,4 @@ # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap nvs, data, nvs, 0x9000, 0x6000, phy_init, data, phy, 0xf000, 0x1000, -factory, app, factory, 0x10000, 1600K, +factory, app, factory, 0x10000, 1700K, diff --git a/examples/openthread/ot_rcp/README.md b/examples/openthread/ot_rcp/README.md index 0096e99bb6..a3f1b8eefd 100644 --- a/examples/openthread/ot_rcp/README.md +++ b/examples/openthread/ot_rcp/README.md @@ -19,6 +19,34 @@ To run this example, a board with IEEE 802.15.4 module (for example ESP32-H2) is The default communication interface is port 0 of ESP32-H2 UART running at 460800 baud, change the configuration in [esp_ot_config.h](main/esp_ot_config.h) if you want to use another interface or need different communication parameters. +### RCP Size Optimization Configuration + +To optimize the size of the RCP firmware, the following configurations are enabled by default: + +``` +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS=y +CONFIG_ESP_ERR_TO_NAME_LOOKUP=n +CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT=y +CONFIG_LOG_DEFAULT_LEVEL_NONE=y +CONFIG_NEWLIB_NANO_FORMAT=y +CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n +CONFIG_OPENTHREAD_LOG_LEVEL_NONE=y +``` +Configure them via `idf.py menuconfig` if you need. + +The firmware size are as follows (reference value): + +``` + Before Optimization After Optimization + +esp_ot_rcp.bin for esp32h2 314KB 184KB + +esp_ot_rcp.bin for esp32c6 299KB 208kb +``` + ### Build and Flash Build the project and flash it to the board: diff --git a/examples/openthread/ot_rcp/sdkconfig.defaults b/examples/openthread/ot_rcp/sdkconfig.defaults index 3b8c9d13e4..cc6c671d8e 100644 --- a/examples/openthread/ot_rcp/sdkconfig.defaults +++ b/examples/openthread/ot_rcp/sdkconfig.defaults @@ -19,12 +19,13 @@ CONFIG_PARTITION_TABLE_MD5=y # CONFIG_OPENTHREAD_ENABLED=y CONFIG_OPENTHREAD_RADIO=y -CONFIG_OPENTHREAD_DIAG=y +CONFIG_OPENTHREAD_DIAG=n CONFIG_OPENTHREAD_COMMISSIONER=n CONFIG_OPENTHREAD_JOINER=n CONFIG_OPENTHREAD_BORDER_ROUTER=n CONFIG_OPENTHREAD_CLI=n CONFIG_OPENTHREAD_SRP_CLIENT=n +CONFIG_OPENTHREAD_DNS_CLIENT=n # end of OpenThread @@ -34,3 +35,18 @@ CONFIG_OPENTHREAD_SRP_CLIENT=n CONFIG_LOG_BOOTLOADER_LEVEL_ERROR=y CONFIG_LOG_BOOTLOADER_LEVEL_INFO=n # End of deprecated options + + +# +# Configurations for optimizing the size of ot_rcp firmware +# +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS=y +CONFIG_ESP_ERR_TO_NAME_LOOKUP=n +CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT=y +CONFIG_LOG_DEFAULT_LEVEL_NONE=y +CONFIG_NEWLIB_NANO_FORMAT=y +CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n +CONFIG_OPENTHREAD_LOG_LEVEL_NONE=y