From 77b3ad8385dfc03a9dbfa79187c17036fa0c78ad Mon Sep 17 00:00:00 2001 From: xiehang Date: Mon, 7 Dec 2020 11:46:04 +0800 Subject: [PATCH] eps_wifi: Optimize WiFi debug log 1. Add esp_wifi_statis_dump() 2. Optimize WiFi related debug log --- components/esp32/cpu_start.c | 6 +++++ components/esp32/include/esp_wifi.h | 11 +++++++++ components/esp32/include/esp_wifi_types.h | 6 +++++ components/esp32/wifi_init.c | 30 +++++++++++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index b02462630f..713c830138 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -176,6 +176,12 @@ void IRAM_ATTR call_start_cpu0() } #endif +#ifdef CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ + ESP_EARLY_LOGI(TAG, "cpu freq: %d", CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ); +#else + ESP_EARLY_LOGI(TAG, "cpu freq: %d", CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ); +#endif + ESP_EARLY_LOGI(TAG, "Pro cpu up."); if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { const esp_app_desc_t *app_desc = esp_ota_get_app_description(); diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index f920c57bce..b49d62cda3 100644 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -1144,6 +1144,17 @@ esp_err_t esp_wifi_set_inactive_time(wifi_interface_t ifx, uint16_t sec); */ esp_err_t esp_wifi_get_inactive_time(wifi_interface_t ifx, uint16_t *sec); +/** + * @brief Dump WiFi statistics + * + * @param modules statistic modules to be dumped + * + * @return + * - ESP_OK: succeed + * - others: failed + */ +esp_err_t esp_wifi_statis_dump(uint32_t modules); + #ifdef __cplusplus } #endif diff --git a/components/esp32/include/esp_wifi_types.h b/components/esp32/include/esp_wifi_types.h index f7786f5a02..30890af242 100644 --- a/components/esp32/include/esp_wifi_types.h +++ b/components/esp32/include/esp_wifi_types.h @@ -520,6 +520,12 @@ typedef struct { } data; /**< Configuration of ioctl command */ } wifi_ioctl_config_t; +#define WIFI_STATIS_BUFFER (1<<0) +#define WIFI_STATIS_RXTX (1<<1) +#define WIFI_STATIS_HW (1<<2) +#define WIFI_STATIS_DIAG (1<<3) +#define WIFI_STATIS_ALL (-1) + #ifdef __cplusplus } #endif diff --git a/components/esp32/wifi_init.c b/components/esp32/wifi_init.c index be9b4241d5..653b505397 100644 --- a/components/esp32/wifi_init.c +++ b/components/esp32/wifi_init.c @@ -98,6 +98,35 @@ static void esp_wifi_set_debug_log() } +static void esp_wifi_config_info(void) +{ +#ifdef CONFIG_ESP32_WIFI_RX_BA_WIN + ESP_LOGI(TAG, "rx ba win: %d", CONFIG_ESP32_WIFI_RX_BA_WIN); +#endif + ESP_LOGI(TAG, "tcpip mbox: %d", CONFIG_LWIP_TCPIP_RECVMBOX_SIZE); + ESP_LOGI(TAG, "udp mbox: %d", CONFIG_LWIP_UDP_RECVMBOX_SIZE); + ESP_LOGI(TAG, "tcp mbox: %d", CONFIG_LWIP_TCP_RECVMBOX_SIZE); + ESP_LOGI(TAG, "tcp tx win: %d", CONFIG_LWIP_TCP_SND_BUF_DEFAULT); + ESP_LOGI(TAG, "tcp rx win: %d", CONFIG_LWIP_TCP_WND_DEFAULT); + ESP_LOGI(TAG, "tcp mss: %d", CONFIG_LWIP_TCP_MSS); + +#ifdef CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP + ESP_LOGI(TAG, "WiFi/LWIP prefer SPIRAM"); +#endif + +#ifdef CONFIG_ESP32_WIFI_IRAM_OPT + ESP_LOGI(TAG, "WiFi IRAM OP enabled"); +#endif + +#ifdef CONFIG_ESP32_WIFI_RX_IRAM_OPT + ESP_LOGI(TAG, "WiFi RX IRAM OP enabled"); +#endif + +#ifdef CONFIG_LWIP_IRAM_OPTIMIZATION + ESP_LOGI(TAG, "LWIP IRAM OP enabled"); +#endif +} + esp_err_t esp_wifi_init(const wifi_init_config_t *config) { #ifdef CONFIG_PM_ENABLE @@ -116,6 +145,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config) s_wifi_mac_time_update_cb = esp_wifi_internal_update_mac_time; } + esp_wifi_config_info(); return result; }