From f83eff6e51dcecc9b89f22a6c1bd3dd95dfe6bea Mon Sep 17 00:00:00 2001 From: liyashuai Date: Mon, 7 Jul 2025 18:02:05 +0800 Subject: [PATCH] example/thread_border_router: add ota function for otbr example --- examples/thread_border_router/README.md | 9 ++++++ .../thread_border_router/main/CMakeLists.txt | 3 +- examples/thread_border_router/main/linker.lf | 31 +++++++++++++++++++ examples/thread_border_router/partitions.csv | 18 +++++++---- .../thread_border_router/sdkconfig.defaults | 26 ++++++++++++---- 5 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 examples/thread_border_router/main/linker.lf diff --git a/examples/thread_border_router/README.md b/examples/thread_border_router/README.md index ffc1368a3..9bbcd24fa 100644 --- a/examples/thread_border_router/README.md +++ b/examples/thread_border_router/README.md @@ -31,6 +31,15 @@ $ idf.py set-target esp32h2 build After flashing the Thread Border Router firmware to ESP32-S3, it will flash the RCP firmware to ESP32-H2 automatically. +### 1.3 Firmware for Host SoC + +The default setting flash size is 8MB, set target and build as below: + +``` +$ idf.py set-target esp32s3 +$ idf.py build +``` + ## 2. Post Commissioning Setup After commissioning the Border Router with chip-tool, you can set up the Thread network with ThreadBorderRouterManagement cluster. diff --git a/examples/thread_border_router/main/CMakeLists.txt b/examples/thread_border_router/main/CMakeLists.txt index 6b91a8cf5..e33ddae48 100644 --- a/examples/thread_border_router/main/CMakeLists.txt +++ b/examples/thread_border_router/main/CMakeLists.txt @@ -1,5 +1,6 @@ idf_component_register(SRC_DIRS "." - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + LDFRAGMENTS "linker.lf") set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H") diff --git a/examples/thread_border_router/main/linker.lf b/examples/thread_border_router/main/linker.lf new file mode 100644 index 000000000..a233ca7a5 --- /dev/null +++ b/examples/thread_border_router/main/linker.lf @@ -0,0 +1,31 @@ +[mapping:CHIP] +archive: libCHIP.a +entries: + if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: + * (extram_bss) + else: + * (default) + +[mapping:esp_matter] +archive: libesp_matter.a +entries: + if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: + * (extram_bss) + else: + * (default) + +[mapping:main] +archive: libmain.a +entries: + if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: + * (extram_bss) + else: + * (default) + +[mapping:openthread_bss] +archive: libopenthread.a +entries: + if SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y && OPENTHREAD_ENABLED = y: + * (extram_bss) + else: + * (default) diff --git a/examples/thread_border_router/partitions.csv b/examples/thread_border_router/partitions.csv index 31841515f..f57fd3f5b 100644 --- a/examples/thread_border_router/partitions.csv +++ b/examples/thread_border_router/partitions.csv @@ -1,6 +1,12 @@ -# Name, Type, SubType, Offset, Size, Flags -# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table -nvs, data, nvs, , 0xA000, -phy_init, data, phy, , 0x1000, -factory, app, factory, , 3000K, -rcp_fw, data, spiffs, , 600K, +# Name, Type, SubType, Offset, Size, Flags +# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table,,,, +esp_secure_cert,0x3F,, 0xd000, 0x2000, encrypted +nvs, data, nvs, 0x10000, 0xC000, +nvs_keys, data, nvs_keys,0x1C000, 0x1000, encrypted +otadata, data, ota, 0x1D000, 0x2000, +phy_init, data, phy, 0x1F000, 0x1000, +ota_0, app, ota_0, 0x20000, 0x250000, +ota_1, app, ota_1, 0x270000, 0x250000, +rcp_fw, data, spiffs, 0x4C0000, 0xA0000, +fctry, data, nvs, 0x560000, 0x6000 + diff --git a/examples/thread_border_router/sdkconfig.defaults b/examples/thread_border_router/sdkconfig.defaults index 7f347eff2..3d511f56f 100644 --- a/examples/thread_border_router/sdkconfig.defaults +++ b/examples/thread_border_router/sdkconfig.defaults @@ -1,4 +1,4 @@ -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y #enable BT CONFIG_BT_ENABLED=y @@ -14,6 +14,7 @@ CONFIG_CHIP_TASK_STACK_SIZE=10240 # partition table CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" # USB console for Thread border board CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y @@ -49,12 +50,25 @@ CONFIG_OPENTHREAD_SRP_CLIENT=n CONFIG_OPENTHREAD_DNS_CLIENT=n CONFIG_OPENTHREAD_BORDER_ROUTER=y CONFIG_THREAD_NETWORK_COMMISSIONING_DRIVER=n +CONFIG_AUTO_UPDATE_RCP=y + +#Enable chip shell +CONFIG_ENABLE_CHIP_SHELL=y + +# Matter OTA +CONFIG_ENABLE_OTA_REQUESTOR=y # Use platform mDNS CONFIG_USE_MINIMAL_MDNS=n -# Enable Matter shell -CONFIG_ENABLE_CHIP_SHELL=y -CONFIG_ESP_MATTER_CONSOLE_TASK_STACK=4096 - -CONFIG_AUTO_UPDATE_RCP=y +# Use SPIRAM and external alloc +CONFIG_SPIRAM=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_SPIRAM_MODE_QUAD=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=512 +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=16384 +CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y +CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL=y +CONFIG_ESP_MATTER_MEM_ALLOC_MODE_EXTERNAL=y +CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y