From 4f93a707f8d2d8c2ffc575fbcdcde964f1a5b19e Mon Sep 17 00:00:00 2001 From: Sagar Bijwe Date: Wed, 5 Feb 2020 18:34:05 +0530 Subject: [PATCH 1/2] WiFi: Add support for ESP32S2 1) Update WiFi and PHY libs for ESP32S2. 2) Remove KConfig options ESP32S2 PHY lib selection. 3) Change target macros from ESP32S2BETA to ESP32S2 --- components/esp32s2/Kconfig | 21 ------------------- components/esp_wifi/CMakeLists.txt | 13 +----------- components/esp_wifi/esp32s2/esp_adapter.c | 2 +- .../include/esp_private/wifi_os_adapter.h | 2 +- components/esp_wifi/include/esp_wifi_types.h | 9 ++++++-- components/esp_wifi/lib | 2 +- components/esp_wifi/src/phy_init.c | 5 +++++ 7 files changed, 16 insertions(+), 38 deletions(-) diff --git a/components/esp32s2/Kconfig b/components/esp32s2/Kconfig index 1bb1b845f5..62c3ab42c3 100644 --- a/components/esp32s2/Kconfig +++ b/components/esp32s2/Kconfig @@ -4,27 +4,6 @@ menu "ESP32S2-specific" # not working so we just hide all items here visible if IDF_TARGET_ESP32S2 - choice ESP32S2_CHIP_VERSION - # TODO: remove once final S2 chip is supported - prompt "ESP32-S2 chip version" - default ESP32S2_VERSION_A - help - There are three versions of ESP32-S2 chip with different Wi-Fi PHY: A, B and Marlin3. - - This setting must match the chip for Wi-Fi to work correctly. You can determine - the chip version by reading the markings on top of the chip. It will be one of the - three options given here. - - The Wi-Fi performance of Marlin3 is the best among the three versions of chip. - - config ESP32S2_VERSION_A - bool "Chip7.2.2-A" - config ESP32S2_VERSION_B - bool "Chip7.2.2-B" - config ESP32S2_VERSION_MARLIN3 - bool "Marlin3-B2 or Marlin3-B3" - endchoice - choice ESP32S2_DEFAULT_CPU_FREQ_MHZ prompt "CPU frequency" default ESP32S2_DEFAULT_CPU_FREQ_160 if !IDF_ENV_FPGA diff --git a/components/esp_wifi/CMakeLists.txt b/components/esp_wifi/CMakeLists.txt index a1664100c4..453f519953 100644 --- a/components/esp_wifi/CMakeLists.txt +++ b/components/esp_wifi/CMakeLists.txt @@ -40,18 +40,7 @@ endif() target_link_libraries(${COMPONENT_LIB} PUBLIC "-L ${CMAKE_CURRENT_SOURCE_DIR}/lib/${target_name}") if(link_binary_libs) - if(CONFIG_IDF_TARGET_ESP32) - set(phy phy) - elseif(CONFIG_IDF_TARGET_ESP32S2) - # TODO: remove once final S2 chip is supported - if(CONFIG_ESP32S2_VERSION_A) - set(phy phyA) - elseif(CONFIG_ESP32S2_VERSION_B) - set(phy phyB) - elseif(CONFIG_ESP32S2_VERSION_MARLIN3) - set(phy phy_marlin3) - endif() - endif() + set(phy phy) set(blobs coexist core espnow mesh net80211 pp rtc smartconfig ${phy}) foreach(blob ${blobs}) diff --git a/components/esp_wifi/esp32s2/esp_adapter.c b/components/esp_wifi/esp32s2/esp_adapter.c index 9e7614dbba..7e1ba7d99f 100644 --- a/components/esp_wifi/esp32s2/esp_adapter.c +++ b/components/esp_wifi/esp32s2/esp_adapter.c @@ -582,7 +582,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = { ._get_random = os_get_random, ._get_time = get_time_wrapper, ._random = os_random, -#if CONFIG_IDF_TARGET_ESP32S2BETA +#if CONFIG_IDF_TARGET_ESP32S2 ._slowclk_cal_get = esp_clk_slowclk_cal_get, #endif ._log_write = esp_log_write, diff --git a/components/esp_wifi/include/esp_private/wifi_os_adapter.h b/components/esp_wifi/include/esp_private/wifi_os_adapter.h index 06cb730ee6..e57fe24e36 100644 --- a/components/esp_wifi/include/esp_private/wifi_os_adapter.h +++ b/components/esp_wifi/include/esp_private/wifi_os_adapter.h @@ -107,7 +107,7 @@ typedef struct { int32_t (* _get_random)(uint8_t *buf, size_t len); int32_t (* _get_time)(void *t); unsigned long (* _random)(void); -#if CONFIG_IDF_TARGET_ESP32S2BETA +#if CONFIG_IDF_TARGET_ESP32S2 uint32_t (* _slowclk_cal_get)(void); #endif void (* _log_write)(uint32_t level, const char* tag, const char* format, ...); diff --git a/components/esp_wifi/include/esp_wifi_types.h b/components/esp_wifi/include/esp_wifi_types.h index 899353a6c2..644de8df81 100644 --- a/components/esp_wifi/include/esp_wifi_types.h +++ b/components/esp_wifi/include/esp_wifi_types.h @@ -325,7 +325,7 @@ typedef struct { unsigned sgi:1; /**< Short Guide Interval(SGI). 0: Long GI; 1: Short GI */ #if CONFIG_IDF_TARGET_ESP32 signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/ -#elif CONFIG_IDF_TARGET_ESP32S2BETA +#elif CONFIG_IDF_TARGET_ESP32S2 unsigned :8; #endif unsigned ampdu_cnt:8; /**< ampdu cnt */ @@ -333,10 +333,15 @@ typedef struct { unsigned secondary_channel:4; /**< secondary channel on which this packet is received. 0: none; 1: above; 2: below */ unsigned :8; /**< reserve */ unsigned timestamp:32; /**< timestamp. The local time when this packet is received. It is precise only if modem sleep or light sleep is not enabled. unit: microsecond */ +#if CONFIG_IDF_TARGET_ESP32 unsigned :32; /**< reserve */ unsigned :31; /**< reserve */ unsigned ant:1; /**< antenna number from which this packet is received. 0: WiFi antenna 0; 1: WiFi antenna 1 */ -#if CONFIG_IDF_TARGET_ESP32S2BETA +#elif CONFIG_IDF_TARGET_ESP32S2 + unsigned :32; + unsigned :32; +#endif +#if CONFIG_IDF_TARGET_ESP32S2 signed noise_floor:8; /**< noise floor of Radio Frequency Module(RF). unit: 0.25dBm*/ unsigned :24; #endif diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index a28af1f3f2..d898b59b3e 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit a28af1f3f2fe9d0a35de0acd80abd58d59d62819 +Subproject commit d898b59b3ea02f0ee2d87081be7e7fecd6448d37 diff --git a/components/esp_wifi/src/phy_init.c b/components/esp_wifi/src/phy_init.c index 452fe97a97..3fe54633cc 100644 --- a/components/esp_wifi/src/phy_init.c +++ b/components/esp_wifi/src/phy_init.c @@ -765,3 +765,8 @@ void esp_phy_load_cal_and_init(phy_rf_module_t module) free(cal_data); // PHY maintains a copy of calibration data, so we can free this } +#if CONFIG_IDF_TARGET_ESP32S2 +/* Just a stub to avoid SSC build failure. Need to update phylib */ +void set_cca(bool en ,uint8_t cca_thr) {} +#endif + From 3e3753faf4a4a976a80e04535ecdc48224593abc Mon Sep 17 00:00:00 2001 From: ChenJianxing Date: Thu, 13 Feb 2020 15:21:38 +0800 Subject: [PATCH 2/2] update WiFi libs for both esp32 and esp32s2. --- components/esp_wifi/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index d898b59b3e..5feec6a032 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit d898b59b3ea02f0ee2d87081be7e7fecd6448d37 +Subproject commit 5feec6a0323b7fd5662c64d2463ad61fba3cd774