diff --git a/components/esp32/ld/esp32.project.ld.in b/components/esp32/ld/esp32.project.ld.in index 4d1d7bd701..dc770b059c 100644 --- a/components/esp32/ld/esp32.project.ld.in +++ b/components/esp32/ld/esp32.project.ld.in @@ -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 : { diff --git a/components/esp32/ld/esp32_fragments.lf b/components/esp32/ld/esp32_fragments.lf index 9e7d77fd25..0a35e27ef0 100644 --- a/components/esp32/ld/esp32_fragments.lf +++ b/components/esp32/ld/esp32_fragments.lf @@ -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: diff --git a/components/esp32c3/ld/esp32c3.project.ld.in b/components/esp32c3/ld/esp32c3.project.ld.in index 2419f1500f..5c3d3aca51 100644 --- a/components/esp32c3/ld/esp32c3.project.ld.in +++ b/components/esp32c3/ld/esp32c3.project.ld.in @@ -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) : { diff --git a/components/esp32c3/ld/esp32c3_fragments.lf b/components/esp32c3/ld/esp32c3_fragments.lf index 252f77e3b1..3df531b55b 100644 --- a/components/esp32c3/ld/esp32c3_fragments.lf +++ b/components/esp32c3/ld/esp32c3_fragments.lf @@ -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: diff --git a/components/esp32s2/ld/esp32s2.project.ld.in b/components/esp32s2/ld/esp32s2.project.ld.in index 172e8296fc..af5c2e07c3 100644 --- a/components/esp32s2/ld/esp32s2.project.ld.in +++ b/components/esp32s2/ld/esp32s2.project.ld.in @@ -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 : { diff --git a/components/esp32s2/ld/esp32s2_fragments.lf b/components/esp32s2/ld/esp32s2_fragments.lf index 5747f62765..96cd3c5082 100644 --- a/components/esp32s2/ld/esp32s2_fragments.lf +++ b/components/esp32s2/ld/esp32s2_fragments.lf @@ -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: diff --git a/components/esp32s3/ld/esp32s3.project.ld.in b/components/esp32s3/ld/esp32s3.project.ld.in index 4735e1fd0f..89796dfb02 100644 --- a/components/esp32s3/ld/esp32s3.project.ld.in +++ b/components/esp32s3/ld/esp32s3.project.ld.in @@ -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) : diff --git a/components/esp32s3/ld/esp32s3_fragments.lf b/components/esp32s3/ld/esp32s3_fragments.lf index 252f77e3b1..3df531b55b 100644 --- a/components/esp32s3/ld/esp32s3_fragments.lf +++ b/components/esp32s3/ld/esp32s3_fragments.lf @@ -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: diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index 1b6d1b2b7a..1a5284dd15 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -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) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 8dc3acb6a6..3de585ffa8 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 8dc3acb6a620b01b9fa69cc8f11e276af8e61580 +Subproject commit 3de585ffa878d062bc19ca55d98fd7dac5475336 diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 2b00a04282..2fd667eab7 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -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