Skip to content

Commit 45fb699

Browse files
committed
Merge branch 'feature/openthread_flash_optimization' into 'master'
openthread: Add some flash optimization options See merge request espressif/esp-idf!20290
2 parents dbdd8ee + 1d826c7 commit 45fb699

File tree

11 files changed

+118
-33
lines changed

11 files changed

+118
-33
lines changed

components/openthread/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,20 @@ if(CONFIG_OPENTHREAD_ENABLED)
3434
if(CONFIG_OPENTHREAD_FTD OR CONFIG_OPENTHREAD_MTD)
3535
list(APPEND src_dirs
3636
"src"
37-
"openthread/examples/apps/cli"
3837
"openthread/src/core/backbone_router"
3938
"openthread/src/core/coap"
4039
"openthread/src/core/meshcop"
4140
"openthread/src/core/net"
42-
"openthread/src/cli"
4341
"openthread/src/lib/platform")
4442

45-
list(APPEND exclude_srcs
46-
"openthread/examples/apps/cli/main.c")
43+
if(CONFIG_OPENTHREAD_CLI)
44+
list(APPEND src_dirs
45+
"openthread/examples/apps/cli"
46+
"openthread/src/cli")
47+
48+
list(APPEND exclude_srcs
49+
"openthread/examples/apps/cli/main.c")
50+
endif()
4751

4852
elseif(CONFIG_OPENTHREAD_RADIO)
4953
list(APPEND src_dirs
@@ -61,6 +65,7 @@ if(CONFIG_OPENTHREAD_ENABLED)
6165
"openthread/src/core/api/ip6_api.cpp"
6266
"openthread/src/core/api/link_api.cpp"
6367
"openthread/src/core/api/message_api.cpp"
68+
"openthread/src/core/api/nat64_api.cpp"
6469
"openthread/src/core/api/netdata_api.cpp"
6570
"openthread/src/core/api/random_crypto_api.cpp"
6671
"openthread/src/core/api/tcp_api.cpp"

components/openthread/Kconfig

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,44 @@ menu "OpenThread"
66
help
77
Select this option to enable OpenThread and show the submenu with OpenThread configuration choices.
88

9+
config OPENTHREAD_LOG_LEVEL_DYNAMIC
10+
bool "Enable dynamic log level control"
11+
depends on OPENTHREAD_ENABLED
12+
default y
13+
help
14+
Select this option to enable dynamic log level control for OpenThread
15+
16+
choice OPENTHREAD_LOG_LEVEL
17+
prompt "OpenThread log verbosity"
18+
depends on OPENTHREAD_ENABLED && !OPENTHREAD_LOG_LEVEL_DYNAMIC
19+
default OPENTHREAD_LOG_LEVEL_INFO
20+
help
21+
Select OpenThread log level.
22+
23+
config OPENTHREAD_LOG_LEVEL_NONE
24+
bool "No logs"
25+
config OPENTHREAD_LOG_LEVEL_CRIT
26+
bool "Error logs"
27+
config OPENTHREAD_LOG_LEVEL_WARN
28+
bool "Warning logs"
29+
config OPENTHREAD_LOG_LEVEL_NOTE
30+
bool "Notice logs"
31+
config OPENTHREAD_LOG_LEVEL_INFO
32+
bool "Info logs"
33+
config OPENTHREAD_LOG_LEVEL_DEBG
34+
bool "Debug logs"
35+
endchoice #OPENTHREAD_LOG_LEVEL
36+
37+
config OPENTHREAD_LOG_LEVEL
38+
int
39+
depends on OPENTHREAD_ENABLED && !OPENTHREAD_LOG_LEVEL_DYNAMIC
40+
default 0 if OPENTHREAD_LOG_LEVEL_NONE
41+
default 1 if OPENTHREAD_LOG_LEVEL_CRIT
42+
default 2 if OPENTHREAD_LOG_LEVEL_WARN
43+
default 3 if OPENTHREAD_LOG_LEVEL_NOTE
44+
default 4 if OPENTHREAD_LOG_LEVEL_INFO
45+
default 5 if OPENTHREAD_LOG_LEVEL_DEBG
46+
947
choice OPENTHREAD_RADIO_TYPE
1048
prompt "Config the Thread radio type"
1149
depends on OPENTHREAD_ENABLED
@@ -51,6 +89,13 @@ menu "OpenThread"
5189
radio only device.
5290
endchoice
5391

92+
config OPENTHREAD_CLI
93+
bool "Enable Openthread Command-Line Interface"
94+
depends on OPENTHREAD_ENABLED
95+
default y
96+
help
97+
Select this option to enable Command-Line Interface in OpenThread.
98+
5499
config OPENTHREAD_DIAG
55100
bool "Enable diag"
56101
depends on OPENTHREAD_ENABLED

components/openthread/openthread

Submodule openthread updated 313 files

components/openthread/private_include/openthread-core-esp32x-ftd-config.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,25 @@
4242
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
4343

4444
/**
45-
* @def OPENTHREAD_CONFIG_LOG_LEVEL
45+
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
4646
*
47-
* The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most
48-
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
47+
* Configuration option to enable dynamic log level control.
4948
*
5049
*/
51-
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
50+
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC
5251

5352
/**
54-
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
53+
* @def OPENTHREAD_CONFIG_LOG_LEVEL
5554
*
56-
* Define as 1 to enable dynamic log level control.
55+
* The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most
56+
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
5757
*
5858
*/
59-
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
59+
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
60+
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
61+
#else
62+
#define OPENTHREAD_CONFIG_LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
63+
#endif
6064

6165
#define OPENTHREAD_CONFIG_LOG_CLI 1
6266
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
@@ -150,13 +154,13 @@
150154
#endif
151155

152156
/**
153-
* @def OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE
157+
* @def OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
154158
*
155159
* Define to 1 to enable Border Routing NAT64 support.
156160
*
157161
*/
158-
#ifndef OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE
159-
#define OPENTHREAD_CONFIG_BORDER_ROUTING_NAT64_ENABLE 1
162+
#ifndef OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE
163+
#define OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE 1
160164
#endif
161165

162166
/**

components/openthread/private_include/openthread-core-esp32x-mtd-config.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,25 @@
4242
#define OPENTHREAD_CONFIG_LOG_OUTPUT OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
4343

4444
/**
45-
* @def OPENTHREAD_CONFIG_LOG_LEVEL
45+
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
4646
*
47-
* The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most
48-
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
47+
* Configuration option to enable dynamic log level control.
4948
*
5049
*/
51-
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
50+
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC
5251

5352
/**
54-
* @def OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
53+
* @def OPENTHREAD_CONFIG_LOG_LEVEL
5554
*
56-
* Define as 1 to enable dynamic log level control.
55+
* The log level (used at compile time). If `OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE` is set, this defines the most
56+
* verbose log level possible. See `OPENTHREAD_CONFIG_LOG_LEVEL_INIT` to set the initial log level.
5757
*
5858
*/
59-
#define OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE 1
59+
#if OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE
60+
#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG
61+
#else
62+
#define OPENTHREAD_CONFIG_LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
63+
#endif
6064

6165
#define OPENTHREAD_CONFIG_LOG_CLI 1
6266
#define OPENTHREAD_CONFIG_LOG_PKT_DUMP 1
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <esp_openthread.h>
8+
#include <openthread/platform/radio.h>
9+
#include <openthread/platform/toolchain.h>
10+
#include <stdint.h>
11+
#include <utils/uart.h>
12+
13+
OT_TOOL_WEAK void otPlatUartReceived(const uint8_t *, uint16_t)
14+
{
15+
}
16+
17+
OT_TOOL_WEAK void otPlatUartSendDone(void)
18+
{
19+
}
20+
21+
OT_TOOL_WEAK void otPlatDiagRadioTransmitDone(otInstance *, otRadioFrame *, otError)
22+
{
23+
}
24+
25+
OT_TOOL_WEAK void otPlatDiagRadioReceiveDone(otInstance *, otRadioFrame *, otError)
26+
{
27+
}
28+
29+
OT_TOOL_WEAK void otPlatDiagAlarmFired(otInstance *)
30+
{
31+
}

examples/openthread/ot_br/main/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## IDF Component Manager Manifest File
22
dependencies:
3-
espressif/esp_ot_cli_extension: "*"
3+
espressif/esp_ot_cli_extension: "~0.1.0"
44
espressif/mdns: "^1.0.3"
55
## Required IDF version
66
idf:

examples/openthread/ot_cli/main/esp_ot_cli.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
#define TAG "ot_esp_cli"
4545

46-
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
4746
static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t *config)
4847
{
4948
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
5352

5453
return netif;
5554
}
56-
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
5755

5856
static void ot_task_worker(void *aContext)
5957
{
@@ -66,16 +64,18 @@ static void ot_task_worker(void *aContext)
6664
// Initialize the OpenThread stack
6765
ESP_ERROR_CHECK(esp_openthread_init(&config));
6866

67+
#if CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC
6968
// The OpenThread log level directly matches ESP log level
7069
(void)otLoggingSetLevel(CONFIG_LOG_DEFAULT_LEVEL);
70+
#endif
7171
// Initialize the OpenThread cli
7272
esp_openthread_cli_init();
7373

74-
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
7574
esp_netif_t *openthread_netif;
7675
// Initialize the esp_netif bindings
7776
openthread_netif = init_openthread_netif(&config);
7877

78+
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
7979
esp_cli_custom_command_init();
8080
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
8181

@@ -84,10 +84,8 @@ static void ot_task_worker(void *aContext)
8484
esp_openthread_launch_mainloop();
8585

8686
// Clean up
87-
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
8887
esp_netif_destroy(openthread_netif);
8988
esp_openthread_netif_glue_deinit();
90-
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
9189

9290
esp_vfs_eventfd_unregister();
9391
vTaskDelete(NULL);
@@ -104,9 +102,7 @@ void app_main(void)
104102
};
105103

106104
ESP_ERROR_CHECK(esp_event_loop_create_default());
107-
#if CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
108105
ESP_ERROR_CHECK(esp_netif_init());
109-
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
110106
ESP_ERROR_CHECK(esp_vfs_eventfd_register(&eventfd_config));
111107
xTaskCreate(ot_task_worker, "ot_cli_main", 10240, xTaskGetCurrentTaskHandle(), 5, NULL);
112108
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## IDF Component Manager Manifest File
22
dependencies:
3-
espressif/esp_ot_cli_extension: "*"
3+
espressif/esp_ot_cli_extension: "~0.1.0"
44
idf:
55
version: ">=4.1.0"

0 commit comments

Comments
 (0)