Merge branch 'feature/openthread_flash_optimization' into 'master'

openthread: Add some flash optimization options

See merge request espressif/esp-idf!20290
This commit is contained in:
Shu Chen 2022-09-28 21:43:44 +08:00
commit 45fb699542
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)
list(APPEND src_dirs
"src"
"openthread/examples/apps/cli"
"openthread/src/core/backbone_router"
"openthread/src/core/coap"
"openthread/src/core/meshcop"
"openthread/src/core/net"
"openthread/src/cli"
"openthread/src/lib/platform")
list(APPEND exclude_srcs
"openthread/examples/apps/cli/main.c")
if(CONFIG_OPENTHREAD_CLI)
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)
list(APPEND src_dirs
@ -61,6 +65,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
"openthread/src/core/api/ip6_api.cpp"
"openthread/src/core/api/link_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/random_crypto_api.cpp"
"openthread/src/core/api/tcp_api.cpp"

View File

@ -6,6 +6,44 @@ menu "OpenThread"
help
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
prompt "Config the Thread radio type"
depends on OPENTHREAD_ENABLED
@ -51,6 +89,13 @@ menu "OpenThread"
radio only device.
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
bool "Enable diag"
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
/**
* @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
*
@ -48,15 +56,11 @@
* 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
/**
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
*
* Define as 1 to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#else
#define OPENTHREAD_CONFIG_LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#endif
#define OPENTHREAD_CONFIG_LOG_CLI 1
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
@ -150,13 +154,13 @@
#endif
/**
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE
* @def OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
*
* Define to 1 to enable Border Routing NAT64 support.
*
*/
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE
#define OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE 1
#ifndef OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 1
#endif
/**

View File

@ -41,6 +41,14 @@
*/
#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
*
@ -48,15 +56,11 @@
* 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
/**
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
*
* Define as 1 to enable dynamic log level control.
*
*/
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
#else
#define OPENTHREAD_CONFIG_LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#endif
#define OPENTHREAD_CONFIG_LOG_CLI 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
dependencies:
espressif/esp_ot_cli_extension: "*"
espressif/esp_ot_cli_extension: "~0.1.0"
espressif/mdns: "^1.0.3"
## Required IDF version
idf:

View File

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

View File

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