From 519ad1a26b2b1df372fc217d08141ea9746f3e4f Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 21 Aug 2024 11:14:15 +0800 Subject: [PATCH 1/3] esp32: update esp_rcp_update version to 1.2.0 --- .../esp32/components/chip/idf_component.yml | 2 +- .../thread-br-app/esp32/create_ota_image.py | 92 ------------------- .../thread-br-app/esp32/main/CMakeLists.txt | 10 -- .../thread-br-app/esp32/sdkconfig.defaults | 3 + src/platform/ESP32/OpenthreadLauncher.cpp | 14 ++- src/platform/ESP32/OpenthreadLauncher.h | 6 +- 6 files changed, 13 insertions(+), 114 deletions(-) delete mode 100755 examples/thread-br-app/esp32/create_ota_image.py diff --git a/config/esp32/components/chip/idf_component.yml b/config/esp32/components/chip/idf_component.yml index b56040ea3aaa07..aeffec708dba8c 100644 --- a/config/esp32/components/chip/idf_component.yml +++ b/config/esp32/components/chip/idf_component.yml @@ -27,7 +27,7 @@ dependencies: - if: "target != esp32h2" espressif/esp_rcp_update: - version: "1.0.3" + version: "1.2.0" rules: - if: "idf_version >=5.0" diff --git a/examples/thread-br-app/esp32/create_ota_image.py b/examples/thread-br-app/esp32/create_ota_image.py deleted file mode 100755 index 56f7caa81f1b85..00000000000000 --- a/examples/thread-br-app/esp32/create_ota_image.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import os -import pathlib -import struct - -FILETAG_RCP_VERSION = 0 -FILETAG_RCP_FLASH_ARGS = 1 -FILETAG_RCP_BOOTLOADER = 2 -FILETAG_RCP_PARTITION_TABLE = 3 -FILETAG_RCP_FIRMWARE = 4 -FILETAG_BR_OTA_IMAGE = 5 -FILETAG_IMAGE_HEADER = 0xff - -HEADER_ENTRY_SIZE = 3 * 4 -RCP_IMAGE_HEADER_SIZE = HEADER_ENTRY_SIZE * 6 -RCP_FLASH_ARGS_SIZE = 2 * 4 * 3 - - -def append_subfile_header(fout, tag, size, offset): - fout.write(struct.pack(' 0: - fout.write(data) - data = fin.read(buf_size) - - -def append_flash_args(fout, flash_args_path): - with open(flash_args_path, 'r') as f: - # skip first line - next(f) - partition_info_list = [line.split() for line in f] - for offset, partition_file in partition_info_list: - offset = int(offset, 0) - if partition_file.find('bootloader') >= 0: - fout.write(struct.pack('= 0: - fout.write(struct.pack(' #include -#include #include #include -#ifdef CONFIG_OPENTHREAD_BORDER_ROUTER +#if defined(CONFIG_OPENTHREAD_BORDER_ROUTER) && defined(CONFIG_AUTO_UPDATE_RCP) +#include esp_err_t openthread_init_br_rcp(const esp_rcp_update_config_t * update_config); -#endif +#endif // CONFIG_OPENTHREAD_BORDER_ROUTER && CONFIG_AUTO_UPDATE_RCP esp_err_t set_openthread_platform_config(esp_openthread_platform_config_t * config); esp_err_t openthread_init_stack(void); esp_err_t openthread_launch_task(void); From 97dbbb3022dbc94936bbf4da8a5eca3efcdb05c5 Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 21 Aug 2024 11:28:23 +0800 Subject: [PATCH 2/3] change for ESP32ThreadInit --- examples/platform/esp32/common/Esp32ThreadInit.cpp | 4 ++-- examples/platform/esp32/common/Esp32ThreadInit.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/platform/esp32/common/Esp32ThreadInit.cpp b/examples/platform/esp32/common/Esp32ThreadInit.cpp index f02f91c06d5538..985f7a3d4ac31b 100644 --- a/examples/platform/esp32/common/Esp32ThreadInit.cpp +++ b/examples/platform/esp32/common/Esp32ThreadInit.cpp @@ -42,7 +42,7 @@ void ESPOpenThreadInit() .host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(), .port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(), }; -#ifdef CONFIG_OPENTHREAD_BORDER_ROUTER +#if defined(CONFIG_OPENTHREAD_BORDER_ROUTER) && defined(CONFIG_AUTO_UPDATE_RCP) esp_vfs_spiffs_conf_t rcp_fw_conf = { .base_path = "/rcp_fw", .partition_label = "rcp_fw", .max_files = 10, .format_if_mount_failed = false }; @@ -53,7 +53,7 @@ void ESPOpenThreadInit() } esp_rcp_update_config_t rcp_update_config = ESP_OPENTHREAD_RCP_UPDATE_CONFIG(); openthread_init_br_rcp(&rcp_update_config); -#endif // CONFIG_OPENTHREAD_BORDER_ROUTER +#endif // CONFIG_OPENTHREAD_BORDER_ROUTER && CONFIG_AUTO_UPDATE_RCP set_openthread_platform_config(&config); if (ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR) diff --git a/examples/platform/esp32/common/Esp32ThreadInit.h b/examples/platform/esp32/common/Esp32ThreadInit.h index affca51392f65a..a29fd5ff62afa8 100644 --- a/examples/platform/esp32/common/Esp32ThreadInit.h +++ b/examples/platform/esp32/common/Esp32ThreadInit.h @@ -84,7 +84,7 @@ .storage_partition_name = "nvs", .netif_queue_size = 10, .task_queue_size = 10, \ } -#ifdef CONFIG_OPENTHREAD_BORDER_ROUTER +#if defined(CONFIG_OPENTHREAD_BORDER_ROUTER) && defined(CONFIG_AUTO_UPDATE_RCP) #include #define RCP_FIRMWARE_DIR "/spiffs/ot_rcp" @@ -93,7 +93,7 @@ .rcp_type = RCP_TYPE_ESP32H2_UART, .uart_rx_pin = 17, .uart_tx_pin = 18, .uart_port = 1, .uart_baudrate = 115200, \ .reset_pin = 7, .boot_pin = 8, .update_baudrate = 460800, .firmware_dir = "/rcp_fw/ot_rcp", .target_chip = ESP32H2_CHIP, \ } -#endif // CONFIG_OPENTHREAD_BORDER_ROUTER +#endif // CONFIG_OPENTHREAD_BORDER_ROUTER && CONFIG_AUTO_UPDATE_RCP #endif // CONFIG_OPENTHREAD_ENABLED From 75117202b59a3fa95ca93bf4e01ceef26d5e9c8e Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 21 Aug 2024 14:24:55 +0800 Subject: [PATCH 3/3] fix compile error when lwip ipv6 address number > 8 --- examples/thread-br-app/esp32/sdkconfig.defaults | 2 +- src/platform/ESP32/DiagnosticDataProviderImpl.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/thread-br-app/esp32/sdkconfig.defaults b/examples/thread-br-app/esp32/sdkconfig.defaults index 20712bf96d5ae1..498081c21f8c47 100644 --- a/examples/thread-br-app/esp32/sdkconfig.defaults +++ b/examples/thread-br-app/esp32/sdkconfig.defaults @@ -41,7 +41,7 @@ CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n # LWIP CONFIG_LWIP_IPV6_FORWARD=y CONFIG_LWIP_IPV6_AUTOCONFIG=y -CONFIG_LWIP_IPV6_NUM_ADDRESSES=8 +CONFIG_LWIP_IPV6_NUM_ADDRESSES=12 CONFIG_LWIP_MULTICAST_PING=y CONFIG_LWIP_NETIF_STATUS_CALLBACK=y CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y diff --git a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp index 33de4d372199ee..fc2992f20d3fc9 100644 --- a/src/platform/ESP32/DiagnosticDataProviderImpl.cpp +++ b/src/platform/ESP32/DiagnosticDataProviderImpl.cpp @@ -206,7 +206,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** esp_netif_t * netif = esp_netif_next(NULL); NetworkInterface * head = NULL; uint8_t ipv6_addr_count = 0; - esp_ip6_addr_t ip6_addr[kMaxIPv6AddrCount]; + esp_ip6_addr_t ip6_addr[LWIP_IPV6_NUM_ADDRESSES]; if (netif == NULL) { ChipLogError(DeviceLayer, "Failed to get network interfaces"); @@ -253,7 +253,6 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** #endif // !defined(CONFIG_DISABLE_IPV4) static_assert(kMaxIPv6AddrCount <= UINT8_MAX, "Count might not fit in ipv6_addr_count"); - static_assert(ArraySize(ip6_addr) >= LWIP_IPV6_NUM_ADDRESSES, "Not enough space for our addresses."); auto addr_count = esp_netif_get_all_ip6(ifa, ip6_addr); if (addr_count < 0) {