mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(wifi): fix psram enabled but initialized fail issue
Closes https://github.com/espressif/esp-idf/issues/11971
This commit is contained in:
parent
1881900781
commit
482ba2b909
@ -13,11 +13,20 @@ config SPIRAM_BOOT_INIT
|
||||
config SPIRAM_IGNORE_NOTFOUND
|
||||
bool "Ignore PSRAM when not found"
|
||||
default "n"
|
||||
depends on SPIRAM_BOOT_INIT && !SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
|
||||
depends on SPIRAM_BOOT_INIT && !SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY && !SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY
|
||||
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.
|
||||
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.
|
||||
|
||||
choice SPIRAM_USE
|
||||
prompt "SPI RAM access method"
|
||||
|
@ -66,4 +66,8 @@ if(CONFIG_ESP_WIFI_ENABLED)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CONFIG_SPIRAM)
|
||||
idf_component_optional_requires(PRIVATE esp_psram)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
@ -180,7 +180,6 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs;
|
||||
extern uint64_t g_wifi_feature_caps;
|
||||
|
||||
#define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F
|
||||
|
||||
@ -214,11 +213,41 @@ extern uint64_t g_wifi_feature_caps;
|
||||
#define WIFI_STA_DISCONNECTED_PM_ENABLED false
|
||||
#endif
|
||||
|
||||
#define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0)
|
||||
#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE
|
||||
#define WIFI_ENABLE_WPA3_SAE (1<<0)
|
||||
#else
|
||||
#define WIFI_ENABLE_WPA3_SAE 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_SPIRAM
|
||||
#define WIFI_ENABLE_SPIRAM (1<<1)
|
||||
#else
|
||||
#define WIFI_ENABLE_SPIRAM 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT
|
||||
#define WIFI_FTM_INITIATOR (1<<2)
|
||||
#else
|
||||
#define WIFI_FTM_INITIATOR 0
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT
|
||||
#define WIFI_FTM_RESPONDER (1<<3)
|
||||
#else
|
||||
#define WIFI_FTM_RESPONDER 0
|
||||
#endif
|
||||
|
||||
#define CONFIG_FEATURE_WPA3_SAE_BIT (1<<0)
|
||||
#define CONFIG_FEATURE_CACHE_TX_BUF_BIT (1<<1)
|
||||
#define CONFIG_FEATURE_FTM_INITIATOR_BIT (1<<2)
|
||||
#define CONFIG_FEATURE_FTM_RESPONDER_BIT (1<<3)
|
||||
|
||||
/* Set additional WiFi features and capabilities */
|
||||
#define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \
|
||||
WIFI_ENABLE_SPIRAM | \
|
||||
WIFI_FTM_INITIATOR | \
|
||||
WIFI_FTM_RESPONDER)
|
||||
|
||||
#define WIFI_INIT_CONFIG_DEFAULT() { \
|
||||
.osi_funcs = &g_wifi_osi_funcs, \
|
||||
.wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \
|
||||
@ -240,7 +269,7 @@ extern uint64_t g_wifi_feature_caps;
|
||||
.wifi_task_core_id = WIFI_TASK_CORE_ID,\
|
||||
.beacon_max_len = WIFI_SOFTAP_BEACON_MAX_LEN, \
|
||||
.mgmt_sbuf_num = WIFI_MGMT_SBUF_NUM, \
|
||||
.feature_caps = g_wifi_feature_caps, \
|
||||
.feature_caps = WIFI_FEATURE_CAPS, \
|
||||
.sta_disconnected_pm = WIFI_STA_DISCONNECTED_PM_ENABLED, \
|
||||
.espnow_max_encrypt_num = CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM, \
|
||||
.magic = WIFI_INIT_CONFIG_MAGIC\
|
||||
|
@ -19,6 +19,9 @@
|
||||
#include "private/esp_coexist_internal.h"
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp_private/phy.h"
|
||||
#if __has_include("esp_psram.h")
|
||||
#include "esp_psram.h"
|
||||
#endif
|
||||
#ifdef CONFIG_ESP_WIFI_NAN_ENABLE
|
||||
#include "apps_private/wifi_apps_private.h"
|
||||
#endif
|
||||
@ -45,22 +48,6 @@ static esp_pm_lock_handle_t s_wifi_modem_sleep_lock;
|
||||
wifi_mac_time_update_cb_t s_wifi_mac_time_update_cb = NULL;
|
||||
#endif
|
||||
|
||||
/* Set additional WiFi features and capabilities */
|
||||
uint64_t g_wifi_feature_caps =
|
||||
#if CONFIG_ESP_WIFI_ENABLE_WPA3_SAE
|
||||
CONFIG_FEATURE_WPA3_SAE_BIT |
|
||||
#endif
|
||||
#if CONFIG_SPIRAM
|
||||
CONFIG_FEATURE_CACHE_TX_BUF_BIT |
|
||||
#endif
|
||||
#if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT
|
||||
CONFIG_FEATURE_FTM_INITIATOR_BIT |
|
||||
#endif
|
||||
#if CONFIG_ESP_WIFI_FTM_RESPONDER_SUPPORT
|
||||
CONFIG_FEATURE_FTM_RESPONDER_BIT |
|
||||
#endif
|
||||
0;
|
||||
|
||||
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
|
||||
# define WIFI_BEACON_MONITOR_CONFIG_DEFAULT(ena) { \
|
||||
.enable = (ena), \
|
||||
@ -235,17 +222,46 @@ static void esp_wifi_config_info(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_SPIRAM
|
||||
static esp_err_t esp_wifi_psram_check(const wifi_init_config_t *config)
|
||||
{
|
||||
#if CONFIG_SPIRAM_IGNORE_NOTFOUND
|
||||
if (!esp_psram_is_initialized()) {
|
||||
if (config->feature_caps & CONFIG_FEATURE_CACHE_TX_BUF_BIT) {
|
||||
ESP_LOGW(TAG, "WiFi cache TX buffers should be disabled when initialize SPIRAM failed");
|
||||
}
|
||||
if (config->tx_buf_type == 0) {
|
||||
ESP_LOGW(TAG, "TX buffers type should be changed from static to dynamic when initialize SPIRAM failed");
|
||||
}
|
||||
#ifdef CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP
|
||||
ESP_LOGW(TAG, "WiFi/LWIP prefer SPIRAM should be disabled when initialize SPIRAM failed");
|
||||
#endif
|
||||
if (config->amsdu_tx_enable) {
|
||||
ESP_LOGW(TAG, "WiFi AMSDU TX should be disabled when initialize SPIRAM failed");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ((config->feature_caps & CONFIG_FEATURE_CACHE_TX_BUF_BIT) && (WIFI_CACHE_TX_BUFFER_NUM == 0)) {
|
||||
ESP_LOGE(TAG, "Number of WiFi cache TX buffers should not equal 0 when enable SPIRAM");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t esp_wifi_init(const wifi_init_config_t *config)
|
||||
{
|
||||
if (s_wifi_inited) {
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
if ((config->feature_caps & CONFIG_FEATURE_CACHE_TX_BUF_BIT) && (WIFI_CACHE_TX_BUFFER_NUM == 0))
|
||||
{
|
||||
ESP_LOGE(TAG, "Number of WiFi cache TX buffers should not equal 0 when enable SPIRAM");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
esp_err_t result = ESP_OK;
|
||||
#ifdef CONFIG_SPIRAM
|
||||
result = esp_wifi_psram_check(config);
|
||||
if (result != ESP_OK) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_ESP_WIFI_SLP_IRAM_OPT
|
||||
int min_freq_mhz = esp_pm_impl_get_cpu_freq(PM_MODE_LIGHT_SLEEP);
|
||||
@ -302,7 +318,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
|
||||
#endif
|
||||
esp_wifi_set_log_level();
|
||||
esp_wifi_power_domain_on();
|
||||
esp_err_t result = esp_wifi_init_internal(config);
|
||||
result = esp_wifi_init_internal(config);
|
||||
if (result == ESP_OK) {
|
||||
#if CONFIG_MAC_BB_PD
|
||||
esp_mac_bb_pd_mem_init();
|
||||
|
Loading…
Reference in New Issue
Block a user