Skip to content

Commit

Permalink
Merge branch 'feat/wifi_support_dynamic_tx_when_psram_enable' into 'm…
Browse files Browse the repository at this point in the history
…aster'

feat(wifi): Fix configuration related to SPIRAM_IGNORE_NOTFOUND

Closes WIFIBUG-701和WIFIBUG-718

See merge request espressif/esp-idf!33138
  • Loading branch information
Wang Tao committed Oct 24, 2024
2 parents 190939e + e65acc9 commit 406dfc1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
16 changes: 6 additions & 10 deletions components/esp_psram/Kconfig.spiram.common
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions components/esp_wifi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/esp_wifi/include/esp_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/esp_wifi/lib
Submodule lib updated 61 files
+ esp32/libcore.a
+ esp32/libespnow.a
+ esp32/libmesh.a
+ esp32/libnet80211.a
+ esp32/libpp.a
+ esp32/libsmartconfig.a
+ esp32/libwapi.a
+ esp32_host/libcore.a
+ esp32_host/libespnow.a
+ esp32_host/libmesh.a
+ esp32_host/libnet80211.a
+ esp32_host/libpp.a
+ esp32_host/libsmartconfig.a
+ esp32_host/libwapi.a
+ esp32c2/libcore.a
+ esp32c2/libespnow.a
+ esp32c2/libnet80211.a
+ esp32c2/libpp.a
+ esp32c2/libsmartconfig.a
+ esp32c3/libcore.a
+ esp32c3/libespnow.a
+ esp32c3/libmesh.a
+ esp32c3/libnet80211.a
+ esp32c3/libpp.a
+ esp32c3/libsmartconfig.a
+ esp32c3/libwapi.a
+ esp32c5/libcore.a
+ esp32c5/libespnow.a
+ esp32c5/libmesh.a
+ esp32c5/libnet80211.a
+ esp32c5/libpp.a
+ esp32c5/libsmartconfig.a
+ esp32c5/libwapi.a
+ esp32c6/libcore.a
+ esp32c6/libespnow.a
+ esp32c6/libmesh.a
+ esp32c6/libnet80211.a
+ esp32c6/libpp.a
+ esp32c6/libsmartconfig.a
+ esp32c6/libwapi.a
+ esp32c61/libcore.a
+ esp32c61/libespnow.a
+ esp32c61/libmesh.a
+ esp32c61/libnet80211.a
+ esp32c61/libpp.a
+ esp32c61/libsmartconfig.a
+ esp32c61/libwapi.a
+ esp32s2/libcore.a
+ esp32s2/libespnow.a
+ esp32s2/libmesh.a
+ esp32s2/libnet80211.a
+ esp32s2/libpp.a
+ esp32s2/libsmartconfig.a
+ esp32s2/libwapi.a
+ esp32s3/libcore.a
+ esp32s3/libespnow.a
+ esp32s3/libmesh.a
+ esp32s3/libnet80211.a
+ esp32s3/libpp.a
+ esp32s3/libsmartconfig.a
+ esp32s3/libwapi.a
2 changes: 1 addition & 1 deletion components/esp_wifi/src/wifi_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions components/lwip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 406dfc1

Please sign in to comment.