From 3a56cfc9b301d82ca2cf8e70271a8c2c1d6bddb7 Mon Sep 17 00:00:00 2001 From: xiehang Date: Mon, 11 Jan 2021 15:32:37 +0800 Subject: [PATCH 1/5] esp_wifi: optimize phy version log --- components/esp32/include/esp_phy_init.h | 7 +++++++ components/esp32/phy_init.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/components/esp32/include/esp_phy_init.h b/components/esp32/include/esp_phy_init.h index 3402f197b0..4a506c72cc 100644 --- a/components/esp32/include/esp_phy_init.h +++ b/components/esp32/include/esp_phy_init.h @@ -244,6 +244,13 @@ esp_err_t esp_modem_sleep_deregister(modem_sleep_module_t module); * microsecond since boot when phy/rf was last switched on */ int64_t esp_phy_rf_get_on_ts(void); + +/** + * @brief Get PHY lib version + * @return PHY lib version. + */ +char * get_phy_version_str(void); + #ifdef __cplusplus } #endif diff --git a/components/esp32/phy_init.c b/components/esp32/phy_init.c index 15bdff74bd..6f2b450658 100644 --- a/components/esp32/phy_init.c +++ b/components/esp32/phy_init.c @@ -621,6 +621,9 @@ static void esp_phy_reduce_tx_power(esp_phy_init_data_t* init_data) void esp_phy_load_cal_and_init(phy_rf_module_t module) { + char * phy_version = get_phy_version_str(); + ESP_LOGI(TAG, "phy_version %s", phy_version); + esp_phy_calibration_data_t* cal_data = (esp_phy_calibration_data_t*) calloc(sizeof(esp_phy_calibration_data_t), 1); if (cal_data == NULL) { From 3df5b89c917959ce566094614a2e26f5d0732dce Mon Sep 17 00:00:00 2001 From: xiehang Date: Tue, 5 Jan 2021 20:21:48 +0800 Subject: [PATCH 2/5] esp_wifi: ESP32 phy add [sections:phy_iram] --- components/esp32/ld/esp32_fragments.lf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/esp32/ld/esp32_fragments.lf b/components/esp32/ld/esp32_fragments.lf index c60b2e19d7..2d46535645 100644 --- a/components/esp32/ld/esp32_fragments.lf +++ b/components/esp32/ld/esp32_fragments.lf @@ -52,6 +52,10 @@ entries: entries: .wifi0iram+ +[sections:phy_iram] +entries: + .phyiram+ + [scheme:default] entries: text -> flash_text @@ -67,6 +71,7 @@ entries: rtc_bss -> rtc_bss wifi_iram -> flash_text wifi_rx_iram -> flash_text + phy_iram -> flash_text [scheme:rtc] entries: @@ -96,3 +101,7 @@ entries: [scheme:wifi_rx_iram] entries: wifi_rx_iram -> iram0_text + +[scheme:phy_iram] +entries: + phy_iram -> iram0_text From ae246927851f30d1f437b0dd7f41110abc854657 Mon Sep 17 00:00:00 2001 From: xiehang Date: Thu, 24 Dec 2020 11:56:18 +0800 Subject: [PATCH 3/5] esp_wifi: Update WiFi lib 1. Add check CSA state before CSA timer process 2. Change wifi scan duration from 120ms to 100ms 3. Using deport reg instead of ahb 4. Check TID in ieee80211_recv_bar() 5. Revert to report specific reason code when receiving deauth during 4-way-handshark 6. Fix the bug that tx ampdu parameter is not from peer device 7. Refactor wifi_interface_t 8. Faster WiFi station connect improvement, avoid 100ms passive scan 9. Add FCS failed packets filter 10.Update esp32 phy lib to v4660 11.Fix csa timer issue 12.Fix country code last byte to space instead of NULL 13.Fix softap cannot forward A-MSDU 14.Fix max tx power to 20dBm 15.Fix the issue that the esp_wifi_sta_get_ap_info can't get country --- components/esp32/include/esp_wifi_types.h | 9 +++++---- components/esp32/lib | 2 +- components/lwip/port/esp32/netif/wlanif.c | 2 +- .../protocols/asio/chat_client/components/wifi_asio.cpp | 2 +- .../protocols/asio/chat_server/components/wifi_asio.cpp | 2 +- .../asio/tcp_echo_server/components/wifi_asio.cpp | 2 +- .../asio/udp_echo_server/components/wifi_asio.cpp | 2 +- examples/protocols/asio/wifi_init/wifi_asio.cpp | 2 +- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/esp32/include/esp_wifi_types.h b/components/esp32/include/esp_wifi_types.h index 9b6b08e777..5725cf8516 100644 --- a/components/esp32/include/esp_wifi_types.h +++ b/components/esp32/include/esp_wifi_types.h @@ -33,10 +33,10 @@ typedef enum { WIFI_MODE_MAX } wifi_mode_t; -typedef esp_interface_t wifi_interface_t; - -#define WIFI_IF_STA ESP_IF_WIFI_STA -#define WIFI_IF_AP ESP_IF_WIFI_AP +typedef enum { + WIFI_IF_STA = ESP_IF_WIFI_STA, + WIFI_IF_AP = ESP_IF_WIFI_AP, +} wifi_interface_t; typedef enum { WIFI_COUNTRY_POLICY_AUTO, /**< Country policy is auto, use the country info of AP to which the station is connected */ @@ -364,6 +364,7 @@ typedef enum { #define WIFI_PROMIS_FILTER_MASK_MISC (1<<3) /**< filter the packets with type of WIFI_PKT_MISC */ #define WIFI_PROMIS_FILTER_MASK_DATA_MPDU (1<<4) /**< filter the MPDU which is a kind of WIFI_PKT_DATA */ #define WIFI_PROMIS_FILTER_MASK_DATA_AMPDU (1<<5) /**< filter the AMPDU which is a kind of WIFI_PKT_DATA */ +#define WIFI_PROMIS_FILTER_MASK_FCSFAIL (1<<6) /**< filter the FCS failed packets, do not open it in general */ #define WIFI_PROMIS_CTRL_FILTER_MASK_ALL (0xFF800000) /**< filter all control packets */ #define WIFI_PROMIS_CTRL_FILTER_MASK_WRAPPER (1<<23) /**< filter the control packets with subtype of Control Wrapper */ diff --git a/components/esp32/lib b/components/esp32/lib index a88a4f3101..c323de3a27 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit a88a4f31015e667fa6ca93aca38a86d85e90aa9d +Subproject commit c323de3a272ff064f72fdb99f45d2e3ec32f6b88 diff --git a/components/lwip/port/esp32/netif/wlanif.c b/components/lwip/port/esp32/netif/wlanif.c index ed5e13ed12..8966297b05 100644 --- a/components/lwip/port/esp32/netif/wlanif.c +++ b/components/lwip/port/esp32/netif/wlanif.c @@ -114,7 +114,7 @@ low_level_output(struct netif *netif, struct pbuf *p) struct pbuf *q = p; err_t ret; - if (wifi_if >= ESP_IF_MAX) { + if (wifi_if > WIFI_IF_AP) { return ERR_IF; } diff --git a/examples/protocols/asio/chat_client/components/wifi_asio.cpp b/examples/protocols/asio/chat_client/components/wifi_asio.cpp index c8d6832a32..f2a0325f22 100644 --- a/examples/protocols/asio/chat_client/components/wifi_asio.cpp +++ b/examples/protocols/asio/chat_client/components/wifi_asio.cpp @@ -95,7 +95,7 @@ void wifi_init_sta() strcpy((char*)(wifi_config.sta.password), EXAMPLE_ESP_WIFI_PASS); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK(esp_wifi_start() ); ESP_LOGI(TAG, "wifi_init_sta finished."); diff --git a/examples/protocols/asio/chat_server/components/wifi_asio.cpp b/examples/protocols/asio/chat_server/components/wifi_asio.cpp index c8d6832a32..f2a0325f22 100644 --- a/examples/protocols/asio/chat_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/chat_server/components/wifi_asio.cpp @@ -95,7 +95,7 @@ void wifi_init_sta() strcpy((char*)(wifi_config.sta.password), EXAMPLE_ESP_WIFI_PASS); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK(esp_wifi_start() ); ESP_LOGI(TAG, "wifi_init_sta finished."); diff --git a/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp b/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp index c8d6832a32..f2a0325f22 100644 --- a/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/tcp_echo_server/components/wifi_asio.cpp @@ -95,7 +95,7 @@ void wifi_init_sta() strcpy((char*)(wifi_config.sta.password), EXAMPLE_ESP_WIFI_PASS); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK(esp_wifi_start() ); ESP_LOGI(TAG, "wifi_init_sta finished."); diff --git a/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp b/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp index c8d6832a32..f2a0325f22 100644 --- a/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp +++ b/examples/protocols/asio/udp_echo_server/components/wifi_asio.cpp @@ -95,7 +95,7 @@ void wifi_init_sta() strcpy((char*)(wifi_config.sta.password), EXAMPLE_ESP_WIFI_PASS); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK(esp_wifi_start() ); ESP_LOGI(TAG, "wifi_init_sta finished."); diff --git a/examples/protocols/asio/wifi_init/wifi_asio.cpp b/examples/protocols/asio/wifi_init/wifi_asio.cpp index c8d6832a32..f2a0325f22 100644 --- a/examples/protocols/asio/wifi_init/wifi_asio.cpp +++ b/examples/protocols/asio/wifi_init/wifi_asio.cpp @@ -95,7 +95,7 @@ void wifi_init_sta() strcpy((char*)(wifi_config.sta.password), EXAMPLE_ESP_WIFI_PASS); ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) ); - ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) ); ESP_ERROR_CHECK(esp_wifi_start() ); ESP_LOGI(TAG, "wifi_init_sta finished."); From 426736c7695aa65abd352488dafd0acb244e185f Mon Sep 17 00:00:00 2001 From: xiehang Date: Mon, 11 Jan 2021 15:41:26 +0800 Subject: [PATCH 4/5] bugfix: fix some wifi bugs 1. fix max tx power to 20dBm 2. fix the issue that the esp_wifi_sta_get_ap_info can't get country --- components/esp32/include/esp_wifi.h | 8 +++++--- components/esp32/phy_init_data.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index d3f78c6caa..6b0931c2c6 100644 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -442,6 +442,8 @@ esp_err_t esp_wifi_scan_get_ap_records(uint16_t *number, wifi_ap_record_t *ap_re /** * @brief Get information of AP which the ESP32 station is associated with * + * @attention When the obtained country information is empty, it means that the AP does not carry country information + * * @param ap_info the wifi_ap_record_t to hold AP information * sta can get the connected ap's phy mode info through the struct member * phy_11b,phy_11g,phy_11n,phy_lr in the wifi_ap_record_t struct. @@ -905,9 +907,9 @@ esp_err_t esp_wifi_set_vendor_ie_cb(esp_vendor_ie_cb_t cb, void *ctx); * @attention 1. Maximum power before wifi startup is limited by PHY init data bin. * @attention 2. The value set by this API will be mapped to the max_tx_power of the structure wifi_country_t variable. * @attention 3. Mapping Table {Power, max_tx_power} = {{8, 2}, {20, 5}, {28, 7}, {34, 8}, {44, 11}, - * {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {78, 20}}. - * @attention 4. Param power unit is 0.25dBm, range is [8, 78] corresponding to 2dBm - 20dBm. - * @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 77],72}, {78,78}} + * {52, 13}, {56, 14}, {60, 15}, {66, 16}, {72, 18}, {80, 20}}. + * @attention 4. Param power unit is 0.25dBm, range is [8, 84] corresponding to 2dBm - 20dBm. + * @attention 5. Relationship between set value and actual value. As follows: {set value range, actual value} = {{[8, 19],8}, {[20, 27],20}, {[28, 33],28}, {[34, 43],34}, {[44, 51],44}, {[52, 55],52}, {[56, 59],56}, {[60, 65],60}, {[66, 71],66}, {[72, 79],72}, {[80, 84],80}}. * * @param power Maximum WiFi transmitting power. * diff --git a/components/esp32/phy_init_data.h b/components/esp32/phy_init_data.h index 2cb12a7378..031813f5b7 100644 --- a/components/esp32/phy_init_data.h +++ b/components/esp32/phy_init_data.h @@ -77,7 +77,7 @@ static const esp_phy_init_data_t phy_init_data= { { 0x18, 0x18, 0x18, - LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 78), + LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 84), LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 72), LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 66), LIMIT(CONFIG_ESP32_PHY_MAX_TX_POWER * 4, 40, 60), From d3a27596a1413a5cb744a7ed12e59c82380b8e49 Mon Sep 17 00:00:00 2001 From: xiehang Date: Wed, 13 Jan 2021 19:48:47 +0800 Subject: [PATCH 5/5] CI: Fix test_phy_rtc_cache_task stack overflow --- components/esp32/test/test_phy_rtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32/test/test_phy_rtc.c b/components/esp32/test/test_phy_rtc.c index 947555bc5a..cc1279520d 100644 --- a/components/esp32/test/test_phy_rtc.c +++ b/components/esp32/test/test_phy_rtc.c @@ -81,7 +81,7 @@ TEST_CASE("Test PHY/RTC functions called when cache is disabled", "[phy_rtc][cac { semphr_done = xSemaphoreCreateCounting(1, 0); - xTaskCreatePinnedToCore(test_phy_rtc_cache_task, "phy_rtc_test_task", 2048, + xTaskCreatePinnedToCore(test_phy_rtc_cache_task, "phy_rtc_test_task", 2176, NULL, configMAX_PRIORITIES-1, NULL, 0); TEST_ASSERT( xSemaphoreTake(semphr_done, portMAX_DELAY) );