From 03ccaa03258cbf2f0fa87e7fce8f5487f139793a Mon Sep 17 00:00:00 2001 From: alberk8 Date: Sun, 3 Dec 2023 10:08:47 +0800 Subject: [PATCH 1/2] Fix Wifi connection failed on noPSRAM hardware --- targets/ESP32/_Network/NF_ESP32_Wireless.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/targets/ESP32/_Network/NF_ESP32_Wireless.cpp b/targets/ESP32/_Network/NF_ESP32_Wireless.cpp index 5638f4ff88..b52606c4a0 100644 --- a/targets/ESP32/_Network/NF_ESP32_Wireless.cpp +++ b/targets/ESP32/_Network/NF_ESP32_Wireless.cpp @@ -157,6 +157,17 @@ esp_err_t NF_ESP32_InitaliseWifi() // Initialise WiFi, allocate resource for WiFi driver, such as WiFi control structure, // RX/TX buffer, WiFi NVS structure etc, this WiFi also start WiFi task. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + +#if CONFIG_SPIRAM_IGNORE_NOTFOUND + //The comment out function below is only avaliable in ESP IDF 5.1x + //if (!esp_psram_is_initialized()){ + if (heap_caps_get_total_size(MALLOC_CAP_SPIRAM) == 0) + { + cfg.cache_tx_buf_num = 0; + cfg.feature_caps &= ~CONFIG_FEATURE_CACHE_TX_BUF_BIT; + } +#endif + ec = esp_wifi_init(&cfg); if (ec != ESP_OK) From b51e67b38613a57380b3c9c829db479233f7531f Mon Sep 17 00:00:00 2001 From: nfbot Date: Sun, 3 Dec 2023 02:28:52 +0000 Subject: [PATCH 2/2] Code style fixes Automated fixes for code style. --- targets/ESP32/_Network/NF_ESP32_Wireless.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/ESP32/_Network/NF_ESP32_Wireless.cpp b/targets/ESP32/_Network/NF_ESP32_Wireless.cpp index b52606c4a0..4a419831a7 100644 --- a/targets/ESP32/_Network/NF_ESP32_Wireless.cpp +++ b/targets/ESP32/_Network/NF_ESP32_Wireless.cpp @@ -159,12 +159,12 @@ esp_err_t NF_ESP32_InitaliseWifi() wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); #if CONFIG_SPIRAM_IGNORE_NOTFOUND - //The comment out function below is only avaliable in ESP IDF 5.1x - //if (!esp_psram_is_initialized()){ + // The comment out function below is only avaliable in ESP IDF 5.1x + // if (!esp_psram_is_initialized()){ if (heap_caps_get_total_size(MALLOC_CAP_SPIRAM) == 0) { - cfg.cache_tx_buf_num = 0; - cfg.feature_caps &= ~CONFIG_FEATURE_CACHE_TX_BUF_BIT; + cfg.cache_tx_buf_num = 0; + cfg.feature_caps &= ~CONFIG_FEATURE_CACHE_TX_BUF_BIT; } #endif