Merge branch 'feature/optimize_wifi_log_by_linker_script_v4.3' into 'release/v4.3'

esp_wifi: move unused WiFi log to noload section to save binary size(backport v4.3)

See merge request espressif/esp-idf!14167
This commit is contained in:
Jiang Jiang Jian 2021-07-01 08:40:11 +00:00
commit ea9dc928ee
11 changed files with 291 additions and 120 deletions

View File

@ -344,7 +344,13 @@ SECTIONS
. = ALIGN(4);
} >default_rodata_seg
_flash_rodata_align = ALIGNOF(.flash.rodata);
.flash.rodata_noload (NOLOAD) :
{
. = ALIGN (4);
mapping[rodata_noload]
} > default_rodata_seg
_flash_rodata_align = ALIGNOF(.flash.rodata_noload);
.flash.text :
{

View File

@ -108,6 +108,26 @@ entries:
entries:
.wifislprxiram+
[sections:wifi_log_error]
entries:
.rodata_wlog_error+
[sections:wifi_log_warning]
entries:
.rodata_wlog_warning+
[sections:wifi_log_info]
entries:
.rodata_wlog_info+
[sections:wifi_log_debug]
entries:
.rodata_wlog_debug+
[sections:wifi_log_verbose]
entries:
.rodata_wlog_verbose+
[scheme:default]
entries:
if APP_BUILD_USE_FLASH_SECTIONS = y:
@ -142,6 +162,42 @@ entries:
wifi_slp_iram -> flash_text
wifi_or_slp_iram -> flash_text
wifi_slp_rx_iram -> flash_text
if WIFI_LOG_DEFAULT_LEVEL_NONE = y:
wifi_log_error -> rodata_noload
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_ERROR = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_WARN = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_INFO = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_DEBUG = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_VERBOSE = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> flash_rodata
[scheme:rtc]
entries:

View File

@ -383,6 +383,12 @@ SECTIONS
. = ALIGN(4);
} > default_rodata_seg
.flash.rodata_noload (NOLOAD) :
{
. = ALIGN (4);
mapping[rodata_noload]
} > default_rodata_seg
/* Marks the end of IRAM code segment */
.iram0.text_end (NOLOAD) :
{

View File

@ -88,6 +88,26 @@ entries:
entries:
.wifislprxiram+
[sections:wifi_log_error]
entries:
.rodata_wlog_error+
[sections:wifi_log_warning]
entries:
.rodata_wlog_warning+
[sections:wifi_log_info]
entries:
.rodata_wlog_info+
[sections:wifi_log_debug]
entries:
.rodata_wlog_debug+
[sections:wifi_log_verbose]
entries:
.rodata_wlog_verbose+
[scheme:default]
entries:
if APP_BUILD_USE_FLASH_SECTIONS = y:
@ -116,6 +136,42 @@ entries:
wifi_slp_iram -> flash_text
wifi_or_slp_iram -> flash_text
wifi_slp_rx_iram -> flash_text
if WIFI_LOG_DEFAULT_LEVEL_NONE = y:
wifi_log_error -> rodata_noload
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_ERROR = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_WARN = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_INFO = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_DEBUG = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_VERBOSE = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> flash_rodata
[scheme:rtc]
entries:

View File

@ -339,7 +339,13 @@ SECTIONS
. = ALIGN(4);
} >default_rodata_seg
_flash_rodata_align = ALIGNOF(.flash.rodata);
.flash.rodata_noload (NOLOAD) :
{
. = ALIGN (4);
mapping[rodata_noload]
} > default_rodata_seg
_flash_rodata_align = ALIGNOF(.flash.rodata_noload);
.flash.text :
{

View File

@ -76,6 +76,26 @@ entries:
entries:
.wifislprxiram+
[sections:wifi_log_error]
entries:
.rodata_wlog_error+
[sections:wifi_log_warning]
entries:
.rodata_wlog_warning+
[sections:wifi_log_info]
entries:
.rodata_wlog_info+
[sections:wifi_log_debug]
entries:
.rodata_wlog_debug+
[sections:wifi_log_verbose]
entries:
.rodata_wlog_verbose+
[scheme:default]
entries:
if APP_BUILD_USE_FLASH_SECTIONS = y:
@ -101,6 +121,42 @@ entries:
wifi_slp_iram -> flash_text
wifi_or_slp_iram -> flash_text
wifi_slp_rx_iram -> flash_text
if WIFI_LOG_DEFAULT_LEVEL_NONE = y:
wifi_log_error -> rodata_noload
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_ERROR = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_WARN = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_INFO = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_DEBUG = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_VERBOSE = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> flash_rodata
[scheme:rtc]
entries:

View File

@ -401,7 +401,13 @@ SECTIONS
. = ALIGN(4);
} > default_rodata_seg
_flash_rodata_align = ALIGNOF(.flash.rodata);
.flash.rodata_noload (NOLOAD) :
{
. = ALIGN (4);
mapping[rodata_noload]
} > default_rodata_seg
_flash_rodata_align = ALIGNOF(.flash.rodata_noload);
/* Marks the end of IRAM code segment */
.iram0.text_end (NOLOAD) :

View File

@ -88,6 +88,26 @@ entries:
entries:
.wifislprxiram+
[sections:wifi_log_error]
entries:
.rodata_wlog_error+
[sections:wifi_log_warning]
entries:
.rodata_wlog_warning+
[sections:wifi_log_info]
entries:
.rodata_wlog_info+
[sections:wifi_log_debug]
entries:
.rodata_wlog_debug+
[sections:wifi_log_verbose]
entries:
.rodata_wlog_verbose+
[scheme:default]
entries:
if APP_BUILD_USE_FLASH_SECTIONS = y:
@ -116,6 +136,42 @@ entries:
wifi_slp_iram -> flash_text
wifi_or_slp_iram -> flash_text
wifi_slp_rx_iram -> flash_text
if WIFI_LOG_DEFAULT_LEVEL_NONE = y:
wifi_log_error -> rodata_noload
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_ERROR = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> rodata_noload
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_WARN = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> rodata_noload
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_INFO = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> rodata_noload
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_DEBUG = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> rodata_noload
if WIFI_LOG_DEFAULT_LEVEL_VERBOSE = y:
wifi_log_error -> flash_rodata
wifi_log_warning -> flash_rodata
wifi_log_info -> flash_rodata
wifi_log_debug -> flash_rodata
wifi_log_verbose -> flash_rodata
[scheme:rtc]
entries:

View File

@ -218,83 +218,33 @@ menu "Wi-Fi"
help
Set the number of WiFi management short buffer.
config ESP32_WIFI_DEBUG_LOG_ENABLE
bool "Enable WiFi debug log"
default n
choice ESP32_WIFI_LOG_DEFAULT_LEVEL
bool "WiFi default log level"
default WIFI_LOG_DEFAULT_LEVEL_INFO
help
Select this option to enable WiFi debug log
Specify how much output to see in logs by default.
You can set lower verbosity level at runtime using
esp_log_level_set function.
choice ESP32_WIFI_DEBUG_LOG_LEVEL
depends on ESP32_WIFI_DEBUG_LOG_ENABLE
prompt "WiFi debug log level"
default ESP32_WIFI_DEBUG_LOG_DEBUG
help
The WiFi log is divided into the following levels: ERROR,WARNING,INFO,DEBUG,VERBOSE.
The ERROR,WARNING,INFO levels are enabled by default, and the DEBUG,VERBOSE levels can be enabled here.
Note that this setting limits which log statements
are compiled into the program. So setting this to, say,
"Warning" would mean that changing log level to "Debug"
at runtime will not be possible.
config ESP32_WIFI_DEBUG_LOG_DEBUG
bool "WiFi Debug Log Debug"
config ESP32_WIFI_DEBUG_LOG_VERBOSE
bool "WiFi Debug Log Verbose"
config WIFI_LOG_DEFAULT_LEVEL_NONE
bool "No output"
config WIFI_LOG_DEFAULT_LEVEL_ERROR
bool "Error"
config WIFI_LOG_DEFAULT_LEVEL_WARN
bool "Warning"
config WIFI_LOG_DEFAULT_LEVEL_INFO
bool "Info"
config WIFI_LOG_DEFAULT_LEVEL_DEBUG
bool "Debug"
config WIFI_LOG_DEFAULT_LEVEL_VERBOSE
bool "Verbose"
endchoice
choice ESP32_WIFI_DEBUG_LOG_MODULE
depends on ESP32_WIFI_DEBUG_LOG_ENABLE
prompt "WiFi debug log module"
default ESP32_WIFI_DEBUG_LOG_MODULE_WIFI
help
The WiFi log module contains three parts: WIFI,COEX,MESH. The WIFI module indicates the logs related to
WiFi, the COEX module indicates the logs related to WiFi and BT(or BLE) coexist, the MESH module indicates
the logs related to Mesh. When ESP32_WIFI_LOG_MODULE_ALL is enabled, all modules are selected.
config ESP32_WIFI_DEBUG_LOG_MODULE_ALL
bool "WiFi Debug Log Module All"
config ESP32_WIFI_DEBUG_LOG_MODULE_WIFI
bool "WiFi Debug Log Module WiFi"
config ESP32_WIFI_DEBUG_LOG_MODULE_COEX
bool "WiFi Debug Log Module Coex"
config ESP32_WIFI_DEBUG_LOG_MODULE_MESH
bool "WiFi Debug Log Module Mesh"
endchoice
config ESP32_WIFI_DEBUG_LOG_SUBMODULE
depends on ESP32_WIFI_DEBUG_LOG_ENABLE
bool "WiFi debug log submodule"
default n
help
Enable this option to set the WiFi debug log submodule.
Currently the log submodule contains the following parts: INIT,IOCTL,CONN,SCAN.
The INIT submodule indicates the initialization process.The IOCTL submodule indicates the API calling
process.
The CONN submodule indicates the connecting process.The SCAN submodule indicates the scaning process.
config ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL
depends on ESP32_WIFI_DEBUG_LOG_SUBMODULE
bool "WiFi Debug Log Submodule All"
default n
help
When this option is enabled, all debug submodules are selected.
config ESP32_WIFI_DEBUG_LOG_SUBMODULE_INIT
depends on ESP32_WIFI_DEBUG_LOG_SUBMODULE && (!ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL)
bool "WiFi Debug Log Submodule Init"
default n
config ESP32_WIFI_DEBUG_LOG_SUBMODULE_IOCTL
depends on ESP32_WIFI_DEBUG_LOG_SUBMODULE && (!ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL)
bool "WiFi Debug Log Submodule Ioctl"
default n
config ESP32_WIFI_DEBUG_LOG_SUBMODULE_CONN
depends on ESP32_WIFI_DEBUG_LOG_SUBMODULE && (!ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL)
bool "WiFi Debug Log Submodule Conn"
default n
config ESP32_WIFI_DEBUG_LOG_SUBMODULE_SCAN
depends on ESP32_WIFI_DEBUG_LOG_SUBMODULE && (!ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL)
bool "WiFi Debug Log Submodule Scan"
default n
config ESP32_WIFI_IRAM_OPT
bool "WiFi IRAM speed optimization"
default n if (BT_ENABLED && ESP32_SPIRAM_SUPPORT)

@ -1 +1 @@
Subproject commit 8dc3acb6a620b01b9fa69cc8f11e276af8e61580
Subproject commit 3de585ffa878d062bc19ca55d98fd7dac5475336

View File

@ -80,51 +80,24 @@ static void __attribute__((constructor)) s_set_default_wifi_log_level(void)
esp_log_level_set("ESPNOW", CONFIG_LOG_DEFAULT_LEVEL);
}
static void esp_wifi_set_debug_log(void)
static void esp_wifi_set_log_level(void)
{
/* set WiFi log level and module */
#if CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE
uint32_t g_wifi_log_level = WIFI_LOG_INFO;
uint32_t g_wifi_log_module = 0;
uint32_t g_wifi_log_submodule = 0;
#if CONFIG_ESP32_WIFI_DEBUG_LOG_DEBUG
g_wifi_log_level = WIFI_LOG_DEBUG;
wifi_log_level_t wifi_log_level = WIFI_LOG_INFO;
/* set WiFi log level */
#if CONFIG_WIFI_LOG_DEFAULT_LEVEL_NONE
wifi_log_level = WIFI_LOG_NONE;
#elif CONFIG_WIFI_LOG_DEFAULT_LEVEL_ERROR
wifi_log_level = WIFI_LOG_ERROR;
#elif CONFIG_WIFI_LOG_DEFAULT_LEVEL_WARN
wifi_log_level = WIFI_LOG_WARNING;
#elif CONFIG_WIFI_LOG_DEFAULT_LEVEL_INFO
wifi_log_level = WIFI_LOG_INFO;
#elif CONFIG_WIFI_LOG_DEFAULT_LEVEL_DEBUG
wifi_log_level = WIFI_LOG_DEBUG;
#elif CONFIG_WIFI_LOG_DEFAULT_LEVEL_VERBOSE
wifi_log_level = WIFI_LOG_VERBOSE;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_VERBOSE
g_wifi_log_level = WIFI_LOG_VERBOSE;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_ALL
g_wifi_log_module = WIFI_LOG_MODULE_ALL;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_WIFI
g_wifi_log_module = WIFI_LOG_MODULE_WIFI;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_COEX
g_wifi_log_module = WIFI_LOG_MODULE_COEX;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_MODULE_MESH
g_wifi_log_module = WIFI_LOG_MODULE_MESH;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_ALL
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_ALL;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_INIT
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_INIT;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_IOCTL
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_IOCTL;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_CONN
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_CONN;
#endif
#if CONFIG_ESP32_WIFI_DEBUG_LOG_SUBMODULE_SCAN
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_SCAN;
#endif
esp_wifi_internal_set_log_level(g_wifi_log_level);
esp_wifi_internal_set_log_mod(g_wifi_log_module, g_wifi_log_submodule, true);
#endif /* CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE*/
esp_wifi_internal_set_log_level(wifi_log_level);
}
esp_err_t esp_wifi_deinit(void)
@ -267,13 +240,13 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
#if CONFIG_SW_COEXIST_ENABLE
coex_init();
#endif
esp_wifi_set_log_level();
esp_err_t result = esp_wifi_init_internal(config);
if (result == ESP_OK) {
#if CONFIG_MAC_BB_PD
esp_mac_bb_pd_mem_init();
esp_wifi_internal_set_mac_sleep(true);
#endif
esp_wifi_set_debug_log();
#if CONFIG_IDF_TARGET_ESP32
s_wifi_mac_time_update_cb = esp_wifi_internal_update_mac_time;
#endif