From e65acc95109de3e31d0d5fbc983cf0aaf00774f4 Mon Sep 17 00:00:00 2001 From: "wangtao@espressif.com" Date: Wed, 28 Aug 2024 13:33:47 +0800 Subject: [PATCH] feat(wifi): fix SPIRAM_IGNORE_NOTFOUND releated config --- components/esp_psram/Kconfig.spiram.common | 16 ++++++---------- components/esp_wifi/Kconfig | 16 ++++++++-------- components/esp_wifi/include/esp_wifi.h | 2 +- components/esp_wifi/lib | 2 +- components/esp_wifi/src/wifi_netif.c | 2 +- components/lwip/Kconfig | 6 +++--- 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/components/esp_psram/Kconfig.spiram.common b/components/esp_psram/Kconfig.spiram.common index cbff587ffc18..2832f1e67789 100644 --- a/components/esp_psram/Kconfig.spiram.common +++ b/components/esp_psram/Kconfig.spiram.common @@ -17,16 +17,12 @@ config SPIRAM_IGNORE_NOTFOUND help Normally, if psram initialization is enabled during compile time but not found at runtime, it is seen as an error making the CPU panic. If this is enabled, booting will complete - but no PSRAM will be available. If PSRAM failed to initialize, the following configs may be affected - and may need to be corrected manually. SPIRAM_TRY_ALLOCATE_WIFI_LWIP will affect some LWIP and WiFi buffer - default values and range values. Enable SPIRAM_TRY_ALLOCATE_WIFI_LWIP, ESP_WIFI_AMSDU_TX_ENABLED, - ESP_WIFI_CACHE_TX_BUFFER_NUM and use static WiFi Tx buffer may cause potential memory exhaustion issues. - Suggest disable SPIRAM_TRY_ALLOCATE_WIFI_LWIP. - Suggest disable ESP_WIFI_AMSDU_TX_ENABLED. - Suggest disable ESP_WIFI_CACHE_TX_BUFFER_NUM, - need clear CONFIG_FEATURE_CACHE_TX_BUF_BIT of config->feature_caps. - Suggest change ESP_WIFI_TX_BUFFER from static to dynamic. Also suggest to adjust some buffer numbers to the - values used without PSRAM case. Such as, ESP_WIFI_STATIC_TX_BUFFER_NUM, ESP_WIFI_DYNAMIC_TX_BUFFER_NUM. + but no PSRAM will be available. In particular, it is important to note that when SPIRAM_IGNORE_NOTFOUND + is enabled, some WIFI related configs will be set to the default value used when SPIRAM is disabled. + It can be assumed that by enabling this config, WIFI and LWIP will assume that the current chip does not + have SPIRAM. SPIRAM_TRY_ALLOCATE_WIFI_LWIP will not work, buffers in WIFI and LWIP will be set to smaller + ranges and default values. WIFI_CACHE_TX_BUFFER_NUM and ESP_WIFI_AMSDU_TX_ENABLED will be disabled, + ESP_WIFI_TX_BUFFER will be set to ESP_WIFI_DYNAMIC_TX_BUFFER. choice SPIRAM_USE prompt "SPI RAM access method" diff --git a/components/esp_wifi/Kconfig b/components/esp_wifi/Kconfig index eb69f2056cef..f105c83ff3fd 100644 --- a/components/esp_wifi/Kconfig +++ b/components/esp_wifi/Kconfig @@ -28,8 +28,8 @@ menu "Wi-Fi" int "Max number of WiFi static RX buffers" range 2 25 if !SOC_WIFI_HE_SUPPORT range 2 128 if SOC_WIFI_HE_SUPPORT - default 10 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 10 if !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + default 16 if (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) help Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. The static rx buffers are allocated when esp_wifi_init is called, they are not freed @@ -80,7 +80,7 @@ menu "Wi-Fi" bool "Static" config ESP_WIFI_DYNAMIC_TX_BUFFER bool "Dynamic" - depends on !SPIRAM_USE_MALLOC + depends on !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) endchoice config ESP_WIFI_TX_BUFFER_TYPE @@ -105,8 +105,8 @@ menu "Wi-Fi" config ESP_WIFI_CACHE_TX_BUFFER_NUM int "Max number of WiFi cache TX buffers" - depends on SPIRAM - range 16 128 + depends on (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + range 0 128 default 32 help Set the number of WiFi cache TX buffer number. @@ -203,8 +203,8 @@ menu "Wi-Fi" depends on ESP_WIFI_AMPDU_RX_ENABLED range 2 32 if !SOC_WIFI_HE_SUPPORT range 2 64 if SOC_WIFI_HE_SUPPORT - default 6 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 16 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 6 if !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + default 16 if (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) help Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better compatibility but more memory. Most of time we should NOT change the default value unless special @@ -215,7 +215,7 @@ menu "Wi-Fi" config ESP_WIFI_AMSDU_TX_ENABLED bool "WiFi AMSDU TX" - depends on SPIRAM + depends on (ESP_WIFI_CACHE_TX_BUFFER_NUM >= 2) default n help Select this option to enable AMSDU TX feature diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index ce08ecb74846..eb112e06070c 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -129,7 +129,7 @@ typedef struct { #define WIFI_STATIC_TX_BUFFER_NUM 0 #endif -#if CONFIG_SPIRAM +#ifdef CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM #define WIFI_CACHE_TX_BUFFER_NUM CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM #else #define WIFI_CACHE_TX_BUFFER_NUM 0 diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index e9aa24f016bc..02217f5aed73 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit e9aa24f016bcab62a9454f8d69db85f949eacc57 +Subproject commit 02217f5aed73e6296fbb12137a1c36b207b0dab5 diff --git a/components/esp_wifi/src/wifi_netif.c b/components/esp_wifi/src/wifi_netif.c index 9b6183bcd6dc..f42ff6bd52e3 100644 --- a/components/esp_wifi/src/wifi_netif.c +++ b/components/esp_wifi/src/wifi_netif.c @@ -69,7 +69,7 @@ static esp_err_t wifi_transmit(void *h, void *buffer, size_t len) static esp_err_t wifi_transmit_wrap(void *h, void *buffer, size_t len, void *netstack_buf) { wifi_netif_driver_t driver = h; -#if CONFIG_SPIRAM +#if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !CONFIG_SPIRAM_IGNORE_NOTFOUND return esp_wifi_internal_tx_by_ref(driver->wifi_if, buffer, len, netstack_buf); #else return esp_wifi_internal_tx(driver->wifi_if, buffer, len); diff --git a/components/lwip/Kconfig b/components/lwip/Kconfig index c51fab4514b0..33f87955b22f 100644 --- a/components/lwip/Kconfig +++ b/components/lwip/Kconfig @@ -744,8 +744,8 @@ menu "LWIP" int "The maximum number of pbufs queued on OOSEQ per pcb" depends on LWIP_TCP_QUEUE_OOSEQ range 0 12 - default 4 if !SPIRAM_TRY_ALLOCATE_WIFI_LWIP - default 0 if SPIRAM_TRY_ALLOCATE_WIFI_LWIP + default 4 if !(SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) + default 0 if (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) help If LWIP_TCP_OOSEQ_MAX_PBUFS = 0, TCP will not control the number of OOSEQ pbufs. @@ -801,7 +801,7 @@ menu "LWIP" config LWIP_WND_SCALE bool "Support TCP window scale" - depends on SPIRAM_TRY_ALLOCATE_WIFI_LWIP + depends on (SPIRAM_TRY_ALLOCATE_WIFI_LWIP && !SPIRAM_IGNORE_NOTFOUND) default n help Enable this feature to support TCP window scaling.