openthread: Add some flash optimization options for openthread component

openthread: use a certain version of esp_openthread_cli_extension managed component
This commit is contained in:
WanqQixiang 2022-09-27 14:30:46 +08:00
parent 1005c3b9d5
commit 1d826c7a2b
11 changed files with 120 additions and 35 deletions

@ -1 +1 @@
Subproject commit a35ccebb0d6f30879367a795efca1586ec6bbfc3 Subproject commit 2b52a261fef2ad7b630e11866dca567d17170401

View File

@ -34,16 +34,20 @@ if(CONFIG_OPENTHREAD_ENABLED)
if(CONFIG_OPENTHREAD_FTD OR CONFIG_OPENTHREAD_MTD) if(CONFIG_OPENTHREAD_FTD OR CONFIG_OPENTHREAD_MTD)
list(APPEND src_dirs list(APPEND src_dirs
"src" "src"
"openthread/examples/apps/cli"
"openthread/src/core/backbone_router" "openthread/src/core/backbone_router"
"openthread/src/core/coap" "openthread/src/core/coap"
"openthread/src/core/meshcop" "openthread/src/core/meshcop"
"openthread/src/core/net" "openthread/src/core/net"
"openthread/src/cli"
"openthread/src/lib/platform") "openthread/src/lib/platform")
list(APPEND exclude_srcs if(CONFIG_OPENTHREAD_CLI)
"openthread/examples/apps/cli/main.c") list(APPEND src_dirs
"openthread/examples/apps/cli"
"openthread/src/cli")
list(APPEND exclude_srcs
"openthread/examples/apps/cli/main.c")
endif()
elseif(CONFIG_OPENTHREAD_RADIO) elseif(CONFIG_OPENTHREAD_RADIO)
list(APPEND src_dirs list(APPEND src_dirs
@ -61,6 +65,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/src/core/api/ip6_api.cpp" "openthread/src/core/api/ip6_api.cpp"
"openthread/src/core/api/link_api.cpp" "openthread/src/core/api/link_api.cpp"
"openthread/src/core/api/message_api.cpp" "openthread/src/core/api/message_api.cpp"
"openthread/src/core/api/nat64_api.cpp"
"openthread/src/core/api/netdata_api.cpp" "openthread/src/core/api/netdata_api.cpp"
"openthread/src/core/api/random_crypto_api.cpp" "openthread/src/core/api/random_crypto_api.cpp"
"openthread/src/core/api/tcp_api.cpp" "openthread/src/core/api/tcp_api.cpp"

View File

@ -6,6 +6,44 @@ menu "OpenThread"
help help
Select this option to enable OpenThread and show the submenu with OpenThread configuration choices. Select this option to enable OpenThread and show the submenu with OpenThread configuration choices.
config OPENTHREAD_LOG_LEVEL_DYNAMIC
bool "Enable dynamic log level control"
depends on OPENTHREAD_ENABLED
default y
help
Select this option to enable dynamic log level control for OpenThread
choice OPENTHREAD_LOG_LEVEL
prompt "OpenThread log verbosity"
depends on OPENTHREAD_ENABLED && !OPENTHREAD_LOG_LEVEL_DYNAMIC
default OPENTHREAD_LOG_LEVEL_INFO
help
Select OpenThread log level.
config OPENTHREAD_LOG_LEVEL_NONE
bool "No logs"
config OPENTHREAD_LOG_LEVEL_CRIT
bool "Error logs"
config OPENTHREAD_LOG_LEVEL_WARN
bool "Warning logs"
config OPENTHREAD_LOG_LEVEL_NOTE
bool "Notice logs"
config OPENTHREAD_LOG_LEVEL_INFO
bool "Info logs"
config OPENTHREAD_LOG_LEVEL_DEBG
bool "Debug logs"
endchoice #OPENTHREAD_LOG_LEVEL
config OPENTHREAD_LOG_LEVEL
int
depends on OPENTHREAD_ENABLED && !OPENTHREAD_LOG_LEVEL_DYNAMIC
default 0 if OPENTHREAD_LOG_LEVEL_NONE
default 1 if OPENTHREAD_LOG_LEVEL_CRIT
default 2 if OPENTHREAD_LOG_LEVEL_WARN
default 3 if OPENTHREAD_LOG_LEVEL_NOTE
default 4 if OPENTHREAD_LOG_LEVEL_INFO
default 5 if OPENTHREAD_LOG_LEVEL_DEBG
choice OPENTHREAD_RADIO_TYPE choice OPENTHREAD_RADIO_TYPE
prompt "Config the Thread radio type" prompt "Config the Thread radio type"
depends on OPENTHREAD_ENABLED depends on OPENTHREAD_ENABLED
@ -51,6 +89,13 @@ menu "OpenThread"
radio only device. radio only device.
endchoice endchoice
config OPENTHREAD_CLI
bool "Enable Openthread Command-Line Interface"
depends on OPENTHREAD_ENABLED
default y
help
Select this option to enable Command-Line Interface in OpenThread.
config OPENTHREAD_DIAG config OPENTHREAD_DIAG
bool "Enable diag" bool "Enable diag"
depends on OPENTHREAD_ENABLED depends on OPENTHREAD_ENABLED

@ -1 +1 @@
Subproject commit 0758f50523b25f75a4a24f8687946fa4eaf7661e Subproject commit 698e8386c31f2c34e167b65f72a6b2553e838dd9

@ -1 +1 @@
Subproject commit 1b5298eb7663a8fb48402e73a17f6e47db89648c Subproject commit e64ba13faa865aa7febd5cb7dc7eb52ff19a2c5c

View File

@ -41,6 +41,14 @@
*/ */
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
/**
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
*
* Configuration option to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC
/** /**
* @def OPENTHREAD_CONFIG_LOG_LEVEL * @def OPENTHREAD_CONFIG_LOG_LEVEL
* *
@ -48,15 +56,11 @@
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level. * verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
* *
*/ */
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
#else
/** #define OPENTHREAD_CONFIG_LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE #endif
*
* Define as 1 to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#define OPENTHREAD_CONFIG_LOG_CLI 1 #define OPENTHREAD_CONFIG_LOG_CLI 1
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
@ -150,13 +154,13 @@
#endif #endif
/** /**
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE * @def OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
* *
* Define to 1 to enable Border Routing NAT64 support. * Define to 1 to enable Border Routing NAT64 support.
* *
*/ */
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE #ifndef OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
#define OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE 1 #define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 1
#endif #endif
/** /**

View File

@ -41,6 +41,14 @@
*/ */
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED #define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
/**
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
*
* Configuration option to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC
/** /**
* @def OPENTHREAD_CONFIG_LOG_LEVEL * @def OPENTHREAD_CONFIG_LOG_LEVEL
* *
@ -48,15 +56,11 @@
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level. * verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
* *
*/ */
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
#else
/** #define OPENTHREAD_CONFIG_LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE #endif
*
* Define as 1 to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#define OPENTHREAD_CONFIG_LOG_CLI 1 #define OPENTHREAD_CONFIG_LOG_CLI 1
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1 #define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1

View File

@ -0,0 +1,31 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <esp_openthread.h>
#include <openthread/platform/radio.h>
#include <openthread/platform/toolchain.h>
#include <stdint.h>
#include <utils/uart.h>
OT_TOOL_WEAK void otPlatUartReceived(const uint8_t *, uint16_t)
{
}
OT_TOOL_WEAK void otPlatUartSendDone(void)
{
}
OT_TOOL_WEAK void otPlatDiagRadioTransmitDone(otInstance *, otRadioFrame *, otError)
{
}
OT_TOOL_WEAK void otPlatDiagRadioReceiveDone(otInstance *, otRadioFrame *, otError)
{
}
OT_TOOL_WEAK void otPlatDiagAlarmFired(otInstance *)
{
}

View File

@ -1,6 +1,6 @@
## IDF Component Manager Manifest File ## IDF Component Manager Manifest File
dependencies: dependencies:
espressif/esp_ot_cli_extension: "*" espressif/esp_ot_cli_extension: "~0.1.0"
espressif/mdns: "^1.0.3" espressif/mdns: "^1.0.3"
## Required IDF version ## Required IDF version
idf: idf:

View File

@ -43,7 +43,6 @@
#define TAG "ot_esp_cli" #define TAG "ot_esp_cli"
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t *config) static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t *config)
{ {
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_OPENTHREAD(); esp_netif_config_t cfg = ESP_NETIF_DEFAULT_OPENTHREAD();
@ -53,7 +52,6 @@ static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t
return netif; return netif;
} }
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
static void ot_task_worker(void *aContext) static void ot_task_worker(void *aContext)
{ {
@ -66,16 +64,18 @@ static void ot_task_worker(void *aContext)
// Initialize the OpenThread stack // Initialize the OpenThread stack
ESP_ERROR_CHECK(esp_openthread_init(&config)); ESP_ERROR_CHECK(esp_openthread_init(&config));
#if CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC
// The OpenThread log level directly matches ESP log level // The OpenThread log level directly matches ESP log level
(void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL); (void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL);
#endif
// Initialize the OpenThread cli // Initialize the OpenThread cli
esp_openthread_cli_init(); esp_openthread_cli_init();
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
esp_netif_t *openthread_netif; esp_netif_t *openthread_netif;
// Initialize the esp_netif bindings // Initialize the esp_netif bindings
openthread_netif = init_openthread_netif(&config); openthread_netif = init_openthread_netif(&config);
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
esp_cli_custom_command_init(); esp_cli_custom_command_init();
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION #endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
@ -84,10 +84,8 @@ static void ot_task_worker(void *aContext)
esp_openthread_launch_mainloop(); esp_openthread_launch_mainloop();
// Clean up // Clean up
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
esp_netif_destroy(openthread_netif); esp_netif_destroy(openthread_netif);
esp_openthread_netif_glue_deinit(); esp_openthread_netif_glue_deinit();
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
esp_vfs_eventfd_unregister(); esp_vfs_eventfd_unregister();
vTaskDelete(NULL); vTaskDelete(NULL);
@ -104,9 +102,7 @@ void app_main(void)
}; };
ESP_ERROR_CHECK(esp_event_loop_create_default()); ESP_ERROR_CHECK(esp_event_loop_create_default());
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
ESP_ERROR_CHECK(esp_netif_init()); ESP_ERROR_CHECK(esp_netif_init());
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config)); ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
xTaskCreate(ot_task_worker, "ot_cli_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL); xTaskCreate(ot_task_worker, "ot_cli_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);
} }

View File

@ -1,5 +1,5 @@
## IDF Component Manager Manifest File ## IDF Component Manager Manifest File
dependencies: dependencies:
espressif/esp_ot_cli_extension: "*" espressif/esp_ot_cli_extension: "~0.1.0"
idf: idf:
version: ">=4.1.0" version: ">=4.1.0"