From f5748226dca46914d65b34a7bf05ce488586c625 Mon Sep 17 00:00:00 2001 From: Filipe Cavalcanti Date: Thu, 16 Jan 2025 15:06:26 -0300 Subject: [PATCH 1/4] arch/xtensa/esp32s3: use common wireless source Remove ESP32S3 specific WiFi files and edit build system to use common layer. --- arch/xtensa/src/common/espressif/Kconfig | 50 +- arch/xtensa/src/common/espressif/Wireless.mk | 6 +- .../src/common/espressif/esp_wifi_utils.c | 3 + arch/xtensa/src/common/espressif/esp_wlan.h | 3 + arch/xtensa/src/esp32/Make.defs | 2 +- arch/xtensa/src/esp32s2/Make.defs | 2 +- arch/xtensa/src/esp32s3/Kconfig | 225 +-- arch/xtensa/src/esp32s3/Make.defs | 17 +- arch/xtensa/src/esp32s3/Wireless.mk | 256 --- arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c | 46 +- arch/xtensa/src/esp32s3/esp32s3_irq.c | 6 +- .../xtensa/src/esp32s3/esp32s3_wifi_adapter.c | 172 +- .../xtensa/src/esp32s3/esp32s3_wifi_adapter.h | 42 +- arch/xtensa/src/esp32s3/esp32s3_wifi_utils.c | 574 ------ arch/xtensa/src/esp32s3/esp32s3_wifi_utils.h | 104 - arch/xtensa/src/esp32s3/esp32s3_wireless.c | 1440 -------------- arch/xtensa/src/esp32s3/esp32s3_wireless.h | 370 ---- arch/xtensa/src/esp32s3/esp32s3_wlan.c | 1769 ----------------- arch/xtensa/src/esp32s3/esp32s3_wlan.h | 111 -- arch/xtensa/src/esp32s3/hal.mk | 1 + 20 files changed, 209 insertions(+), 4990 deletions(-) delete mode 100644 arch/xtensa/src/esp32s3/Wireless.mk delete mode 100644 arch/xtensa/src/esp32s3/esp32s3_wifi_utils.c delete mode 100644 arch/xtensa/src/esp32s3/esp32s3_wifi_utils.h delete mode 100644 arch/xtensa/src/esp32s3/esp32s3_wireless.c delete mode 100644 arch/xtensa/src/esp32s3/esp32s3_wireless.h delete mode 100644 arch/xtensa/src/esp32s3/esp32s3_wlan.c delete mode 100644 arch/xtensa/src/esp32s3/esp32s3_wlan.h diff --git a/arch/xtensa/src/common/espressif/Kconfig b/arch/xtensa/src/common/espressif/Kconfig index 234b90a638e06..3a2f5b8b883dc 100644 --- a/arch/xtensa/src/common/espressif/Kconfig +++ b/arch/xtensa/src/common/espressif/Kconfig @@ -513,7 +513,10 @@ config ESPRESSIF_WIRELESS select ESP32S2_RNG if ARCH_CHIP_ESP32S2 select ESP32S2_RT_TIMER if ARCH_CHIP_ESP32S2 select ESP32S2_TIMER0 if ARCH_CHIP_ESP32S2 - depends on ARCH_CHIP_ESP32S2 + select ESP32S3_RNG if ARCH_CHIP_ESP32S3 + select ESP32S3_RT_TIMER if ARCH_CHIP_ESP32S3 + select ESP32S3_TIMER0 if ARCH_CHIP_ESP32S3 + depends on ARCH_CHIP_ESP32S2 || ARCH_CHIP_ESP32S3 ---help--- Enable Wireless support @@ -524,6 +527,32 @@ config ESPRESSIF_WIFI ---help--- Enable Wi-Fi support +config ESPRESSIF_BLE + bool "BLE" + depends on ARCH_CHIP_ESP32S3 + default n + select ESPRESSIF_WIRELESS + ---help--- + Enable BLE support. + +config ESP_COEX_SW_COEXIST_ENABLE + bool "Software WiFi/Bluetooth/IEEE 802.15.4 coexistence" + depends on (ESPRESSIF_WIFI && ESPRESSIF_BLE) + default y + ---help--- + If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware. + Recommended for heavy traffic scenarios. Both coexistence configuration options are + automatically managed, no user intervention is required. + If only Bluetooth is used, it is recommended to disable this option to reduce binary file + size. + +menuconfig ESPRESSIF_WIFI_BT_COEXIST + bool "Wi-Fi and BT coexist" + default y if ESPRESSIF_WIFI && ESPRESSIF_BLE + default n + depends on ESPRESSIF_WIFI && ESPRESSIF_BLE + select ESPRESSIF_WIFI_STA_DISCONNECT_PM + menu "Wi-Fi Configuration" depends on ESPRESSIF_WIFI @@ -692,3 +721,22 @@ config ESPRESSIF_WIFI_LISTEN_INTERVAL to beacon is 300 ms. endmenu # ESPRESSIF_WIFI + +menu "BLE Configuration" + depends on ESPRESSIF_BLE + +config ESPRESSIF_BLE_TASK_STACK_SIZE + int "Controller task stack size" + default 4096 + +config ESPRESSIF_BLE_TASK_PRIORITY + int "Controller task priority" + default 253 + +config ESPRESSIF_BLE_INTERRUPT_SAVE_STATUS + int "Number of interrupt save status" + default 3 + ---help--- + Number of interrupt save status variables to keep track. Increase it if any related bug is found. + +endmenu # BLE Configuration diff --git a/arch/xtensa/src/common/espressif/Wireless.mk b/arch/xtensa/src/common/espressif/Wireless.mk index 9faaee1d61b1f..78fd547102a06 100644 --- a/arch/xtensa/src/common/espressif/Wireless.mk +++ b/arch/xtensa/src/common/espressif/Wireless.mk @@ -20,14 +20,18 @@ # ############################################################################ +INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)include$(DELIM)esp32c3$(DELIM)include +INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)$(CHIP_SERIES)$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)esp_wifi +EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32c3_family$(DELIM)$(CHIP_SERIES) +EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)lib$(DELIM)$(CHIP_SERIES) EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)lib$(DELIM)$(CHIP_SERIES) EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)lib$(DELIM)$(CHIP_SERIES) -EXTRA_LIBS += -lphy +EXTRA_LIBS += -lphy -lcoexist ifeq ($(CONFIG_ESPRESSIF_WIFI),y) EXTRA_LIBS += -lcore -lnet80211 -lpp diff --git a/arch/xtensa/src/common/espressif/esp_wifi_utils.c b/arch/xtensa/src/common/espressif/esp_wifi_utils.c index bda3129a91c10..248764ff3ab76 100644 --- a/arch/xtensa/src/common/espressif/esp_wifi_utils.c +++ b/arch/xtensa/src/common/espressif/esp_wifi_utils.c @@ -37,6 +37,9 @@ #ifdef CONFIG_ARCH_CHIP_ESP32S2 #include "esp32s2_wifi_adapter.h" #endif +#ifdef CONFIG_ARCH_CHIP_ESP32S3 +#include "esp32s3_wifi_adapter.h" +#endif #include "esp_wifi_utils.h" #include "esp_wireless.h" diff --git a/arch/xtensa/src/common/espressif/esp_wlan.h b/arch/xtensa/src/common/espressif/esp_wlan.h index e43cd892599f0..a0426ff24e87b 100644 --- a/arch/xtensa/src/common/espressif/esp_wlan.h +++ b/arch/xtensa/src/common/espressif/esp_wlan.h @@ -32,6 +32,9 @@ #ifdef CONFIG_ARCH_CHIP_ESP32S2 # include "esp32s2_wifi_adapter.h" #endif +#ifdef CONFIG_ARCH_CHIP_ESP32S3 +# include "esp32s3_wifi_adapter.h" +#endif #ifndef __ASSEMBLY__ diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index d607dcec60e33..7e0fd3b9e7846 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -214,7 +214,7 @@ endif ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty ifndef ESP_HAL_3RDPARTY_VERSION - ESP_HAL_3RDPARTY_VERSION = 87ccbf88b6fd490dae1993524e70f51bb2ea181d + ESP_HAL_3RDPARTY_VERSION = e5cef265cca9d272c428d210453d574bcc25c5f4 endif ifndef ESP_HAL_3RDPARTY_URL diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs index 7859102243aff..934ddc394466a 100644 --- a/arch/xtensa/src/esp32s2/Make.defs +++ b/arch/xtensa/src/esp32s2/Make.defs @@ -147,7 +147,7 @@ endif ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty ifndef ESP_HAL_3RDPARTY_VERSION - ESP_HAL_3RDPARTY_VERSION = 87ccbf88b6fd490dae1993524e70f51bb2ea181d + ESP_HAL_3RDPARTY_VERSION = e5cef265cca9d272c428d210453d574bcc25c5f4 endif ifndef ESP_HAL_3RDPARTY_URL diff --git a/arch/xtensa/src/esp32s3/Kconfig b/arch/xtensa/src/esp32s3/Kconfig index dbb70880dd586..38cf7d35b4976 100644 --- a/arch/xtensa/src/esp32s3/Kconfig +++ b/arch/xtensa/src/esp32s3/Kconfig @@ -655,31 +655,6 @@ config ESP32S3_UART2 select UART2_SERIALDRIVER select ARCH_HAVE_SERIAL_TERMIOS -config ESP32S3_WIRELESS - bool - default n - select NET - select ARCH_PHY_INTERRUPT - select ESP32S3_RNG - select ESP32S3_RT_TIMER - select ESP32S3_TIMER0 - ---help--- - Enable Wireless support - -config ESP32S3_WIFI - bool "Wi-Fi" - default n - select ESP32S3_WIRELESS - ---help--- - Enable Wi-Fi support - -config ESP32S3_BLE - bool "BLE" - default n - select ESP32S3_WIRELESS - ---help--- - Enable BLE support - config ESP32S3_I2C0 bool "I2C 0" default n @@ -822,13 +797,6 @@ config ESP32S3_AES_ACCELERATOR endmenu # ESP32-S3 Peripheral Selection -menuconfig ESP32S3_WIFI_BT_COEXIST - bool "Wi-Fi and BT coexist" - default y if ESP32S3_WIFI && ESP32S3_BLE - default n - depends on ESP32S3_WIFI && ESP32S3_BLE - select ESP32S3_WIFI_STA_DISCONNECT_PM - menu "Interrupt Configuration" config ESP32S3_IRAM_ISR_DEBUG @@ -1494,180 +1462,10 @@ config ESP32S3_TWAI_REGDEBUG endmenu #ESP32S3_TWAI -menu "Wi-Fi Configuration" - depends on ESP32S3_WIFI - -menu "ESP WPA-Supplicant" - -config WPA_WAPI_PSK - bool "Enable WAPI PSK support" - default n - ---help--- - Select this option to enable WAPI-PSK - which is a Chinese National Standard Encryption for Wireless LANs (GB 15629.11-2003). - -config WPA_SUITE_B_192 - bool "Enable NSA suite B support with 192-bit key" - default n - select ESP_WIFI_GCMP_SUPPORT - select ESP_WIFI_GMAC_SUPPORT - ---help--- - Select this option to enable 192-bit NSA suite-B. - This is necessary to support WPA3 192-bit security. - -config ESP_WPA_DEBUG_PRINT - bool "Print debug messages from Espressif's WPA Supplicant" - default n - ---help--- - Select this option to print logging information from WPA supplicant, - this includes handshake information and key hex dumps depending - on the project logging level. - - Enabling this could increase the build size ~60kb - depending on the project logging level. - -endmenu # ESP WPA-Supplicant - -choice - prompt "ESP32S3 Wi-Fi mode" - default ESP32S3_WIFI_STATION - -config ESP32S3_WIFI_STATION - bool "Station mode" - -config ESP32S3_WIFI_SOFTAP - bool "SoftAP mode" - -config ESP32S3_WIFI_STATION_SOFTAP - bool "Station + SoftAP" - -endchoice # ESP32S3 Wi-Fi mode - -config ESP_WIFI_ENABLE_SAE_PK - bool "Enable SAE-PK" - default y - ---help--- - Select this option to enable SAE-PK - -config ESP_WIFI_ENABLE_WPA3_OWE_STA - bool "Enable OWE STA" - default y - ---help--- - Select this option to allow the device to establish OWE connection with eligible AP's. - PMF (Protected Management Frames) is a prerequisite feature for a WPA3 connection, it needs to be - explicitly configured before attempting connection. Please refer to the Wi-Fi Driver API Guide for details. - -config ESP32S3_WIFI_STATIC_RXBUF_NUM - int "Wi-Fi static RX buffer number" - default 10 - -config ESP32S3_WIFI_DYNAMIC_RXBUF_NUM - int "Wi-Fi dynamic RX buffer number" - default 32 - -config ESP32S3_WIFI_DYNAMIC_TXBUF_NUM - int "Wi-Fi dynamic TX buffer number" - default 32 - -config ESP32S3_WIFI_TX_AMPDU - bool "Wi-Fi TX AMPDU" - default y - -config ESP32S3_WIFI_RX_AMPDU - bool "Wi-Fi RX AMPDU" - default y - -config ESP32S3_WIFI_RXBA_AMPDU_WZ - int "Wi-Fi RX BA AMPDU windown size" - default 6 - -config ESP32S3_WLAN_PKTBUF_NUM - int "WLAN netcard packet buffer number per netcard" - default 16 - -config ESP_WIFI_GCMP_SUPPORT - bool "WiFi GCMP Support(GCMP128 and GCMP256)" - default n - ---help--- - Select this option to enable GCMP support. GCMP support is compulsory for WiFi Suite-B support. - -config ESP_WIFI_GMAC_SUPPORT - bool "WiFi GMAC Support(GMAC128 and GMAC256)" - default n - ---help--- - Select this option to enable GMAC support. GMAC support is compulsory for WiFi 192-bit certification. - -config ESP32S3_WIFI_CONNECT_TIMEOUT - int "Connect timeout in second" - default 10 - ---help--- - Max waiting time of connecting to AP. - -config ESP32S3_WIFI_SCAN_RESULT_SIZE - int "Scan result buffer" - default 4096 - ---help--- - Maximum scan result buffer size. - -config ESP32S3_WIFI_STA_DISCONNECT_PM - bool "Power Management for station when disconnected" - default y - ---help--- - Select this option to enable power management for station when disconnected. - Chip will do modem-sleep when RF module is not in use anymore. - -choice ESP32S3_POWER_SAVE_MODE - prompt "Wi-Fi Power save mode" - default ESP32S3_POWER_SAVE_MIN_MODEM if ESP32S3_WIFI_BT_COEXIST - default ESP32S3_POWER_SAVE_NONE - ---help--- - Wi-Fi supports the Modem-sleep mode which refers to the legacy power-saving mode in the IEEE 802.11 protocol. - Modem-sleep mode works in station-only mode and the station must connect to the AP first. If the Modem-sleep - mode is enabled, station will switch between active and sleep state periodically. In sleep state, RF, PHY and - BB are turned off in order to reduce power consumption. Station can keep connection with AP in modem-sleep mode. - - Modem-sleep mode includes minimum and maximum power-saving modes. - - In minimum power-saving mode, station wakes - up every DTIM to receive beacon. Broadcast data will not be lost because it is transmitted after DTIM. - However, it cannot save much more power if DTIM is short for DTIM is determined by AP. - - In maximum power-saving mode, station wakes up in every listen interval to receive beacon. This listen interval - can be set to be longer than the AP DTIM period. Broadcast data may be lost because station may be in sleep - state at DTIM time. If listen interval is longer, more power is saved, but broadcast data is more easy to lose. - Listen interval can be configured by setting ESP32S3_WIFI_LISTEN_INTERVAL. - - ESP32S3_POWER_SAVE_NONE disables Modem-sleep mode entirely. Disabling it increases power consumption, but - minimizes the delay in receiving Wi-Fi data in real time. When Modem-sleep mode is enabled, the delay in - receiving Wi-Fi data may be the same as the DTIM cycle (minimum power-saving mode) or the listening interval - (maximum power-saving mode). Setting ESP32S3_POWER_SAVE_NONE is suitable when high throughput is required. - -config ESP32S3_POWER_SAVE_NONE - bool "No power save" - -config ESP32S3_POWER_SAVE_MIN_MODEM - bool "Minimum modem power saving." - -config ESP32S3_POWER_SAVE_MAX_MODEM - bool "Maximum modem power saving" - -endchoice # ESP32S3_POWER_SAVE_MODE - -config ESP32S3_WIFI_LISTEN_INTERVAL - int "Wi-Fi listen interval" - depends on ESP32S3_POWER_SAVE_MAX_MODEM - default 3 - ---help--- - Interval for station to listen to beacon from AP. The unit of listen interval is one beacon interval. - For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen - to beacon is 300 ms. - -endmenu # ESP32S3_WIFI - config ESP32S3_OPENETH bool "Opencores Ethernet MAC" default n - depends on !ESP32S3_WIFI + depends on !ESPRESSIF_WIFI select NET select SCHED_WORKQUEUE ---help--- @@ -1685,29 +1483,10 @@ config ESP32S3_OPENETH_DMA_RX_BUFFER_NUM endif # ESP32S3_OPENETH -menu "BLE Configuration" - depends on ESP32S3_BLE - -config ESP32S3_BLE_TASK_STACK_SIZE - int "Controller task stack size" - default 4096 - -config ESP32S3_BLE_TASK_PRIORITY - int "Controller task priority" - default 253 - -config ESP32S3_BLE_INTERRUPT_SAVE_STATUS - int "Number of interrupt save status" - default 3 - ---help--- - Number of interrupt save status variables to keep track. Increase it if any related bug is found. - -endmenu # BLE Configuration - choice ESP32S3_UNIVERSAL_MAC_ADDRESSES bool "Number of universally administered (by IEEE) MAC address" default ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR - depends on ESP32S3_WIFI || ESP32S3_BLE + depends on ESPRESSIF_WIFI || ESPRESSIF_BLE ---help--- Configure the number of universally administered (by IEEE) MAC addresses. During initialization, MAC addresses for each network interface are generated or derived from a diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs index f5c876e8856ea..669a4500daef3 100644 --- a/arch/xtensa/src/esp32s3/Make.defs +++ b/arch/xtensa/src/esp32s3/Make.defs @@ -208,6 +208,15 @@ ifeq ($(CONFIG_ESP32S3_OPENETH),y) CHIP_CSRCS += esp_openeth.c endif +ifeq ($(CONFIG_ESPRESSIF_WIFI),y) +CHIP_CSRCS += esp32s3_wifi_adapter.c +endif + +ifeq ($(CONFIG_ESPRESSIF_BLE),y) +CHIP_CSRCS += esp32s3_ble_adapter.c esp32s3_ble.c +EXTRA_LIBS += -lbtbb -lbtdm_app +endif + ############################################################################# # Espressif HAL for 3rd Party Platforms ############################################################################# @@ -216,7 +225,7 @@ endif ESP_HAL_3RDPARTY_REPO = esp-hal-3rdparty ifndef ESP_HAL_3RDPARTY_VERSION - ESP_HAL_3RDPARTY_VERSION = 87ccbf88b6fd490dae1993524e70f51bb2ea181d + ESP_HAL_3RDPARTY_VERSION = e5cef265cca9d272c428d210453d574bcc25c5f4 endif ifndef ESP_HAL_3RDPARTY_URL @@ -269,7 +278,7 @@ include chip/hal.mk include common/espressif/Make.defs context:: chip/$(ESP_HAL_3RDPARTY_REPO) -ifeq ($(CONFIG_ESP32S3_WIRELESS),y) +ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32c3_family components/esp_coex/lib $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard @@ -277,9 +286,5 @@ ifeq ($(CONFIG_ESP32S3_WIRELESS),y) $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch endif -ifeq ($(CONFIG_ESP32S3_WIRELESS),y) -include chip/Wireless.mk -endif - distclean:: $(call DELDIR,chip/$(ESP_HAL_3RDPARTY_REPO)) diff --git a/arch/xtensa/src/esp32s3/Wireless.mk b/arch/xtensa/src/esp32s3/Wireless.mk deleted file mode 100644 index 74b6384e4b10c..0000000000000 --- a/arch/xtensa/src/esp32s3/Wireless.mk +++ /dev/null @@ -1,256 +0,0 @@ -############################################################################ -# arch/xtensa/src/esp32s3/Wireless.mk -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################ - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)include$(DELIM)esp32c3$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)$(CHIP_SERIES)$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)esp_wifi - -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32c3_family$(DELIM)$(CHIP_SERIES) -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)lib$(DELIM)$(CHIP_SERIES) -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)lib$(DELIM)$(CHIP_SERIES) -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)lib$(DELIM)$(CHIP_SERIES) - -EXTRA_LIBS += -lphy -lcoexist - -# Wireless interfaces. - -CHIP_CSRCS += esp32s3_wireless.c - -ifeq ($(CONFIG_ESP32S3_BLE),y) -CHIP_CSRCS += esp32s3_ble_adapter.c esp32s3_ble.c -EXTRA_LIBS += -lbtbb -lbtdm_app -endif - -ifeq ($(CONFIG_ESP32S3_WIFI),y) -CHIP_CSRCS += esp32s3_wlan.c esp32s3_wifi_utils.c esp32s3_wifi_adapter.c -EXTRA_LIBS += -lcore -lnet80211 -lpp - -ifeq ($(CONFIG_WPA_WAPI_PSK),y) -EXTRA_LIBS += -lwapi -endif - -## ESP-IDF's mbedTLS - -VPATH += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)mbedtls$(DELIM)library - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)mbedtls$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)mbedtls$(DELIM)library -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)port$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)mbedtls - -### Define Espressif's configs for mbedTLS - -CFLAGS += $(DEFINE_PREFIX)MBEDTLS_CONFIG_FILE="" - -CHIP_CSRCS += aes.c -CHIP_CSRCS += aria.c -CHIP_CSRCS += bignum_core.c -CHIP_CSRCS += bignum.c -CHIP_CSRCS += ccm.c -CHIP_CSRCS += cipher_wrap.c -CHIP_CSRCS += cipher.c -CHIP_CSRCS += cmac.c -CHIP_CSRCS += constant_time.c -CHIP_CSRCS += ctr_drbg.c -CHIP_CSRCS += ecp_curves.c -CHIP_CSRCS += ecp.c -CHIP_CSRCS += entropy.c -CHIP_CSRCS += gcm.c -CHIP_CSRCS += md.c -CHIP_CSRCS += pkcs5.c -CHIP_CSRCS += platform_util.c -CHIP_CSRCS += platform.c -CHIP_CSRCS += sha1.c -CHIP_CSRCS += sha3.c -CHIP_CSRCS += sha256.c -CHIP_CSRCS += sha512.c -CHIP_CSRCS += pk.c -CHIP_CSRCS += pk_wrap.c -CHIP_CSRCS += pkparse.c -CHIP_CSRCS += ecdsa.c -CHIP_CSRCS += asn1parse.c -CHIP_CSRCS += asn1write.c -CHIP_CSRCS += rsa.c -CHIP_CSRCS += md5.c -CHIP_CSRCS += oid.c -CHIP_CSRCS += pem.c -CHIP_CSRCS += hmac_drbg.c -CHIP_CSRCS += rsa_alt_helpers.c -CHIP_CSRCS += ecdh.c -CHIP_CSRCS += pk_ecc.c - -VPATH += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)port - -CHIP_CSRCS += esp_hardware.c -CHIP_CSRCS += esp_mem.c -CHIP_CSRCS += esp_timing.c - -VPATH += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)port$(DELIM)md - -CHIP_CSRCS += esp_md.c - -## WPA Supplicant - -WIFI_WPA_SUPPLICANT = chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)wpa_supplicant - -CFLAGS += $(DEFINE_PREFIX)__ets__ -CFLAGS += $(DEFINE_PREFIX)CONFIG_CRYPTO_MBEDTLS -CFLAGS += $(DEFINE_PREFIX)CONFIG_ECC -CFLAGS += $(DEFINE_PREFIX)CONFIG_IEEE80211W -CFLAGS += $(DEFINE_PREFIX)CONFIG_WPA3_SAE -CFLAGS += $(DEFINE_PREFIX)EAP_PEER_METHOD -CFLAGS += $(DEFINE_PREFIX)ESP_PLATFORM=1 -CFLAGS += $(DEFINE_PREFIX)ESP_SUPPLICANT -CFLAGS += $(DEFINE_PREFIX)ESPRESSIF_USE -CFLAGS += $(DEFINE_PREFIX)IEEE8021X_EAPOL -CFLAGS += $(DEFINE_PREFIX)USE_WPA2_TASK -CFLAGS += $(DEFINE_PREFIX)CONFIG_SHA256 -CFLAGS += $(DEFINE_PREFIX)CONFIG_SAE -CFLAGS += $(DEFINE_PREFIX)USE_WPS_TASK - -ifeq ($(CONFIG_ESP_WIFI_ENABLE_SAE_PK),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_SAE_PK -endif - -ifeq ($(CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_OWE_STA -endif - -ifeq ($(CONFIG_ESP_WIFI_GCMP_SUPPORT),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_GCMP -endif - -ifeq ($(CONFIG_ESP_WIFI_GMAC_SUPPORT),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_GMAC -endif - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)ap - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)ap - -CHIP_CSRCS += ap_config.c -CHIP_CSRCS += ieee802_11.c -CHIP_CSRCS += comeback_token.c -CHIP_CSRCS += pmksa_cache_auth.c -CHIP_CSRCS += sta_info.c -CHIP_CSRCS += wpa_auth_ie.c -CHIP_CSRCS += wpa_auth.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)common - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)common - -CHIP_CSRCS += dragonfly.c -CHIP_CSRCS += sae.c -CHIP_CSRCS += wpa_common.c -CHIP_CSRCS += sae_pk.c -CHIP_CSRCS += bss.c -CHIP_CSRCS += scan.c -CHIP_CSRCS += ieee802_11_common.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)crypto - -CHIP_CSRCS += aes-ccm.c -CHIP_CSRCS += aes-gcm.c -CHIP_CSRCS += aes-omac1.c -CHIP_CSRCS += aes-unwrap.c -CHIP_CSRCS += aes-wrap.c -CHIP_CSRCS += ccmp.c -CHIP_CSRCS += crypto_ops.c -CHIP_CSRCS += des-internal.c -CHIP_CSRCS += dh_groups.c -CHIP_CSRCS += rc4.c -CHIP_CSRCS += sha1-prf.c -CHIP_CSRCS += sha256-kdf.c -CHIP_CSRCS += sha256-prf.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)eap_peer - -CHIP_CSRCS += chap.c -CHIP_CSRCS += eap_common.c -CHIP_CSRCS += eap_mschapv2.c -CHIP_CSRCS += eap_peap_common.c -CHIP_CSRCS += eap_peap.c -CHIP_CSRCS += eap_tls_common.c -CHIP_CSRCS += eap_tls.c -CHIP_CSRCS += eap_ttls.c -CHIP_CSRCS += eap.c -CHIP_CSRCS += mschapv2.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)rsn_supp - -CHIP_CSRCS += pmksa_cache.c -CHIP_CSRCS += wpa_ie.c -CHIP_CSRCS += wpa.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)utils - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)utils - -CHIP_CSRCS += base64.c -CHIP_CSRCS += bitfield.c -CHIP_CSRCS += common.c -CHIP_CSRCS += ext_password.c -CHIP_CSRCS += json.c -CHIP_CSRCS += uuid.c -CHIP_CSRCS += wpa_debug.c -CHIP_CSRCS += wpabuf.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)port - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)port$(DELIM)include - -CHIP_CSRCS += eloop.c -CHIP_CSRCS += os_xtensa.c - -## ESP Supplicant (Espressif's WPA supplicant extension) - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)include - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)src - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)src - -CHIP_CSRCS += esp_common.c -CHIP_CSRCS += esp_hostap.c -CHIP_CSRCS += esp_wpa_main.c -CHIP_CSRCS += esp_wpa3.c -CHIP_CSRCS += esp_wpas_glue.c -CHIP_CSRCS += esp_owe.c -CHIP_CSRCS += esp_scan.c -CHIP_CSRCS += esp_wps.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)src$(DELIM)crypto - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)crypto - -CHIP_CSRCS += crypto_mbedtls-bignum.c -CHIP_CSRCS += crypto_mbedtls-ec.c -CHIP_CSRCS += crypto_mbedtls-rsa.c -CHIP_CSRCS += crypto_mbedtls.c -CHIP_CSRCS += tls_mbedtls.c -CHIP_CSRCS += aes-siv.c - -endif diff --git a/arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c b/arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c index efcefc48d52d7..49c4153a16aac 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c +++ b/arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c @@ -58,7 +58,7 @@ #include "esp32s3_rt_timer.h" #include "esp32s3_rtc.h" #include "esp32s3_spiflash.h" -#include "esp32s3_wireless.h" +#include "espressif/esp_wireless.h" #include "esp_bt.h" #include "esp_log.h" @@ -104,8 +104,8 @@ # define BLE_TASK_EVENT_QUEUE_LEN 8 #endif -#ifdef CONFIG_ESP32S3_BLE_INTERRUPT_SAVE_STATUS -# define NR_IRQSTATE_FLAGS CONFIG_ESP32S3_BLE_INTERRUPT_SAVE_STATUS +#ifdef CONFIG_ESPRESSIF_BLE_INTERRUPT_SAVE_STATUS +# define NR_IRQSTATE_FLAGS CONFIG_ESPRESSIF_BLE_INTERRUPT_SAVE_STATUS #else # define NR_IRQSTATE_FLAGS 3 #endif @@ -1845,7 +1845,7 @@ static void coex_wifi_sleep_set_hook(bool sleep) * Description: * This is a wrapper for registering a BTDM callback with the coexistence * scheme. If the Wi-Fi and Bluetooth coexistence feature is enabled - * (CONFIG_ESP32S3_WIFI_BT_COEXIST), it calls the + * (CONFIG_ESPRESSIF_WIFI_BT_COEXIST), it calls the * coex_schm_register_callback function with COEX_SCHM_CALLBACK_TYPE_BT * and the provided callback. If the feature is not enabled, it returns 0. * @@ -1860,7 +1860,7 @@ static void coex_wifi_sleep_set_hook(bool sleep) static int coex_schm_register_btdm_callback_wrapper(void *callback) { -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback); #else return 0; @@ -1884,7 +1884,7 @@ static int coex_schm_register_btdm_callback_wrapper(void *callback) static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_set(type, status); #endif } @@ -1907,7 +1907,7 @@ static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_clear(type, status); #endif } @@ -1917,7 +1917,7 @@ static void coex_schm_status_bit_clear_wrapper(uint32_t type, * * Description: * This is a wrapper for coex_schm_interval_get. If the WiFi and Bluetooth - * coexistence feature is enabled (CONFIG_ESP32S3_WIFI_BT_COEXIST), it + * coexistence feature is enabled (CONFIG_ESPRESSIF_WIFI_BT_COEXIST), it * calls the function and returns its result. If not enabled, it returns 0. * * Input Parameters: @@ -1931,7 +1931,7 @@ static void coex_schm_status_bit_clear_wrapper(uint32_t type, static uint32_t coex_schm_interval_get_wrapper(void) { -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_get(); #else return 0; @@ -1944,8 +1944,8 @@ static uint32_t coex_schm_interval_get_wrapper(void) * Description: * This is a wrapper for coex_schm_curr_period_get. If the WiFi and * Bluetooth coexistence feature is enabled - * (CONFIG_ESP32S3_WIFI_BT_COEXIST), it calls the function and returns its - * result. If the feature is not enabled, it returns 1. + * (CONFIG_ESPRESSIF_WIFI_BT_COEXIST), it calls the function and returns + * its result. If the feature is not enabled, it returns 1. * * Input Parameters: * None @@ -1958,7 +1958,7 @@ static uint32_t coex_schm_interval_get_wrapper(void) static uint8_t coex_schm_curr_period_get_wrapper(void) { -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_period_get(); #else return 1; @@ -1971,8 +1971,8 @@ static uint8_t coex_schm_curr_period_get_wrapper(void) * Description: * This is a wrapper for coex_schm_curr_phase_get. If the WiFi and * Bluetooth coexistence feature is enabled - * (CONFIG_ESP32S3_WIFI_BT_COEXIST), it calls the function and returns its - * result. If the feature is not enabled, it returns NULL. + * (CONFIG_ESPRESSIF_WIFI_BT_COEXIST), it calls the function and returns + * its result. If the feature is not enabled, it returns NULL. * * Input Parameters: * None @@ -1985,7 +1985,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void) static void * coex_schm_curr_phase_get_wrapper(void) { -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_phase_get(); #else return NULL; @@ -2627,7 +2627,7 @@ static esp_err_t btdm_low_power_mode_init(esp_bt_controller_config_t *cfg) break; } -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_update_lpclk_interval(); #endif @@ -2767,7 +2767,7 @@ static void btdm_low_power_mode_deinit(void) btdm_lpclk_select_src(BTDM_LPCLK_SEL_RTC_SLOW); btdm_lpclk_set_div(0); -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_update_lpclk_interval(); #endif } @@ -3076,8 +3076,8 @@ int esp32s3_bt_controller_init(void) } } - cfg->controller_task_stack_size = CONFIG_ESP32S3_BLE_TASK_STACK_SIZE; - cfg->controller_task_prio = CONFIG_ESP32S3_BLE_TASK_PRIORITY; + cfg->controller_task_stack_size = CONFIG_ESPRESSIF_BLE_TASK_STACK_SIZE; + cfg->controller_task_prio = CONFIG_ESPRESSIF_BLE_TASK_PRIORITY; cfg->controller_task_run_cpu = CONFIG_BT_CTRL_PINNED_TO_CORE; cfg->magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL; @@ -3113,7 +3113,7 @@ int esp32s3_bt_controller_init(void) goto error; } -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_init(); #endif @@ -3213,7 +3213,7 @@ int esp32s3_bt_controller_enable(esp_bt_mode_t mode) esp_phy_enable(PHY_MODEM_BT); g_lp_stat.phy_enabled = 1; -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_enable(); #endif @@ -3290,7 +3290,7 @@ int esp32s3_bt_controller_enable(esp_bt_mode_t mode) } #endif -#if CONFIG_ESP32S3_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_disable(); #endif if (g_lp_stat.phy_enabled) @@ -3334,7 +3334,7 @@ int esp32s3_bt_controller_disable(void) async_wakeup_request_end(BTDM_ASYNC_WAKEUP_SRC_DISA); -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_disable(); #endif diff --git a/arch/xtensa/src/esp32s3/esp32s3_irq.c b/arch/xtensa/src/esp32s3/esp32s3_irq.c index 7780d2563b10e..e3769bc8842d3 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_irq.c +++ b/arch/xtensa/src/esp32s3/esp32s3_irq.c @@ -109,7 +109,7 @@ #define ESP32S3_MAX_PRIORITY 5 #define ESP32S3_PRIO_INDEX(p) ((p) - ESP32S3_MIN_PRIORITY) -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # define ESP32S3_WIFI_RESERVE_INT (1 << ESP32S3_CPUINT_MAC) #else # define ESP32S3_WIFI_RESERVE_INT 0 @@ -489,7 +489,7 @@ void up_irqinitialize(void) g_irqmap[XTENSA_IRQ_SWINT] = IRQ_MKMAP(0, ESP32S3_CPUINT_SOFTWARE1); g_irqmap[XTENSA_IRQ_SWINT] = IRQ_MKMAP(1, ESP32S3_CPUINT_SOFTWARE1); -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI g_irqmap[ESP32S3_IRQ_MAC] = IRQ_MKMAP(0, ESP32S3_CPUINT_MAC); g_irqmap[ESP32S3_IRQ_PWR] = IRQ_MKMAP(0, ESP32S3_CPUINT_PWR); #endif @@ -500,7 +500,7 @@ void up_irqinitialize(void) /* Reserve CPU0 interrupt for some special drivers */ -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI g_cpu0_intmap[ESP32S3_CPUINT_MAC] = CPUINT_ASSIGN(ESP32S3_IRQ_MAC); g_cpu0_intmap[ESP32S3_CPUINT_PWR] = CPUINT_ASSIGN(ESP32S3_IRQ_PWR); xtensa_enable_cpuint(&g_intenable[0], 1 << ESP32S3_CPUINT_MAC); diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c index 5f3e6274b7b28..9e056d9073412 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c +++ b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c @@ -60,19 +60,19 @@ #include "hardware/esp32s3_syscon.h" #include "hardware/esp32s3_soc.h" #include "esp32s3_irq.h" -#include "esp32s3_wireless.h" +#include "espressif/esp_wireless.h" #include "esp32s3_wifi_adapter.h" #include "esp32s3_rt_timer.h" -#include "esp32s3_wifi_utils.h" -#include "esp32s3_wlan.h" +#include "espressif/esp_wifi_utils.h" +#include "espressif/esp_wlan.h" #ifdef CONFIG_PM # include "esp32s3_pm.h" #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32s3_ble_adapter.h" -# ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +# ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "private/esp_coexist_internal.h" # endif #endif @@ -94,7 +94,7 @@ #define PHY_RF_MASK ((1 << PHY_BT_MODULE) | (1 << PHY_WIFI_MODULE)) -#define WIFI_CONNECT_TIMEOUT CONFIG_ESP32S3_WIFI_CONNECT_TIMEOUT +#define WIFI_CONNECT_TIMEOUT CONFIG_ESPRESSIF_WIFI_CONNECT_TIMEOUT #define TIMER_INITIALIZED_VAL (0x5aa5a55a) @@ -115,11 +115,11 @@ /* CONFIG_POWER_SAVE_MODEM */ -#if defined(CONFIG_ESP32S3_POWER_SAVE_MIN_MODEM) +#if defined(CONFIG_ESPRESSIF_POWER_SAVE_MIN_MODEM) # define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM -#elif defined(CONFIG_ESP32S3_POWER_SAVE_MAX_MODEM) +#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM) # define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM -#elif defined(CONFIG_ESP32S3_POWER_SAVE_NONE) +#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_NONE) # define DEFAULT_PS_MODE WIFI_PS_NONE #else # define DEFAULT_PS_MODE WIFI_PS_NONE @@ -197,11 +197,11 @@ struct nvs_adpt * Private Function Prototypes ****************************************************************************/ -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST static int semphr_take_from_isr_wrapper(void *semphr, void *hptw); static int semphr_give_from_isr_wrapper(void *semphr, void *hptw); static int is_in_isr_wrapper(void); -#endif /* CONFIG_ESP32S3_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ static bool wifi_env_is_chip(void); static void wifi_set_intr(int32_t cpu_no, uint32_t intr_source, @@ -365,7 +365,7 @@ static mutex_t g_wifiexcl_lock = NXMUTEX_INITIALIZER; static int g_wifi_ref; -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /* If reconnect automatically */ @@ -387,9 +387,9 @@ static wifi_txdone_cb_t g_sta_txdone_cb; static wifi_config_t g_sta_wifi_cfg; -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP /* If Wi-Fi SoftAP starts */ @@ -403,7 +403,7 @@ static wifi_txdone_cb_t g_softap_txdone_cb; static wifi_config_t g_softap_wifi_cfg; -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ /* Device specific lock */ @@ -415,7 +415,7 @@ static spinlock_t g_lock; /* Wi-Fi and BT coexistence OS adapter data */ -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, @@ -436,7 +436,7 @@ coex_adapter_funcs_t g_coex_adapter_funcs = ._timer_arm_us = esp_timer_arm_us, ._magic = COEX_ADAPTER_MAGIC, }; -#endif /* CONFIG_ESP32S3_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ /* Wi-Fi OS adapter data */ @@ -498,7 +498,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = ._wifi_apb80m_release = wifi_apb80m_release, ._phy_disable = esp_phy_disable_wrapper, ._phy_enable = esp_phy_enable_wrapper, - ._phy_update_country_info = esp32s3_phy_update_country_info, + ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_wifi_read_mac, ._timer_arm = esp_timer_arm, ._timer_disarm = esp_timer_disarm, @@ -2046,7 +2046,7 @@ static int esp_event_id_map(int event_id) id = WIFI_ADPT_EVT_SCAN_DONE; break; -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA case WIFI_EVENT_STA_START: id = WIFI_ADPT_EVT_STA_START; break; @@ -2066,9 +2066,9 @@ static int esp_event_id_map(int event_id) case WIFI_EVENT_STA_STOP: id = WIFI_ADPT_EVT_STA_STOP; break; -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP case WIFI_EVENT_AP_START: id = WIFI_ADPT_EVT_AP_START; break; @@ -2084,7 +2084,7 @@ static int esp_event_id_map(int event_id) case WIFI_EVENT_AP_STADISCONNECTED: id = WIFI_ADPT_EVT_AP_STADISCONNECTED; break; -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ default: return -1; @@ -2140,13 +2140,13 @@ static void esp_evt_work_cb(void *arg) esp_wifi_scan_event_parse(); break; -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA case WIFI_ADPT_EVT_STA_START: wlinfo("Wi-Fi sta start\n"); g_sta_connected = false; -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE if (esp32s3_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) { @@ -2178,7 +2178,7 @@ static void esp_evt_work_cb(void *arg) case WIFI_ADPT_EVT_STA_CONNECT: wlinfo("Wi-Fi sta connect\n"); g_sta_connected = true; - ret = esp32s3_wlan_sta_set_linkstatus(true); + ret = esp_wlan_sta_set_linkstatus(true); if (ret < 0) { wlerr("ERROR: Failed to set Wi-Fi station link status\n"); @@ -2189,7 +2189,7 @@ static void esp_evt_work_cb(void *arg) case WIFI_ADPT_EVT_STA_DISCONNECT: wlinfo("Wi-Fi sta disconnect\n"); g_sta_connected = false; - ret = esp32s3_wlan_sta_set_linkstatus(false); + ret = esp_wlan_sta_set_linkstatus(false); if (ret < 0) { wlerr("ERROR: Failed to set Wi-Fi station link status\n"); @@ -2209,13 +2209,13 @@ static void esp_evt_work_cb(void *arg) wlinfo("Wi-Fi sta stop\n"); g_sta_connected = false; break; -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP case WIFI_ADPT_EVT_AP_START: wlinfo("INFO: Wi-Fi softap start\n"); -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE if (esp32s3_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) { @@ -2255,7 +2255,7 @@ static void esp_evt_work_cb(void *arg) case WIFI_ADPT_EVT_AP_STADISCONNECTED: wlinfo("INFO: Wi-Fi station leave\n"); break; -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ default: break; } @@ -2281,7 +2281,7 @@ static void esp_evt_work_cb(void *arg) } } -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST /**************************************************************************** * Name: semphr_take_from_isr_wrapper @@ -2346,7 +2346,7 @@ static int IRAM_ATTR is_in_isr_wrapper(void) return up_interrupt_context(); } -#endif /* CONFIG_ESP32S3_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ /**************************************************************************** * Name: wifi_env_is_chip @@ -3655,7 +3655,7 @@ static void esp_wifi_delete_queue(void *queue) static int coex_init_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_init(); #else return 0; @@ -3678,7 +3678,7 @@ static int coex_init_wrapper(void) static void coex_deinit_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_deinit(); #endif } @@ -3700,7 +3700,7 @@ static void coex_deinit_wrapper(void) static int coex_enable_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_enable(); #else return 0; @@ -3723,7 +3723,7 @@ static int coex_enable_wrapper(void) static void coex_disable_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_disable(); #endif } @@ -3745,7 +3745,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_status_get(); #else return 0; @@ -3772,7 +3772,7 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) static int32_t coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_request(event, latency, duration); #else return 0; @@ -3796,7 +3796,7 @@ static int32_t coex_wifi_request_wrapper(uint32_t event, uint32_t latency, static IRAM_ATTR int32_t coex_wifi_release_wrapper(uint32_t event) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_release(event); #else return 0; @@ -3821,7 +3821,7 @@ static IRAM_ATTR int32_t coex_wifi_release_wrapper(uint32_t event) static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_channel_set(primary, secondary); #else return 0; @@ -3847,7 +3847,7 @@ static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary) static int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_event_duration_get(event, duration); #else return 0; @@ -3872,7 +3872,7 @@ static int coex_event_duration_get_wrapper(uint32_t event, static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_pti_get(event, pti); #else return 0; @@ -3897,7 +3897,7 @@ static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti) static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_clear(type, status); #endif } @@ -3919,7 +3919,7 @@ static void coex_schm_status_bit_clear_wrapper(uint32_t type, static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_set(type, status); #endif } @@ -3941,7 +3941,7 @@ static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_set(interval); #else return 0; @@ -3964,7 +3964,7 @@ static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval) static uint32_t coex_schm_interval_get_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_get(); #else return 0; @@ -3987,7 +3987,7 @@ static uint32_t coex_schm_interval_get_wrapper(void) static uint8_t coex_schm_curr_period_get_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_period_get(); #else return 0; @@ -4010,7 +4010,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void) static void *coex_schm_curr_phase_get_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_phase_get(); #else return NULL; @@ -4034,7 +4034,7 @@ static void *coex_schm_curr_phase_get_wrapper(void) static int coex_register_start_cb_wrapper(int (* cb)(void)) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_register_start_cb(cb); #else return 0; @@ -4058,7 +4058,7 @@ static int coex_register_start_cb_wrapper(int (* cb)(void)) static int coex_schm_process_restart_wrapper(void) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_process_restart(); #else return 0; @@ -4083,7 +4083,7 @@ static int coex_schm_process_restart_wrapper(void) static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_register_callback(type, cb); #else return 0; @@ -4185,7 +4185,7 @@ static unsigned long esp_random_ulong(void) static IRAM_ATTR void esp_wifi_tx_done_cb(uint8_t ifidx, uint8_t *data, uint16_t *len, bool txstatus) { -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA if (ifidx == ESP_IF_WIFI_STA) { if (g_sta_txdone_cb) @@ -4194,9 +4194,9 @@ static IRAM_ATTR void esp_wifi_tx_done_cb(uint8_t ifidx, uint8_t *data, } } else -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP if (ifidx == ESP_IF_WIFI_AP) { if (g_softap_txdone_cb) @@ -4205,13 +4205,13 @@ static IRAM_ATTR void esp_wifi_tx_done_cb(uint8_t ifidx, uint8_t *data, } } else -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ { wlerr("ifidx=%d is error\n", ifidx); } } -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_auth_trans @@ -4313,7 +4313,7 @@ static int esp_wifi_cipher_trans(uint32_t wifi_cipher) return cipher_mode; } -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ /**************************************************************************** * Name: esp_freq_to_channel @@ -4649,28 +4649,28 @@ int esp_wifi_adapter_init(void) wifi_cfg.nvs_enable = 0; -#ifdef CONFIG_ESP32S3_WIFI_TX_AMPDU +#ifdef CONFIG_ESPRESSIF_WIFI_TX_AMPDU wifi_cfg.ampdu_tx_enable = 1; #else wifi_cfg.ampdu_tx_enable = 0; #endif -#ifdef CONFIG_ESP32S3_WIFI_RX_AMPDU +#ifdef CONFIG_ESPRESSIF_WIFI_RX_AMPDU wifi_cfg.ampdu_rx_enable = 1; #else wifi_cfg.ampdu_rx_enable = 0; #endif -#ifdef CONFIG_ESP32S3_WIFI_STA_DISCONNECT_PM +#ifdef CONFIG_ESPRESSIF_WIFI_STA_DISCONNECT_PM wifi_cfg.sta_disconnected_pm = true; #else wifi_cfg.sta_disconnected_pm = false; #endif - wifi_cfg.rx_ba_win = CONFIG_ESP32S3_WIFI_RXBA_AMPDU_WZ; - wifi_cfg.static_rx_buf_num = CONFIG_ESP32S3_WIFI_STATIC_RXBUF_NUM; - wifi_cfg.dynamic_rx_buf_num = CONFIG_ESP32S3_WIFI_DYNAMIC_RXBUF_NUM; - wifi_cfg.dynamic_tx_buf_num = CONFIG_ESP32S3_WIFI_DYNAMIC_TXBUF_NUM; + wifi_cfg.rx_ba_win = CONFIG_ESPRESSIF_WIFI_RXBA_AMPDU_WZ; + wifi_cfg.static_rx_buf_num = CONFIG_ESPRESSIF_WIFI_STATIC_RXBUF_NUM; + wifi_cfg.dynamic_rx_buf_num = CONFIG_ESPRESSIF_WIFI_DYNAMIC_RXBUF_NUM; + wifi_cfg.dynamic_tx_buf_num = CONFIG_ESPRESSIF_WIFI_DYNAMIC_TXBUF_NUM; ret = esp_wifi_init(&wifi_cfg); if (ret) @@ -4708,7 +4708,7 @@ int esp_wifi_adapter_init(void) * Station functions ****************************************************************************/ -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_sta_start @@ -4738,13 +4738,13 @@ int esp_wifi_sta_start(void) wlinfo("Failed to stop Wi-Fi ret=%d\n", ret); } -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP if (g_softap_started) { mode = WIFI_MODE_APSTA; } else -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ { mode = WIFI_MODE_STA; } @@ -4803,7 +4803,7 @@ int esp_wifi_sta_stop(void) g_sta_started = false; -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP if (g_softap_started) { ret = esp_wifi_set_mode(WIFI_MODE_AP); @@ -4822,13 +4822,13 @@ int esp_wifi_sta_stop(void) goto errout; } } -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ wlinfo("OK to stop Wi-Fi station\n"); -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP errout: -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ esp_wifi_lock(false); return ret; @@ -5703,7 +5703,7 @@ int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set) return OK; } -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ /**************************************************************************** * Name: esp_wifi_sta_get_txpower @@ -5906,7 +5906,7 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set) return OK; } -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_sta_rssi @@ -5953,13 +5953,13 @@ int esp_wifi_sta_rssi(struct iwreq *iwr, bool set) return OK; } -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ /**************************************************************************** * SoftAP functions ****************************************************************************/ -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP /**************************************************************************** * Name: esp_wifi_softap_start @@ -5989,13 +5989,13 @@ int esp_wifi_softap_start(void) wlinfo("Failed to stop Wi-Fi ret=%d\n", ret); } -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA if (g_sta_started) { mode = WIFI_MODE_APSTA; } else -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ { mode = WIFI_MODE_AP; } @@ -6054,7 +6054,7 @@ int esp_wifi_softap_stop(void) g_softap_started = false; -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA if (g_sta_started) { ret = esp_wifi_set_mode(WIFI_MODE_STA); @@ -6073,13 +6073,13 @@ int esp_wifi_softap_stop(void) goto errout; } } -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ wlinfo("OK to stop Wi-Fi SoftAP\n"); -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA errout: -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ esp_wifi_lock(false); return ret; @@ -6718,10 +6718,10 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set) return -ENOSYS; } -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ /**************************************************************************** - * Name: esp32s3_wifi_bt_coexist_init + * Name: esp_wifi_bt_coexist_init * * Description: * Initialize ESP32-S3 Wi-Fi and BT coexistance module. @@ -6735,15 +6735,15 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set) * ****************************************************************************/ -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST -int esp32s3_wifi_bt_coexist_init(void) +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST +int esp_wifi_bt_coexist_init(void) { esp_coex_adapter_register(&g_coex_adapter_funcs); coex_pre_init(); return 0; } -#endif /* CONFIG_ESP32S3_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ /**************************************************************************** * Name: esp_wifi_stop_callback diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.h b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.h index 87d62edc88dae..d2c89e6178a99 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.h +++ b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.h @@ -45,20 +45,20 @@ extern "C" * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_ESP32S3_WIFI_STATION) -# define ESP32S3_WLAN_HAS_STA -# define ESP32S3_WLAN_STA_DEVNO 0 -# define ESP32S3_WLAN_DEVS 1 -#elif defined(CONFIG_ESP32S3_WIFI_SOFTAP) -# define ESP32S3_WLAN_HAS_SOFTAP -# define ESP32S3_WLAN_SOFTAP_DEVNO 0 -# define ESP32S3_WLAN_DEVS 1 -#elif defined(CONFIG_ESP32S3_WIFI_STATION_SOFTAP) -# define ESP32S3_WLAN_HAS_STA -# define ESP32S3_WLAN_HAS_SOFTAP -# define ESP32S3_WLAN_STA_DEVNO 0 -# define ESP32S3_WLAN_SOFTAP_DEVNO 1 -# define ESP32S3_WLAN_DEVS 2 +#if defined(CONFIG_ESPRESSIF_WIFI_STATION) +# define ESPRESSIF_WLAN_HAS_STA +# define ESPRESSIF_WLAN_STA_DEVNO 0 +# define ESPRESSIF_WLAN_DEVS 1 +#elif defined(CONFIG_ESPRESSIF_WIFI_SOFTAP) +# define ESPRESSIF_WLAN_HAS_SOFTAP +# define ESPRESSIF_WLAN_SOFTAP_DEVNO 0 +# define ESPRESSIF_WLAN_DEVS 1 +#elif defined(CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP) +# define ESPRESSIF_WLAN_HAS_STA +# define ESPRESSIF_WLAN_HAS_SOFTAP +# define ESPRESSIF_WLAN_STA_DEVNO 0 +# define ESPRESSIF_WLAN_SOFTAP_DEVNO 1 +# define ESPRESSIF_WLAN_DEVS 2 #endif #define SSID_MAX_LEN (32) @@ -148,7 +148,7 @@ void esp_wifi_free_eb(void *eb); int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event); -#ifdef ESP32S3_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_sta_start @@ -484,9 +484,9 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set); ****************************************************************************/ int esp_wifi_sta_rssi(struct iwreq *iwr, bool set); -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32S3_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP /**************************************************************************** * Name: esp_wifi_softap_start @@ -822,10 +822,10 @@ int esp_wifi_softap_country(struct iwreq *iwr, bool set); ****************************************************************************/ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set); -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ /**************************************************************************** - * Name: esp32s3_wifi_bt_coexist_init + * Name: esp_wifi_bt_coexist_init * * Description: * Initialize ESP32-S3 Wi-Fi and BT coexistance module. @@ -839,8 +839,8 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set); * ****************************************************************************/ -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST -int esp32s3_wifi_bt_coexist_init(void); +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST +int esp_wifi_bt_coexist_init(void); #endif /**************************************************************************** diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_utils.c b/arch/xtensa/src/esp32s3/esp32s3_wifi_utils.c deleted file mode 100644 index 65d1704ccf228..0000000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_wifi_utils.c +++ /dev/null @@ -1,574 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_wifi_utils.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "esp32s3_wifi_adapter.h" -#include "esp32s3_wifi_utils.h" -#include "esp32s3_wireless.h" - -#include "esp_log.h" -#include "esp_mac.h" -#include "esp_private/phy.h" -#include "esp_private/wifi.h" -#include "esp_random.h" -#include "esp_timer.h" -#include "esp_wpa.h" -#include "rom/ets_sys.h" -#include "soc/soc_caps.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Helper to get iw_event size */ - -#define ESP_IW_EVENT_SIZE(field) \ - (offsetof(struct iw_event, u) + sizeof(((union iwreq_data *)0)->field)) - -#ifdef CONFIG_ESP32S3_WIFI_SCAN_RESULT_SIZE -# define WIFI_SCAN_RESULT_SIZE CONFIG_ESP32S3_WIFI_SCAN_RESULT_SIZE -#else -# define WIFI_SCAN_RESULT_SIZE (4096) -#endif - -#define SCAN_TIME_SEC (5) - -/* Maximum number of channels for Wi-Fi 2.4Ghz */ - -#define CHANNEL_MAX_NUM (14) - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -enum scan_status_e -{ - ESP_SCAN_DISABLED = 0, - ESP_SCAN_RUN, - ESP_SCAN_DONE -}; - -/* Wi-Fi scan result information */ - -struct wifi_scan_result -{ - enum scan_status_e scan_status; /* Scan status */ - sem_t scan_signal; /* Scan notification signal */ - uint8_t *scan_result; /* Temp buffer that holds results */ - unsigned int scan_result_size; /* Current size of temp buffer */ -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static struct wifi_scan_result g_scan_priv = -{ - .scan_signal = SEM_INITIALIZER(0), -}; -static uint8_t g_channel_num; -static uint8_t g_channel_list[CHANNEL_MAX_NUM]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_start_scan - * - * Description: - * Scan all available APs. - * - * Input Parameters: - * iwr - The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_start_scan(struct iwreq *iwr) -{ - struct wifi_scan_result *priv = &g_scan_priv; - wifi_scan_config_t *config = NULL; - struct iw_scan_req *req; - int ret = 0; - int i; - uint8_t target_mac[MAC_LEN]; - uint8_t target_ssid[SSID_MAX_LEN + 1]; - memset(target_ssid, 0x0, sizeof(SSID_MAX_LEN + 1)); - - if (iwr == NULL) - { - wlerr("ERROR: Invalid ioctl cmd.\n"); - return -EINVAL; - } - - if (g_scan_priv.scan_status != ESP_SCAN_DISABLED) - { - return OK; - } - - config = kmm_calloc(1, sizeof(wifi_scan_config_t)); - if (config == NULL) - { - wlerr("ERROR: Cannot allocate result buffer\n"); - return -ENOMEM; - } - - g_channel_num = 0; - memset(g_channel_list, 0x0, CHANNEL_MAX_NUM); - - if (iwr->u.data.pointer && - iwr->u.data.length >= sizeof(struct iw_scan_req)) - { - req = (struct iw_scan_req *)iwr->u.data.pointer; - config->scan_type = (req->scan_type == IW_SCAN_TYPE_ACTIVE ? - WIFI_SCAN_TYPE_ACTIVE : WIFI_SCAN_TYPE_PASSIVE); - if (iwr->u.data.flags & IW_SCAN_THIS_ESSID && - req->essid_len < sizeof(target_ssid)) - { - /* Scan specific ESSID */ - - config->show_hidden = true; - config->bssid = NULL; - memcpy(&target_ssid[0], req->essid, req->essid_len); - config->ssid = &target_ssid[0]; - config->ssid[req->essid_len] = '\0'; - } - - if (iwr->u.data.flags & IW_SCAN_THIS_FREQ && - req->num_channels > 0) - { - /* Scan specific channels */ - - DEBUGASSERT(req->num_channels <= CHANNEL_MAX_NUM); - g_channel_num = req->num_channels; - if (req->num_channels == 1) - { - config->channel = req->channel_list[0].m; - } - else - { - for (i = 0; i < req->num_channels; i++) - { - g_channel_list[i] = req->channel_list[i].m; - } - } - } - - memset(target_mac, 0xff, MAC_LEN); - if (memcmp(req->bssid.sa_data, target_mac, MAC_LEN) != 0) - { - /* Scan specific bssid */ - - memcpy(target_mac, req->bssid.sa_data, MAC_LEN); - config->bssid = &target_mac[0]; - } - } - else - { - /* Default scan parameters */ - - wlinfo("INFO: Use default scan parameters\n"); - config->scan_type = WIFI_SCAN_TYPE_ACTIVE; /* Active scan */ - } - - esp_wifi_start(); - ret = esp_wifi_scan_start(config, false); - if (ret != OK) - { - wlerr("ERROR: Scan error, ret: %d\n", ret); - ret = ERROR; - } - else - { - /* Allocate buffer to store scan result */ - - if (priv->scan_result == NULL) - { - priv->scan_result = kmm_malloc(WIFI_SCAN_RESULT_SIZE); - if (priv->scan_result == NULL) - { - wlerr("ERROR: Cannot allocate result buffer\n"); - ret = -ENOMEM; - } - else - { - memset(priv->scan_result, 0x0, WIFI_SCAN_RESULT_SIZE); - } - } - } - - if (config) - { - kmm_free(config); - config = NULL; - } - - if (ret == OK) - { - wlinfo("INFO: start scan\n"); - g_scan_priv.scan_status = ESP_SCAN_RUN; - } - - return ret; -} - -/**************************************************************************** - * Name: esp_wifi_get_scan_results - * - * Description: - * Get scan result - * - * Input Parameters: - * iwr - The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_get_scan_results(struct iwreq *iwr) -{ - int ret = OK; - static bool scan_block = false; - struct wifi_scan_result *priv = &g_scan_priv; - - if (g_scan_priv.scan_status == ESP_SCAN_RUN) - { - irqstate_t irqstate = enter_critical_section(); - if (!scan_block) - { - scan_block = true; - leave_critical_section(irqstate); - nxsem_tickwait(&priv->scan_signal, SEC2TICK(SCAN_TIME_SEC)); - scan_block = false; - } - else - { - leave_critical_section(irqstate); - ret = -EINVAL; - goto exit_failed; - } - } - else if (g_scan_priv.scan_status == ESP_SCAN_DISABLED) - { - ret = -EINVAL; - goto exit_failed; - } - - if ((iwr == NULL) || (g_scan_priv.scan_status != ESP_SCAN_DONE)) - { - ret = -EINVAL; - goto exit_failed; - } - - if (priv->scan_result == NULL) - { - /* Result have already been requested */ - - ret = OK; - iwr->u.data.length = 0; - goto exit_failed; - } - - if (priv->scan_result_size <= 0) - { - ret = OK; - iwr->u.data.length = 0; - goto exit_free_buffer; - } - - if (iwr->u.data.pointer == NULL || - iwr->u.data.length < priv->scan_result_size) - { - /* Stat request, return scan_result_size */ - - ret = -E2BIG; - iwr->u.data.pointer = NULL; - iwr->u.data.length = priv->scan_result_size; - return ret; - } - - /* Copy result to user buffer */ - - if (iwr->u.data.length > priv->scan_result_size) - { - iwr->u.data.length = priv->scan_result_size; - } - - memcpy(iwr->u.data.pointer, priv->scan_result, iwr->u.data.length); - -exit_free_buffer: - - /* Free scan result buffer */ - - kmm_free(priv->scan_result); - priv->scan_result = NULL; - priv->scan_result_size = 0; - g_scan_priv.scan_status = ESP_SCAN_DISABLED; - -exit_failed: - if (ret < 0) - { - iwr->u.data.length = 0; - } - - return ret; -} - -/**************************************************************************** - * Name: esp_wifi_scan_event_parse - * - * Description: - * Parse scan information - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_wifi_scan_event_parse(void) -{ - struct wifi_scan_result *priv = &g_scan_priv; - wifi_ap_record_t *ap_list_buffer = NULL; - uint16_t bss_total = 0; - uint8_t bss_count = 0; - bool parse_done = false; - - if (priv->scan_status != ESP_SCAN_RUN) - { - return; - } - - esp_wifi_scan_get_ap_num(&bss_total); - if (bss_total == 0) - { - priv->scan_status = ESP_SCAN_DONE; - wlinfo("INFO: None AP is scanned\n"); - nxsem_post(&priv->scan_signal); - return; - } - - ap_list_buffer = kmm_calloc(bss_total, sizeof(wifi_ap_record_t)); - if (ap_list_buffer == NULL) - { - priv->scan_status = ESP_SCAN_DONE; - wlerr("ERROR: Failed to calloc buffer to print scan results"); - nxsem_post(&priv->scan_signal); - return; - } - - if (esp_wifi_scan_get_ap_records(&bss_total, - (wifi_ap_record_t *)ap_list_buffer) == OK) - { - struct iw_event *iwe; - unsigned int result_size; - size_t essid_len; - size_t essid_len_aligned; - bool is_target_channel = true; - int i; - - for (bss_count = 0; bss_count < bss_total; bss_count++) - { - if (g_channel_num > 1) - { - is_target_channel = false; - for (i = 0; i < g_channel_num; i++) - { - if (g_channel_list[i] == ap_list_buffer[bss_count].primary) - { - is_target_channel = true; - break; - } - } - } - else - { - is_target_channel = true; - } - - if (is_target_channel) - { - result_size = WIFI_SCAN_RESULT_SIZE - priv->scan_result_size; - - /* Copy BSSID */ - - if (result_size < ESP_IW_EVENT_SIZE(ap_addr)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(ap_addr); - iwe->cmd = SIOCGIWAP; - memcpy(&iwe->u.ap_addr.sa_data, - ap_list_buffer[bss_count].bssid, - sizeof(ap_list_buffer[bss_count].bssid)); - iwe->u.ap_addr.sa_family = ARPHRD_ETHER; - priv->scan_result_size += ESP_IW_EVENT_SIZE(ap_addr); - result_size -= ESP_IW_EVENT_SIZE(ap_addr); - - /* Copy ESSID */ - - essid_len = MIN(strlen((const char *) - ap_list_buffer[bss_count].ssid), SSID_MAX_LEN); - essid_len_aligned = (essid_len + 3) & -4; - if (result_size < ESP_IW_EVENT_SIZE(essid) + essid_len_aligned) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(essid) + essid_len_aligned; - iwe->cmd = SIOCGIWESSID; - iwe->u.essid.flags = 0; - iwe->u.essid.length = essid_len; - - /* Special processing for iw_point, set offset - * in pointer field. - */ - - iwe->u.essid.pointer = (void *)sizeof(iwe->u.essid); - memcpy(&iwe->u.essid + 1, - ap_list_buffer[bss_count].ssid, essid_len); - - wlinfo("INFO: ssid %s\n", ap_list_buffer[bss_count].ssid); - - priv->scan_result_size += - ESP_IW_EVENT_SIZE(essid) + essid_len_aligned; - result_size -= ESP_IW_EVENT_SIZE(essid) + essid_len_aligned; - - /* Copy link quality info */ - - if (result_size < ESP_IW_EVENT_SIZE(qual)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(qual); - iwe->cmd = IWEVQUAL; - iwe->u.qual.qual = 0x00; - - wlinfo("INFO: signal %d\n", ap_list_buffer[bss_count].rssi); - - iwe->u.qual.level = ap_list_buffer[bss_count].rssi; - iwe->u.qual.noise = 0x00; - iwe->u.qual.updated = IW_QUAL_DBM | IW_QUAL_ALL_UPDATED; - - priv->scan_result_size += ESP_IW_EVENT_SIZE(qual); - result_size -= ESP_IW_EVENT_SIZE(qual); - - /* Copy AP mode */ - - if (result_size < ESP_IW_EVENT_SIZE(mode)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(mode); - iwe->cmd = SIOCGIWMODE; - iwe->u.mode = IW_MODE_MASTER; - priv->scan_result_size += ESP_IW_EVENT_SIZE(mode); - result_size -= ESP_IW_EVENT_SIZE(mode); - - /* Copy AP encryption mode */ - - if (result_size < ESP_IW_EVENT_SIZE(data)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(data); - iwe->cmd = SIOCGIWENCODE; - iwe->u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - iwe->u.data.length = 0; - iwe->u.essid.pointer = NULL; - - priv->scan_result_size += ESP_IW_EVENT_SIZE(data); - result_size -= ESP_IW_EVENT_SIZE(data); - - /* Copy AP channel */ - - if (result_size < ESP_IW_EVENT_SIZE(freq)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(freq); - iwe->cmd = SIOCGIWFREQ; - iwe->u.freq.e = 0; - iwe->u.freq.m = ap_list_buffer[bss_count].primary; - - priv->scan_result_size += ESP_IW_EVENT_SIZE(freq); - result_size -= ESP_IW_EVENT_SIZE(freq); - } - } - - parse_done = true; - } - -scan_result_full: - - /* Continue instead of break to log dropped AP results */ - - if (!parse_done) - { - wlerr("ERROR: No more space in scan_result buffer\n"); - } - - if (ap_list_buffer) - { - kmm_free(ap_list_buffer); - ap_list_buffer = NULL; - } - - priv->scan_status = ESP_SCAN_DONE; - nxsem_post(&priv->scan_signal); -} diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_utils.h b/arch/xtensa/src/esp32s3/esp32s3_wifi_utils.h deleted file mode 100644 index 8439e83f8137e..0000000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_wifi_utils.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_wifi_utils.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WIFI_UTILS_H -#define __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WIFI_UTILS_H - -#include -#include - -#ifndef __ASSEMBLY__ - -#include - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_start_scan - * - * Description: - * Scan all available APs. - * - * Input Parameters: - * iwr - The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_start_scan(struct iwreq *iwr); - -/**************************************************************************** - * Name: esp_wifi_get_scan_results - * - * Description: - * Get scan result - * - * Input Parameters: - * req The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_get_scan_results(struct iwreq *iwr); - -/**************************************************************************** - * Name: esp_wifi_scan_event_parse - * - * Description: - * Parse scan information - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_wifi_scan_event_parse(void); - -#ifdef __cplusplus -} -#endif -#undef EXTERN - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WIFI_UTILS_H */ diff --git a/arch/xtensa/src/esp32s3/esp32s3_wireless.c b/arch/xtensa/src/esp32s3/esp32s3_wireless.c deleted file mode 100644 index cdefe131ee575..0000000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_wireless.c +++ /dev/null @@ -1,1440 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_wireless.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include - -#include "xtensa.h" -#include "hardware/esp32s3_efuse.h" -#include "hardware/esp32s3_rtccntl.h" -#include "hardware/esp32s3_soc.h" -#include "hardware/esp32s3_syscon.h" -#include "hardware/esp32s3_system.h" -#include "esp32s3_irq.h" -#include "esp32s3_partition.h" - -#include "esp_private/phy.h" -#ifdef CONFIG_ESP32S3_WIFI -# include "esp_private/wifi.h" -# include "esp_wpa.h" -#endif -#include "private/esp_coexist_internal.h" -#include "periph_ctrl.h" -#include "esp_phy_init.h" -#include "phy_init_data.h" - -#include "esp32s3_wireless.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Software Interrupt */ - -#define SWI_IRQ ESP32S3_IRQ_INT_FROM_CPU2 -#define SWI_PERIPH ESP32S3_PERIPH_INT_FROM_CPU2 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/* Wireless Private Data */ - -struct esp_wireless_priv_s -{ - volatile int ref; /* Reference count */ - - int cpuint; /* CPU interrupt assigned to SWI */ - - struct list_node sc_list; /* Semaphore cache list */ - struct list_node qc_list; /* Queue cache list */ -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static inline void phy_digital_regs_store(void); -static inline void phy_digital_regs_load(void); -static int esp_swi_irq(int irq, void *context, void *arg); - -/**************************************************************************** - * Extern Functions declaration - ****************************************************************************/ - -extern uint8_t esp_crc8(const uint8_t *p, uint32_t len); -extern void phy_wakeup_init(void); -extern void phy_close_rf(void); -extern uint8_t phy_dig_reg_backup(bool init, uint32_t *regs); -extern int register_chipv7_phy(const esp_phy_init_data_t *init_data, - esp_phy_calibration_data_t *cal_data, - esp_phy_calibration_mode_t cal_mode); -extern uint32_t crc32_le(uint32_t crc, uint8_t const *buf, uint32_t len); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* Wi-Fi sleep private data */ - -static uint32_t g_phy_clk_en_cnt; - -/* Reference count of enabling PHY */ - -static uint8_t g_phy_access_ref; - -/* Memory to store PHY digital registers */ - -static uint32_t *g_phy_digital_regs_mem = NULL; - -/* Indicate PHY is calibrated or not */ - -static bool g_is_phy_calibrated = false; - -/* Private data of the wireless common interface */ - -static struct esp_wireless_priv_s g_esp_wireless_priv; - -#ifdef CONFIG_ESP32S3_PHY_INIT_DATA_IN_PARTITION -static const char *phy_partion_label = "phy_init"; -#endif - -#ifdef CONFIG_ESP32S3_SUPPORT_MULTIPLE_PHY_INIT_DATA - -static phy_init_data_type_t g_phy_init_data_type; - -static phy_init_data_type_t g_current_apply_phy_init_data; - -static char g_phy_current_country[PHY_COUNTRY_CODE_LEN]; - -/* Whether it is a new bin */ - -static bool g_multiple_phy_init_data_bin; - -/* PHY init data type array */ - -static const char *g_phy_type[ESP_PHY_INIT_DATA_TYPE_NUMBER] = -{ - "DEFAULT", "SRRC", "FCC", "CE", "NCC", "KCC", "MIC", "IC", - "ACMA", "ANATEL", "ISED", "WPC", "OFCA", "IFETEL", "RCM" -}; - -/* Country and PHY init data type map */ - -static phy_country_to_bin_type_t g_country_code_map_type_table[] = -{ - {"01", ESP_PHY_INIT_DATA_TYPE_DEFAULT}, - {"AT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"AU", ESP_PHY_INIT_DATA_TYPE_ACMA}, - {"BE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"BG", ESP_PHY_INIT_DATA_TYPE_CE}, - {"BR", ESP_PHY_INIT_DATA_TYPE_ANATEL}, - {"CA", ESP_PHY_INIT_DATA_TYPE_ISED}, - {"CH", ESP_PHY_INIT_DATA_TYPE_CE}, - {"CN", ESP_PHY_INIT_DATA_TYPE_SRRC}, - {"CY", ESP_PHY_INIT_DATA_TYPE_CE}, - {"CZ", ESP_PHY_INIT_DATA_TYPE_CE}, - {"DE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"DK", ESP_PHY_INIT_DATA_TYPE_CE}, - {"EE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"ES", ESP_PHY_INIT_DATA_TYPE_CE}, - {"FI", ESP_PHY_INIT_DATA_TYPE_CE}, - {"FR", ESP_PHY_INIT_DATA_TYPE_CE}, - {"GB", ESP_PHY_INIT_DATA_TYPE_CE}, - {"GR", ESP_PHY_INIT_DATA_TYPE_CE}, - {"HK", ESP_PHY_INIT_DATA_TYPE_OFCA}, - {"HR", ESP_PHY_INIT_DATA_TYPE_CE}, - {"HU", ESP_PHY_INIT_DATA_TYPE_CE}, - {"IE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"IN", ESP_PHY_INIT_DATA_TYPE_WPC}, - {"IS", ESP_PHY_INIT_DATA_TYPE_CE}, - {"IT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"JP", ESP_PHY_INIT_DATA_TYPE_MIC}, - {"KR", ESP_PHY_INIT_DATA_TYPE_KCC}, - {"LI", ESP_PHY_INIT_DATA_TYPE_CE}, - {"LT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"LU", ESP_PHY_INIT_DATA_TYPE_CE}, - {"LV", ESP_PHY_INIT_DATA_TYPE_CE}, - {"MT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"MX", ESP_PHY_INIT_DATA_TYPE_IFETEL}, - {"NL", ESP_PHY_INIT_DATA_TYPE_CE}, - {"NO", ESP_PHY_INIT_DATA_TYPE_CE}, - {"NZ", ESP_PHY_INIT_DATA_TYPE_RCM}, - {"PL", ESP_PHY_INIT_DATA_TYPE_CE}, - {"PT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"RO", ESP_PHY_INIT_DATA_TYPE_CE}, - {"SE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"SI", ESP_PHY_INIT_DATA_TYPE_CE}, - {"SK", ESP_PHY_INIT_DATA_TYPE_CE}, - {"TW", ESP_PHY_INIT_DATA_TYPE_NCC}, - {"US", ESP_PHY_INIT_DATA_TYPE_FCC}, -}; - -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: phy_digital_regs_store - * - * Description: - * Store PHY digital registers. - * - ****************************************************************************/ - -static inline void phy_digital_regs_store(void) -{ - if (g_phy_digital_regs_mem == NULL) - { - g_phy_digital_regs_mem = (uint32_t *) - kmm_malloc(SOC_PHY_DIG_REGS_MEM_SIZE); - } - - DEBUGASSERT(g_phy_digital_regs_mem != NULL); - - phy_dig_reg_backup(true, g_phy_digital_regs_mem); -} - -/**************************************************************************** - * Name: phy_digital_regs_load - * - * Description: - * Load PHY digital registers. - * - ****************************************************************************/ - -static inline void phy_digital_regs_load(void) -{ - if (g_phy_digital_regs_mem != NULL) - { - phy_dig_reg_backup(false, g_phy_digital_regs_mem); - } -} - -/**************************************************************************** - * Name: esp_swi_irq - * - * Description: - * Wireless software interrupt callback function. - * - * Parameters: - * cpuint - CPU interrupt index - * context - Context data from the ISR - * arg - NULL - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -static int esp_swi_irq(int irq, void *context, void *arg) -{ - int i; - int ret; - struct esp_semcache_s *sc; - struct esp_semcache_s *sc_tmp; - struct esp_queuecache_s *qc; - struct esp_queuecache_s *qc_tmp; - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - modifyreg32(SYSTEM_CPU_INTR_FROM_CPU_2_REG, SYSTEM_CPU_INTR_FROM_CPU_2, 0); - - list_for_every_entry_safe(&priv->sc_list, sc, sc_tmp, - struct esp_semcache_s, node) - { - for (i = 0; i < sc->count; i++) - { - ret = nxsem_post(sc->sem); - if (ret < 0) - { - wlerr("ERROR: Failed to post sem ret=%d\n", ret); - } - } - - sc->count = 0; - list_delete(&sc->node); - } - - list_for_every_entry_safe(&priv->qc_list, qc, qc_tmp, - struct esp_queuecache_s, node) - { - ret = file_mq_send(qc->mq_ptr, (const char *)qc->buffer, qc->size, 0); - if (ret < 0) - { - wlerr("ERROR: Failed to send queue ret=%d\n", ret); - } - - list_delete(&qc->node); - } - - return OK; -} - -#ifdef CONFIG_ESP32S3_WIFI - -/**************************************************************************** - * Name: esp_wifi_set_log_level - * - * Description: - * Sets the log level for the ESP32 WiFi module based on preprocessor - * definitions. The log level can be verbose, warning, or error. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void esp_wifi_set_log_level(void) -{ - wifi_log_level_t wifi_log_level = WIFI_LOG_NONE; - - /* set WiFi log level */ - -#if defined(CONFIG_DEBUG_WIRELESS_INFO) - wifi_log_level = WIFI_LOG_VERBOSE; -#elif defined(CONFIG_DEBUG_WIRELESS_WARN) - wifi_log_level = WIFI_LOG_WARNING; -#elif defined(CONFIG_LOG_MAXIMUM_LEVEL) - wifi_log_level = WIFI_LOG_ERROR; -#endif - - esp_wifi_internal_set_log_level(wifi_log_level); -} -#endif /* CONFIG_ESP32S3_WIFI */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_to_errno - * - * Description: - * Transform from ESP Wi-Fi error code to NuttX error code - * - * Input Parameters: - * err - ESP Wi-Fi error code - * - * Returned Value: - * NuttX error code defined in errno.h - * - ****************************************************************************/ - -int32_t esp_wifi_to_errno(int err) -{ - int ret; - - if (err < ESP_ERR_WIFI_BASE) - { - /* Unmask component error bits */ - - ret = err & 0xfff; - - switch (ret) - { - case ESP_OK: - ret = OK; - break; - case ESP_ERR_NO_MEM: - ret = -ENOMEM; - break; - - case ESP_ERR_INVALID_ARG: - ret = -EINVAL; - break; - - case ESP_ERR_INVALID_STATE: - ret = -EIO; - break; - - case ESP_ERR_INVALID_SIZE: - ret = -EINVAL; - break; - - case ESP_ERR_NOT_FOUND: - ret = -ENOSYS; - break; - - case ESP_ERR_NOT_SUPPORTED: - ret = -ENOSYS; - break; - - case ESP_ERR_TIMEOUT: - ret = -ETIMEDOUT; - break; - - case ESP_ERR_INVALID_MAC: - ret = -EINVAL; - break; - - default: - ret = ERROR; - break; - } - } - else - { - ret = ERROR; - } - - if (ret != OK) - { - wlerr("ERROR: %s\n", esp_err_to_name(err)); - } - - return ret; -} - -/**************************************************************************** - * Functions needed by libphy.a - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_dport_access_reg_read - * - * Description: - * Read register value safely in SMP - * - * Input Parameters: - * reg - Register address - * - * Returned Value: - * Register value - * - ****************************************************************************/ - -uint32_t IRAM_ATTR esp_dport_access_reg_read(uint32_t reg) -{ - return getreg32(reg); -} - -/**************************************************************************** - * Name: phy_printf - * - * Description: - * Output format string and its arguments - * - * Input Parameters: - * format - format string - * - * Returned Value: - * 0 - * - ****************************************************************************/ - -int phy_printf(const char *format, ...) -{ -#ifdef CONFIG_DEBUG_WIRELESS_INFO - va_list arg; - - va_start(arg, format); - vsyslog(LOG_INFO, format, arg); - va_end(arg); -#endif - - return 0; -} - -#ifdef CONFIG_ESP32S3_SUPPORT_MULTIPLE_PHY_INIT_DATA - -/**************************************************************************** - * Name: phy_crc_check - * - * Description: - * Check the checksum value of data - * - * Input Parameters: - * data - Data buffer pointer - * length - Data length - * checksum - Checksum pointer - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_crc_check(uint8_t *data, const uint8_t *checksum, - size_t length) -{ - uint32_t crc_data = crc32_le(0, data, length); - uint32_t crc_size_conversion = HTONL(crc_data); - uint32_t tmp_crc = checksum[0] | (checksum[1] << 8) | (checksum[2] << 16) | - (checksum[3] << 24); - if (crc_size_conversion != tmp_crc) - { - return ERROR; - } - - return OK; -} - -/**************************************************************************** - * Name: phy_find_bin_type_according_country - * - * Description: - * Find the PHY initialization data type according to country code - * - * Input Parameters: - * country - Country code pointer - * - * Returned Value: - * PHY initialization data type - * - ****************************************************************************/ - -static uint8_t phy_find_bin_type_according_country(const char *country) -{ - uint8_t i; - uint8_t phy_init_data_type; - uint8_t num = nitems(g_country_code_map_type_table); - for (i = 0; i < num; i++) - { - if (memcmp(country, g_country_code_map_type_table[i].cc, - sizeof(g_phy_current_country)) == 0) - { - phy_init_data_type = g_country_code_map_type_table[i].type; - wlinfo("Current country is %c%c, PHY init data type is %s\n", - g_country_code_map_type_table[i].cc[0], - g_country_code_map_type_table[i].cc[1], - g_phy_type[g_country_code_map_type_table[i].type]); - break; - } - } - - if (i == num) - { - phy_init_data_type = ESP_PHY_INIT_DATA_TYPE_DEFAULT; - wlerr("Use the default certification code beacuse %c%c doesn't " - "have a certificate\n", country[0], country[1]); - } - - return phy_init_data_type; -} - -/**************************************************************************** - * Name: phy_find_bin_data_according_type - * - * Description: - * Find the PHY initialization data according to PHY init data type - * - * Input Parameters: - * output_data - Output data buffer pointer - * control_info - PHY init data control infomation - * input_data - Input data buffer pointer - * init_data_type - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_find_bin_data_according_type(uint8_t *output_data, - const phy_control_info_data_t *control_info, - const esp_phy_init_data_t *input_data, - phy_init_data_type_t init_data_type) -{ - int i; - for (i = 0; i < control_info->number; i++) - { - if (init_data_type == *((uint8_t *)(input_data + i) - + PHY_INIT_DATA_TYPE_OFFSET)) - { - memcpy(output_data + sizeof(phy_init_magic_pre), - (input_data + i), sizeof(esp_phy_init_data_t)); - break; - } - } - - if (i == control_info->number) - { - return ERROR; - } - - return OK; -} - -/**************************************************************************** - * Name: phy_get_multiple_init_data - * - * Description: - * Get multiple PHY init data according to PHY init data type - * - * Input Parameters: - * data - Data buffer pointer - * length - Data length - * init_data_type - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_get_multiple_init_data(uint8_t *data, size_t length, - phy_init_data_type_t init_data_type) -{ - phy_control_info_data_t *control_info = (phy_control_info_data_t *) - kmm_malloc(sizeof(phy_control_info_data_t)); - if (control_info == NULL) - { - wlerr("ERROR: Failed to allocate memory for\ - PHY init data control info\n"); - return -ENOMEM; - } - - int ret = esp32s3_partition_read(phy_partion_label, - length, - control_info, - sizeof(phy_control_info_data_t)); - if (ret != OK) - { - kmm_free(control_info); - wlerr("ERROR: Failed to read PHY control info data partition\n"); - return ret; - } - - if ((control_info->check_algorithm) == PHY_CRC_ALGORITHM) - { - ret = phy_crc_check(control_info->multiple_bin_checksum, - control_info->control_info_checksum, - sizeof(phy_control_info_data_t) - - sizeof(control_info->control_info_checksum)); - if (ret != OK) - { - kmm_free(control_info); - wlerr("ERROR: PHY init data control info check error\n"); - return ret; - } - } - else - { - kmm_free(control_info); - wlerr("ERROR: Check algorithm not CRC, PHY init data update failed\n"); - return ERROR; - } - - uint8_t *init_data_multiple = (uint8_t *) - kmm_malloc(sizeof(esp_phy_init_data_t) * control_info->number); - if (init_data_multiple == NULL) - { - kmm_free(control_info); - wlerr("ERROR: Failed to allocate memory for PHY init data\n"); - return -ENOMEM; - } - - ret = esp32s3_partition_read(phy_partion_label, length + - sizeof(phy_control_info_data_t), init_data_multiple, - sizeof(esp_phy_init_data_t) * control_info->number); - if (ret != OK) - { - kmm_free(init_data_multiple); - kmm_free(control_info); - wlerr("ERROR: Failed to read PHY init data multiple bin partition\n"); - return ret; - } - - if ((control_info->check_algorithm) == PHY_CRC_ALGORITHM) - { - ret = phy_crc_check(init_data_multiple, - control_info->multiple_bin_checksum, - sizeof(esp_phy_init_data_t) * control_info->number); - if (ret != OK) - { - kmm_free(init_data_multiple); - kmm_free(control_info); - wlerr("ERROR: PHY init data multiple bin check error\n"); - return ret; - } - } - else - { - kmm_free(init_data_multiple); - kmm_free(control_info); - wlerr("ERROR: Check algorithm not CRC, PHY init data update failed\n"); - return ERROR; - } - - ret = phy_find_bin_data_according_type(data, control_info, - (const esp_phy_init_data_t *)init_data_multiple, init_data_type); - if (ret != OK) - { - wlerr("ERROR: %s has not been certified, use DEFAULT PHY init data\n", - g_phy_type[init_data_type]); - g_phy_init_data_type = ESP_PHY_INIT_DATA_TYPE_DEFAULT; - } - else - { - g_phy_init_data_type = init_data_type; - } - - kmm_free(init_data_multiple); - kmm_free(control_info); - return OK; -} - -/**************************************************************************** - * Name: phy_update_init_data - * - * Description: - * Update PHY init data according to PHY init data type - * - * Input Parameters: - * init_data_type - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_update_init_data(phy_init_data_type_t init_data_type) -{ - int ret; - size_t length = sizeof(phy_init_magic_pre) + - sizeof(esp_phy_init_data_t) + sizeof(phy_init_magic_post); - uint8_t *init_data_store = kmm_malloc(length); - if (init_data_store == NULL) - { - wlerr("ERROR: Failed to allocate memory for updated country code " - "PHY init data\n"); - return -ENOMEM; - } - - ret = esp32s3_partition_read(phy_partion_label, 0, init_data_store, - length); - if (ret != OK) - { - kmm_free(init_data_store); - wlerr("ERROR: Failed to read updated country code PHY data\n"); - return ret; - } - - if (memcmp(init_data_store, PHY_INIT_MAGIC, - sizeof(phy_init_magic_pre)) != 0 || - memcmp(init_data_store + length - sizeof(phy_init_magic_post), - PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) - { - kmm_free(init_data_store); - wlerr("ERROR: Failed to validate updated country code PHY data\n"); - return ERROR; - } - - /* find init data bin according init data type */ - - if (init_data_type != ESP_PHY_INIT_DATA_TYPE_DEFAULT) - { - ret = phy_get_multiple_init_data(init_data_store, length, - init_data_type); - if (ret != OK) - { - kmm_free(init_data_store); -#ifdef CONFIG_ESP32S3_PHY_INIT_DATA_ERROR - abort(); -#else - return ret; -#endif - } - } - else - { - g_phy_init_data_type = ESP_PHY_INIT_DATA_TYPE_DEFAULT; - } - - if (g_current_apply_phy_init_data != g_phy_init_data_type) - { - ret = esp_phy_apply_phy_init_data(init_data_store + - sizeof(phy_init_magic_pre)); - if (ret != OK) - { - wlerr("ERROR: PHY init data failed to load\n"); - kmm_free(init_data_store); - return ret; - } - - wlinfo("PHY init data type updated from %s to %s\n", - g_phy_type[g_current_apply_phy_init_data], - g_phy_type[g_phy_init_data_type]); - g_current_apply_phy_init_data = g_phy_init_data_type; - } - - kmm_free(init_data_store); - return OK; -} - -#endif - -#ifdef CONFIG_ESP32S3_PHY_INIT_DATA_IN_PARTITION - -/**************************************************************************** - * Name: esp_phy_get_init_data - * - * Description: - * Get PHY init data - * - * Input Parameters: - * None - * - * Returned Value: - * Pointer to PHY init data structure - * - ****************************************************************************/ - -const esp_phy_init_data_t *esp_phy_get_init_data(void) -{ - int ret; - size_t length = sizeof(phy_init_magic_pre) + - sizeof(esp_phy_init_data_t) + sizeof(phy_init_magic_post); - uint8_t *init_data_store = kmm_malloc(length); - if (init_data_store == NULL) - { - wlerr("ERROR: Failed to allocate memory for PHY init data\n"); - return NULL; - } - - ret = esp32s3_partition_read(phy_partion_label, 0, init_data_store, - length); - if (ret != OK) - { - wlerr("ERROR: Failed to get read data from MTD\n"); - kmm_free(init_data_store); - return NULL; - } - - if (memcmp(init_data_store, PHY_INIT_MAGIC, sizeof(phy_init_magic_pre)) - != 0 || memcmp(init_data_store + length - sizeof(phy_init_magic_post), - PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) - { -#ifdef CONFIG_ESP32S3_PHY_DEFAULT_INIT_IF_INVALID - wlerr("ERROR: Failed to validate PHY data partition, restoring " - "default data into flash..."); - memcpy(init_data_store, PHY_INIT_MAGIC, sizeof(phy_init_magic_pre)); - memcpy(init_data_store + sizeof(phy_init_magic_pre), - &phy_init_data, sizeof(phy_init_data)); - memcpy(init_data_store + sizeof(phy_init_magic_pre) + - sizeof(phy_init_data), PHY_INIT_MAGIC, - sizeof(phy_init_magic_post)); - DEBUGASSERT(memcmp(init_data_store, PHY_INIT_MAGIC, - sizeof(phy_init_magic_pre)) == 0); - DEBUGASSERT(memcmp(init_data_store + length - - sizeof(phy_init_magic_post), PHY_INIT_MAGIC, - sizeof(phy_init_magic_post)) == 0); - - /* write default data */ - - ret = esp32s3_partition_write(phy_partion_label, 0, init_data_store, - length); - if (ret != OK) - { - wlerr("ERROR: Failed to write default PHY data partition\n"); - kmm_free(init_data_store); - return NULL; - } -#else /* CONFIG_ESP32S3_PHY_DEFAULT_INIT_IF_INVALID */ - wlerr("ERROR: Failed to validate PHY data partition\n"); - kmm_free(init_data_store); - return NULL; -#endif - } - -#ifdef CONFIG_ESP32S3_SUPPORT_MULTIPLE_PHY_INIT_DATA - if (*(init_data_store + (sizeof(phy_init_magic_pre) + - PHY_SUPPORT_MULTIPLE_BIN_OFFSET))) - { - g_multiple_phy_init_data_bin = true; - wlinfo("Support multiple PHY init data bins\n"); - } - else - { - wlinfo("Does not support multiple PHY init data bins\n"); - } -#endif - - wlinfo("PHY data partition validated\n"); - return (const esp_phy_init_data_t *) - (init_data_store + sizeof(phy_init_magic_pre)); -} - -/**************************************************************************** - * Name: esp_phy_release_init_data - * - * Description: - * Release PHY init data - * - * Input Parameters: - * init_data - Pointer to PHY init data structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_phy_release_init_data(const esp_phy_init_data_t *init_data) -{ - kmm_free((uint8_t *)init_data - sizeof(phy_init_magic_pre)); -} - -#else /* CONFIG_ESP32S3_PHY_INIT_DATA_IN_PARTITION */ - -/**************************************************************************** - * Name: esp_phy_get_init_data - * - * Description: - * Get PHY init data - * - * Input Parameters: - * None - * - * Returned Value: - * Pointer to PHY init data structure - * - ****************************************************************************/ - -const esp_phy_init_data_t *esp_phy_get_init_data(void) -{ - wlinfo("Loading PHY init data from application binary\n"); - return &phy_init_data; -} - -/**************************************************************************** - * Name: esp_phy_release_init_data - * - * Description: - * Release PHY init data - * - * Input Parameters: - * init_data - Pointer to PHY init data structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_phy_release_init_data(const esp_phy_init_data_t *init_data) -{ -} -#endif - -/**************************************************************************** - * Name: esp32s3_phy_update_country_info - * - * Description: - * Update PHY init data according to country code - * - * Input Parameters: - * country - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -int esp32s3_phy_update_country_info(const char *country) -{ -#ifdef CONFIG_ESP32S3_SUPPORT_MULTIPLE_PHY_INIT_DATA - uint8_t phy_init_data_type_map = 0; - if (memcmp(country, g_phy_current_country, sizeof(g_phy_current_country)) - == 0) - { - return OK; - } - - memcpy(g_phy_current_country, country, sizeof(g_phy_current_country)); - if (!g_multiple_phy_init_data_bin) - { - wlerr("ERROR: Does not support multiple PHY init data bins\n"); - return ERROR; - } - - phy_init_data_type_map = phy_find_bin_type_according_country(country); - if (phy_init_data_type_map == g_phy_init_data_type) - { - return OK; - } - - int ret = phy_update_init_data(phy_init_data_type_map); - if (ret != OK) - { - wlerr("ERROR: Failed to update PHY init data\n"); - return ret; - } -#endif - - return OK; -} - -/**************************************************************************** - * Name: esp_timer_create - * - * Description: - * Create timer with given arguments - * - * Input Parameters: - * create_args - Timer arguments data pointer - * out_handle - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_create(const esp_timer_create_args_t *create_args, - esp_timer_handle_t *out_handle) -{ - int ret; - struct rt_timer_args_s rt_timer_args; - struct rt_timer_s *rt_timer; - - rt_timer_args.arg = create_args->arg; - rt_timer_args.callback = create_args->callback; - - ret = esp32s3_rt_timer_create(&rt_timer_args, &rt_timer); - if (ret) - { - wlerr("Failed to create rt_timer error=%d\n", ret); - return ret; - } - - *out_handle = (esp_timer_handle_t)rt_timer; - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_start_once - * - * Description: - * Start timer with one shot mode - * - * Input Parameters: - * timer - Timer handle pointer - * timeout_us - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - esp32s3_rt_timer_start(rt_timer, timeout_us, false); - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_start_periodic - * - * Description: - * Start timer with periodic mode - * - * Input Parameters: - * timer - Timer handle pointer - * period - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - esp32s3_rt_timer_start(rt_timer, period, true); - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_stop - * - * Description: - * Stop timer - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_stop(esp_timer_handle_t timer) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - esp32s3_rt_timer_stop(rt_timer); - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_delete - * - * Description: - * Delete timer and free resource - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_delete(esp_timer_handle_t timer) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - esp32s3_rt_timer_delete(rt_timer); - - return 0; -} - -/**************************************************************************** - * Name: esp_init_semcache - * - * Description: - * Initialize semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * sem - Semaphore data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_semcache(struct esp_semcache_s *sc, sem_t *sem) -{ - sc->sem = sem; - sc->count = 0; - list_initialize(&sc->node); -} - -/**************************************************************************** - * Name: esp_post_semcache - * - * Description: - * Store posting semaphore action into semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -IRAM_ATTR void esp_post_semcache(struct esp_semcache_s *sc) -{ - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - if (!sc->count) - { - list_add_tail(&priv->sc_list, &sc->node); - } - - sc->count++; - - /* Enable CPU 2 interrupt. This will generate an IRQ as soon as non-IRAM - * are (re)enabled. - */ - - modifyreg32(SYSTEM_CPU_INTR_FROM_CPU_2_REG, 0, SYSTEM_CPU_INTR_FROM_CPU_2); -} - -/**************************************************************************** - * Name: esp_init_queuecache - * - * Description: - * Initialize queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * mq_ptr - Queue data pointer - * buffer - Queue cache buffer pointer - * size - Queue cache buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_queuecache(struct esp_queuecache_s *qc, - struct file *mq_ptr, - uint8_t *buffer, - size_t size) -{ - qc->mq_ptr = mq_ptr; - qc->size = size; - qc->buffer = buffer; - list_initialize(&qc->node); -} - -/**************************************************************************** - * Name: esp_send_queuecache - * - * Description: - * Store posting queue action and data into queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * buffer - Data buffer - * size - Buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -IRAM_ATTR void esp_send_queuecache(struct esp_queuecache_s *qc, - uint8_t *buffer, - int size) -{ - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - DEBUGASSERT(qc->size == size); - - list_add_tail(&priv->qc_list, &qc->node); - memcpy(qc->buffer, buffer, size); - - /* Enable CPU 0 interrupt. This will generate an IRQ as soon as non-IRAM - * are (re)enabled. - */ - - modifyreg32(SYSTEM_CPU_INTR_FROM_CPU_2_REG, 0, SYSTEM_CPU_INTR_FROM_CPU_2); -} - -/**************************************************************************** - * Name: esp_wireless_init - * - * Description: - * Initialize ESP32 wireless common components for both BT and Wi-Fi. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_init(void) -{ - int ret; - irqstate_t flags; - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - flags = enter_critical_section(); - if (priv->ref != 0) - { - priv->ref++; - leave_critical_section(flags); - return OK; - } - - priv->cpuint = esp32s3_setup_irq(0, SWI_PERIPH, ESP32S3_INT_PRIO_DEF, 0); - if (priv->cpuint < 0) - { - /* Failed to allocate a CPU interrupt of this type. */ - - wlerr("ERROR: Failed to attach IRQ ret=%d\n", ret); - ret = priv->cpuint; - leave_critical_section(flags); - - return ret; - } - - ret = irq_attach(SWI_IRQ, esp_swi_irq, NULL); - if (ret < 0) - { - esp32s3_teardown_irq(0, SWI_PERIPH, priv->cpuint); - leave_critical_section(flags); - wlerr("ERROR: Failed to attach IRQ ret=%d\n", ret); - - return ret; - } - - list_initialize(&priv->sc_list); - list_initialize(&priv->qc_list); - - up_enable_irq(SWI_IRQ); - - priv->ref++; - - leave_critical_section(flags); - - return OK; -} - -/**************************************************************************** - * Name: esp_wireless_deinit - * - * Description: - * De-initialize ESP32 wireless common components. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_deinit(void) -{ - irqstate_t flags; - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - flags = enter_critical_section(); - - if (priv->ref > 0) - { - priv->ref--; - if (priv->ref == 0) - { - up_disable_irq(SWI_IRQ); - irq_detach(SWI_IRQ); - esp32s3_teardown_irq(0, SWI_PERIPH, priv->cpuint); - } - } - - leave_critical_section(flags); - - return OK; -} - -#ifdef CONFIG_ESP32S3_WIFI - -/**************************************************************************** - * Name: esp_wifi_init - * - * Description: - * Initialize Wi-Fi - * - * Input Parameters: - * config - Initialization config parameters - * - * Returned Value: - * 0 if success or others if fail - * - ****************************************************************************/ - -int32_t esp_wifi_init(const wifi_init_config_t *config) -{ - int32_t ret; - uint32_t min_active_time_us = - CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME * 1000; - uint32_t keep_alive_time_us = - CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME * 1000 * 1000; - uint32_t wait_broadcast_data_time_us = - CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME * 1000; - - esp_wifi_set_sleep_min_active_time(min_active_time_us); - esp_wifi_set_keep_alive_time(keep_alive_time_us); - esp_wifi_set_sleep_wait_broadcast_data_time(wait_broadcast_data_time_us); - -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST - ret = coex_init(); - if (ret) - { - wlerr("ERROR: Failed to initialize coex error=%d\n", ret); - return ret; - } -#endif /* CONFIG_ESP32S3_WIFI_BT_COEXIST */ - - esp_wifi_set_log_level(); - esp_wifi_power_domain_on(); - - ret = esp_wifi_init_internal(config); - if (ret) - { - wlerr("Failed to initialize Wi-Fi error=%d\n", ret); - return ret; - } - - esp_phy_modem_init(); - - ret = esp_supplicant_init(); - if (ret) - { - wlerr("Failed to initialize WPA supplicant error=%d\n", ret); - esp_wifi_deinit_internal(); - return ret; - } - - return 0; -} - -/**************************************************************************** - * Name: esp_wifi_deinit - * - * Description: - * Deinitialize Wi-Fi and free resource - * - * Input Parameters: - * None - * - * Returned Value: - * 0 if success or others if fail - * - ****************************************************************************/ - -int32_t esp_wifi_deinit(void) -{ - int ret; - - ret = esp_supplicant_deinit(); - if (ret) - { - wlerr("Failed to deinitialize supplicant\n"); - return ret; - } - - ret = esp_wifi_deinit_internal(); - if (ret != 0) - { - wlerr("Failed to deinitialize Wi-Fi\n"); - return ret; - } - - return ret; -} -#endif /* CONFIG_ESP32S3_WIFI */ diff --git a/arch/xtensa/src/esp32s3/esp32s3_wireless.h b/arch/xtensa/src/esp32s3/esp32s3_wireless.h deleted file mode 100644 index 35970ab06f631..0000000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_wireless.h +++ /dev/null @@ -1,370 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_wireless.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WIRELESS_H -#define __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WIRELESS_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ -#include -#include -#include - -#include -#include - -#include "esp_attr.h" -#include "esp32s3_rt_timer.h" - -#include "esp_log.h" -#include "esp_mac.h" -#include "esp_private/phy.h" -#include "esp_private/wifi.h" -#include "esp_random.h" -#include "esp_timer.h" -#include "rom/ets_sys.h" -#include "soc/soc_caps.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Note: Don't remove these definitions, they are needed by the 3rdparty IDF - * headers - */ - -#define CONFIG_MAC_BB_PD (0) -#define MAC_LEN (6) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/* Semaphore Cache Data */ - -struct esp_semcache_s -{ - struct list_node node; - - sem_t *sem; - uint32_t count; -}; - -/* Queue Cache Data */ - -struct esp_queuecache_s -{ - struct list_node node; - - struct file *mq_ptr; - size_t size; - uint8_t *buffer; -}; - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nuttx_err_to_freertos - * - * Description: - * Transform from Nuttx OS error code to FreeRTOS's pdTRUE or pdFALSE. - * - * Input Parameters: - * ret - NuttX error code - * - * Returned Value: - * Wi-Fi adapter error code - * - ****************************************************************************/ - -static inline int32_t nuttx_err_to_freertos(int ret) -{ - return ret >= 0; -} - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_to_errno - * - * Description: - * Transform from ESP Wi-Fi error code to NuttX error code - * - * Input Parameters: - * err - ESP Wi-Fi error code - * - * Returned Value: - * NuttX error code defined in errno.h - * - ****************************************************************************/ - -int32_t esp_wifi_to_errno(int err); - -/**************************************************************************** - * Functions needed by libphy.a - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_dport_access_reg_read - * - * Description: - * Read register value safely in SMP - * - * Input Parameters: - * reg - Register address - * - * Returned Value: - * Register value - * - ****************************************************************************/ - -uint32_t IRAM_ATTR esp_dport_access_reg_read(uint32_t reg); - -/**************************************************************************** - * Name: phy_printf - * - * Description: - * Output format string and its arguments - * - * Input Parameters: - * format - format string - * - * Returned Value: - * 0 - * - ****************************************************************************/ - -int phy_printf(const char *format, ...) printf_like(1, 2); - -/**************************************************************************** - * Name: esp_timer_create - * - * Description: - * Create timer with given arguments - * - * Input Parameters: - * create_args - Timer arguments data pointer - * out_handle - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_create(const esp_timer_create_args_t *create_args, - esp_timer_handle_t *out_handle); - -/**************************************************************************** - * Name: esp_timer_start_once - * - * Description: - * Start timer with one shot mode - * - * Input Parameters: - * timer - Timer handle pointer - * timeout_us - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us); - -/**************************************************************************** - * Name: esp_timer_start_periodic - * - * Description: - * Start timer with periodic mode - * - * Input Parameters: - * timer - Timer handle pointer - * period - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period); - -/**************************************************************************** - * Name: esp_timer_stop - * - * Description: - * Stop timer - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_stop(esp_timer_handle_t timer); - -/**************************************************************************** - * Name: esp_timer_delete - * - * Description: - * Delete timer and free resource - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_delete(esp_timer_handle_t timer); - -/**************************************************************************** - * Name: esp32s3_phy_update_country_info - * - * Description: - * Update PHY init data according to country code - * - * Input Parameters: - * country - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -int esp32s3_phy_update_country_info(const char *country); - -/**************************************************************************** - * Name: esp_init_semcache - * - * Description: - * Initialize semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * sem - Semaphore data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_semcache(struct esp_semcache_s *sc, sem_t *sem); - -/**************************************************************************** - * Name: esp_post_semcache - * - * Description: - * Store posting semaphore action into semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_post_semcache(struct esp_semcache_s *sc); - -/**************************************************************************** - * Name: esp_init_queuecache - * - * Description: - * Initialize queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * mq_ptr - Queue data pointer - * buffer - Queue cache buffer pointer - * size - Queue cache buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_queuecache(struct esp_queuecache_s *qc, - struct file *mq_ptr, - uint8_t *buffer, - size_t size); - -/**************************************************************************** - * Name: esp32_wl_send_queuecache - * - * Description: - * Store posting queue action and data into queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * buffer - Data buffer - * size - Buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_send_queuecache(struct esp_queuecache_s *qc, - uint8_t *buffer, - int size); - -/**************************************************************************** - * Name: esp_wireless_init - * - * Description: - * Initialize ESP32 wireless common components for both BT and Wi-Fi. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_init(void); - -/**************************************************************************** - * Name: esp_wireless_deinit - * - * Description: - * De-initialize ESP32 wireless common components. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_deinit(void); - -#endif /* __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WIRELESS_H */ diff --git a/arch/xtensa/src/esp32s3/esp32s3_wlan.c b/arch/xtensa/src/esp32s3/esp32s3_wlan.c deleted file mode 100644 index d7c0578d0b86c..0000000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_wlan.c +++ /dev/null @@ -1,1769 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_wlan.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#ifdef CONFIG_ESP32S3_WIFI - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_NET_PKT) -# include -#endif - -#include "esp32s3_wlan.h" -#include "esp32s3_wifi_utils.h" -#include "esp32s3_wifi_adapter.h" -#include "esp32s3_wireless.h" -#include "esp32s3_systemreset.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* TX timeout = 1 minute */ - -#define WLAN_TXTOUT (60 * CLK_TCK) - -/* Low-priority work queue processes RX/TX */ - -#define WLAN_WORK LPWORK - -/* Ethernet frame: - * Resource address : 6 bytes - * Destination address: 6 bytes - * Type : 2 bytes - * Payload : MAX 1500 - * Checksum : Ignore - * - * Total size : 1514 - */ - -#define WLAN_BUF_SIZE (CONFIG_NET_ETH_PKTSIZE) - -/* WLAN packet buffer number */ - -#define WLAN_PKTBUF_NUM (CONFIG_ESP32S3_WLAN_PKTBUF_NUM) - -/* Receive threshold which allows the receive function to trigger a scheduler - * to activate the application if possible. - */ - -#ifdef CONFIG_MM_IOB -# define IOBBUF_SIZE (CONFIG_IOB_NBUFFERS * CONFIG_IOB_BUFSIZE) -# if (IOBBUF_SIZE) > (WLAN_BUF_SIZE + 1) -# define WLAN_RX_THRESHOLD (IOBBUF_SIZE - WLAN_BUF_SIZE + 1) -# endif -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/* WLAN packet buffer */ - -struct wlan_pktbuf -{ - sq_entry_t entry; /* Queue entry */ - - /* Packet data buffer */ - - uint8_t buffer[WLAN_BUF_SIZE]; - uint16_t len; /* Packet data length */ -}; - -/* WLAN operations */ - -struct wlan_ops -{ - int (*start)(void); - int (*send)(void *pdata, size_t n); - int (*essid)(struct iwreq *iwr, bool set); - int (*bssid)(struct iwreq *iwr, bool set); - int (*passwd)(struct iwreq *iwr, bool set); - int (*mode)(struct iwreq *iwr, bool set); - int (*auth)(struct iwreq *iwr, bool set); - int (*freq)(struct iwreq *iwr, bool set); - int (*bitrate)(struct iwreq *iwr, bool set); - int (*txpower)(struct iwreq *iwr, bool set); - int (*channel)(struct iwreq *iwr, bool set); - int (*country)(struct iwreq *iwr, bool set); - int (*rssi)(struct iwreq *iwr, bool set); - int (*connect)(void); - int (*disconnect)(void); - int (*event)(pid_t pid, struct sigevent *event); - int (*stop)(void); -}; - -/* The wlan_priv_s encapsulates all state information for a single - * hardware interface - */ - -struct wlan_priv_s -{ - int ref; /* Reference count */ - - bool ifup; /* true:ifup false:ifdown */ - - struct wdog_s txtimeout; /* TX timeout timer */ - - struct work_s rxwork; /* Send packet work */ - struct work_s txwork; /* Receive packet work */ - struct work_s pollwork; /* Poll work */ - struct work_s toutwork; /* Send packet timeout work */ - - const struct wlan_ops *ops; /* WLAN operations */ - - /* This holds the information visible to the NuttX network */ - - struct net_driver_s dev; - - /* Packet buffer cache */ - - struct wlan_pktbuf pktbuf[WLAN_PKTBUF_NUM]; - - /* RX packet queue */ - - sq_queue_t rxb; - - /* TX ready packet queue */ - - sq_queue_t txb; - - /* Free packet buffer queue */ - - sq_queue_t freeb; - - /* Device specific lock */ - - spinlock_t lock; -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* Reference count of register Wi-Fi handler */ - -static uint8_t g_callback_register_ref; - -static struct wlan_priv_s g_wlan_priv[ESP32S3_WLAN_DEVS]; - -#ifdef ESP32S3_WLAN_HAS_STA -static const struct wlan_ops g_sta_ops = -{ - .start = esp_wifi_sta_start, - .send = esp_wifi_sta_send_data, - .essid = esp_wifi_sta_essid, - .bssid = esp_wifi_sta_bssid, - .passwd = esp_wifi_sta_password, - .mode = esp_wifi_sta_mode, - .auth = esp_wifi_sta_auth, - .freq = esp_wifi_sta_freq, - .bitrate = esp_wifi_sta_bitrate, - .txpower = esp_wifi_sta_txpower, - .channel = esp_wifi_sta_channel, - .country = esp_wifi_sta_country, - .rssi = esp_wifi_sta_rssi, - .connect = esp_wifi_sta_connect, - .disconnect = esp_wifi_sta_disconnect, - .event = esp_wifi_notify_subscribe, - .stop = esp_wifi_sta_stop -}; -#endif /* ESP32S3_WLAN_HAS_STA */ - -#ifdef ESP32S3_WLAN_HAS_SOFTAP -static const struct wlan_ops g_softap_ops = -{ - .start = esp_wifi_softap_start, - .send = esp_wifi_softap_send_data, - .essid = esp_wifi_softap_essid, - .bssid = esp_wifi_softap_bssid, - .passwd = esp_wifi_softap_password, - .mode = esp_wifi_softap_mode, - .auth = esp_wifi_softap_auth, - .freq = esp_wifi_softap_freq, - .bitrate = esp_wifi_softap_bitrate, - .txpower = esp_wifi_softap_txpower, - .channel = esp_wifi_softap_channel, - .country = esp_wifi_softap_country, - .rssi = esp_wifi_softap_rssi, - .connect = esp_wifi_softap_connect, - .disconnect = esp_wifi_softap_disconnect, - .event = esp_wifi_notify_subscribe, - .stop = esp_wifi_softap_stop -}; -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* Common TX/RX logic */ - -static struct wlan_pktbuf *wlan_recvframe(struct wlan_priv_s *priv); -static struct wlan_pktbuf *wlan_txframe(struct wlan_priv_s *priv); -static void wlan_transmit(struct wlan_priv_s *priv); -static void wlan_rxpoll(void *arg); -static int wlan_txpoll(struct net_driver_s *dev); -static void wlan_dopoll(struct wlan_priv_s *priv); - -/* Watchdog timer expirations */ - -static void wlan_txtimeout_work(void *arg); -static void wlan_txtimeout_expiry(wdparm_t arg); - -/* NuttX callback functions */ - -static int wlan_ifup(struct net_driver_s *dev); -static int wlan_ifdown(struct net_driver_s *dev); - -static void wlan_txavail_work(void *arg); -static int wlan_txavail(struct net_driver_s *dev); - -#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) -static int wlan_addmac(struct net_driver_s *dev, const uint8_t *mac); -#endif - -#ifdef CONFIG_NET_MCASTGROUP -static int wlan_rmmac(struct net_driver_s *dev, const uint8_t *mac); -#endif - -#ifdef CONFIG_NETDEV_IOCTL -static int wlan_ioctl(struct net_driver_s *dev, int cmd, - unsigned long arg); -#endif - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* Note: - * All TX done/RX done/Error trigger functions are not called from - * interrupts, this is much different from ethernet driver, including: - * * wlan_rx_done - * * wlan_tx_done - * - * These functions are called in a Wi-Fi private thread. So we just use - * mutex/semaphore instead of disable interrupt, if necessary. - */ - -/**************************************************************************** - * Function: wlan_init_buffer - * - * Description: - * Initialize the free buffer list - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_init_buffer(struct wlan_priv_s *priv) -{ - irqstate_t flags; - - int i; - flags = spin_lock_irqsave(&priv->lock); - - priv->dev.d_buf = NULL; - priv->dev.d_len = 0; - - sq_init(&priv->freeb); - sq_init(&priv->rxb); - sq_init(&priv->txb); - - for (i = 0; i < WLAN_PKTBUF_NUM; i++) - { - sq_addlast(&priv->pktbuf[i].entry, &priv->freeb); - } - - spin_unlock_irqrestore(&priv->lock, flags); -} - -/**************************************************************************** - * Function: wlan_alloc_buffer - * - * Description: - * Allocate one buffer from the free buffer queue - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * Pointer to the allocated buffer on success; NULL on failure - * - ****************************************************************************/ - -static inline struct wlan_pktbuf *wlan_alloc_buffer(struct wlan_priv_s *priv) -{ - struct wlan_pktbuf *pktbuf = NULL; - - sq_entry_t *entry; - irqstate_t flags = spin_lock_irqsave(&priv->lock); - - entry = sq_remfirst(&priv->freeb); - if (entry) - { - pktbuf = container_of(entry, struct wlan_pktbuf, entry); - } - - spin_unlock_irqrestore(&priv->lock, flags); - - return pktbuf; -} - -/**************************************************************************** - * Function: wlan_free_buffer - * - * Description: - * Insert a free Rx buffer into the free queue - * - * Input Parameters: - * priv - Reference to the driver state structure - * buffer - A pointer to the packet buffer to be freed - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_free_buffer(struct wlan_priv_s *priv, - uint8_t *buffer) -{ - struct wlan_pktbuf *pktbuf; - - irqstate_t flags = spin_lock_irqsave(&priv->lock); - - pktbuf = container_of(buffer, struct wlan_pktbuf, buffer); - sq_addlast(&pktbuf->entry, &priv->freeb); - - spin_unlock_irqrestore(&priv->lock, flags); -} - -/**************************************************************************** - * Function: wlan_cache_txpkt_tail - * - * Description: - * Cache packet from dev->d_buf into tail of TX ready queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_cache_txpkt_tail(struct wlan_priv_s *priv) -{ - struct wlan_pktbuf *pktbuf; - irqstate_t flags; - struct net_driver_s *dev = &priv->dev; - - pktbuf = container_of(dev->d_buf, struct wlan_pktbuf, buffer); - pktbuf->len = dev->d_len; - - flags = spin_lock_irqsave(&priv->lock); - sq_addlast(&pktbuf->entry, &priv->txb); - spin_unlock_irqrestore(&priv->lock, flags); - - dev->d_buf = NULL; - dev->d_len = 0; -} - -/**************************************************************************** - * Function: wlan_add_txpkt_head - * - * Description: - * Add packet into head of TX ready queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_add_txpkt_head(struct wlan_priv_s *priv, - struct wlan_pktbuf *pktbuf) -{ - irqstate_t flags; - - flags = spin_lock_irqsave(&priv->lock); - sq_addfirst(&pktbuf->entry, &priv->txb); - spin_unlock_irqrestore(&priv->lock, flags); -} - -/**************************************************************************** - * Function: wlan_recvframe - * - * Description: - * Try to receive RX packet from RX done packet queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * RX packet if success or NULl if no packet in queue. - * - ****************************************************************************/ - -static struct wlan_pktbuf *wlan_recvframe(struct wlan_priv_s *priv) -{ - irqstate_t flags; - sq_entry_t *entry; - struct wlan_pktbuf *pktbuf = NULL; - - flags = spin_lock_irqsave(&priv->lock); - - entry = sq_remfirst(&priv->rxb); - if (entry) - { - pktbuf = container_of(entry, struct wlan_pktbuf, entry); - } - - spin_unlock_irqrestore(&priv->lock, flags); - - return pktbuf; -} - -/**************************************************************************** - * Function: wlan_txframe - * - * Description: - * Try to receive TX buffer from TX ready buffer queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * TX packets buffer if success or NULL if no packet in queue. - * - ****************************************************************************/ - -static struct wlan_pktbuf *wlan_txframe(struct wlan_priv_s *priv) -{ - irqstate_t flags; - sq_entry_t *entry; - struct wlan_pktbuf *pktbuf = NULL; - - flags = spin_lock_irqsave(&priv->lock); - - entry = sq_remfirst(&priv->txb); - if (entry) - { - pktbuf = container_of(entry, struct wlan_pktbuf, entry); - } - - spin_unlock_irqrestore(&priv->lock, flags); - - return pktbuf; -} - -/**************************************************************************** - * Name: wlan_transmit - * - * Description: - * Try to send all TX packets in TX ready queue to Wi-Fi driver. If this - * sending fails, then breaks loop and returns. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_transmit(struct wlan_priv_s *priv) -{ - struct wlan_pktbuf *pktbuf; - int ret; - - while ((pktbuf = wlan_txframe(priv))) - { - ret = priv->ops->send(pktbuf->buffer, pktbuf->len); - if (ret == -ENOMEM) - { - wlan_add_txpkt_head(priv, pktbuf); - wd_start(&priv->txtimeout, WLAN_TXTOUT, - wlan_txtimeout_expiry, (uint32_t)priv); - break; - } - else - { - if (ret < 0) - { - nwarn("WARN: Failed to send pkt, ret: %d\n", ret); - } - - wlan_free_buffer(priv, pktbuf->buffer); - } - } -} - -/**************************************************************************** - * Name: wlan_tx_done - * - * Description: - * Wi-Fi TX done callback function. If this is called, it means sending - * next packet. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_tx_done(struct wlan_priv_s *priv) -{ - wd_cancel(&priv->txtimeout); - - wlan_txavail(&priv->dev); -} - -/**************************************************************************** - * Function: wlan_rx_done - * - * Description: - * Wi-Fi RX done callback function. If this is called, it means receiving - * packet. - * - * Input Parameters: - * priv - Reference to the driver state structure - * buffer - Wi-Fi received packet buffer - * len - Length of received packet - * eb - Wi-Fi receive callback input eb pointer - * - * Returned Value: - * 0 on success or a negated errno on failure - * - ****************************************************************************/ - -static int wlan_rx_done(struct wlan_priv_s *priv, void *buffer, - uint16_t len, void *eb) -{ - struct wlan_pktbuf *pktbuf; - irqstate_t flags; - int ret = 0; - - if (!priv->ifup) - { - goto out; - } - - if (len > WLAN_BUF_SIZE) - { - nwarn("ERROR: Wlan receive %d larger than %d\n", - len, WLAN_BUF_SIZE); - ret = -EINVAL; - goto out; - } - - pktbuf = wlan_alloc_buffer(priv); - if (!pktbuf) - { - ret = -ENOBUFS; - goto out; - } - - memcpy(pktbuf->buffer, buffer, len); - pktbuf->len = len; - - if (eb) - { - esp_wifi_free_eb(eb); - } - - flags = spin_lock_irqsave(&priv->lock); - sq_addlast(&pktbuf->entry, &priv->rxb); - spin_unlock_irqrestore(&priv->lock, flags); - - if (work_available(&priv->rxwork)) - { - work_queue(WLAN_WORK, &priv->rxwork, wlan_rxpoll, priv, 0); - } - - return 0; - -out: - if (eb) - { - esp_wifi_free_eb(eb); - } - - return ret; -} - -/**************************************************************************** - * Function: wlan_rxpoll - * - * Description: - * Try to receive packets from RX done queue and pass packets into IP - * stack and send packets which is from IP stack if necessary. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_rxpoll(void *arg) -{ - struct wlan_pktbuf *pktbuf; - struct eth_hdr_s *eth_hdr; - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - struct net_driver_s *dev = &priv->dev; -#ifdef WLAN_RX_THRESHOLD - uint32_t rbytes = 0; -#endif - - /* Try to send all cached TX packets for TX ack and so on */ - - wlan_transmit(priv); - - /* Loop while while wlan_recvframe() successfully retrieves valid - * Ethernet frames. - */ - - net_lock(); - - while ((pktbuf = wlan_recvframe(priv)) != NULL) - { - dev->d_buf = pktbuf->buffer; - dev->d_len = pktbuf->len; - -#ifdef WLAN_RX_THRESHOLD - rbytes += pktbuf->len; -#endif - -#ifdef CONFIG_NET_PKT - - /* When packet sockets are enabled, - * feed the frame into the packet tap. - */ - - pkt_input(&priv->dev); -#endif - - /* Check if the packet is a valid size for the network - * buffer configuration (this should not happen) - */ - - if (dev->d_len > WLAN_BUF_SIZE) - { - nwarn("WARNING: DROPPED Too big: %d\n", dev->d_len); - - /* Free dropped packet buffer */ - - if (dev->d_buf) - { - wlan_free_buffer(priv, dev->d_buf); - dev->d_buf = NULL; - dev->d_len = 0; - } - - continue; - } - - eth_hdr = (struct eth_hdr_s *)dev->d_buf; - - /* We only accept IP packets of the configured type and ARP packets */ - -#ifdef CONFIG_NET_IPv4 - if (eth_hdr->type == HTONS(ETHTYPE_IP)) - { - ninfo("IPv4 frame\n"); - - /* Receive an IPv4 packet from the network device */ - - ipv4_input(&priv->dev); - - /* If the above function invocation resulted in data - * that should be sent out on the network, - * the field d_len will set to a value > 0. - */ - - if (priv->dev.d_len > 0) - { - /* And send the packet */ - - wlan_cache_txpkt_tail(priv); - } - } - else -#endif -#ifdef CONFIG_NET_IPv6 - if (eth_hdr->type == HTONS(ETHTYPE_IP6)) - { - ninfo("IPv6 frame\n"); - - /* Give the IPv6 packet to the network layer */ - - ipv6_input(&priv->dev); - - /* If the above function invocation resulted in data - * that should be sent out on the network, the field - * d_len will set to a value > 0. - */ - - if (priv->dev.d_len > 0) - { - /* And send the packet */ - - wlan_cache_txpkt_tail(priv); - } - } - else -#endif -#ifdef CONFIG_NET_ARP - if (eth_hdr->type == HTONS(ETHTYPE_ARP)) - { - ninfo("ARP frame\n"); - - /* Handle ARP packet */ - - arp_input(&priv->dev); - - /* If the above function invocation resulted in data - * that should be sent out on the network, the field - * d_len will set to a value > 0. - */ - - if (priv->dev.d_len > 0) - { - wlan_cache_txpkt_tail(priv); - } - } - else -#endif - { - ninfo("INFO: Dropped, Unknown type: %04x\n", eth_hdr->type); - } - - /* We are finished with the RX buffer. NOTE: If the buffer is - * re-used for transmission, the dev->d_buf field will have been - * nullified. - */ - - if (dev->d_buf) - { - /* Free the receive packet buffer */ - - wlan_free_buffer(priv, dev->d_buf); - dev->d_buf = NULL; - dev->d_len = 0; - } - -#ifdef WLAN_RX_THRESHOLD - /* If received total bytes is larger than receive threshold, - * then do "unlock" to try to active applicantion to receive - * data from low-level buffer of IP stack. - */ - - if (rbytes >= WLAN_RX_THRESHOLD) - { - net_unlock(); - rbytes = 0; - net_lock(); - } -#endif - } - - /* Try to send all cached TX packets */ - - wlan_transmit(priv); - - net_unlock(); -} - -/**************************************************************************** - * Name: wlan_txpoll - * - * Description: - * The transmitter is available, check if the network has any outgoing - * packets ready to send. This is a callback from devif_poll(). - * devif_poll() may be called: - * - * 1. When the preceding TX packets send times out and the interface is - * reset - * 2. During normal TX polling - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int wlan_txpoll(struct net_driver_s *dev) -{ - struct wlan_pktbuf *pktbuf; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - DEBUGASSERT(dev->d_buf != NULL); - - wlan_cache_txpkt_tail(priv); - - pktbuf = wlan_alloc_buffer(priv); - if (!pktbuf) - { - return -ENOMEM; - } - - dev->d_buf = pktbuf->buffer; - dev->d_len = WLAN_BUF_SIZE; - - /* If zero is returned, the polling will continue until - * all connections have been examined. - */ - - return OK; -} - -/**************************************************************************** - * Function: wlan_dopoll - * - * Description: - * The function is called in order to perform an out-of-sequence TX poll. - * This is done: - * - * 1. When new TX data is available (wlan_txavail) - * 2. After a TX timeout to restart the sending process - * (wlan_txtimeout_expiry). - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_dopoll(struct wlan_priv_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - struct wlan_pktbuf *pktbuf; - uint8_t *txbuf; - int ret; - - pktbuf = wlan_alloc_buffer(priv); - if (!pktbuf) - { - return; - } - - dev->d_buf = pktbuf->buffer; - dev->d_len = WLAN_BUF_SIZE; - - /* Try to let TCP/IP to send all packets to netcard driver */ - - do - { - txbuf = dev->d_buf; - ret = devif_poll(dev, wlan_txpoll); - } - while ((ret == 0) && - (dev->d_buf != txbuf)); - - if (dev->d_buf) - { - wlan_free_buffer(priv, dev->d_buf); - - dev->d_buf = NULL; - dev->d_len = 0; - } - - /* Try to send all cached TX packets */ - - wlan_transmit(priv); -} - -/**************************************************************************** - * Function: wlan_txtimeout_work - * - * Description: - * Perform TX timeout related work from the worker thread - * - * Input Parameters: - * arg - The argument passed when work_queue() as called. - * - * Returned Value: - * OK on success - * - ****************************************************************************/ - -static void wlan_txtimeout_work(void *arg) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - - /* Try to send all cached TX packets */ - - wlan_transmit(priv); - - net_lock(); - - wlan_ifdown(&priv->dev); - wlan_ifup(&priv->dev); - - /* Then poll for new XMIT data */ - - wlan_dopoll(priv); - - net_unlock(); -} - -/**************************************************************************** - * Function: wlan_txtimeout_expiry - * - * Description: - * Our TX watchdog timed out. Called from the timer callback handler. - * The last TX never completed. Reset the hardware and start again. - * - * Input Parameters: - * argc - The number of available arguments - * arg - The first argument - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_txtimeout_expiry(wdparm_t arg) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - - /* Schedule to perform the TX timeout processing on the worker thread. */ - - if (work_available(&priv->toutwork)) - { - work_queue(WLAN_WORK, &priv->toutwork, wlan_txtimeout_work, priv, 0); - } -} - -/**************************************************************************** - * Name: wlan_txavail_work - * - * Description: - * Perform an out-of-cycle poll on the worker thread. - * - * Input Parameters: - * arg - Reference to the NuttX driver state structure (cast to void*) - * - * Returned Value: - * None - * - * Assumptions: - * Called on the higher priority worker thread. - * - ****************************************************************************/ - -static void wlan_txavail_work(void *arg) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - - /* Try to send all cached TX packets even if net is down */ - - wlan_transmit(priv); - - /* Lock the network and serialize driver operations if necessary. - * NOTE: Serialization is only required in the case where the driver work - * is performed on an LP worker thread and where more than one LP worker - * thread has been configured. - */ - - net_lock(); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - wlan_dopoll(priv); - } - - net_unlock(); -} - -/**************************************************************************** - * Name: wlan_ifup - * - * Description: - * NuttX Callback: Bring up the Ethernet interface when an IP address is - * provided - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static int wlan_ifup(struct net_driver_s *dev) -{ - int ret; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - -#ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %u.%u.%u.%u\n", - ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), - ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); -#endif -#ifdef CONFIG_NET_IPv6 - ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", - dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2], - dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5], - dev->d_ipv6addr[6], dev->d_ipv6addr[7]); -#endif - - net_lock(); - - if (priv->ifup) - { - net_unlock(); - return OK; - } - - wlan_init_buffer(priv); - ret = priv->ops->start(); - if (ret < 0) - { - net_unlock(); - nerr("ERROR: Failed to start Wi-Fi ret=%d\n", ret); - return ret; - } - - priv->ifup = true; - if (g_callback_register_ref == 0) - { - ret = esp32s3_register_shutdown_handler(esp_wifi_stop_callback); - if (ret < 0) - { - nwarn("WARN: Failed to register handler ret=%d\n", ret); - } - } - - ++g_callback_register_ref; - net_unlock(); - - return OK; -} - -/**************************************************************************** - * Name: wlan_ifdown - * - * Description: - * NuttX Callback: Stop the interface. - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static int wlan_ifdown(struct net_driver_s *dev) -{ - int ret; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - net_lock(); - - if (!priv->ifup) - { - net_unlock(); - return OK; - } - - /* Cancel the TX poll timer and TX timeout timers */ - - wd_cancel(&priv->txtimeout); - - /* Mark the device "down" */ - - priv->ifup = false; - - ret = priv->ops->stop(); - if (ret < 0) - { - nerr("ERROR: Failed to stop Wi-Fi ret=%d\n", ret); - } - - --g_callback_register_ref; - if (g_callback_register_ref == 0) - { - ret = esp32s3_unregister_shutdown_handler(esp_wifi_stop_callback); - if (ret < 0) - { - nwarn("WARN: Failed to unregister handler ret=%d\n", ret); - } - } - - net_unlock(); - - return OK; -} - -/**************************************************************************** - * Name: wlan_txavail - * - * Description: - * Driver callback invoked when new TX data is available. This is a - * stimulus perform an out-of-cycle poll and, thereby, reduce the TX - * latency. - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - * Assumptions: - * Called in normal user mode - * - ****************************************************************************/ - -static int wlan_txavail(struct net_driver_s *dev) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - if (work_available(&priv->txwork)) - { - /* Schedule to serialize the poll on the worker thread. */ - - work_queue(WLAN_WORK, &priv->txwork, wlan_txavail_work, priv, 0); - } - - return OK; -} - -/**************************************************************************** - * Name: wlan_addmac - * - * Description: - * NuttX Callback: Add the specified MAC address to the hardware multicast - * address filtering - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * mac - The MAC address to be added - * - * Returned Value: - * None - * - ****************************************************************************/ - -#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) -static int wlan_addmac(struct net_driver_s *dev, const uint8_t *mac) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - /* Add the MAC address to the hardware multicast routing table */ - - return OK; -} -#endif - -/**************************************************************************** - * Name: wlan_rmmac - * - * Description: - * NuttX Callback: Remove the specified MAC address from the - * hardware multicast address filtering - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * mac - The MAC address to be removed - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_MCASTGROUP -static int wlan_rmmac(struct net_driver_s *dev, const uint8_t *mac) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - /* Add the MAC address to the hardware multicast routing table */ - - return OK; -} -#endif - -/**************************************************************************** - * Name: wlan_ioctl - * - * Description: - * Handle network IOCTL commands directed to this device. - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * cmd - The IOCTL command - * arg - The argument for the IOCTL command - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef CONFIG_NETDEV_IOCTL -static int wlan_ioctl(struct net_driver_s *dev, - int cmd, - unsigned long arg) -{ - int ret; - struct iwreq *iwr = (struct iwreq *)arg; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - const struct wlan_ops *ops = priv->ops; - - /* Decode and dispatch the driver-specific IOCTL command */ - - switch (cmd) - { -#ifdef CONFIG_NETDEV_PHY_IOCTL -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ - { - struct mii_ioctl_notify_s *req = (struct mii_ioctl_notify_s *)arg; - ret = ops->event(req->pid, &req->event); - if (ret < 0) - { - nerr("ERROR: Failed to subscribe event\n"); - } - } - break; -#endif -#endif - - case SIOCSIWENCODEEXT: - ret = ops->passwd(iwr, true); - - break; - - case SIOCGIWENCODEEXT: - ret = ops->passwd(iwr, false); - break; - - case SIOCSIWESSID: - if ((iwr->u.essid.flags == IW_ESSID_ON) || - (iwr->u.essid.flags == IW_ESSID_DELAY_ON)) - { - ret = ops->essid(iwr, true); - if (ret < 0) - { - break; - } - - if (iwr->u.essid.flags == IW_ESSID_ON) - { - ret = ops->connect(); - if (ret < 0) - { - nerr("ERROR: Failed to connect\n"); - break; - } - } - } - else - { - ret = ops->disconnect(); - if (ret < 0) - { - nerr("ERROR: Failed to disconnect\n"); - break; - } - } - - break; - - case SIOCGIWESSID: /* Get ESSID */ - ret = ops->essid(iwr, false); - break; - - case SIOCSIWAP: /* Set access point MAC addresses */ - if (iwr->u.ap_addr.sa_data[0] != 0 && - iwr->u.ap_addr.sa_data[1] != 0 && - iwr->u.ap_addr.sa_data[2] != 0) - { - ret = ops->bssid(iwr, true); - if (ret < 0) - { - nerr("ERROR: Failed to set BSSID\n"); - break; - } - - ret = ops->connect(); - if (ret < 0) - { - nerr("ERROR: Failed to connect\n"); - break; - } - } - else - { - ret = ops->disconnect(); - if (ret < 0) - { - nerr("ERROR: Failed to disconnect\n"); - break; - } - } - - break; - - case SIOCGIWAP: /* Get access point MAC addresses */ - ret = ops->bssid(iwr, false); - break; - - case SIOCSIWSCAN: - ret = esp_wifi_start_scan(iwr); - break; - - case SIOCGIWSCAN: - ret = esp_wifi_get_scan_results(iwr); - break; - - case SIOCSIWCOUNTRY: /* Set country code */ - ret = ops->country(iwr, true); - break; - - case SIOCGIWCOUNTRY: /* Set country code */ - ret = ops->country(iwr, false); - break; - - case SIOCGIWSENS: /* Get sensitivity (dBm) */ - ret = ops->rssi(iwr, false); - break; - - case SIOCSIWMODE: /* Set operation mode */ - ret = ops->mode(iwr, true); - break; - - case SIOCGIWMODE: /* Get operation mode */ - ret = ops->mode(iwr, false); - break; - - case SIOCSIWAUTH: /* Set authentication mode params */ - ret = ops->auth(iwr, true); - break; - - case SIOCGIWAUTH: /* Get authentication mode params */ - ret = ops->auth(iwr, false); - break; - - case SIOCSIWFREQ: /* Set channel/frequency (MHz) */ - ret = ops->freq(iwr, true); - break; - - case SIOCGIWFREQ: /* Get channel/frequency (MHz) */ - ret = ops->freq(iwr, false); - break; - - case SIOCSIWRATE: /* Set default bit rate (Mbps) */ - wlwarn("WARNING: SIOCSIWRATE not implemented\n"); - ret = -ENOSYS; - break; - - case SIOCGIWRATE: /* Get default bit rate (Mbps) */ - ret = ops->bitrate(iwr, false); - break; - - case SIOCSIWTXPOW: /* Set transmit power (dBm) */ - ret = ops->txpower(iwr, true); - break; - - case SIOCGIWTXPOW: /* Get transmit power (dBm) */ - ret = ops->txpower(iwr, false); - break; - - case SIOCGIWRANGE: /* Get range of parameters */ - ret = ops->channel(iwr, false); - break; - - default: - nerr("ERROR: Unrecognized IOCTL command: %d\n", cmd); - ret = -ENOTTY; /* Special return value for this case */ - break; - } - - return ret; -} -#endif /* CONFIG_NETDEV_IOCTL */ - -/**************************************************************************** - * Name: esp32s3_net_initialize - * - * Description: - * Initialize the ESP32-S3 driver - * - * Input Parameters: - * devno - The device number - * mac_addr - MAC address - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -static int esp32s3_net_initialize(int devno, uint8_t *mac_addr, - const struct wlan_ops *ops) -{ - int ret; - struct wlan_priv_s *priv; - struct net_driver_s *netdev; - - priv = &g_wlan_priv[devno]; - if (priv->ref) - { - priv->ref++; - return OK; - } - - netdev = &priv->dev; - - /* Initialize the driver structure */ - - memset(priv, 0, sizeof(struct wlan_priv_s)); - - netdev->d_ifup = wlan_ifup; /* I/F down callback */ - netdev->d_ifdown = wlan_ifdown; /* I/F up (new IP address) callback */ - netdev->d_txavail = wlan_txavail; /* New TX data callback */ -#ifdef CONFIG_NET_MCASTGROUP - netdev->d_addmac = wlan_addmac; /* Add multicast MAC address */ - netdev->d_rmmac = wlan_rmmac; /* Remove multicast MAC address */ -#endif -#ifdef CONFIG_NETDEV_IOCTL - netdev->d_ioctl = wlan_ioctl; /* Handle network IOCTL commands */ -#endif - - /* Used to recover private state from dev */ - - netdev->d_private = (void *)priv; - - memcpy(netdev->d_mac.ether.ether_addr_octet, mac_addr, MAC_LEN); - - ret = netdev_register(netdev, NET_LL_IEEE80211); - if (ret < 0) - { - nerr("ERROR: Initialization of IEEE 802.11 block failed: %d\n", ret); - return ret; - } - - priv->ops = ops; - - priv->ref++; - - ninfo("INFO: Initialize Wi-Fi adapter No.%d success\n", devno); - - return OK; -} - -/**************************************************************************** - * Function: wlan_sta_rx_done - * - * Description: - * Wi-Fi station RX done callback function. If this is called, it means - * station receiveing packet. - * - * Input Parameters: - * buffer - Wi-Fi received packet buffer - * len - Length of received packet - * eb - Wi-Fi receive callback input eb pointer - * - * Returned Value: - * 0 on success or a negated errno on failure - * - ****************************************************************************/ - -#ifdef ESP32S3_WLAN_HAS_STA -static int wlan_sta_rx_done(void *buffer, uint16_t len, void *eb) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32S3_WLAN_STA_DEVNO]; - - return wlan_rx_done(priv, buffer, len, eb); -} - -/**************************************************************************** - * Name: wlan_sta_tx_done - * - * Description: - * Wi-Fi station TX done callback function. If this is called, it means - * station sending next packet. - * - * Input Parameters: - * data - Pointer to the data transmitted. - * len - Length of the data transmitted. - * status - True if data was transmitted successfully or false if failed. - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_sta_tx_done(uint8_t *data, uint16_t *len, bool status) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32S3_WLAN_STA_DEVNO]; - - wlan_tx_done(priv); -} -#endif /* ESP32S3_WLAN_HAS_STA */ - -/**************************************************************************** - * Function: wlan_softap_rx_done - * - * Description: - * Wi-Fi softAP RX done callback function. If this is called, it means - * softAP receiveing packet. - * - * Input Parameters: - * buffer - Wi-Fi received packet buffer - * len - Length of received packet - * eb - Wi-Fi receive callback input eb pointer - * - * Returned Value: - * 0 on success or a negated errno on failure - * - ****************************************************************************/ - -#ifdef ESP32S3_WLAN_HAS_SOFTAP -static int wlan_softap_rx_done(void *buffer, uint16_t len, void *eb) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32S3_WLAN_SOFTAP_DEVNO]; - - return wlan_rx_done(priv, buffer, len, eb); -} - -/**************************************************************************** - * Name: wlan_softap_tx_done - * - * Description: - * Wi-Fi softAP TX done callback function. If this is called, it means - * softAP sending next packet. - * - * Input Parameters: - * ifidx - The interface ID that the TX callback has been triggered from. - * data - Pointer to the data transmitted. - * len - Length of the data transmitted. - * status - True if data was transmitted successfully or false if failed. - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_softap_tx_done(uint8_t *data, uint16_t *len, bool status) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32S3_WLAN_SOFTAP_DEVNO]; - - wlan_tx_done(priv); -} -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: esp32s3_wlan_sta_set_linkstatus - * - * Description: - * Set Wi-Fi station link status - * - * Parameters: - * linkstatus - true Notifies the networking layer about an available - * carrier, false Notifies the networking layer about an - * disappeared carrier. - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef ESP32S3_WLAN_HAS_STA -int esp32s3_wlan_sta_set_linkstatus(bool linkstatus) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32S3_WLAN_STA_DEVNO]; - - if (linkstatus) - { - netdev_carrier_on(&priv->dev); - } - else - { - netdev_carrier_off(&priv->dev); - } - - return OK; -} - -/**************************************************************************** - * Name: esp32s3_wlan_sta_initialize - * - * Description: - * Initialize the ESP32-S3 WLAN station netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32s3_wlan_sta_initialize(void) -{ - int ret; - uint8_t eth_mac[6]; - - ret = esp_wifi_adapter_init(); - if (ret < 0) - { - nerr("ERROR: Initialize Wi-Fi adapter error: %d\n", ret); - return ret; - } - - ret = esp_wifi_sta_read_mac(eth_mac); - if (ret < 0) - { - nerr("ERROR: Failed to read MAC address\n"); - return ret; - } - - ninfo("Wi-Fi station MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", - eth_mac[0], eth_mac[1], eth_mac[2], - eth_mac[3], eth_mac[4], eth_mac[5]); - - ret = esp32s3_net_initialize(ESP32S3_WLAN_STA_DEVNO, eth_mac, &g_sta_ops); - if (ret < 0) - { - nerr("ERROR: Failed to initialize net\n"); - return ret; - } - - ret = esp_wifi_sta_register_recv_cb(wlan_sta_rx_done); - if (ret < 0) - { - nerr("ERROR: Failed to register RX callback\n"); - return ret; - } - - esp_wifi_sta_register_txdone_cb(wlan_sta_tx_done); - - ninfo("INFO: Initialize Wi-Fi station success net\n"); - - return OK; -} -#endif /* ESP32S3_WLAN_HAS_STA */ - -/**************************************************************************** - * Name: esp32s3_wlan_softap_initialize - * - * Description: - * Initialize the ESP32-S3 WLAN softAP netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef ESP32S3_WLAN_HAS_SOFTAP -int esp32s3_wlan_softap_initialize(void) -{ - int ret; - uint8_t eth_mac[6]; - - ret = esp_wifi_adapter_init(); - if (ret < 0) - { - nerr("ERROR: Initialize Wi-Fi adapter error: %d\n", ret); - return ret; - } - - ret = esp_wifi_softap_read_mac(eth_mac); - if (ret < 0) - { - nerr("ERROR: Failed to read MAC address\n"); - return ret; - } - - ninfo("Wi-Fi softAP MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", - eth_mac[0], eth_mac[1], eth_mac[2], - eth_mac[3], eth_mac[4], eth_mac[5]); - - ret = esp32s3_net_initialize(ESP32S3_WLAN_SOFTAP_DEVNO, eth_mac, - &g_softap_ops); - if (ret < 0) - { - nerr("ERROR: Failed to initialize net\n"); - return ret; - } - - ret = esp_wifi_softap_register_recv_cb(wlan_softap_rx_done); - if (ret < 0) - { - nerr("ERROR: Failed to register RX callback\n"); - return ret; - } - - esp_wifi_softap_register_txdone_cb(wlan_softap_tx_done); - - ninfo("INFO: Initialize Wi-Fi softAP net success\n"); - - return OK; -} -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ - -#endif /* CONFIG_ESP32S3_WIFI */ diff --git a/arch/xtensa/src/esp32s3/esp32s3_wlan.h b/arch/xtensa/src/esp32s3/esp32s3_wlan.h deleted file mode 100644 index a522a602e5955..0000000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_wlan.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_wlan.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WLAN_H -#define __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WLAN_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include "esp32s3_wifi_adapter.h" - -#ifndef __ASSEMBLY__ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#ifdef CONFIG_ESP32S3_WIFI - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -#ifdef ESP32S3_WLAN_HAS_STA - -/**************************************************************************** - * Name: esp32s3_wlan_sta_set_linkstatus - * - * Description: - * Set Wi-Fi station link status - * - * Parameters: - * linkstatus - true Notifies the networking layer about an available - * carrier, false Notifies the networking layer about an - * disappeared carrier. - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32s3_wlan_sta_set_linkstatus(bool linkstatus); - -/**************************************************************************** - * Name: esp32s3_wlan_sta_initialize - * - * Description: - * Initialize the ESP32-S3 WLAN station netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32s3_wlan_sta_initialize(void); -#endif /* ESP32S3_WLAN_HAS_STA */ - -/**************************************************************************** - * Name: esp32s3_wlan_softap_initialize - * - * Description: - * Initialize the ESP32-S3 WLAN softAP netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef ESP32S3_WLAN_HAS_SOFTAP -int esp32s3_wlan_softap_initialize(void); -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ - -#endif /* CONFIG_ESP32S3_WIFI */ -#ifdef __cplusplus -} -#endif -#undef EXTERN - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_XTENSA_SRC_ESP32S3_ESP32S3_WLAN_H */ diff --git a/arch/xtensa/src/esp32s3/hal.mk b/arch/xtensa/src/esp32s3/hal.mk index 7c2bb45f68eed..17ff6c043ae7d 100644 --- a/arch/xtensa/src/esp32s3/hal.mk +++ b/arch/xtensa/src/esp32s3/hal.mk @@ -28,6 +28,7 @@ INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)$(CHIP_SERIES)$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)efuse$(DELIM)$(CHIP_SERIES)$(DELIM)private_include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_common$(DELIM)include +INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_event$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hw_support$(DELIM)include$(DELIM)esp_private From cf76d063e7444c7cf09f4d236a92a693d913373a Mon Sep 17 00:00:00 2001 From: Filipe Cavalcanti Date: Thu, 16 Jan 2025 15:07:41 -0300 Subject: [PATCH 2/4] boards/xtensa/esp32s3: update wireless symbols Update the wireless symbols from ESP32S3_* to ESPRESSIF_* for using common layer. --- .../esp32s3/common/include/esp32s3_board_wlan.h | 4 ++-- .../esp32s3/common/scripts/esp32s3_aliases.ld | 4 ++-- .../esp32s3/common/scripts/esp32s3_sections.ld | 2 +- .../esp32s3/common/scripts/legacy_sections.ld | 2 +- .../esp32s3/common/scripts/mcuboot_sections.ld | 2 +- boards/xtensa/esp32s3/common/src/Make.defs | 2 +- .../esp32s3/common/src/esp32s3_board_wlan.c | 15 +++++++-------- .../esp32s3/esp32s3-box/src/esp32s3_bringup.c | 14 +++++++------- .../esp32s3-devkit/configs/audio/defconfig | 2 +- .../esp32s3/esp32s3-devkit/configs/ble/defconfig | 2 +- .../esp32s3-devkit/configs/blewifi/defconfig | 6 +++--- .../esp32s3-devkit/configs/ksta_softap/defconfig | 4 ++-- .../esp32s3-devkit/configs/sta_softap/defconfig | 4 ++-- .../esp32s3-devkit/configs/toywasm/defconfig | 2 +- .../esp32s3-devkit/configs/wifi/defconfig | 2 +- .../esp32s3/esp32s3-devkit/src/esp32s3_bringup.c | 16 ++++++++-------- .../esp32s3/esp32s3-eye/configs/wifi/defconfig | 2 +- .../esp32s3/esp32s3-eye/src/esp32s3_bringup.c | 14 +++++++------- .../esp32s3-korvo-2/configs/audio/defconfig | 2 +- .../esp32s3-korvo-2/configs/rtptools/defconfig | 2 +- .../esp32s3-korvo-2/src/esp32s3_bringup.c | 14 +++++++------- .../esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c | 14 +++++++------- 22 files changed, 65 insertions(+), 66 deletions(-) diff --git a/boards/xtensa/esp32s3/common/include/esp32s3_board_wlan.h b/boards/xtensa/esp32s3/common/include/esp32s3_board_wlan.h index 057b85bcbd7ca..7dae2c36ce65a 100644 --- a/boards/xtensa/esp32s3/common/include/esp32s3_board_wlan.h +++ b/boards/xtensa/esp32s3/common/include/esp32s3_board_wlan.h @@ -48,7 +48,7 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI /**************************************************************************** * Name: board_wlan_init @@ -64,7 +64,7 @@ extern "C" int board_wlan_init(void); -#endif /* CONFIG_ESP32S3_WIFI */ +#endif /* CONFIG_ESPRESSIF_WIFI */ #undef EXTERN #if defined(__cplusplus) diff --git a/boards/xtensa/esp32s3/common/scripts/esp32s3_aliases.ld b/boards/xtensa/esp32s3/common/scripts/esp32s3_aliases.ld index e2e35ff08401a..cc74507fcc906 100644 --- a/boards/xtensa/esp32s3/common/scripts/esp32s3_aliases.ld +++ b/boards/xtensa/esp32s3/common/scripts/esp32s3_aliases.ld @@ -24,10 +24,10 @@ /* Bluetooth needs symbol alias, to be removed after IDF rename it */ -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE api_vhci_host_check_send_available = API_vhci_host_check_send_available; api_vhci_host_send_packet = API_vhci_host_send_packet; api_vhci_host_register_callback = API_vhci_host_register_callback; #endif -PROVIDE( cache_writeback_addr = Cache_WriteBack_Addr ); \ No newline at end of file +PROVIDE( cache_writeback_addr = Cache_WriteBack_Addr ); diff --git a/boards/xtensa/esp32s3/common/scripts/esp32s3_sections.ld b/boards/xtensa/esp32s3/common/scripts/esp32s3_sections.ld index e1b9066cc543b..b0d5edd15ca65 100644 --- a/boards/xtensa/esp32s3/common/scripts/esp32s3_sections.ld +++ b/boards/xtensa/esp32s3/common/scripts/esp32s3_sections.ld @@ -474,7 +474,7 @@ SECTIONS *libarch.a:*cache_hal.* *libarch.a:*mmu_hal.* *libarch.a:*mpu_hal.*) .rodata.*) -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS *(.rodata_wlog_verbose.*) *(.rodata_wlog_debug.*) *(.rodata_wlog_info.*) diff --git a/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld b/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld index 8f582331a023a..c9d0a08af37ef 100644 --- a/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld +++ b/boards/xtensa/esp32s3/common/scripts/legacy_sections.ld @@ -303,7 +303,7 @@ SECTIONS *(.rodata) *(.rodata.*) -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS *(.rodata_wlog_verbose.*) *(.rodata_wlog_debug.*) *(.rodata_wlog_info.*) diff --git a/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld b/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld index 5053b7fd5740e..4924fdec5b760 100644 --- a/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld +++ b/boards/xtensa/esp32s3/common/scripts/mcuboot_sections.ld @@ -79,7 +79,7 @@ SECTIONS *libarch.a:*cache_hal.* *libarch.a:*mmu_hal.* *libarch.a:*mpu_hal.*) .rodata.*) -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS *(.rodata_wlog_verbose.*) *(.rodata_wlog_debug.*) *(.rodata_wlog_info.*) diff --git a/boards/xtensa/esp32s3/common/src/Make.defs b/boards/xtensa/esp32s3/common/src/Make.defs index e17991dbea8bc..7ac84eed3eb69 100644 --- a/boards/xtensa/esp32s3/common/src/Make.defs +++ b/boards/xtensa/esp32s3/common/src/Make.defs @@ -38,7 +38,7 @@ ifeq ($(CONFIG_SPI_DRIVER),y) CSRCS += esp32s3_board_spidev.c endif -ifeq ($(CONFIG_ESP32S3_WIFI),y) +ifeq ($(CONFIG_ESPRESSIF_WIFI),y) CSRCS += esp32s3_board_wlan.c endif diff --git a/boards/xtensa/esp32s3/common/src/esp32s3_board_wlan.c b/boards/xtensa/esp32s3/common/src/esp32s3_board_wlan.c index 0659aa5d112be..5c5b6770fc217 100644 --- a/boards/xtensa/esp32s3/common/src/esp32s3_board_wlan.c +++ b/boards/xtensa/esp32s3/common/src/esp32s3_board_wlan.c @@ -36,7 +36,7 @@ #include #include "esp32s3_spiflash.h" -#include "esp32s3_wlan.h" +#include "espressif/esp_wlan.h" /**************************************************************************** * Public Functions @@ -61,24 +61,23 @@ int board_wlan_init(void) { int ret = OK; -#ifdef ESP32S3_WLAN_HAS_STA - ret = esp32s3_wlan_sta_initialize(); +#ifdef ESPRESSIF_WLAN_HAS_STA + ret = esp_wlan_sta_initialize(); if (ret) { wlerr("ERROR: Failed to initialize Wi-Fi station\n"); return ret; } -#endif /* ESP32S3_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32S3_WLAN_HAS_SOFTAP - ret = esp32s3_wlan_softap_initialize(); +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP + ret = esp_wlan_softap_initialize(); if (ret) { wlerr("ERROR: Failed to initialize Wi-Fi softAP\n"); return ret; } -#endif /* ESP32S3_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ return ret; } - diff --git a/boards/xtensa/esp32s3/esp32s3-box/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-box/src/esp32s3_bringup.c index 17581e3b82230..8d0d9179231d3 100644 --- a/boards/xtensa/esp32s3/esp32s3-box/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-box/src/esp32s3_bringup.c @@ -42,15 +42,15 @@ # include "esp32s3_board_tim.h" #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32s3_board_wlan.h" #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32s3_ble.h" #endif -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32s3_wifi_adapter.h" #endif @@ -193,9 +193,9 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32s3_wifi_bt_coexist_init(); if (ret) { @@ -203,7 +203,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32s3_ble_initialize(); if (ret) { @@ -211,7 +211,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/audio/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/audio/defconfig index cb8c46337e9dc..8187bedad6e77 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/audio/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/audio/defconfig @@ -47,7 +47,7 @@ CONFIG_ESP32S3_I2S=y CONFIG_ESP32S3_SPIFLASH=y CONFIG_ESP32S3_SPIFLASH_SPIFFS=y CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_RANDOM=y CONFIG_FS_PROCFS=y CONFIG_I2S_DMADESC_NUM=4 diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/ble/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/ble/defconfig index c5fa5b7a37b8d..b821ddd37921b 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/ble/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/ble/defconfig @@ -28,9 +28,9 @@ CONFIG_DEFAULT_TASK_STACKSIZE=4096 CONFIG_DRIVERS_BLUETOOTH=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y -CONFIG_ESP32S3_BLE=y CONFIG_ESP32S3_RT_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP32S3_UART0=y +CONFIG_ESPRESSIF_BLE=y CONFIG_FS_LARGEFILE=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/blewifi/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/blewifi/defconfig index 32040c7d9871e..e72013446f5b1 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/blewifi/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/blewifi/defconfig @@ -31,11 +31,11 @@ CONFIG_DEFAULT_TASK_STACKSIZE=4096 CONFIG_DRIVERS_BLUETOOTH=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y -CONFIG_ESP32S3_BLE=y CONFIG_ESP32S3_RT_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y -CONFIG_ESP32S3_WIFI_STATION_SOFTAP=y +CONFIG_ESPRESSIF_BLE=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP=y CONFIG_EXAMPLES_DHCPD=y CONFIG_EXAMPLES_RANDOM=y CONFIG_FS_LARGEFILE=y diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/ksta_softap/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/ksta_softap/defconfig index f28a50fbceadb..8a0ea03229a19 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/ksta_softap/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/ksta_softap/defconfig @@ -33,8 +33,8 @@ CONFIG_ESP32S3_SPIFLASH_SPIFFS=y CONFIG_ESP32S3_STORAGE_MTD_OFFSET=0x200000 CONFIG_ESP32S3_UART0=y CONFIG_ESP32S3_WCL=y -CONFIG_ESP32S3_WIFI=y -CONFIG_ESP32S3_WIFI_STATION_SOFTAP=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP=y CONFIG_EXAMPLES_DHCPD=y CONFIG_EXAMPLES_RANDOM=y CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/sta_softap/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/sta_softap/defconfig index 554b6d5031bd7..e362fbcc5ec87 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/sta_softap/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/sta_softap/defconfig @@ -31,8 +31,8 @@ CONFIG_ESP32S3_RT_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP32S3_SPIFLASH=y CONFIG_ESP32S3_SPIFLASH_SPIFFS=y CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y -CONFIG_ESP32S3_WIFI_STATION_SOFTAP=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP=y CONFIG_ESP_WPA_DEBUG_PRINT=y CONFIG_EXAMPLES_DHCPD=y CONFIG_EXAMPLES_RANDOM=y diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/toywasm/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/toywasm/defconfig index 2732517118320..30e019a935b93 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/toywasm/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/toywasm/defconfig @@ -31,7 +31,7 @@ CONFIG_ESP32S3_SPIRAM_MODE_OCT=y CONFIG_ESP32S3_SPI_FLASH_SUPPORT_PSRAM_STACK=y CONFIG_ESP32S3_STORAGE_MTD_SIZE=0x1e80000 CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_RANDOM=y CONFIG_FS_LARGEFILE=y CONFIG_FS_LITTLEFS=y diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/configs/wifi/defconfig b/boards/xtensa/esp32s3/esp32s3-devkit/configs/wifi/defconfig index cb7bec786f405..8d2a790dfa7e4 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/configs/wifi/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-devkit/configs/wifi/defconfig @@ -29,7 +29,7 @@ CONFIG_ESP32S3_RT_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP32S3_SPIFLASH=y CONFIG_ESP32S3_SPIFLASH_SPIFFS=y CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_RANDOM=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c index 13ecad5863d05..a84a675d2b0aa 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-devkit/src/esp32s3_bringup.c @@ -44,15 +44,15 @@ # include "esp32s3_board_tim.h" #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32s3_board_wlan.h" #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32s3_ble.h" #endif -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32s3_wifi_adapter.h" #endif @@ -429,17 +429,17 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST - ret = esp32s3_wifi_bt_coexist_init(); +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST + ret = esp_wifi_bt_coexist_init(); if (ret) { syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi and BT coexist\n"); } #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32s3_ble_initialize(); if (ret) { @@ -447,7 +447,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32s3/esp32s3-eye/configs/wifi/defconfig b/boards/xtensa/esp32s3/esp32s3-eye/configs/wifi/defconfig index 6ca378e3023a8..e01041fd13ed2 100644 --- a/boards/xtensa/esp32s3/esp32s3-eye/configs/wifi/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-eye/configs/wifi/defconfig @@ -29,7 +29,7 @@ CONFIG_ESP32S3_RT_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP32S3_SPIRAM=y CONFIG_ESP32S3_SPIRAM_MODE_OCT=y CONFIG_ESP32S3_USBSERIAL=y -CONFIG_ESP32S3_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_RANDOM=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 diff --git a/boards/xtensa/esp32s3/esp32s3-eye/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-eye/src/esp32s3_bringup.c index 93aaa33fbe852..2b0a2a4dadc67 100644 --- a/boards/xtensa/esp32s3/esp32s3-eye/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-eye/src/esp32s3_bringup.c @@ -42,15 +42,15 @@ # include "esp32s3_board_tim.h" #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32s3_board_wlan.h" #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32s3_ble.h" #endif -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32s3_wifi_adapter.h" #endif @@ -184,9 +184,9 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32s3_wifi_bt_coexist_init(); if (ret) { @@ -194,7 +194,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32s3_ble_initialize(); if (ret) { @@ -202,7 +202,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/audio/defconfig b/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/audio/defconfig index bce2a5ea5daa4..5a39f01b5caa6 100644 --- a/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/audio/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/audio/defconfig @@ -52,7 +52,7 @@ CONFIG_ESP32S3_SPIFLASH_SPIFFS=y CONFIG_ESP32S3_SPIRAM=y CONFIG_ESP32S3_SPIRAM_MODE_OCT=y CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/rtptools/defconfig b/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/rtptools/defconfig index daa79a3f6db03..9f549da732b48 100644 --- a/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/rtptools/defconfig +++ b/boards/xtensa/esp32s3/esp32s3-korvo-2/configs/rtptools/defconfig @@ -53,7 +53,7 @@ CONFIG_ESP32S3_SPIFLASH_SPIFFS=y CONFIG_ESP32S3_SPIRAM=y CONFIG_ESP32S3_SPIRAM_MODE_OCT=y CONFIG_ESP32S3_UART0=y -CONFIG_ESP32S3_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32s3/esp32s3-korvo-2/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-korvo-2/src/esp32s3_bringup.c index 74d06fc1e2c75..069b89bfd8971 100644 --- a/boards/xtensa/esp32s3/esp32s3-korvo-2/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-korvo-2/src/esp32s3_bringup.c @@ -45,15 +45,15 @@ # include "esp32s3_board_tim.h" #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32s3_board_wlan.h" #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32s3_ble.h" #endif -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32s3_wifi_adapter.h" #endif @@ -377,9 +377,9 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32s3_wifi_bt_coexist_init(); if (ret) { @@ -387,7 +387,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32s3_ble_initialize(); if (ret) { @@ -395,7 +395,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c index cf9a4573a08a2..c2e2e683bd1d7 100644 --- a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c @@ -42,15 +42,15 @@ # include "esp32s3_board_tim.h" #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32s3_board_wlan.h" #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32s3_ble.h" #endif -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32s3_wifi_adapter.h" #endif @@ -188,9 +188,9 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS -#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32s3_wifi_bt_coexist_init(); if (ret) { @@ -198,7 +198,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32s3_ble_initialize(); if (ret) { @@ -206,7 +206,7 @@ int esp32s3_bringup(void) } #endif -#ifdef CONFIG_ESP32S3_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { From 35156b853d0a44ec4b79d14b5363139fb8f15582 Mon Sep 17 00:00:00 2001 From: Filipe Cavalcanti Date: Mon, 20 Jan 2025 13:44:30 -0300 Subject: [PATCH 3/4] arch/xtensa/esp32: use common wireless source Remove ESP32 specific WiFi files and edit build system to use common layer. --- arch/xtensa/src/common/espressif/Kconfig | 15 +- arch/xtensa/src/common/espressif/Wireless.mk | 20 +- .../src/common/espressif/esp_wifi_utils.c | 3 + .../src/common/espressif/esp_wireless.c | 5 +- arch/xtensa/src/common/espressif/esp_wlan.c | 78 + arch/xtensa/src/common/espressif/esp_wlan.h | 3 + arch/xtensa/src/esp32/Kconfig | 172 +- arch/xtensa/src/esp32/Make.defs | 15 +- arch/xtensa/src/esp32/Wireless.mk | 255 --- arch/xtensa/src/esp32/esp32_allocateheap.c | 2 +- arch/xtensa/src/esp32/esp32_ble_adapter.c | 46 +- arch/xtensa/src/esp32/esp32_irq.c | 12 +- arch/xtensa/src/esp32/esp32_wifi_adapter.c | 168 +- arch/xtensa/src/esp32/esp32_wifi_adapter.h | 38 +- arch/xtensa/src/esp32/esp32_wifi_utils.c | 573 ----- arch/xtensa/src/esp32/esp32_wifi_utils.h | 104 - arch/xtensa/src/esp32/esp32_wireless.c | 1468 ------------- arch/xtensa/src/esp32/esp32_wireless.h | 376 ---- arch/xtensa/src/esp32/esp32_wlan.c | 1845 ----------------- arch/xtensa/src/esp32/esp32_wlan.h | 125 -- 20 files changed, 264 insertions(+), 5059 deletions(-) delete mode 100644 arch/xtensa/src/esp32/Wireless.mk delete mode 100644 arch/xtensa/src/esp32/esp32_wifi_utils.c delete mode 100644 arch/xtensa/src/esp32/esp32_wifi_utils.h delete mode 100644 arch/xtensa/src/esp32/esp32_wireless.c delete mode 100644 arch/xtensa/src/esp32/esp32_wireless.h delete mode 100644 arch/xtensa/src/esp32/esp32_wlan.c delete mode 100644 arch/xtensa/src/esp32/esp32_wlan.h diff --git a/arch/xtensa/src/common/espressif/Kconfig b/arch/xtensa/src/common/espressif/Kconfig index 3a2f5b8b883dc..4ee5ab0ab31a3 100644 --- a/arch/xtensa/src/common/espressif/Kconfig +++ b/arch/xtensa/src/common/espressif/Kconfig @@ -516,7 +516,9 @@ config ESPRESSIF_WIRELESS select ESP32S3_RNG if ARCH_CHIP_ESP32S3 select ESP32S3_RT_TIMER if ARCH_CHIP_ESP32S3 select ESP32S3_TIMER0 if ARCH_CHIP_ESP32S3 - depends on ARCH_CHIP_ESP32S2 || ARCH_CHIP_ESP32S3 + select ESP32_RNG if ARCH_CHIP_ESP32 + select ESP32_RT_TIMER if ARCH_CHIP_ESP32 + select ESP32_TIMER0 if ARCH_CHIP_ESP32 ---help--- Enable Wireless support @@ -529,9 +531,11 @@ config ESPRESSIF_WIFI config ESPRESSIF_BLE bool "BLE" - depends on ARCH_CHIP_ESP32S3 + depends on ARCH_CHIP_ESP32S3 || ARCH_CHIP_ESP32 default n select ESPRESSIF_WIRELESS + select BLUETOOTH_TXCMD_PINNED_TO_CORE if SMP && ARCH_CHIP_ESP32 + select BLUETOOTH_CNTRL_HOST_FLOW_DISABLE if ARCH_CHIP_ESP32 ---help--- Enable BLE support. @@ -720,6 +724,13 @@ config ESPRESSIF_WIFI_LISTEN_INTERVAL For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen to beacon is 300 ms. +config ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION + bool "Enable optimization of WLAN driver buffer" + default n + depends on ARCH_CHIP_ESP32 + ---help--- + Enable optimization of WLAN memory + endmenu # ESPRESSIF_WIFI menu "BLE Configuration" diff --git a/arch/xtensa/src/common/espressif/Wireless.mk b/arch/xtensa/src/common/espressif/Wireless.mk index 78fd547102a06..12d45740e9062 100644 --- a/arch/xtensa/src/common/espressif/Wireless.mk +++ b/arch/xtensa/src/common/espressif/Wireless.mk @@ -20,18 +20,36 @@ # ############################################################################ +ifeq ($(CONFIG_ARCH_CHIP_ESP32),y) +INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)include$(DELIM)$(CHIP_SERIES)$(DELIM)include +endif +ifeq ($(CONFIG_ARCH_CHIP_ESP32S3),y) INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)include$(DELIM)esp32c3$(DELIM)include +endif INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)soc$(DELIM)$(CHIP_SERIES)$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)$(CHIP_SERIES)$(DELIM)include INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)esp_wifi +ifeq ($(CONFIG_ARCH_CHIP_ESP32),y) +EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32$(DELIM)$(CHIP_SERIES) +endif +ifeq ($(CONFIG_ARCH_CHIP_ESP32S3),y) EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32c3_family$(DELIM)$(CHIP_SERIES) +endif EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)lib$(DELIM)$(CHIP_SERIES) EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)lib$(DELIM)$(CHIP_SERIES) EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)lib$(DELIM)$(CHIP_SERIES) -EXTRA_LIBS += -lphy -lcoexist +ifeq ($(CONFIG_ARCH_CHIP_ESP32),y) +EXTRA_LIBS += -lrtc +endif + +ifneq ($(CONFIG_ARCH_CHIP_ESP32S2),y) +EXTRA_LIBS += -lcoexist +endif + +EXTRA_LIBS += -lphy ifeq ($(CONFIG_ESPRESSIF_WIFI),y) EXTRA_LIBS += -lcore -lnet80211 -lpp diff --git a/arch/xtensa/src/common/espressif/esp_wifi_utils.c b/arch/xtensa/src/common/espressif/esp_wifi_utils.c index 248764ff3ab76..d5e18670c4846 100644 --- a/arch/xtensa/src/common/espressif/esp_wifi_utils.c +++ b/arch/xtensa/src/common/espressif/esp_wifi_utils.c @@ -34,6 +34,9 @@ #include #include +#ifdef CONFIG_ARCH_CHIP_ESP32 +#include "esp32_wifi_adapter.h" +#endif #ifdef CONFIG_ARCH_CHIP_ESP32S2 #include "esp32s2_wifi_adapter.h" #endif diff --git a/arch/xtensa/src/common/espressif/esp_wireless.c b/arch/xtensa/src/common/espressif/esp_wireless.c index 1438037e5c907..24f1ee7e74769 100644 --- a/arch/xtensa/src/common/espressif/esp_wireless.c +++ b/arch/xtensa/src/common/espressif/esp_wireless.c @@ -132,7 +132,7 @@ struct esp_wireless_priv_s static inline void phy_digital_regs_store(void); static inline void phy_digital_regs_load(void); static int esp_swi_irq(int irq, void *context, void *arg); -#ifdef CONFIG_ESP32_WIFI +# if defined(CONFIG_ARCH_CHIP_ESP32) && defined(CONFIG_ESPRESSIF_WIFI) static void esp_wifi_set_log_level(void); #endif @@ -1516,8 +1516,7 @@ int32_t esp_wifi_init(const wifi_init_config_t *config) esp_wifi_set_sleep_wait_broadcast_data_time(wait_broadcast_data_time_us); #endif -#if defined(CONFIG_ESP32S3_WIFI_BT_COEXIST) || \ - defined(CONFIG_ESP32_WIFI_BT_COEXIST) +#if defined(CONFIG_ESPRESSIF_WIFI_BT_COEXIST) ret = coex_init(); if (ret) { diff --git a/arch/xtensa/src/common/espressif/esp_wlan.c b/arch/xtensa/src/common/espressif/esp_wlan.c index 4ec4a2df90575..61d4d0b19eb72 100644 --- a/arch/xtensa/src/common/espressif/esp_wlan.c +++ b/arch/xtensa/src/common/espressif/esp_wlan.c @@ -178,7 +178,11 @@ struct wlan_priv_s /* Packet buffer cache */ +#ifdef CONFIG_ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION + struct wlan_pktbuf *pktbuf; +#else struct wlan_pktbuf pktbuf[WLAN_PKTBUF_NUM]; +#endif /* RX packet queue */ @@ -292,6 +296,9 @@ static int wlan_ioctl(struct net_driver_s *dev, int cmd, unsigned long arg); #endif +static inline void wlan_free_buffer(struct wlan_priv_s *priv, + uint8_t *buffer); + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -324,6 +331,17 @@ static inline void wlan_init_buffer(struct wlan_priv_s *priv) { irqstate_t flags; +#ifdef CONFIG_ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION + flags = spin_lock_irqsave(&priv->lock); + + priv->dev.d_buf = NULL; + priv->dev.d_len = 0; + + sq_init(&priv->rxb); + sq_init(&priv->txb); + + spin_unlock_irqrestore(&priv->lock, flags); +#else int i; flags = spin_lock_irqsave(&priv->lock); @@ -340,6 +358,40 @@ static inline void wlan_init_buffer(struct wlan_priv_s *priv) } spin_unlock_irqrestore(&priv->lock, flags); +#endif +} + +/**************************************************************************** + * Function: wlan_deinit_buffer + * + * Description: + * De-initialize the buffer list + * + * Input Parameters: + * priv - Reference to the driver state structure + * + * Returned Value: + * None. + * + ****************************************************************************/ + +static inline void wlan_deinit_buffer(struct wlan_priv_s *priv) +{ +#ifdef CONFIG_ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION + struct wlan_pktbuf *pktbuf; + while ((pktbuf = (struct wlan_pktbuf *)wlan_recvframe(priv)) != NULL) + { + wlan_free_buffer(priv, (void *)pktbuf->buffer); + } + + while ((pktbuf = (struct wlan_pktbuf *)wlan_txframe(priv)) != NULL) + { + wlan_free_buffer(priv, (void *)pktbuf->buffer); + } + + sq_init(&priv->rxb); + sq_init(&priv->txb); +#endif } /**************************************************************************** @@ -360,6 +412,15 @@ static inline struct wlan_pktbuf *wlan_alloc_buffer(struct wlan_priv_s *priv) { struct wlan_pktbuf *pktbuf = NULL; +#ifdef CONFIG_ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION + struct mallinfo info = kmm_mallinfo(); + if (info.fordblks < MINIMUM_HEAP_SIZE) + { + return NULL; + } + + pktbuf = kmm_malloc(sizeof(struct wlan_pktbuf) + WLAN_BUF_SIZE); +#else sq_entry_t *entry; irqstate_t flags = spin_lock_irqsave(&priv->lock); @@ -371,6 +432,7 @@ static inline struct wlan_pktbuf *wlan_alloc_buffer(struct wlan_priv_s *priv) spin_unlock_irqrestore(&priv->lock, flags); +#endif return pktbuf; } @@ -394,12 +456,17 @@ static inline void wlan_free_buffer(struct wlan_priv_s *priv, { struct wlan_pktbuf *pktbuf; +#ifdef CONFIG_ESPRESSIF_WIFI_WLAN_BUFFER_OPTIMIZATION + pktbuf = container_of(buffer, struct wlan_pktbuf, buffer); + kmm_free(pktbuf); +#else irqstate_t flags = spin_lock_irqsave(&priv->lock); pktbuf = container_of(buffer, struct wlan_pktbuf, buffer); sq_addlast(&pktbuf->entry, &priv->freeb); spin_unlock_irqrestore(&priv->lock, flags); +#endif } /**************************************************************************** @@ -1098,6 +1165,9 @@ static int wlan_ifup(struct net_driver_s *dev) ret = priv->ops->start(); if (ret < 0) { +#ifdef CONFIG_ARCH_CHIP_ESP32 + wlan_deinit_buffer(priv); +#endif net_unlock(); nerr("ERROR: Failed to start Wi-Fi ret=%d\n", ret); return ret; @@ -1114,6 +1184,14 @@ static int wlan_ifup(struct net_driver_s *dev) } ++g_callback_register_ref; + +#ifdef CONFIG_ARCH_CHIP_ESP32 + /* We can make sure that the WLAN TX and RX are not doing, because + * the process is in "net_lock()" + */ + + wlan_deinit_buffer(priv); +#endif net_unlock(); return OK; diff --git a/arch/xtensa/src/common/espressif/esp_wlan.h b/arch/xtensa/src/common/espressif/esp_wlan.h index a0426ff24e87b..30b29efe0b151 100644 --- a/arch/xtensa/src/common/espressif/esp_wlan.h +++ b/arch/xtensa/src/common/espressif/esp_wlan.h @@ -29,6 +29,9 @@ #include +#ifdef CONFIG_ARCH_CHIP_ESP32 +# include "esp32_wifi_adapter.h" +#endif #ifdef CONFIG_ARCH_CHIP_ESP32S2 # include "esp32s2_wifi_adapter.h" #endif diff --git a/arch/xtensa/src/esp32/Kconfig b/arch/xtensa/src/esp32/Kconfig index 232fa70b95f2b..2e5be61168b01 100644 --- a/arch/xtensa/src/esp32/Kconfig +++ b/arch/xtensa/src/esp32/Kconfig @@ -734,33 +734,6 @@ config ESP32_UART2 select UART2_SERIALDRIVER select ARCH_HAVE_SERIAL_TERMIOS -config ESP32_WIRELESS - bool - default n - select NET - select ARCH_PHY_INTERRUPT - select ESP32_RNG - select ESP32_RT_TIMER - select ESP32_TIMER0 - ---help--- - Enable Wireless support - -config ESP32_WIFI - bool "Wi-Fi" - default n - select ESP32_WIRELESS - ---help--- - Enable Wi-Fi support - -config ESP32_BLE - bool "BLE" - default n - select ESP32_WIRELESS - select BLUETOOTH_TXCMD_PINNED_TO_CORE if SMP - select BLUETOOTH_CNTRL_HOST_FLOW_DISABLE - ---help--- - Enable BLE support - config ESP32_I2C0 bool "I2C 0" default n @@ -792,13 +765,6 @@ config ESP32_PID endmenu # ESP32 Peripheral Selection -config ESP32_WIFI_BT_COEXIST - bool "Wi-Fi and BT coexist" - default y if ESP32_WIFI && ESP32_BLE - default n - depends on ESP32_WIFI && ESP32_BLE - select ESP32_WIFI_STA_DISCONNECT_PM - menu "Interrupt Configuration" config ESP32_IRAM_ISR_DEBUG @@ -816,8 +782,8 @@ menu "Memory Configuration" config ESP32_BT_RESERVE_DRAM int "Reserved BT DRAM" - default 0 if !ESP32_BLE - default 65536 if ESP32_BLE + default 0 if !ESPRESSIF_BLE + default 65536 if ESPRESSIF_BLE config ESP32_TRACEMEM_RESERVE_DRAM int "Reserved trace memory DRAM" @@ -2074,142 +2040,10 @@ config ESP32_ETH_PHY_ADDR endmenu # ESP32_EMAC -menu "Wi-Fi Configuration" - depends on ESP32_WIFI - -choice - prompt "ESP32 Wi-Fi mode" - default ESP32_WIFI_STATION - -config ESP32_WIFI_STATION - bool "Station mode" - -config ESP32_WIFI_SOFTAP - bool "SoftAP mode" - -config ESP32_WIFI_STATION_SOFTAP - bool "Station + SoftAP" - -endchoice # ESP32 Wi-Fi mode - -config ESP32_WIFI_STATIC_RXBUF_NUM - int "Wi-Fi static RX buffer number" - default 10 - -config ESP32_WIFI_DYNAMIC_RXBUF_NUM - int "Wi-Fi dynamic RX buffer number" - default 32 - -config ESP32_WIFI_DYNAMIC_TXBUF_NUM - int "Wi-Fi dynamic TX buffer number" - default 32 - -config ESP32_WIFI_TX_AMPDU - bool "Wi-Fi TX AMPDU" - default y - -config ESP32_WIFI_RX_AMPDU - bool "Wi-Fi RX AMPDU" - default y - -config ESP32_WIFI_RXBA_AMPDU_WZ - int "Wi-Fi RX BA AMPDU windown size" - default 6 - -config ESP32_WLAN_PKTBUF_NUM - int "WLAN netcard packet buffer number per netcard" - default 16 - -config ESP32_WIFI_CONNECT_TIMEOUT - int "Connect timeout by second" - default 10 - ---help--- - Max waiting time of connecting to AP. - -config ESP32_WIFI_SCAN_RESULT_SIZE - int "Scan result buffer" - default 4096 - ---help--- - Maximum scan result buffer size. - -config ESP32_WIFI_STA_DISCONNECT_PM - bool "Power Management for station when disconnected" - default n - ---help--- - Select this option to enable power management for station when disconnected. - Chip will do modem-sleep when RF module is not in use anymore. - -config EXAMPLE_WIFI_LISTEN_INTERVAL - int "Wi-Fi listen interval" - default 3 - ---help--- - Interval for station to listen to beacon from AP. The unit of listen interval is one beacon interval. - For example, if beacon interval is 100 ms and listen interval is 3, the interval for station to listen - to beacon is 300 ms. - -choice EXAMPLE_POWER_SAVE_MODE - prompt "Power save mode" - default EXAMPLE_POWER_SAVE_NONE - ---help--- - Power save mode for the esp32 to use. Modem sleep mode includes minimum and maximum power save modes. - In minimum power save mode, station wakes up every DTIM to receive beacon. Broadcast data will not be - lost because it is transmitted after DTIM. However, it can not save much more power if DTIM is short - for DTIM is determined by AP. - In maximum power save mode, station wakes up every listen interval to receive beacon. Broadcast data - may be lost because station may be in sleep state at DTIM time. If listen interval is longer, more power - is saved but broadcast data is more easy to lose. - -config EXAMPLE_POWER_SAVE_NONE - bool "none" - -config EXAMPLE_POWER_SAVE_MIN_MODEM - bool "minimum modem" - -config EXAMPLE_POWER_SAVE_MAX_MODEM - bool "maximum modem" - -endchoice # EXAMPLE_POWER_SAVE_MODE - -config ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - bool "Enable optimization of WLAN driver buffer" - default n - ---help--- - Enable optimization of WLAN memory - -endmenu # ESP32_WIFI - -menu "BLE Configuration" - depends on ESP32_BLE - -config ESP32_BLE_PKTBUF_NUM - int "BLE netcard packet buffer number per netcard" - default 16 - -config ESP32_BLE_TASK_STACK_SIZE - int "Controller task stack size" - default 4096 - -config ESP32_BLE_TASK_PRIORITY - int "Controller task priority" - default 110 - -config ESP32_BLE_INTERRUPT_SAVE_STATUS - int "Number of interrupt save status" - default 3 - ---help--- - Number of interrupt save status variables to keep track. Increase it if any related bug is found. - -config ESP32_BLE_MAX_CONN - int "Maximum BLE simultaneous connections" - range 1 3 - default 1 - -endmenu # BLE Configuration - choice ESP32_UNIVERSAL_MAC_ADDRESSES bool "Number of universally administered (by IEEE) MAC addresses" default ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR - depends on ESP32_WIFI || ESP32_BLE + depends on ESPRESSIF_WIFI || ESPRESSIF_BLE ---help--- Configure the number of universally administered (by IEEE) MAC addresses. During initialization, MAC addresses for each network interface are generated or derived from a diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index 7e0fd3b9e7846..4a9a6919410f0 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -206,6 +206,15 @@ ifeq ($(CONFIG_ESP32_OPENETH),y) CHIP_CSRCS += esp_openeth.c endif +ifeq ($(CONFIG_ESPRESSIF_WIFI),y) +CHIP_CSRCS += esp32_wifi_adapter.c +endif + +ifeq ($(CONFIG_ESPRESSIF_BLE),y) +CHIP_CSRCS += esp32_ble_adapter.c esp32_ble.c +EXTRA_LIBS += -lbtdm_app +endif + ############################################################################# # Espressif HAL for 3rd Party Platforms ############################################################################# @@ -264,7 +273,7 @@ include chip/hal.mk include common/espressif/Make.defs context:: chip/$(ESP_HAL_3RDPARTY_REPO) -ifeq ($(CONFIG_ESP32_WIRELESS),y) +ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y) $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing submodules..." $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update --init $(GIT_DEPTH_PARAMETER) components/mbedtls/mbedtls components/esp_phy/lib components/esp_wifi/lib components/bt/controller/lib_esp32 components/esp_coex/lib $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls reset --quiet --hard @@ -272,10 +281,6 @@ ifeq ($(CONFIG_ESP32_WIRELESS),y) $(Q) cd chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls && git apply ../../../nuttx/patches/components/mbedtls/mbedtls/*.patch endif -ifeq ($(CONFIG_ESP32_WIRELESS),y) -include chip/Wireless.mk -endif - distclean:: $(call DELDIR,chip/$(ESP_HAL_3RDPARTY_REPO)) diff --git a/arch/xtensa/src/esp32/Wireless.mk b/arch/xtensa/src/esp32/Wireless.mk deleted file mode 100644 index 127d82a149a1f..0000000000000 --- a/arch/xtensa/src/esp32/Wireless.mk +++ /dev/null @@ -1,255 +0,0 @@ -############################################################################ -# arch/xtensa/src/esp32/Wireless.mk -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################ - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)include$(DELIM)$(CHIP_SERIES)$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)$(CHIP_SERIES)$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)esp_wifi - -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32$(DELIM)$(CHIP_SERIES) -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)lib$(DELIM)$(CHIP_SERIES) -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)lib$(DELIM)$(CHIP_SERIES) -EXTRA_LIBPATHS += -L $(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)lib$(DELIM)$(CHIP_SERIES) - -EXTRA_LIBS += -lrtc -lphy -lcoexist - -# Wireless interfaces. - -CHIP_CSRCS += esp32_wireless.c - -ifeq ($(CONFIG_ESP32_BLE),y) -CHIP_CSRCS += esp32_ble_adapter.c esp32_ble.c -EXTRA_LIBS += -lbtdm_app -endif - -ifeq ($(CONFIG_ESP32_WIFI),y) -CHIP_CSRCS += esp32_wlan.c esp32_wifi_utils.c esp32_wifi_adapter.c -EXTRA_LIBS += -lcore -lnet80211 -lpp - -ifeq ($(CONFIG_WPA_WAPI_PSK),y) -EXTRA_LIBS += -lwapi -endif - -## ESP-IDF's mbedTLS - -VPATH += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)mbedtls$(DELIM)library - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)mbedtls$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)mbedtls$(DELIM)library -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)port$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)mbedtls - -### Define Espressif's configs for mbedTLS - -CFLAGS += $(DEFINE_PREFIX)MBEDTLS_CONFIG_FILE="" - -CHIP_CSRCS += aes.c -CHIP_CSRCS += aria.c -CHIP_CSRCS += bignum_core.c -CHIP_CSRCS += bignum.c -CHIP_CSRCS += ccm.c -CHIP_CSRCS += cipher_wrap.c -CHIP_CSRCS += cipher.c -CHIP_CSRCS += cmac.c -CHIP_CSRCS += constant_time.c -CHIP_CSRCS += ctr_drbg.c -CHIP_CSRCS += ecp_curves.c -CHIP_CSRCS += ecp.c -CHIP_CSRCS += entropy.c -CHIP_CSRCS += gcm.c -CHIP_CSRCS += md.c -CHIP_CSRCS += pkcs5.c -CHIP_CSRCS += platform_util.c -CHIP_CSRCS += platform.c -CHIP_CSRCS += sha1.c -CHIP_CSRCS += sha3.c -CHIP_CSRCS += sha256.c -CHIP_CSRCS += sha512.c -CHIP_CSRCS += pk.c -CHIP_CSRCS += pk_wrap.c -CHIP_CSRCS += pkparse.c -CHIP_CSRCS += ecdsa.c -CHIP_CSRCS += asn1parse.c -CHIP_CSRCS += asn1write.c -CHIP_CSRCS += rsa.c -CHIP_CSRCS += md5.c -CHIP_CSRCS += oid.c -CHIP_CSRCS += pem.c -CHIP_CSRCS += hmac_drbg.c -CHIP_CSRCS += rsa_alt_helpers.c -CHIP_CSRCS += ecdh.c -CHIP_CSRCS += pk_ecc.c - -VPATH += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)port - -CHIP_CSRCS += esp_hardware.c -CHIP_CSRCS += esp_mem.c -CHIP_CSRCS += esp_timing.c - -VPATH += chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)mbedtls$(DELIM)port$(DELIM)md - -CHIP_CSRCS += esp_md.c - -## WPA Supplicant - -WIFI_WPA_SUPPLICANT = chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)wpa_supplicant - -CFLAGS += $(DEFINE_PREFIX)__ets__ -CFLAGS += $(DEFINE_PREFIX)CONFIG_CRYPTO_MBEDTLS -CFLAGS += $(DEFINE_PREFIX)CONFIG_ECC -CFLAGS += $(DEFINE_PREFIX)CONFIG_IEEE80211W -CFLAGS += $(DEFINE_PREFIX)CONFIG_WPA3_SAE -CFLAGS += $(DEFINE_PREFIX)EAP_PEER_METHOD -CFLAGS += $(DEFINE_PREFIX)ESP_PLATFORM=1 -CFLAGS += $(DEFINE_PREFIX)ESP_SUPPLICANT -CFLAGS += $(DEFINE_PREFIX)ESPRESSIF_USE -CFLAGS += $(DEFINE_PREFIX)IEEE8021X_EAPOL -CFLAGS += $(DEFINE_PREFIX)USE_WPA2_TASK -CFLAGS += $(DEFINE_PREFIX)CONFIG_SHA256 -CFLAGS += $(DEFINE_PREFIX)CONFIG_SAE -CFLAGS += $(DEFINE_PREFIX)USE_WPS_TASK - -ifeq ($(CONFIG_ESP_WIFI_ENABLE_SAE_PK),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_SAE_PK -endif - -ifeq ($(CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_OWE_STA -endif - -ifeq ($(CONFIG_ESP_WIFI_GCMP_SUPPORT),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_GCMP -endif - -ifeq ($(CONFIG_ESP_WIFI_GMAC_SUPPORT),y) -CFLAGS += $(DEFINE_PREFIX)CONFIG_GMAC -endif - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)include -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)ap - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)ap - -CHIP_CSRCS += ap_config.c -CHIP_CSRCS += ieee802_11.c -CHIP_CSRCS += comeback_token.c -CHIP_CSRCS += pmksa_cache_auth.c -CHIP_CSRCS += sta_info.c -CHIP_CSRCS += wpa_auth_ie.c -CHIP_CSRCS += wpa_auth.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)common - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)common - -CHIP_CSRCS += dragonfly.c -CHIP_CSRCS += sae.c -CHIP_CSRCS += wpa_common.c -CHIP_CSRCS += sae_pk.c -CHIP_CSRCS += bss.c -CHIP_CSRCS += scan.c -CHIP_CSRCS += ieee802_11_common.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)crypto - -CHIP_CSRCS += aes-ccm.c -CHIP_CSRCS += aes-gcm.c -CHIP_CSRCS += aes-omac1.c -CHIP_CSRCS += aes-unwrap.c -CHIP_CSRCS += aes-wrap.c -CHIP_CSRCS += ccmp.c -CHIP_CSRCS += crypto_ops.c -CHIP_CSRCS += des-internal.c -CHIP_CSRCS += dh_groups.c -CHIP_CSRCS += rc4.c -CHIP_CSRCS += sha1-prf.c -CHIP_CSRCS += sha256-kdf.c -CHIP_CSRCS += sha256-prf.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)eap_peer - -CHIP_CSRCS += chap.c -CHIP_CSRCS += eap_common.c -CHIP_CSRCS += eap_mschapv2.c -CHIP_CSRCS += eap_peap_common.c -CHIP_CSRCS += eap_peap.c -CHIP_CSRCS += eap_tls_common.c -CHIP_CSRCS += eap_tls.c -CHIP_CSRCS += eap_ttls.c -CHIP_CSRCS += eap.c -CHIP_CSRCS += mschapv2.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)rsn_supp - -CHIP_CSRCS += pmksa_cache.c -CHIP_CSRCS += wpa_ie.c -CHIP_CSRCS += wpa.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)utils - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)utils - -CHIP_CSRCS += base64.c -CHIP_CSRCS += bitfield.c -CHIP_CSRCS += common.c -CHIP_CSRCS += ext_password.c -CHIP_CSRCS += json.c -CHIP_CSRCS += uuid.c -CHIP_CSRCS += wpa_debug.c -CHIP_CSRCS += wpabuf.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)port - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)port$(DELIM)include - -CHIP_CSRCS += eloop.c -CHIP_CSRCS += os_xtensa.c - -## ESP Supplicant (Espressif's WPA supplicant extension) - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)include - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)src - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)src - -CHIP_CSRCS += esp_common.c -CHIP_CSRCS += esp_hostap.c -CHIP_CSRCS += esp_wpa_main.c -CHIP_CSRCS += esp_wpa3.c -CHIP_CSRCS += esp_wpas_glue.c -CHIP_CSRCS += esp_owe.c -CHIP_CSRCS += esp_scan.c -CHIP_CSRCS += esp_wps.c - -VPATH += $(WIFI_WPA_SUPPLICANT)$(DELIM)esp_supplicant$(DELIM)src$(DELIM)crypto - -INCLUDES += $(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)$(WIFI_WPA_SUPPLICANT)$(DELIM)src$(DELIM)crypto - -CHIP_CSRCS += crypto_mbedtls-bignum.c -CHIP_CSRCS += crypto_mbedtls-ec.c -CHIP_CSRCS += crypto_mbedtls-rsa.c -CHIP_CSRCS += crypto_mbedtls.c -CHIP_CSRCS += tls_mbedtls.c -CHIP_CSRCS += aes-siv.c - -endif diff --git a/arch/xtensa/src/esp32/esp32_allocateheap.c b/arch/xtensa/src/esp32/esp32_allocateheap.c index 7db30f3de72bd..d67e573d94ca8 100644 --- a/arch/xtensa/src/esp32/esp32_allocateheap.c +++ b/arch/xtensa/src/esp32/esp32_allocateheap.c @@ -236,7 +236,7 @@ void xtensa_add_region(void) MM_ADDREGION(start, size); #endif -#ifndef CONFIG_ESP32_BLE +#ifndef CONFIG_ESPRESSIF_BLE start = (void *)HEAP_REGION0_START; size = (size_t)(HEAP_REGION0_END - HEAP_REGION0_START); MM_ADDREGION(start, size); diff --git a/arch/xtensa/src/esp32/esp32_ble_adapter.c b/arch/xtensa/src/esp32/esp32_ble_adapter.c index c6122c3ce87a5..6388fee1e8aa0 100644 --- a/arch/xtensa/src/esp32/esp32_ble_adapter.c +++ b/arch/xtensa/src/esp32/esp32_ble_adapter.c @@ -55,7 +55,7 @@ #include "xtensa_attr.h" #include "utils/memory_reserve.h" #include "esp32_rt_timer.h" -#include "esp32_wireless.h" +#include "espressif/esp_wireless.h" #include "esp32_irq.h" #include "esp32_spicache.h" @@ -127,8 +127,8 @@ # define BLE_TASK_EVENT_QUEUE_LEN 8 #endif -#ifdef CONFIG_ESP32_BLE_INTERRUPT_SAVE_STATUS -# define NR_IRQSTATE_FLAGS CONFIG_ESP32_BLE_INTERRUPT_SAVE_STATUS +#ifdef CONFIG_ESPRESSIF_BLE_INTERRUPT_SAVE_STATUS +# define NR_IRQSTATE_FLAGS CONFIG_ESPRESSIF_BLE_INTERRUPT_SAVE_STATUS #else # define NR_IRQSTATE_FLAGS 3 #endif @@ -1958,7 +1958,7 @@ static int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_bt_request(event, latency, duration); #else return 0; @@ -1981,7 +1981,7 @@ static int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, static int IRAM_ATTR coex_bt_release_wrapper(uint32_t event) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_bt_release(event); #else return 0; @@ -2005,7 +2005,7 @@ static int IRAM_ATTR coex_bt_release_wrapper(uint32_t event) static int adapter_coex_register_bt_cb_wrapper(coex_func_cb_t cb) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_register_bt_cb(cb); #else return 0; @@ -2029,7 +2029,7 @@ static int adapter_coex_register_bt_cb_wrapper(coex_func_cb_t cb) static uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_bb_reset_lock(); #else return 0; @@ -2054,7 +2054,7 @@ static uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void) static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_bb_reset_unlock(restore); #endif } @@ -2075,7 +2075,7 @@ static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore) static int coex_schm_register_btdm_callback_wrapper(void *callback) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_register_callback(COEX_SCHM_CALLBACK_TYPE_BT, callback); #else return 0; @@ -2100,7 +2100,7 @@ static int coex_schm_register_btdm_callback_wrapper(void *callback) static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_clear(type, status); #endif } @@ -2122,7 +2122,7 @@ static void coex_schm_status_bit_clear_wrapper(uint32_t type, static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_set(type, status); #endif } @@ -2143,7 +2143,7 @@ static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) static uint32_t coex_schm_interval_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_get(); #else return 0; @@ -2166,7 +2166,7 @@ static uint32_t coex_schm_interval_get_wrapper(void) static uint8_t coex_schm_curr_period_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_get(); #else return 0; @@ -2189,7 +2189,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void) static void *coex_schm_curr_phase_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_phase_get(); #else return NULL; @@ -2214,7 +2214,7 @@ static void *coex_schm_curr_phase_get_wrapper(void) static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_channel_get(primary, secondary); #else return -1; @@ -2238,7 +2238,7 @@ static int coex_wifi_channel_get_wrapper(uint8_t *primary, static int coex_register_wifi_channel_change_callback_wrapper(void *cb) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_register_wifi_channel_change_callback(cb); #else return -1; @@ -2265,7 +2265,7 @@ static int coex_version_get_wrapper(unsigned int *major, unsigned int *minor, unsigned int *patch) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_version_t version; ASSERT(coex_version_get_value(&version) == ESP_OK); @@ -2944,8 +2944,8 @@ int esp32_bt_controller_init(void) /* overwrite some parameters */ - cfg.controller_task_stack_size = CONFIG_ESP32_BLE_TASK_STACK_SIZE; - cfg.controller_task_prio = CONFIG_ESP32_BLE_TASK_PRIORITY; + cfg.controller_task_stack_size = CONFIG_ESPRESSIF_BLE_TASK_STACK_SIZE; + cfg.controller_task_prio = CONFIG_ESPRESSIF_BLE_TASK_PRIORITY; cfg.bt_max_sync_conn = CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF; cfg.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL; @@ -3062,7 +3062,7 @@ int esp32_bt_controller_init(void) g_pm_lock_acquired = true; #endif -#if CONFIG_ESP32_WIFI_BT_COEXIST +#if CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_init(); #endif @@ -3162,7 +3162,7 @@ int esp32_bt_controller_enable(esp_bt_mode_t mode) esp_phy_enable(PHY_MODEM_BT); -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_enable(); #endif @@ -3180,7 +3180,7 @@ int esp32_bt_controller_enable(esp_bt_mode_t mode) ret = btdm_controller_enable(mode); if (ret != 0) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_disable(); #endif esp_phy_disable(PHY_MODEM_BT); @@ -3236,7 +3236,7 @@ int esp32_bt_controller_disable(void) btdm_controller_disable(); -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_disable(); #endif diff --git a/arch/xtensa/src/esp32/esp32_irq.c b/arch/xtensa/src/esp32/esp32_irq.c index 0079321cf637d..9a75ca6116a0f 100644 --- a/arch/xtensa/src/esp32/esp32_irq.c +++ b/arch/xtensa/src/esp32/esp32_irq.c @@ -100,13 +100,13 @@ #define ESP32_MAX_PRIORITY 5 #define ESP32_PRIO_INDEX(p) ((p) - ESP32_MIN_PRIORITY) -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # define ESP32_WIFI_RESERVE_INT (1 << ESP32_CPUINT_MAC) #else # define ESP32_WIFI_RESERVE_INT 0 #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # define ESP32_BLE_RESERVE_INT ((1 << ESP32_PERIPH_BT_BB_NMI) | \ (1 << ESP32_PERIPH_RWBLE_IRQ) | \ (1 << ESP32_PERIPH_RWBT_NMI)) @@ -528,11 +528,11 @@ void up_irqinitialize(void) g_irqmap[XTENSA_IRQ_SWINT] = IRQ_MKMAP(0, ESP32_CPUINT_SOFTWARE1); g_irqmap[XTENSA_IRQ_SWINT] = IRQ_MKMAP(1, ESP32_CPUINT_SOFTWARE1); -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI g_irqmap[ESP32_IRQ_MAC] = IRQ_MKMAP(0, ESP32_CPUINT_MAC); #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE g_irqmap[ESP32_IRQ_BT_BB_NMI] = IRQ_MKMAP(0, ESP32_PERIPH_BT_BB_NMI); g_irqmap[ESP32_IRQ_RWBT_NMI] = IRQ_MKMAP(0, ESP32_PERIPH_RWBT_NMI); g_irqmap[ESP32_IRQ_RWBLE_IRQ] = IRQ_MKMAP(0, ESP32_PERIPH_RWBLE_IRQ); @@ -544,12 +544,12 @@ void up_irqinitialize(void) /* Reserve CPU0 interrupt for some special drivers */ -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI g_cpu0_intmap[ESP32_CPUINT_MAC] = CPUINT_ASSIGN(ESP32_IRQ_MAC); xtensa_enable_cpuint(&g_intenable[0], 1 << ESP32_CPUINT_MAC); #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE g_cpu0_intmap[ESP32_PERIPH_BT_BB_NMI] = CPUINT_ASSIGN(ESP32_IRQ_BT_BB_NMI); g_cpu0_intmap[ESP32_PERIPH_RWBT_NMI] = CPUINT_ASSIGN(ESP32_IRQ_RWBT_NMI); g_cpu0_intmap[ESP32_PERIPH_RWBLE_IRQ] = CPUINT_ASSIGN(ESP32_IRQ_RWBLE_IRQ); diff --git a/arch/xtensa/src/esp32/esp32_wifi_adapter.c b/arch/xtensa/src/esp32/esp32_wifi_adapter.c index 3517ebdceaf27..53a8c202d9e18 100644 --- a/arch/xtensa/src/esp32/esp32_wifi_adapter.c +++ b/arch/xtensa/src/esp32/esp32_wifi_adapter.c @@ -58,19 +58,19 @@ #include "hardware/esp32_dport.h" #include "hardware/esp32_emac.h" #include "esp32_irq.h" -#include "esp32_wireless.h" +#include "espressif/esp_wireless.h" #include "esp32_wifi_adapter.h" #include "esp32_rt_timer.h" -#include "esp32_wifi_utils.h" -#include "esp32_wlan.h" +#include "espressif/esp_wifi_utils.h" +#include "espressif/esp_wlan.h" #ifdef CONFIG_PM # include "esp32_pm.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble_adapter.h" -# ifdef CONFIG_ESP32_WIFI_BT_COEXIST +# ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "private/esp_coexist_internal.h" # endif #endif @@ -92,7 +92,7 @@ #define PHY_RF_MASK ((1 << PHY_BT_MODULE) | (1 << PHY_WIFI_MODULE)) -#define WIFI_CONNECT_TIMEOUT CONFIG_ESP32_WIFI_CONNECT_TIMEOUT +#define WIFI_CONNECT_TIMEOUT CONFIG_ESPRESSIF_WIFI_CONNECT_TIMEOUT #define TIMER_INITIALIZED_VAL (0x5aa5a55a) @@ -111,11 +111,11 @@ /* CONFIG_POWER_SAVE_MODEM */ -#if defined(CONFIG_ESP32_POWER_SAVE_MIN_MODEM) +#if defined(CONFIG_ESPRESSIF_POWER_SAVE_MIN_MODEM) # define DEFAULT_PS_MODE WIFI_PS_MIN_MODEM -#elif defined(CONFIG_ESP32_POWER_SAVE_MAX_MODEM) +#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_MAX_MODEM) # define DEFAULT_PS_MODE WIFI_PS_MAX_MODEM -#elif defined(CONFIG_ESP32_POWER_SAVE_NONE) +#elif defined(CONFIG_ESPRESSIF_POWER_SAVE_NONE) # define DEFAULT_PS_MODE WIFI_PS_NONE #else # define DEFAULT_PS_MODE WIFI_PS_NONE @@ -193,11 +193,11 @@ struct nvs_adpt * Private Function Prototypes ****************************************************************************/ -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST static int semphr_take_from_isr_wrapper(void *semphr, void *hptw); static int semphr_give_from_isr_wrapper(void *semphr, void *hptw); static int is_in_isr_wrapper(void); -#endif /* CONFIG_ESP32_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ static bool wifi_env_is_chip(void); static void wifi_set_intr(int32_t cpu_no, uint32_t intr_source, @@ -360,7 +360,7 @@ static mutex_t g_wifiexcl_lock = NXMUTEX_INITIALIZER; static int g_wifi_ref; -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /* If reconnect automatically */ @@ -382,9 +382,9 @@ static wifi_txdone_cb_t g_sta_txdone_cb; static wifi_config_t g_sta_wifi_cfg; -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP /* If Wi-Fi SoftAP starts */ @@ -398,7 +398,7 @@ static wifi_txdone_cb_t g_softap_txdone_cb; static wifi_config_t g_softap_wifi_cfg; -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ /* Device specific lock */ @@ -410,7 +410,7 @@ static spinlock_t g_lock; /* Wi-Fi and BT coexistence OS adapter data */ -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_adapter_funcs_t g_coex_adapter_funcs = { ._version = COEX_ADAPTER_VERSION, @@ -435,7 +435,7 @@ coex_adapter_funcs_t g_coex_adapter_funcs = ._timer_arm_us = esp_timer_arm_us, ._magic = COEX_ADAPTER_MAGIC, }; -#endif /* CONFIG_ESP32_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ /* Wi-Fi OS adapter data */ @@ -499,7 +499,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = ._phy_enable = esp_phy_enable_wrapper, ._phy_common_clock_enable = esp_phy_common_clock_enable, ._phy_common_clock_disable = esp_phy_common_clock_disable, - ._phy_update_country_info = esp32_phy_update_country_info, + ._phy_update_country_info = esp_phy_update_country_info, ._read_mac = esp_wifi_read_mac, ._timer_arm = esp_timer_arm, ._timer_disarm = esp_timer_disarm, @@ -2043,7 +2043,7 @@ static int esp_event_id_map(int event_id) id = WIFI_ADPT_EVT_SCAN_DONE; break; -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA case WIFI_EVENT_STA_START: id = WIFI_ADPT_EVT_STA_START; break; @@ -2063,9 +2063,9 @@ static int esp_event_id_map(int event_id) case WIFI_EVENT_STA_STOP: id = WIFI_ADPT_EVT_STA_STOP; break; -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP case WIFI_EVENT_AP_START: id = WIFI_ADPT_EVT_AP_START; break; @@ -2081,7 +2081,7 @@ static int esp_event_id_map(int event_id) case WIFI_EVENT_AP_STADISCONNECTED: id = WIFI_ADPT_EVT_AP_STADISCONNECTED; break; -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ default: return -1; @@ -2122,7 +2122,7 @@ static void esp_evt_work_cb(void *arg) break; } - /* Some of the following logic (eg. esp32_wlan_sta_set_linkstatus) + /* Some of the following logic (eg. esp_wlan_sta_set_linkstatus) * can take net_lock(). To maintain the consistent locking order, * we take net_lock() here before taking esp_wifi_lock. Note that * net_lock() is a recursive lock. @@ -2137,13 +2137,13 @@ static void esp_evt_work_cb(void *arg) esp_wifi_scan_event_parse(); break; -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA case WIFI_ADPT_EVT_STA_START: wlinfo("Wi-Fi sta start\n"); g_sta_connected = false; -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE if (esp32_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) { @@ -2175,7 +2175,7 @@ static void esp_evt_work_cb(void *arg) case WIFI_ADPT_EVT_STA_CONNECT: wlinfo("Wi-Fi sta connect\n"); g_sta_connected = true; - ret = esp32_wlan_sta_set_linkstatus(true); + ret = esp_wlan_sta_set_linkstatus(true); if (ret < 0) { wlerr("ERROR: Failed to set Wi-Fi station link status\n"); @@ -2186,7 +2186,7 @@ static void esp_evt_work_cb(void *arg) case WIFI_ADPT_EVT_STA_DISCONNECT: wlinfo("Wi-Fi sta disconnect\n"); g_sta_connected = false; - ret = esp32_wlan_sta_set_linkstatus(false); + ret = esp_wlan_sta_set_linkstatus(false); if (ret < 0) { wlerr("ERROR: Failed to set Wi-Fi station link status\n"); @@ -2206,13 +2206,13 @@ static void esp_evt_work_cb(void *arg) wlinfo("Wi-Fi sta stop\n"); g_sta_connected = false; break; -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP case WIFI_ADPT_EVT_AP_START: wlinfo("INFO: Wi-Fi softap start\n"); -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE if (esp32_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_IDLE) { @@ -2252,7 +2252,7 @@ static void esp_evt_work_cb(void *arg) case WIFI_ADPT_EVT_AP_STADISCONNECTED: wlinfo("INFO: Wi-Fi station leave\n"); break; -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ default: break; } @@ -2278,7 +2278,7 @@ static void esp_evt_work_cb(void *arg) } } -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST /**************************************************************************** * Name: semphr_take_from_isr_wrapper @@ -2343,7 +2343,7 @@ static int IRAM_ATTR is_in_isr_wrapper(void) return up_interrupt_context(); } -#endif /* CONFIG_ESP32_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ /**************************************************************************** * Name: wifi_env_is_chip @@ -3619,7 +3619,7 @@ static void esp_wifi_delete_queue(void *queue) static int coex_init_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_init(); #else return 0; @@ -3642,7 +3642,7 @@ static int coex_init_wrapper(void) static void coex_deinit_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_deinit(); #endif } @@ -3664,7 +3664,7 @@ static void coex_deinit_wrapper(void) static int coex_enable_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_enable(); #else return 0; @@ -3687,7 +3687,7 @@ static int coex_enable_wrapper(void) static void coex_disable_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_disable(); #endif } @@ -3709,7 +3709,7 @@ static void coex_disable_wrapper(void) static IRAM_ATTR uint32_t coex_status_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_status_get(); #else return 0; @@ -3736,7 +3736,7 @@ static IRAM_ATTR uint32_t coex_status_get_wrapper(void) static int32_t coex_wifi_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_request(event, latency, duration); #else return 0; @@ -3760,7 +3760,7 @@ static int32_t coex_wifi_request_wrapper(uint32_t event, uint32_t latency, static IRAM_ATTR int32_t coex_wifi_release_wrapper(uint32_t event) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_release(event); #else return 0; @@ -3785,7 +3785,7 @@ static IRAM_ATTR int32_t coex_wifi_release_wrapper(uint32_t event) static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_wifi_channel_set(primary, secondary); #else return 0; @@ -3811,7 +3811,7 @@ static int coex_wifi_channel_set_wrapper(uint8_t primary, uint8_t secondary) static int coex_event_duration_get_wrapper(uint32_t event, uint32_t *duration) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_event_duration_get(event, duration); #else return 0; @@ -3857,7 +3857,7 @@ static int coex_pti_get_wrapper(uint32_t event, uint8_t *pti) static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_clear(type, status); #endif } @@ -3879,7 +3879,7 @@ static void coex_schm_status_bit_clear_wrapper(uint32_t type, static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST coex_schm_status_bit_set(type, status); #endif } @@ -3901,7 +3901,7 @@ static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status) static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_set(interval); #else return 0; @@ -3924,7 +3924,7 @@ static IRAM_ATTR int coex_schm_interval_set_wrapper(uint32_t interval) static uint32_t coex_schm_interval_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_interval_get(); #else return 0; @@ -3947,7 +3947,7 @@ static uint32_t coex_schm_interval_get_wrapper(void) static uint8_t coex_schm_curr_period_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_period_get(); #else return 0; @@ -3970,7 +3970,7 @@ static uint8_t coex_schm_curr_period_get_wrapper(void) static void *coex_schm_curr_phase_get_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_curr_phase_get(); #else return NULL; @@ -3994,7 +3994,7 @@ static void *coex_schm_curr_phase_get_wrapper(void) static int coex_register_start_cb_wrapper(int (* cb)(void)) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_register_start_cb(cb); #else return 0; @@ -4018,7 +4018,7 @@ static int coex_register_start_cb_wrapper(int (* cb)(void)) static int coex_schm_process_restart_wrapper(void) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_process_restart(); #else return 0; @@ -4043,7 +4043,7 @@ static int coex_schm_process_restart_wrapper(void) static int coex_schm_register_cb_wrapper(int type, int(*cb)(int)) { -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST return coex_schm_register_callback(type, cb); #else return 0; @@ -4145,7 +4145,7 @@ static unsigned long esp_random_ulong(void) static IRAM_ATTR void esp_wifi_tx_done_cb(uint8_t ifidx, uint8_t *data, uint16_t *len, bool txstatus) { -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA if (ifidx == ESP_IF_WIFI_STA) { if (g_sta_txdone_cb) @@ -4154,9 +4154,9 @@ static IRAM_ATTR void esp_wifi_tx_done_cb(uint8_t ifidx, uint8_t *data, } } else -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP if (ifidx == ESP_IF_WIFI_AP) { if (g_softap_txdone_cb) @@ -4165,13 +4165,13 @@ static IRAM_ATTR void esp_wifi_tx_done_cb(uint8_t ifidx, uint8_t *data, } } else -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ { wlerr("ifidx=%d is error\n", ifidx); } } -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_auth_trans @@ -4273,7 +4273,7 @@ static int esp_wifi_cipher_trans(uint32_t wifi_cipher) return cipher_mode; } -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ /**************************************************************************** * Name: esp_freq_to_channel @@ -4609,28 +4609,28 @@ int esp_wifi_adapter_init(void) wifi_cfg.nvs_enable = 0; -#ifdef CONFIG_ESP32_WIFI_TX_AMPDU +#ifdef CONFIG_ESPRESSIF_WIFI_TX_AMPDU wifi_cfg.ampdu_tx_enable = 1; #else wifi_cfg.ampdu_tx_enable = 0; #endif -#ifdef CONFIG_ESP32_WIFI_RX_AMPDU +#ifdef CONFIG_ESPRESSIF_WIFI_RX_AMPDU wifi_cfg.ampdu_rx_enable = 1; #else wifi_cfg.ampdu_rx_enable = 0; #endif -#ifdef CONFIG_ESP32_WIFI_STA_DISCONNECT_PM +#ifdef CONFIG_ESPRESSIF_WIFI_STA_DISCONNECT_PM wifi_cfg.sta_disconnected_pm = true; #else wifi_cfg.sta_disconnected_pm = false; #endif - wifi_cfg.rx_ba_win = CONFIG_ESP32_WIFI_RXBA_AMPDU_WZ; - wifi_cfg.static_rx_buf_num = CONFIG_ESP32_WIFI_STATIC_RXBUF_NUM; - wifi_cfg.dynamic_rx_buf_num = CONFIG_ESP32_WIFI_DYNAMIC_RXBUF_NUM; - wifi_cfg.dynamic_tx_buf_num = CONFIG_ESP32_WIFI_DYNAMIC_TXBUF_NUM; + wifi_cfg.rx_ba_win = CONFIG_ESPRESSIF_WIFI_RXBA_AMPDU_WZ; + wifi_cfg.static_rx_buf_num = CONFIG_ESPRESSIF_WIFI_STATIC_RXBUF_NUM; + wifi_cfg.dynamic_rx_buf_num = CONFIG_ESPRESSIF_WIFI_DYNAMIC_RXBUF_NUM; + wifi_cfg.dynamic_tx_buf_num = CONFIG_ESPRESSIF_WIFI_DYNAMIC_TXBUF_NUM; ret = esp_wifi_init(&wifi_cfg); if (ret) @@ -4668,7 +4668,7 @@ int esp_wifi_adapter_init(void) * Station functions ****************************************************************************/ -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_sta_start @@ -4698,13 +4698,13 @@ int esp_wifi_sta_start(void) wlinfo("Failed to stop Wi-Fi ret=%d\n", ret); } -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP if (g_softap_started) { mode = WIFI_MODE_APSTA; } else -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ { mode = WIFI_MODE_STA; } @@ -4763,7 +4763,7 @@ int esp_wifi_sta_stop(void) g_sta_started = false; -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP if (g_softap_started) { ret = esp_wifi_set_mode(WIFI_MODE_AP); @@ -4782,13 +4782,13 @@ int esp_wifi_sta_stop(void) goto errout; } } -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ wlinfo("OK to stop Wi-Fi station\n"); -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP errout: -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ esp_wifi_lock(false); return ret; @@ -5663,7 +5663,7 @@ int esp_wifi_sta_bitrate(struct iwreq *iwr, bool set) return OK; } -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ /**************************************************************************** * Name: esp_wifi_sta_get_txpower @@ -5858,7 +5858,7 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set) return OK; } -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_sta_rssi @@ -5905,13 +5905,13 @@ int esp_wifi_sta_rssi(struct iwreq *iwr, bool set) return OK; } -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ /**************************************************************************** * SoftAP functions ****************************************************************************/ -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP /**************************************************************************** * Name: esp_wifi_softap_start @@ -5941,13 +5941,13 @@ int esp_wifi_softap_start(void) wlinfo("Failed to stop Wi-Fi ret=%d\n", ret); } -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA if (g_sta_started) { mode = WIFI_MODE_APSTA; } else -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ { mode = WIFI_MODE_AP; } @@ -6006,7 +6006,7 @@ int esp_wifi_softap_stop(void) g_softap_started = false; -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA if (g_sta_started) { ret = esp_wifi_set_mode(WIFI_MODE_STA); @@ -6025,13 +6025,13 @@ int esp_wifi_softap_stop(void) goto errout; } } -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ wlinfo("OK to stop Wi-Fi SoftAP\n"); -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA errout: -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ esp_wifi_lock(false); return ret; @@ -6670,7 +6670,7 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set) return -ENOSYS; } -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ /**************************************************************************** * Name: esp32_wifi_bt_coexist_init @@ -6687,7 +6687,7 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set) * ****************************************************************************/ -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST int esp32_wifi_bt_coexist_init(void) { esp_coex_adapter_register(&g_coex_adapter_funcs); @@ -6695,7 +6695,7 @@ int esp32_wifi_bt_coexist_init(void) return 0; } -#endif /* CONFIG_ESP32_WIFI_BT_COEXIST */ +#endif /* CONFIG_ESPRESSIF_WIFI_BT_COEXIST */ /**************************************************************************** * Name: esp_wifi_stop_callback diff --git a/arch/xtensa/src/esp32/esp32_wifi_adapter.h b/arch/xtensa/src/esp32/esp32_wifi_adapter.h index 309cf3ae288d9..29ece5bf31aff 100644 --- a/arch/xtensa/src/esp32/esp32_wifi_adapter.h +++ b/arch/xtensa/src/esp32/esp32_wifi_adapter.h @@ -45,20 +45,20 @@ extern "C" * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_ESP32_WIFI_STATION) -# define ESP32_WLAN_HAS_STA -# define ESP32_WLAN_STA_DEVNO 0 -# define ESP32_WLAN_DEVS 1 -#elif defined(CONFIG_ESP32_WIFI_SOFTAP) -# define ESP32_WLAN_HAS_SOFTAP -# define ESP32_WLAN_SOFTAP_DEVNO 0 -# define ESP32_WLAN_DEVS 1 -#elif defined(CONFIG_ESP32_WIFI_STATION_SOFTAP) -# define ESP32_WLAN_HAS_STA -# define ESP32_WLAN_HAS_SOFTAP -# define ESP32_WLAN_STA_DEVNO 0 -# define ESP32_WLAN_SOFTAP_DEVNO 1 -# define ESP32_WLAN_DEVS 2 +#if defined(CONFIG_ESPRESSIF_WIFI_STATION) +# define ESPRESSIF_WLAN_HAS_STA +# define ESPRESSIF_WLAN_STA_DEVNO 0 +# define ESPRESSIF_WLAN_DEVS 1 +#elif defined(CONFIG_ESPRESSIF_WIFI_SOFTAP) +# define ESPRESSIF_WLAN_HAS_SOFTAP +# define ESPRESSIF_WLAN_SOFTAP_DEVNO 0 +# define ESPRESSIF_WLAN_DEVS 1 +#elif defined(CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP) +# define ESPRESSIF_WLAN_HAS_STA +# define ESPRESSIF_WLAN_HAS_SOFTAP +# define ESPRESSIF_WLAN_STA_DEVNO 0 +# define ESPRESSIF_WLAN_SOFTAP_DEVNO 1 +# define ESPRESSIF_WLAN_DEVS 2 #endif #define SSID_MAX_LEN (32) @@ -160,7 +160,7 @@ void esp_wifi_free_eb(void *eb); int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event); -#ifdef ESP32_WLAN_HAS_STA +#ifdef ESPRESSIF_WLAN_HAS_STA /**************************************************************************** * Name: esp_wifi_sta_start @@ -496,9 +496,9 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set); ****************************************************************************/ int esp_wifi_sta_rssi(struct iwreq *iwr, bool set); -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32_WLAN_HAS_SOFTAP +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP /**************************************************************************** * Name: esp_wifi_softap_start @@ -834,7 +834,7 @@ int esp_wifi_softap_country(struct iwreq *iwr, bool set); ****************************************************************************/ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set); -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ /**************************************************************************** * Name: esp32_wifi_bt_coexist_init @@ -851,7 +851,7 @@ int esp_wifi_softap_rssi(struct iwreq *iwr, bool set); * ****************************************************************************/ -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST int esp32_wifi_bt_coexist_init(void); void coex_dbg_set_log_level(int level); #endif diff --git a/arch/xtensa/src/esp32/esp32_wifi_utils.c b/arch/xtensa/src/esp32/esp32_wifi_utils.c deleted file mode 100644 index d6ae1317e1898..0000000000000 --- a/arch/xtensa/src/esp32/esp32_wifi_utils.c +++ /dev/null @@ -1,573 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_wifi_utils.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "esp32_wifi_adapter.h" -#include "esp32_wifi_utils.h" -#include "esp32_wireless.h" - -#include "esp_log.h" -#include "esp_mac.h" -#include "esp_private/phy.h" -#include "esp_private/wifi.h" -#include "esp_random.h" -#include "esp_timer.h" -#include "rom/ets_sys.h" -#include "soc/soc_caps.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Helper to get iw_event size */ - -#define ESP_IW_EVENT_SIZE(field) \ - (offsetof(struct iw_event, u) + sizeof(((union iwreq_data *)0)->field)) - -#ifdef CONFIG_ESP32_WIFI_SCAN_RESULT_SIZE -# define WIFI_SCAN_RESULT_SIZE CONFIG_ESP32_WIFI_SCAN_RESULT_SIZE -#else -# define WIFI_SCAN_RESULT_SIZE (4096) -#endif - -#define SCAN_TIME_SEC (5) - -/* Maximum number of channels for Wi-Fi 2.4Ghz */ - -#define CHANNEL_MAX_NUM (14) - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -enum scan_status_e -{ - ESP_SCAN_DISABLED = 0, - ESP_SCAN_RUN, - ESP_SCAN_DONE -}; - -/* Wi-Fi scan result information */ - -struct wifi_scan_result -{ - enum scan_status_e scan_status; /* Scan status */ - sem_t scan_signal; /* Scan notification signal */ - uint8_t *scan_result; /* Temp buffer that holds results */ - unsigned int scan_result_size; /* Current size of temp buffer */ -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static struct wifi_scan_result g_scan_priv = -{ - .scan_signal = SEM_INITIALIZER(0), -}; -static uint8_t g_channel_num; -static uint8_t g_channel_list[CHANNEL_MAX_NUM]; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_start_scan - * - * Description: - * Scan all available APs. - * - * Input Parameters: - * iwr - The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_start_scan(struct iwreq *iwr) -{ - struct wifi_scan_result *priv = &g_scan_priv; - wifi_scan_config_t *config = NULL; - struct iw_scan_req *req; - int ret = 0; - int i; - uint8_t target_mac[MAC_LEN]; - uint8_t target_ssid[SSID_MAX_LEN + 1]; - memset(target_ssid, 0x0, sizeof(SSID_MAX_LEN + 1)); - - if (iwr == NULL) - { - wlerr("ERROR: Invalid ioctl cmd.\n"); - return -EINVAL; - } - - if (g_scan_priv.scan_status != ESP_SCAN_DISABLED) - { - return OK; - } - - config = kmm_calloc(1, sizeof(wifi_scan_config_t)); - if (config == NULL) - { - wlerr("ERROR: Cannot allocate result buffer\n"); - return -ENOMEM; - } - - g_channel_num = 0; - memset(g_channel_list, 0x0, CHANNEL_MAX_NUM); - - if (iwr->u.data.pointer && - iwr->u.data.length >= sizeof(struct iw_scan_req)) - { - req = (struct iw_scan_req *)iwr->u.data.pointer; - config->scan_type = (req->scan_type == IW_SCAN_TYPE_ACTIVE ? - WIFI_SCAN_TYPE_ACTIVE : WIFI_SCAN_TYPE_PASSIVE); - if (iwr->u.data.flags & IW_SCAN_THIS_ESSID && - req->essid_len < sizeof(target_ssid)) - { - /* Scan specific ESSID */ - - config->show_hidden = true; - config->bssid = NULL; - memcpy(&target_ssid[0], req->essid, req->essid_len); - config->ssid = &target_ssid[0]; - config->ssid[req->essid_len] = '\0'; - } - - if (iwr->u.data.flags & IW_SCAN_THIS_FREQ && - req->num_channels > 0) - { - /* Scan specific channels */ - - DEBUGASSERT(req->num_channels <= CHANNEL_MAX_NUM); - g_channel_num = req->num_channels; - if (req->num_channels == 1) - { - config->channel = req->channel_list[0].m; - } - else - { - for (i = 0; i < req->num_channels; i++) - { - g_channel_list[i] = req->channel_list[i].m; - } - } - } - - memset(target_mac, 0xff, MAC_LEN); - if (memcmp(req->bssid.sa_data, target_mac, MAC_LEN) != 0) - { - /* Scan specific bssid */ - - memcpy(target_mac, req->bssid.sa_data, MAC_LEN); - config->bssid = &target_mac[0]; - } - } - else - { - /* Default scan parameters */ - - wlinfo("INFO: Use default scan parameters\n"); - config->scan_type = WIFI_SCAN_TYPE_ACTIVE; /* Active scan */ - } - - esp_wifi_start(); - ret = esp_wifi_scan_start(config, false); - if (ret != OK) - { - wlerr("ERROR: Scan error, ret: %d\n", ret); - ret = ERROR; - } - else - { - /* Allocate buffer to store scan result */ - - if (priv->scan_result == NULL) - { - priv->scan_result = kmm_malloc(WIFI_SCAN_RESULT_SIZE); - if (priv->scan_result == NULL) - { - wlerr("ERROR: Cannot allocate result buffer\n"); - ret = -ENOMEM; - } - else - { - memset(priv->scan_result, 0x0, WIFI_SCAN_RESULT_SIZE); - } - } - } - - if (config) - { - kmm_free(config); - config = NULL; - } - - if (ret == OK) - { - wlinfo("INFO: start scan\n"); - g_scan_priv.scan_status = ESP_SCAN_RUN; - } - - return ret; -} - -/**************************************************************************** - * Name: esp_wifi_get_scan_results - * - * Description: - * Get scan result - * - * Input Parameters: - * iwr - The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_get_scan_results(struct iwreq *iwr) -{ - int ret = OK; - static bool scan_block = false; - struct wifi_scan_result *priv = &g_scan_priv; - - if (g_scan_priv.scan_status == ESP_SCAN_RUN) - { - irqstate_t irqstate = enter_critical_section(); - if (!scan_block) - { - scan_block = true; - leave_critical_section(irqstate); - nxsem_tickwait(&priv->scan_signal, SEC2TICK(SCAN_TIME_SEC)); - scan_block = false; - } - else - { - leave_critical_section(irqstate); - ret = -EINVAL; - goto exit_failed; - } - } - else if (g_scan_priv.scan_status == ESP_SCAN_DISABLED) - { - ret = -EINVAL; - goto exit_failed; - } - - if ((iwr == NULL) || (g_scan_priv.scan_status != ESP_SCAN_DONE)) - { - ret = -EINVAL; - goto exit_failed; - } - - if (priv->scan_result == NULL) - { - /* Result have already been requested */ - - ret = OK; - iwr->u.data.length = 0; - goto exit_failed; - } - - if (priv->scan_result_size <= 0) - { - ret = OK; - iwr->u.data.length = 0; - goto exit_free_buffer; - } - - if (iwr->u.data.pointer == NULL || - iwr->u.data.length < priv->scan_result_size) - { - /* Stat request, return scan_result_size */ - - ret = -E2BIG; - iwr->u.data.pointer = NULL; - iwr->u.data.length = priv->scan_result_size; - return ret; - } - - /* Copy result to user buffer */ - - if (iwr->u.data.length > priv->scan_result_size) - { - iwr->u.data.length = priv->scan_result_size; - } - - memcpy(iwr->u.data.pointer, priv->scan_result, iwr->u.data.length); - -exit_free_buffer: - - /* Free scan result buffer */ - - kmm_free(priv->scan_result); - priv->scan_result = NULL; - priv->scan_result_size = 0; - g_scan_priv.scan_status = ESP_SCAN_DISABLED; - -exit_failed: - if (ret < 0) - { - iwr->u.data.length = 0; - } - - return ret; -} - -/**************************************************************************** - * Name: esp_wifi_scan_event_parse - * - * Description: - * Parse scan information - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_wifi_scan_event_parse(void) -{ - struct wifi_scan_result *priv = &g_scan_priv; - wifi_ap_record_t *ap_list_buffer = NULL; - uint16_t bss_total = 0; - uint8_t bss_count = 0; - bool parse_done = false; - - if (priv->scan_status != ESP_SCAN_RUN) - { - return; - } - - esp_wifi_scan_get_ap_num(&bss_total); - if (bss_total == 0) - { - priv->scan_status = ESP_SCAN_DONE; - wlinfo("INFO: None AP is scanned\n"); - nxsem_post(&priv->scan_signal); - return; - } - - ap_list_buffer = kmm_calloc(bss_total, sizeof(wifi_ap_record_t)); - if (ap_list_buffer == NULL) - { - priv->scan_status = ESP_SCAN_DONE; - wlerr("ERROR: Failed to calloc buffer to print scan results"); - nxsem_post(&priv->scan_signal); - return; - } - - if (esp_wifi_scan_get_ap_records(&bss_total, - (wifi_ap_record_t *)ap_list_buffer) == OK) - { - struct iw_event *iwe; - unsigned int result_size; - size_t essid_len; - size_t essid_len_aligned; - bool is_target_channel = true; - int i; - - for (bss_count = 0; bss_count < bss_total; bss_count++) - { - if (g_channel_num > 1) - { - is_target_channel = false; - for (i = 0; i < g_channel_num; i++) - { - if (g_channel_list[i] == ap_list_buffer[bss_count].primary) - { - is_target_channel = true; - break; - } - } - } - else - { - is_target_channel = true; - } - - if (is_target_channel) - { - result_size = WIFI_SCAN_RESULT_SIZE - priv->scan_result_size; - - /* Copy BSSID */ - - if (result_size < ESP_IW_EVENT_SIZE(ap_addr)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(ap_addr); - iwe->cmd = SIOCGIWAP; - memcpy(&iwe->u.ap_addr.sa_data, - ap_list_buffer[bss_count].bssid, - sizeof(ap_list_buffer[bss_count].bssid)); - iwe->u.ap_addr.sa_family = ARPHRD_ETHER; - priv->scan_result_size += ESP_IW_EVENT_SIZE(ap_addr); - result_size -= ESP_IW_EVENT_SIZE(ap_addr); - - /* Copy ESSID */ - - essid_len = MIN(strlen((const char *) - ap_list_buffer[bss_count].ssid), SSID_MAX_LEN); - essid_len_aligned = (essid_len + 3) & -4; - if (result_size < ESP_IW_EVENT_SIZE(essid) + essid_len_aligned) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(essid) + essid_len_aligned; - iwe->cmd = SIOCGIWESSID; - iwe->u.essid.flags = 0; - iwe->u.essid.length = essid_len; - - /* Special processing for iw_point, set offset - * in pointer field. - */ - - iwe->u.essid.pointer = (void *)sizeof(iwe->u.essid); - memcpy(&iwe->u.essid + 1, - ap_list_buffer[bss_count].ssid, essid_len); - - wlinfo("INFO: ssid %s\n", ap_list_buffer[bss_count].ssid); - - priv->scan_result_size += - ESP_IW_EVENT_SIZE(essid) + essid_len_aligned; - result_size -= ESP_IW_EVENT_SIZE(essid) + essid_len_aligned; - - /* Copy link quality info */ - - if (result_size < ESP_IW_EVENT_SIZE(qual)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(qual); - iwe->cmd = IWEVQUAL; - iwe->u.qual.qual = 0x00; - - wlinfo("INFO: signal %d\n", ap_list_buffer[bss_count].rssi); - - iwe->u.qual.level = ap_list_buffer[bss_count].rssi; - iwe->u.qual.noise = 0x00; - iwe->u.qual.updated = IW_QUAL_DBM | IW_QUAL_ALL_UPDATED; - - priv->scan_result_size += ESP_IW_EVENT_SIZE(qual); - result_size -= ESP_IW_EVENT_SIZE(qual); - - /* Copy AP mode */ - - if (result_size < ESP_IW_EVENT_SIZE(mode)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(mode); - iwe->cmd = SIOCGIWMODE; - iwe->u.mode = IW_MODE_MASTER; - priv->scan_result_size += ESP_IW_EVENT_SIZE(mode); - result_size -= ESP_IW_EVENT_SIZE(mode); - - /* Copy AP encryption mode */ - - if (result_size < ESP_IW_EVENT_SIZE(data)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(data); - iwe->cmd = SIOCGIWENCODE; - iwe->u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - iwe->u.data.length = 0; - iwe->u.essid.pointer = NULL; - - priv->scan_result_size += ESP_IW_EVENT_SIZE(data); - result_size -= ESP_IW_EVENT_SIZE(data); - - /* Copy AP channel */ - - if (result_size < ESP_IW_EVENT_SIZE(freq)) - { - goto scan_result_full; - } - - iwe = (struct iw_event *) - &priv->scan_result[priv->scan_result_size]; - iwe->len = ESP_IW_EVENT_SIZE(freq); - iwe->cmd = SIOCGIWFREQ; - iwe->u.freq.e = 0; - iwe->u.freq.m = ap_list_buffer[bss_count].primary; - - priv->scan_result_size += ESP_IW_EVENT_SIZE(freq); - result_size -= ESP_IW_EVENT_SIZE(freq); - } - } - - parse_done = true; - } - -scan_result_full: - - /* Continue instead of break to log dropped AP results */ - - if (!parse_done) - { - wlerr("ERROR: No more space in scan_result buffer\n"); - } - - if (ap_list_buffer) - { - kmm_free(ap_list_buffer); - ap_list_buffer = NULL; - } - - priv->scan_status = ESP_SCAN_DONE; - nxsem_post(&priv->scan_signal); -} diff --git a/arch/xtensa/src/esp32/esp32_wifi_utils.h b/arch/xtensa/src/esp32/esp32_wifi_utils.h deleted file mode 100644 index 0ef37848f9819..0000000000000 --- a/arch/xtensa/src/esp32/esp32_wifi_utils.h +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_wifi_utils.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WIFI_UTILS_H -#define __ARCH_XTENSA_SRC_ESP32_ESP32_WIFI_UTILS_H - -#include -#include - -#include - -#ifndef __ASSEMBLY__ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_start_scan - * - * Description: - * Scan all available APs. - * - * Input Parameters: - * iwr - The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_start_scan(struct iwreq *iwr); - -/**************************************************************************** - * Name: esp_wifi_get_scan_results - * - * Description: - * Get scan result - * - * Input Parameters: - * req The argument of the ioctl cmd - * - * Returned Value: - * OK on success (positive non-zero values are cmd-specific) - * Negated errno returned on failure. - * - ****************************************************************************/ - -int esp_wifi_get_scan_results(struct iwreq *iwr); - -/**************************************************************************** - * Name: esp_wifi_scan_event_parse - * - * Description: - * Parse scan information - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_wifi_scan_event_parse(void); - -#ifdef __cplusplus -} -#endif -#undef EXTERN - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WIFI_UTILS_H */ diff --git a/arch/xtensa/src/esp32/esp32_wireless.c b/arch/xtensa/src/esp32/esp32_wireless.c deleted file mode 100644 index 5b807eaf5bb23..0000000000000 --- a/arch/xtensa/src/esp32/esp32_wireless.c +++ /dev/null @@ -1,1468 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_wireless.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include - -#include "xtensa.h" -#include "hardware/esp32_dport.h" -#include "hardware/esp32_emac.h" -#include "hardware/esp32_soc.h" -#include "esp32_irq.h" -#include "esp32_partition.h" - -#include "esp_private/phy.h" -#ifdef CONFIG_ESP32_WIFI -# include "esp_private/wifi.h" -# include "esp_wpa.h" -#endif -#include "private/esp_coexist_internal.h" -#include "periph_ctrl.h" -#include "esp_phy_init.h" -#include "phy_init_data.h" - -#include "esp32_wireless.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Software Interrupt */ - -#define SWI_IRQ ESP32_IRQ_CPU_CPU2 -#define SWI_PERIPH ESP32_PERIPH_CPU_CPU2 - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/* Wireless Private Data */ - -struct esp_wireless_priv_s -{ - volatile int ref; /* Reference count */ - - int cpuint; /* CPU interrupt assigned to SWI */ - - struct list_node sc_list; /* Semaphore cache list */ - struct list_node qc_list; /* Queue cache list */ - struct list_node qc_freelist; /* List of free queue cache structures */ -}; - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -static inline void phy_digital_regs_store(void); -static inline void phy_digital_regs_load(void); -static int esp_swi_irq(int irq, void *context, void *arg); -#ifdef CONFIG_ESP32_WIFI -static void esp_wifi_set_log_level(void); -#endif - -/**************************************************************************** - * Extern Functions declaration - ****************************************************************************/ - -extern uint8_t esp_crc8(const uint8_t *p, uint32_t len); -extern void phy_wakeup_init(void); -extern void phy_close_rf(void); -extern uint8_t phy_dig_reg_backup(bool init, uint32_t *regs); -extern int register_chipv7_phy(const esp_phy_init_data_t *init_data, - esp_phy_calibration_data_t *cal_data, - esp_phy_calibration_mode_t cal_mode); -extern uint32_t crc32_le(uint32_t crc, uint8_t const *buf, uint32_t len); - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* Wi-Fi sleep private data */ - -static uint32_t g_phy_clk_en_cnt; - -/* Reference count of enabling PHY */ - -static uint8_t g_phy_access_ref; - -/* Memory to store PHY digital registers */ - -static uint32_t *g_phy_digital_regs_mem = NULL; - -/* Indicate PHY is calibrated or not */ - -static bool g_is_phy_calibrated = false; - -/* Private data of the wireless common interface */ - -static struct esp_wireless_priv_s g_esp_wireless_priv; - -#ifdef CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION -static const char *phy_partion_label = "phy_init"; -#endif - -#ifdef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA - -static phy_init_data_type_t g_phy_init_data_type; - -static phy_init_data_type_t g_current_apply_phy_init_data; - -static char g_phy_current_country[PHY_COUNTRY_CODE_LEN]; - -/* Whether it is a new bin */ - -static bool g_multiple_phy_init_data_bin; - -/* PHY init data type array */ - -static const char *g_phy_type[ESP_PHY_INIT_DATA_TYPE_NUMBER] = -{ - "DEFAULT", "SRRC", "FCC", "CE", "NCC", "KCC", "MIC", "IC", - "ACMA", "ANATEL", "ISED", "WPC", "OFCA", "IFETEL", "RCM" -}; - -/* Country and PHY init data type map */ - -static phy_country_to_bin_type_t g_country_code_map_type_table[] = -{ - {"01", ESP_PHY_INIT_DATA_TYPE_DEFAULT}, - {"AT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"AU", ESP_PHY_INIT_DATA_TYPE_ACMA}, - {"BE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"BG", ESP_PHY_INIT_DATA_TYPE_CE}, - {"BR", ESP_PHY_INIT_DATA_TYPE_ANATEL}, - {"CA", ESP_PHY_INIT_DATA_TYPE_ISED}, - {"CH", ESP_PHY_INIT_DATA_TYPE_CE}, - {"CN", ESP_PHY_INIT_DATA_TYPE_SRRC}, - {"CY", ESP_PHY_INIT_DATA_TYPE_CE}, - {"CZ", ESP_PHY_INIT_DATA_TYPE_CE}, - {"DE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"DK", ESP_PHY_INIT_DATA_TYPE_CE}, - {"EE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"ES", ESP_PHY_INIT_DATA_TYPE_CE}, - {"FI", ESP_PHY_INIT_DATA_TYPE_CE}, - {"FR", ESP_PHY_INIT_DATA_TYPE_CE}, - {"GB", ESP_PHY_INIT_DATA_TYPE_CE}, - {"GR", ESP_PHY_INIT_DATA_TYPE_CE}, - {"HK", ESP_PHY_INIT_DATA_TYPE_OFCA}, - {"HR", ESP_PHY_INIT_DATA_TYPE_CE}, - {"HU", ESP_PHY_INIT_DATA_TYPE_CE}, - {"IE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"IN", ESP_PHY_INIT_DATA_TYPE_WPC}, - {"IS", ESP_PHY_INIT_DATA_TYPE_CE}, - {"IT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"JP", ESP_PHY_INIT_DATA_TYPE_MIC}, - {"KR", ESP_PHY_INIT_DATA_TYPE_KCC}, - {"LI", ESP_PHY_INIT_DATA_TYPE_CE}, - {"LT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"LU", ESP_PHY_INIT_DATA_TYPE_CE}, - {"LV", ESP_PHY_INIT_DATA_TYPE_CE}, - {"MT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"MX", ESP_PHY_INIT_DATA_TYPE_IFETEL}, - {"NL", ESP_PHY_INIT_DATA_TYPE_CE}, - {"NO", ESP_PHY_INIT_DATA_TYPE_CE}, - {"NZ", ESP_PHY_INIT_DATA_TYPE_RCM}, - {"PL", ESP_PHY_INIT_DATA_TYPE_CE}, - {"PT", ESP_PHY_INIT_DATA_TYPE_CE}, - {"RO", ESP_PHY_INIT_DATA_TYPE_CE}, - {"SE", ESP_PHY_INIT_DATA_TYPE_CE}, - {"SI", ESP_PHY_INIT_DATA_TYPE_CE}, - {"SK", ESP_PHY_INIT_DATA_TYPE_CE}, - {"TW", ESP_PHY_INIT_DATA_TYPE_NCC}, - {"US", ESP_PHY_INIT_DATA_TYPE_FCC}, -}; - -#endif - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -/* Callback function to update WiFi MAC time */ - -wifi_mac_time_update_cb_t g_wifi_mac_time_update_cb = NULL; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: phy_digital_regs_store - * - * Description: - * Store PHY digital registers. - * - ****************************************************************************/ - -static inline void phy_digital_regs_store(void) -{ - if (g_phy_digital_regs_mem == NULL) - { - g_phy_digital_regs_mem = (uint32_t *) - kmm_malloc(SOC_PHY_DIG_REGS_MEM_SIZE); - } - - DEBUGASSERT(g_phy_digital_regs_mem != NULL); - - phy_dig_reg_backup(true, g_phy_digital_regs_mem); -} - -/**************************************************************************** - * Name: phy_digital_regs_load - * - * Description: - * Load PHY digital registers. - * - ****************************************************************************/ - -static inline void phy_digital_regs_load(void) -{ - if (g_phy_digital_regs_mem != NULL) - { - phy_dig_reg_backup(false, g_phy_digital_regs_mem); - } -} - -/**************************************************************************** - * Name: esp_swi_irq - * - * Description: - * Wireless software interrupt callback function. - * - * Parameters: - * cpuint - CPU interrupt index - * context - Context data from the ISR - * arg - NULL - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -static int esp_swi_irq(int irq, void *context, void *arg) -{ - int i; - int ret; - struct esp_semcache_s *sc; - struct esp_semcache_s *sc_tmp; - struct esp_queuecache_s *qc_entry; - struct esp_queuecache_s *qc_tmp; - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - modifyreg32(DPORT_CPU_INTR_FROM_CPU_2_REG, DPORT_CPU_INTR_FROM_CPU_2, 0); - - list_for_every_entry_safe(&priv->sc_list, sc, sc_tmp, - struct esp_semcache_s, node) - { - for (i = 0; i < sc->count; i++) - { - ret = nxsem_post(sc->sem); - if (ret < 0) - { - wlerr("ERROR: Failed to post sem ret=%d\n", ret); - } - } - - sc->count = 0; - list_delete(&sc->node); - } - - list_for_every_entry_safe(&priv->qc_list, qc_entry, qc_tmp, - struct esp_queuecache_s, node) - { - ret = file_mq_send(qc_entry->mq_ptr, (const char *)qc_entry->buffer, - qc_entry->size, 0); - if (ret < 0) - { - wlerr("ERROR: Failed to send queue ret=%d\n", ret); - } - - list_delete(&qc_entry->node); - list_add_tail(&priv->qc_freelist, &qc_entry->node); - } - - return OK; -} - -#ifdef CONFIG_ESP32_WIFI - -/**************************************************************************** - * Name: esp_wifi_set_log_level - * - * Description: - * Sets the log level for the ESP32 WiFi module based on preprocessor - * definitions. The log level can be verbose, warning, or error. - * - * Input Parameters: - * None - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void esp_wifi_set_log_level(void) -{ - wifi_log_level_t wifi_log_level = WIFI_LOG_NONE; - - /* set WiFi log level */ - -#if defined(CONFIG_DEBUG_WIRELESS_INFO) - wifi_log_level = WIFI_LOG_VERBOSE; -#elif defined(CONFIG_DEBUG_WIRELESS_WARN) - wifi_log_level = WIFI_LOG_WARNING; -#elif defined(CONFIG_LOG_MAXIMUM_LEVEL) - wifi_log_level = WIFI_LOG_ERROR; -#endif - - esp_wifi_internal_set_log_level(wifi_log_level); -} -#endif /* CONFIG_ESP32_WIFI */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_to_errno - * - * Description: - * Transform from ESP Wi-Fi error code to NuttX error code - * - * Input Parameters: - * err - ESP Wi-Fi error code - * - * Returned Value: - * NuttX error code defined in errno.h - * - ****************************************************************************/ - -int32_t esp_wifi_to_errno(int err) -{ - int ret; - - if (err < ESP_ERR_WIFI_BASE) - { - /* Unmask component error bits */ - - ret = err & 0xfff; - - switch (ret) - { - case ESP_OK: - ret = OK; - break; - case ESP_ERR_NO_MEM: - ret = -ENOMEM; - break; - - case ESP_ERR_INVALID_ARG: - ret = -EINVAL; - break; - - case ESP_ERR_INVALID_STATE: - ret = -EIO; - break; - - case ESP_ERR_INVALID_SIZE: - ret = -EINVAL; - break; - - case ESP_ERR_NOT_FOUND: - ret = -ENOSYS; - break; - - case ESP_ERR_NOT_SUPPORTED: - ret = -ENOSYS; - break; - - case ESP_ERR_TIMEOUT: - ret = -ETIMEDOUT; - break; - - case ESP_ERR_INVALID_MAC: - ret = -EINVAL; - break; - - default: - ret = ERROR; - break; - } - } - else - { - ret = ERROR; - } - - if (ret != OK) - { - wlerr("ERROR: %s\n", esp_err_to_name(err)); - } - - return ret; -} - -/**************************************************************************** - * Functions needed by libphy.a - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_dport_access_reg_read - * - * Description: - * Read register value safely in SMP - * - * Input Parameters: - * reg - Register address - * - * Returned Value: - * Register value - * - ****************************************************************************/ - -uint32_t IRAM_ATTR esp_dport_access_reg_read(uint32_t reg) -{ - return getreg32(reg); -} - -/**************************************************************************** - * Name: phy_printf - * - * Description: - * Output format string and its arguments - * - * Input Parameters: - * format - format string - * - * Returned Value: - * 0 - * - ****************************************************************************/ - -int phy_printf(const char *format, ...) -{ -#ifdef CONFIG_DEBUG_WIRELESS_INFO - va_list arg; - - va_start(arg, format); - vsyslog(LOG_INFO, format, arg); - va_end(arg); -#endif - - return 0; -} - -#ifdef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA - -/**************************************************************************** - * Name: phy_crc_check - * - * Description: - * Check the checksum value of data - * - * Input Parameters: - * data - Data buffer pointer - * length - Data length - * checksum - Checksum pointer - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_crc_check(uint8_t *data, const uint8_t *checksum, - size_t length) -{ - uint32_t crc_data = crc32_le(0, data, length); - uint32_t crc_size_conversion = HTONL(crc_data); - uint32_t tmp_crc = checksum[0] | (checksum[1] << 8) | (checksum[2] << 16) | - (checksum[3] << 24); - if (crc_size_conversion != tmp_crc) - { - return ERROR; - } - - return OK; -} - -/**************************************************************************** - * Name: phy_find_bin_type_according_country - * - * Description: - * Find the PHY initialization data type according to country code - * - * Input Parameters: - * country - Country code pointer - * - * Returned Value: - * PHY initialization data type - * - ****************************************************************************/ - -static uint8_t phy_find_bin_type_according_country(const char *country) -{ - uint8_t i; - uint8_t phy_init_data_type; - uint8_t num = nitems(g_country_code_map_type_table); - for (i = 0; i < num; i++) - { - if (memcmp(country, g_country_code_map_type_table[i].cc, - sizeof(g_phy_current_country)) == 0) - { - phy_init_data_type = g_country_code_map_type_table[i].type; - wlinfo("Current country is %c%c, PHY init data type is %s\n", - g_country_code_map_type_table[i].cc[0], - g_country_code_map_type_table[i].cc[1], - g_phy_type[g_country_code_map_type_table[i].type]); - break; - } - } - - if (i == num) - { - phy_init_data_type = ESP_PHY_INIT_DATA_TYPE_DEFAULT; - wlerr("Use the default certification code beacuse %c%c doesn't " - "have a certificate\n", country[0], country[1]); - } - - return phy_init_data_type; -} - -/**************************************************************************** - * Name: phy_find_bin_data_according_type - * - * Description: - * Find the PHY initialization data according to PHY init data type - * - * Input Parameters: - * output_data - Output data buffer pointer - * control_info - PHY init data control infomation - * input_data - Input data buffer pointer - * init_data_type - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_find_bin_data_according_type(uint8_t *output_data, - const phy_control_info_data_t *control_info, - const esp_phy_init_data_t *input_data, - phy_init_data_type_t init_data_type) -{ - int i; - for (i = 0; i < control_info->number; i++) - { - if (init_data_type == *((uint8_t *)(input_data + i) - + PHY_INIT_DATA_TYPE_OFFSET)) - { - memcpy(output_data + sizeof(phy_init_magic_pre), - (input_data + i), sizeof(esp_phy_init_data_t)); - break; - } - } - - if (i == control_info->number) - { - return ERROR; - } - - return OK; -} - -/**************************************************************************** - * Name: phy_get_multiple_init_data - * - * Description: - * Get multiple PHY init data according to PHY init data type - * - * Input Parameters: - * data - Data buffer pointer - * length - Data length - * init_data_type - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_get_multiple_init_data(uint8_t *data, size_t length, - phy_init_data_type_t init_data_type) -{ - phy_control_info_data_t *control_info = (phy_control_info_data_t *) - kmm_malloc(sizeof(phy_control_info_data_t)); - if (control_info == NULL) - { - wlerr("ERROR: Failed to allocate memory for\ - PHY init data control info\n"); - return -ENOMEM; - } - - int ret = esp32_partition_read(phy_partion_label, - length, - control_info, - sizeof(phy_control_info_data_t)); - if (ret != OK) - { - kmm_free(control_info); - wlerr("ERROR: Failed to read PHY control info data partition\n"); - return ret; - } - - if ((control_info->check_algorithm) == PHY_CRC_ALGORITHM) - { - ret = phy_crc_check(control_info->multiple_bin_checksum, - control_info->control_info_checksum, - sizeof(phy_control_info_data_t) - - sizeof(control_info->control_info_checksum)); - if (ret != OK) - { - kmm_free(control_info); - wlerr("ERROR: PHY init data control info check error\n"); - return ret; - } - } - else - { - kmm_free(control_info); - wlerr("ERROR: Check algorithm not CRC, PHY init data update failed\n"); - return ERROR; - } - - uint8_t *init_data_multiple = (uint8_t *) - kmm_malloc(sizeof(esp_phy_init_data_t) * control_info->number); - if (init_data_multiple == NULL) - { - kmm_free(control_info); - wlerr("ERROR: Failed to allocate memory for PHY init data\n"); - return -ENOMEM; - } - - ret = esp32_partition_read(phy_partion_label, length + - sizeof(phy_control_info_data_t), init_data_multiple, - sizeof(esp_phy_init_data_t) * control_info->number); - if (ret != OK) - { - kmm_free(init_data_multiple); - kmm_free(control_info); - wlerr("ERROR: Failed to read PHY init data multiple bin partition\n"); - return ret; - } - - if ((control_info->check_algorithm) == PHY_CRC_ALGORITHM) - { - ret = phy_crc_check(init_data_multiple, - control_info->multiple_bin_checksum, - sizeof(esp_phy_init_data_t) * control_info->number); - if (ret != OK) - { - kmm_free(init_data_multiple); - kmm_free(control_info); - wlerr("ERROR: PHY init data multiple bin check error\n"); - return ret; - } - } - else - { - kmm_free(init_data_multiple); - kmm_free(control_info); - wlerr("ERROR: Check algorithm not CRC, PHY init data update failed\n"); - return ERROR; - } - - ret = phy_find_bin_data_according_type(data, control_info, - (const esp_phy_init_data_t *)init_data_multiple, init_data_type); - if (ret != OK) - { - wlerr("ERROR: %s has not been certified, use DEFAULT PHY init data\n", - g_phy_type[init_data_type]); - g_phy_init_data_type = ESP_PHY_INIT_DATA_TYPE_DEFAULT; - } - else - { - g_phy_init_data_type = init_data_type; - } - - kmm_free(init_data_multiple); - kmm_free(control_info); - return OK; -} - -/**************************************************************************** - * Name: phy_update_init_data - * - * Description: - * Update PHY init data according to PHY init data type - * - * Input Parameters: - * init_data_type - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int phy_update_init_data(phy_init_data_type_t init_data_type) -{ - int ret; - size_t length = sizeof(phy_init_magic_pre) + - sizeof(esp_phy_init_data_t) + sizeof(phy_init_magic_post); - uint8_t *init_data_store = kmm_malloc(length); - if (init_data_store == NULL) - { - wlerr("ERROR: Failed to allocate memory for updated country code " - "PHY init data\n"); - return -ENOMEM; - } - - ret = esp32_partition_read(phy_partion_label, 0, init_data_store, length); - if (ret != OK) - { - kmm_free(init_data_store); - wlerr("ERROR: Failed to read updated country code PHY data\n"); - return ret; - } - - if (memcmp(init_data_store, PHY_INIT_MAGIC, - sizeof(phy_init_magic_pre)) != 0 || - memcmp(init_data_store + length - sizeof(phy_init_magic_post), - PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) - { - kmm_free(init_data_store); - wlerr("ERROR: Failed to validate updated country code PHY data\n"); - return ERROR; - } - - /* find init data bin according init data type */ - - if (init_data_type != ESP_PHY_INIT_DATA_TYPE_DEFAULT) - { - ret = phy_get_multiple_init_data(init_data_store, length, - init_data_type); - if (ret != OK) - { - kmm_free(init_data_store); -#ifdef CONFIG_ESP32_PHY_INIT_DATA_ERROR - abort(); -#else - return ret; -#endif - } - } - else - { - g_phy_init_data_type = ESP_PHY_INIT_DATA_TYPE_DEFAULT; - } - - if (g_current_apply_phy_init_data != g_phy_init_data_type) - { - ret = esp_phy_apply_phy_init_data(init_data_store + - sizeof(phy_init_magic_pre)); - if (ret != OK) - { - wlerr("ERROR: PHY init data failed to load\n"); - kmm_free(init_data_store); - return ret; - } - - wlinfo("PHY init data type updated from %s to %s\n", - g_phy_type[g_current_apply_phy_init_data], - g_phy_type[g_phy_init_data_type]); - g_current_apply_phy_init_data = g_phy_init_data_type; - } - - kmm_free(init_data_store); - return OK; -} - -#endif - -#ifdef CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION - -/**************************************************************************** - * Name: esp_phy_get_init_data - * - * Description: - * Get PHY init data - * - * Input Parameters: - * None - * - * Returned Value: - * Pointer to PHY init data structure - * - ****************************************************************************/ - -const esp_phy_init_data_t *esp_phy_get_init_data(void) -{ - int ret; - size_t length = sizeof(phy_init_magic_pre) + - sizeof(esp_phy_init_data_t) + sizeof(phy_init_magic_post); - uint8_t *init_data_store = kmm_malloc(length); - if (init_data_store == NULL) - { - wlerr("ERROR: Failed to allocate memory for PHY init data\n"); - return NULL; - } - - ret = esp32_partition_read(phy_partion_label, 0, init_data_store, length); - if (ret != OK) - { - wlerr("ERROR: Failed to get read data from MTD\n"); - kmm_free(init_data_store); - return NULL; - } - - if (memcmp(init_data_store, PHY_INIT_MAGIC, sizeof(phy_init_magic_pre)) - != 0 || memcmp(init_data_store + length - sizeof(phy_init_magic_post), - PHY_INIT_MAGIC, sizeof(phy_init_magic_post)) != 0) - { -#ifdef CONFIG_ESP32_PHY_DEFAULT_INIT_IF_INVALID - wlerr("ERROR: Failed to validate PHY data partition, restoring " - "default data into flash..."); - memcpy(init_data_store, PHY_INIT_MAGIC, sizeof(phy_init_magic_pre)); - memcpy(init_data_store + sizeof(phy_init_magic_pre), - &phy_init_data, sizeof(phy_init_data)); - memcpy(init_data_store + sizeof(phy_init_magic_pre) + - sizeof(phy_init_data), PHY_INIT_MAGIC, - sizeof(phy_init_magic_post)); - DEBUGASSERT(memcmp(init_data_store, PHY_INIT_MAGIC, - sizeof(phy_init_magic_pre)) == 0); - DEBUGASSERT(memcmp(init_data_store + length - - sizeof(phy_init_magic_post), PHY_INIT_MAGIC, - sizeof(phy_init_magic_post)) == 0); - - /* write default data */ - - ret = esp32_partition_write(phy_partion_label, 0, init_data_store, - length); - if (ret != OK) - { - wlerr("ERROR: Failed to write default PHY data partition\n"); - kmm_free(init_data_store); - return NULL; - } -#else /* CONFIG_ESP32_PHY_DEFAULT_INIT_IF_INVALID */ - wlerr("ERROR: Failed to validate PHY data partition\n"); - kmm_free(init_data_store); - return NULL; -#endif - } - -#ifdef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA - if (*(init_data_store + (sizeof(phy_init_magic_pre) + - PHY_SUPPORT_MULTIPLE_BIN_OFFSET))) - { - g_multiple_phy_init_data_bin = true; - wlinfo("Support multiple PHY init data bins\n"); - } - else - { - wlinfo("Does not support multiple PHY init data bins\n"); - } -#endif - - wlinfo("PHY data partition validated\n"); - return (const esp_phy_init_data_t *) - (init_data_store + sizeof(phy_init_magic_pre)); -} - -/**************************************************************************** - * Name: esp_phy_release_init_data - * - * Description: - * Release PHY init data - * - * Input Parameters: - * init_data - Pointer to PHY init data structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_phy_release_init_data(const esp_phy_init_data_t *init_data) -{ - kmm_free((uint8_t *)init_data - sizeof(phy_init_magic_pre)); -} - -#else /* CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION */ - -/**************************************************************************** - * Name: esp_phy_get_init_data - * - * Description: - * Get PHY init data - * - * Input Parameters: - * None - * - * Returned Value: - * Pointer to PHY init data structure - * - ****************************************************************************/ - -const esp_phy_init_data_t *esp_phy_get_init_data(void) -{ - wlinfo("Loading PHY init data from application binary\n"); - return &phy_init_data; -} - -/**************************************************************************** - * Name: esp_phy_release_init_data - * - * Description: - * Release PHY init data - * - * Input Parameters: - * init_data - Pointer to PHY init data structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -void esp_phy_release_init_data(const esp_phy_init_data_t *init_data) -{ -} -#endif - -/**************************************************************************** - * Name: esp32_phy_update_country_info - * - * Description: - * Update PHY init data according to country code - * - * Input Parameters: - * country - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -int esp32_phy_update_country_info(const char *country) -{ -#ifdef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA - uint8_t phy_init_data_type_map = 0; - if (memcmp(country, g_phy_current_country, sizeof(g_phy_current_country)) - == 0) - { - return OK; - } - - memcpy(g_phy_current_country, country, sizeof(g_phy_current_country)); - if (!g_multiple_phy_init_data_bin) - { - wlerr("ERROR: Does not support multiple PHY init data bins\n"); - return ERROR; - } - - phy_init_data_type_map = phy_find_bin_type_according_country(country); - if (phy_init_data_type_map == g_phy_init_data_type) - { - return OK; - } - - int ret = phy_update_init_data(phy_init_data_type_map); - if (ret != OK) - { - wlerr("ERROR: Failed to update PHY init data\n"); - return ret; - } -#endif - - return OK; -} - -/**************************************************************************** - * Name: esp_timer_create - * - * Description: - * Create timer with given arguments - * - * Input Parameters: - * create_args - Timer arguments data pointer - * out_handle - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_create(const esp_timer_create_args_t *create_args, - esp_timer_handle_t *out_handle) -{ - int ret; - struct rt_timer_args_s rt_timer_args; - struct rt_timer_s *rt_timer; - - rt_timer_args.arg = create_args->arg; - rt_timer_args.callback = create_args->callback; - - ret = rt_timer_create(&rt_timer_args, &rt_timer); - if (ret) - { - wlerr("Failed to create rt_timer error=%d\n", ret); - return ret; - } - - *out_handle = (esp_timer_handle_t)rt_timer; - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_start_once - * - * Description: - * Start timer with one shot mode - * - * Input Parameters: - * timer - Timer handle pointer - * timeout_us - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - rt_timer_start(rt_timer, timeout_us, false); - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_start_periodic - * - * Description: - * Start timer with periodic mode - * - * Input Parameters: - * timer - Timer handle pointer - * period - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - rt_timer_start(rt_timer, period, true); - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_stop - * - * Description: - * Stop timer - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_stop(esp_timer_handle_t timer) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - rt_timer_stop(rt_timer); - - return 0; -} - -/**************************************************************************** - * Name: esp_timer_delete - * - * Description: - * Delete timer and free resource - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_delete(esp_timer_handle_t timer) -{ - struct rt_timer_s *rt_timer = (struct rt_timer_s *)timer; - - rt_timer_delete(rt_timer); - - return 0; -} - -/**************************************************************************** - * Name: esp_init_semcache - * - * Description: - * Initialize semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * sem - Semaphore data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_semcache(struct esp_semcache_s *sc, sem_t *sem) -{ - sc->sem = sem; - sc->count = 0; - list_initialize(&sc->node); -} - -/**************************************************************************** - * Name: esp_post_semcache - * - * Description: - * Store posting semaphore action into semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -IRAM_ATTR void esp_post_semcache(struct esp_semcache_s *sc) -{ - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - if (!sc->count) - { - list_add_tail(&priv->sc_list, &sc->node); - } - - sc->count++; - - /* Enable CPU 2 interrupt. This will generate an IRQ as soon as non-IRAM - * are (re)enabled. - */ - - modifyreg32(DPORT_CPU_INTR_FROM_CPU_2_REG, 0, DPORT_CPU_INTR_FROM_CPU_2); -} - -/**************************************************************************** - * Name: esp_init_queuecache - * - * Description: - * Initialize queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * mq_ptr - Queue data pointer - * buffer - Queue cache buffer pointer - * len - Queue cache max length - * size - Queue cache buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_queuecache(struct esp_queuecache_s *qc, - struct file *mq_ptr, - uint8_t *buffer, - size_t len, - size_t size) -{ - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - int i; - - for (i = 0; i < len; i++) - { - qc[i].mq_ptr = mq_ptr; - qc[i].size = size; - qc[i].buffer = buffer; - list_initialize(&qc[i].node); - - list_add_tail(&priv->qc_freelist, &qc[i].node); - } -} - -/**************************************************************************** - * Name: esp_send_queuecache - * - * Description: - * Store posting queue action and data into queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * buffer - Data buffer - * size - Buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -IRAM_ATTR void esp_send_queuecache(void *queue, uint8_t *buffer, int size) -{ - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - struct esp_queuecache_s *msg; - irqstate_t flags; - - flags = enter_critical_section(); - - msg = (struct esp_queuecache_s *)list_remove_head(&priv->qc_freelist); - DEBUGASSERT(msg != NULL); - - DEBUGASSERT(msg->size == size); - DEBUGASSERT(msg->mq_ptr == queue); - - memcpy(msg->buffer, buffer, size); - - list_add_tail(&priv->qc_list, &msg->node); - - leave_critical_section(flags); - - /* Enable CPU 2 interrupt. This will generate an IRQ as soon as non-IRAM - * are (re)enabled. - */ - - modifyreg32(DPORT_CPU_INTR_FROM_CPU_2_REG, 0, DPORT_CPU_INTR_FROM_CPU_2); -} - -/**************************************************************************** - * Name: esp_wireless_init - * - * Description: - * Initialize ESP32 wireless common components for both BT and Wi-Fi. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_init(void) -{ - int ret; - irqstate_t flags; - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - flags = enter_critical_section(); - if (priv->ref != 0) - { - priv->ref++; - leave_critical_section(flags); - return OK; - } - - priv->cpuint = esp32_setup_irq(0, SWI_PERIPH, 1, ESP32_CPUINT_LEVEL); - if (priv->cpuint < 0) - { - /* Failed to allocate a CPU interrupt of this type. */ - - wlerr("ERROR: Failed to attach IRQ ret=%d\n", ret); - ret = priv->cpuint; - leave_critical_section(flags); - - return ret; - } - - ret = irq_attach(SWI_IRQ, esp_swi_irq, NULL); - if (ret < 0) - { - esp32_teardown_irq(0, SWI_PERIPH, priv->cpuint); - leave_critical_section(flags); - wlerr("ERROR: Failed to attach IRQ ret=%d\n", ret); - - return ret; - } - - list_initialize(&priv->sc_list); - list_initialize(&priv->qc_list); - list_initialize(&priv->qc_freelist); - - up_enable_irq(SWI_IRQ); - - priv->ref++; - - leave_critical_section(flags); - - return OK; -} - -/**************************************************************************** - * Name: esp_wireless_deinit - * - * Description: - * De-initialize ESP32 wireless common components. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_deinit(void) -{ - irqstate_t flags; - struct esp_wireless_priv_s *priv = &g_esp_wireless_priv; - - flags = enter_critical_section(); - - if (priv->ref > 0) - { - priv->ref--; - if (priv->ref == 0) - { - up_disable_irq(SWI_IRQ); - irq_detach(SWI_IRQ); - esp32_teardown_irq(0, SWI_PERIPH, priv->cpuint); - } - } - - leave_critical_section(flags); - - return OK; -} - -#ifdef CONFIG_ESP32_WIFI - -/**************************************************************************** - * Name: esp_wifi_init - * - * Description: - * Initialize Wi-Fi - * - * Input Parameters: - * config - Initialization config parameters - * - * Returned Value: - * 0 if success or others if fail - * - ****************************************************************************/ - -int32_t esp_wifi_init(const wifi_init_config_t *config) -{ - int32_t ret; - - esp_wifi_power_domain_on(); - -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST - ret = coex_init(); - if (ret) - { - wlerr("ERROR: Failed to initialize coex error=%d\n", ret); - return ret; - } -#endif /* CONFIG_ESP32_WIFI_BT_COEXIST */ - - esp_wifi_set_log_level(); - - ret = esp_wifi_init_internal(config); - if (ret) - { - wlerr("Failed to initialize Wi-Fi error=%d\n", ret); - return ret; - } - -#if CONFIG_MAC_BB_PD - esp_mac_bb_pd_mem_init(); - esp_wifi_internal_set_mac_sleep(true); -#endif - - esp_phy_modem_init(); - - g_wifi_mac_time_update_cb = esp_wifi_internal_update_mac_time; - - ret = esp_supplicant_init(); - if (ret) - { - wlerr("Failed to initialize WPA supplicant error=%d\n", ret); - esp_wifi_deinit_internal(); - return ret; - } - - return 0; -} - -/**************************************************************************** - * Name: esp_wifi_deinit - * - * Description: - * Deinitialize Wi-Fi and free resource - * - * Input Parameters: - * None - * - * Returned Value: - * 0 if success or others if fail - * - ****************************************************************************/ - -int32_t esp_wifi_deinit(void) -{ - int ret; - - ret = esp_supplicant_deinit(); - if (ret) - { - wlerr("Failed to deinitialize supplicant\n"); - return ret; - } - - ret = esp_wifi_deinit_internal(); - if (ret != 0) - { - wlerr("Failed to deinitialize Wi-Fi\n"); - return ret; - } - - return ret; -} -#endif /* CONFIG_ESP32_WIFI */ diff --git a/arch/xtensa/src/esp32/esp32_wireless.h b/arch/xtensa/src/esp32/esp32_wireless.h deleted file mode 100644 index 27edf9a80d69b..0000000000000 --- a/arch/xtensa/src/esp32/esp32_wireless.h +++ /dev/null @@ -1,376 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_wireless.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WIRELESS_H -#define __ARCH_XTENSA_SRC_ESP32_ESP32_WIRELESS_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ -#include -#include -#include - -#include -#include - -#include "xtensa_attr.h" -#include "esp32_rt_timer.h" - -#include "esp_log.h" -#include "esp_mac.h" -#include "esp_private/phy.h" -#include "esp_private/wifi.h" -#include "esp_random.h" -#include "esp_timer.h" -#include "rom/ets_sys.h" -#include "soc/soc_caps.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Note: Don't remove these definitions, they are needed by the 3rdparty IDF - * headers - */ - -#ifdef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA -# undef CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN -# define CONFIG_ESP32_SUPPORT_MULTIPLE_PHY_INIT_DATA_BIN 1 -#endif -#define CONFIG_MAC_BB_PD 0 -#define SOC_COEX_HW_PTI 0 - -#define MAC_LEN (6) - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/* Semaphore Cache Data */ - -struct esp_semcache_s -{ - struct list_node node; - - sem_t *sem; - uint32_t count; -}; - -/* Queue Cache Data */ - -struct esp_queuecache_s -{ - struct list_node node; - - struct file *mq_ptr; - size_t size; - uint8_t *buffer; -}; - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: nuttx_err_to_freertos - * - * Description: - * Transform from Nuttx OS error code to FreeRTOS's pdTRUE or pdFALSE. - * - * Input Parameters: - * ret - NuttX error code - * - * Returned Value: - * Wi-Fi adapter error code - * - ****************************************************************************/ - -static inline int32_t nuttx_err_to_freertos(int ret) -{ - return ret >= 0; -} - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_wifi_to_errno - * - * Description: - * Transform from ESP Wi-Fi error code to NuttX error code - * - * Input Parameters: - * err - ESP Wi-Fi error code - * - * Returned Value: - * NuttX error code defined in errno.h - * - ****************************************************************************/ - -int32_t esp_wifi_to_errno(int err); - -/**************************************************************************** - * Functions needed by libphy.a - ****************************************************************************/ - -/**************************************************************************** - * Name: esp_dport_access_reg_read - * - * Description: - * Read register value safely in SMP - * - * Input Parameters: - * reg - Register address - * - * Returned Value: - * Register value - * - ****************************************************************************/ - -uint32_t IRAM_ATTR esp_dport_access_reg_read(uint32_t reg); - -/**************************************************************************** - * Name: phy_printf - * - * Description: - * Output format string and its arguments - * - * Input Parameters: - * format - format string - * - * Returned Value: - * 0 - * - ****************************************************************************/ - -int phy_printf(const char *format, ...) printf_like(1, 2); - -/**************************************************************************** - * Name: esp_timer_create - * - * Description: - * Create timer with given arguments - * - * Input Parameters: - * create_args - Timer arguments data pointer - * out_handle - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_create(const esp_timer_create_args_t *create_args, - esp_timer_handle_t *out_handle); - -/**************************************************************************** - * Name: esp_timer_start_once - * - * Description: - * Start timer with one shot mode - * - * Input Parameters: - * timer - Timer handle pointer - * timeout_us - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us); - -/**************************************************************************** - * Name: esp_timer_start_periodic - * - * Description: - * Start timer with periodic mode - * - * Input Parameters: - * timer - Timer handle pointer - * period - Timeout value by micro second - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period); - -/**************************************************************************** - * Name: esp_timer_stop - * - * Description: - * Stop timer - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_stop(esp_timer_handle_t timer); - -/**************************************************************************** - * Name: esp_timer_delete - * - * Description: - * Delete timer and free resource - * - * Input Parameters: - * timer - Timer handle pointer - * - * Returned Value: - * 0 if success or -1 if fail - * - ****************************************************************************/ - -int32_t esp_timer_delete(esp_timer_handle_t timer); - -/**************************************************************************** - * Name: esp32_phy_update_country_info - * - * Description: - * Update PHY init data according to country code - * - * Input Parameters: - * country - PHY init data type - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -int esp32_phy_update_country_info(const char *country); - -/**************************************************************************** - * Name: esp_init_semcache - * - * Description: - * Initialize semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * sem - Semaphore data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_semcache(struct esp_semcache_s *sc, sem_t *sem); - -/**************************************************************************** - * Name: esp_post_semcache - * - * Description: - * Store posting semaphore action into semaphore cache. - * - * Parameters: - * sc - Semaphore cache data pointer - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_post_semcache(struct esp_semcache_s *sc); - -/**************************************************************************** - * Name: esp_init_queuecache - * - * Description: - * Initialize queue cache. - * - * Parameters: - * qc - Queue cache data pointer - * mq_ptr - Queue data pointer - * buffer - Queue cache buffer pointer - * len - Queue cache max length - * size - Queue cache buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_init_queuecache(struct esp_queuecache_s *qc, - struct file *mq_ptr, - uint8_t *buffer, - size_t len, - size_t size); - -/**************************************************************************** - * Name: esp32_wl_send_queuecache - * - * Description: - * Store posting queue action and data into queue cache. - * - * Parameters: - * queue - Pointer to the queue - * buffer - Data buffer - * size - Buffer size - * - * Returned Value: - * None. - * - ****************************************************************************/ - -void esp_send_queuecache(void *queue, uint8_t *buffer, int size); - -/**************************************************************************** - * Name: esp_wireless_init - * - * Description: - * Initialize ESP32 wireless common components for both BT and Wi-Fi. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_init(void); - -/**************************************************************************** - * Name: esp_wireless_deinit - * - * Description: - * De-initialize ESP32 wireless common components. - * - * Parameters: - * None - * - * Returned Value: - * Zero (OK) is returned on success. A negated errno value is returned on - * failure. - * - ****************************************************************************/ - -int esp_wireless_deinit(void); - -#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WIRELESS_H */ diff --git a/arch/xtensa/src/esp32/esp32_wlan.c b/arch/xtensa/src/esp32/esp32_wlan.c deleted file mode 100644 index aa860b1d5eb53..0000000000000 --- a/arch/xtensa/src/esp32/esp32_wlan.c +++ /dev/null @@ -1,1845 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_wlan.c - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#ifdef CONFIG_ESP32_WIFI - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(CONFIG_NET_PKT) -# include -#endif - -#include "esp32_wlan.h" -#include "esp32_wifi_utils.h" -#include "esp32_wifi_adapter.h" -#include "esp32_systemreset.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* TX timeout = 1 minute */ - -#define WLAN_TXTOUT (60 * CLK_TCK) - -/* Low-priority work queue processes RX/TX */ - -#define WLAN_WORK LPWORK - -/* Ethernet frame: - * Resource address : 6 bytes - * Destination address: 6 bytes - * Type : 2 bytes - * Payload : MAX 1500 - * Checksum : Ignore - * - * Total size : 1514 - */ - -#define WLAN_BUF_SIZE (CONFIG_NET_ETH_PKTSIZE) - -/* WLAN packet buffer number */ - -#define WLAN_PKTBUF_NUM (CONFIG_ESP32_WLAN_PKTBUF_NUM) - -/* Receive threshold which allows the receive function to trigger a scheduler - * to activate the application if possible. - */ - -#ifdef CONFIG_MM_IOB -# define IOBBUF_SIZE (CONFIG_IOB_NBUFFERS * CONFIG_IOB_BUFSIZE) -# if (IOBBUF_SIZE) > (WLAN_BUF_SIZE + 1) -# define WLAN_RX_THRESHOLD (IOBBUF_SIZE - WLAN_BUF_SIZE + 1) -# endif -#endif - -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - -/* The smallest available heap is to ensure that Wi-Fi is not disconnected */ - -# define MINIMUM_HEAP_SIZE (6000) -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/* WLAN packet buffer */ - -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION -struct wlan_pktbuf -{ - sq_entry_t entry; /* Queue entry */ - uint16_t len; /* Packet data length */ - uint8_t buffer[0]; /* Packet data */ -}; -#else -struct wlan_pktbuf -{ - sq_entry_t entry; /* Queue entry */ - - /* Packet data buffer */ - - uint8_t buffer[WLAN_BUF_SIZE]; - uint16_t len; /* Packet data length */ -}; -#endif - -/* WLAN operations */ - -struct wlan_ops -{ - int (*start)(void); - int (*send)(void *pdata, size_t n); - int (*essid)(struct iwreq *iwr, bool set); - int (*bssid)(struct iwreq *iwr, bool set); - int (*passwd)(struct iwreq *iwr, bool set); - int (*mode)(struct iwreq *iwr, bool set); - int (*auth)(struct iwreq *iwr, bool set); - int (*freq)(struct iwreq *iwr, bool set); - int (*bitrate)(struct iwreq *iwr, bool set); - int (*txpower)(struct iwreq *iwr, bool set); - int (*channel)(struct iwreq *iwr, bool set); - int (*country)(struct iwreq *iwr, bool set); - int (*rssi)(struct iwreq *iwr, bool set); - int (*connect)(void); - int (*disconnect)(void); - int (*event)(pid_t pid, struct sigevent *event); - int (*stop)(void); -}; - -/* The wlan_priv_s encapsulates all state information for a single - * hardware interface - */ - -struct wlan_priv_s -{ - int ref; /* Referernce count */ - - bool ifup; /* true:ifup false:ifdown */ - - struct wdog_s txtimeout; /* TX timeout timer */ - - struct work_s rxwork; /* Send packet work */ - struct work_s txwork; /* Receive packet work */ - struct work_s pollwork; /* Poll work */ - struct work_s toutwork; /* Send packet timeout work */ - - const struct wlan_ops *ops; /* WLAN operations */ - - /* This holds the information visible to the NuttX network */ - - struct net_driver_s dev; - - /* Packet buffer cache */ - -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - struct wlan_pktbuf *pktbuf; -#else - struct wlan_pktbuf pktbuf[WLAN_PKTBUF_NUM]; -#endif - - /* RX packet queue */ - - sq_queue_t rxb; - - /* TX ready packet queue */ - - sq_queue_t txb; - - /* Free packet buffer queue */ - - sq_queue_t freeb; - - /* Device specific lock */ - - spinlock_t lock; -}; - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* Reference count of register Wi-Fi handler */ - -static uint8_t g_callback_register_ref; - -static struct wlan_priv_s g_wlan_priv[ESP32_WLAN_DEVS]; - -#ifdef ESP32_WLAN_HAS_STA -static const struct wlan_ops g_sta_ops = -{ - .start = esp_wifi_sta_start, - .send = esp_wifi_sta_send_data, - .essid = esp_wifi_sta_essid, - .bssid = esp_wifi_sta_bssid, - .passwd = esp_wifi_sta_password, - .mode = esp_wifi_sta_mode, - .auth = esp_wifi_sta_auth, - .freq = esp_wifi_sta_freq, - .bitrate = esp_wifi_sta_bitrate, - .txpower = esp_wifi_sta_txpower, - .channel = esp_wifi_sta_channel, - .country = esp_wifi_sta_country, - .rssi = esp_wifi_sta_rssi, - .connect = esp_wifi_sta_connect, - .disconnect = esp_wifi_sta_disconnect, - .event = esp_wifi_notify_subscribe, - .stop = esp_wifi_sta_stop -}; -#endif /* ESP32_WLAN_HAS_STA */ - -#ifdef ESP32_WLAN_HAS_SOFTAP -static const struct wlan_ops g_softap_ops = -{ - .start = esp_wifi_softap_start, - .send = esp_wifi_softap_send_data, - .essid = esp_wifi_softap_essid, - .bssid = esp_wifi_softap_bssid, - .passwd = esp_wifi_softap_password, - .mode = esp_wifi_softap_mode, - .auth = esp_wifi_softap_auth, - .freq = esp_wifi_softap_freq, - .bitrate = esp_wifi_softap_bitrate, - .txpower = esp_wifi_softap_txpower, - .channel = esp_wifi_softap_channel, - .country = esp_wifi_softap_country, - .rssi = esp_wifi_softap_rssi, - .connect = esp_wifi_softap_connect, - .disconnect = esp_wifi_softap_disconnect, - .event = esp_wifi_notify_subscribe, - .stop = esp_wifi_softap_stop -}; -#endif /* ESP32_WLAN_HAS_SOFTAP */ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* Common TX logic */ - -static void wlan_transmit(struct wlan_priv_s *priv); -static void wlan_rxpoll(void *arg); -static int wlan_txpoll(struct net_driver_s *dev); -static void wlan_dopoll(struct wlan_priv_s *priv); - -/* Watchdog timer expirations */ - -static void wlan_txtimeout_work(void *arg); -static void wlan_txtimeout_expiry(wdparm_t arg); - -/* NuttX callback functions */ - -static int wlan_ifup(struct net_driver_s *dev); -static int wlan_ifdown(struct net_driver_s *dev); - -static void wlan_txavail_work(void *arg); -static int wlan_txavail(struct net_driver_s *dev); - -#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) -static int wlan_addmac(struct net_driver_s *dev, const uint8_t *mac); -#endif - -#ifdef CONFIG_NET_MCASTGROUP -static int wlan_rmmac(struct net_driver_s *dev, const uint8_t *mac); -#endif - -#ifdef CONFIG_NETDEV_IOCTL -static int wlan_ioctl(struct net_driver_s *dev, int cmd, - unsigned long arg); -#endif - -static struct wlan_pktbuf *wlan_recvframe(struct wlan_priv_s *priv); -static struct wlan_pktbuf *wlan_txframe(struct wlan_priv_s *priv); -static inline void wlan_free_buffer(struct wlan_priv_s *priv, - uint8_t *buffer); - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* Note: - * All TX done/RX done/Error trigger functions are not called from - * interrupts, this is much different from ethernet driver, including: - * * wlan_rx_done - * * wlan_tx_done - * - * These functions are called in a Wi-Fi private thread. So we just use - * mutex/semaphore instead of disable interrupt, if necessary. - */ - -/**************************************************************************** - * Function: wlan_init_buffer - * - * Description: - * Initialize the free buffer list - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_init_buffer(struct wlan_priv_s *priv) -{ - irqstate_t flags; - -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - flags = spin_lock_irqsave(&priv->lock); - - priv->dev.d_buf = NULL; - priv->dev.d_len = 0; - - sq_init(&priv->rxb); - sq_init(&priv->txb); - - spin_unlock_irqrestore(&priv->lock, flags); -#else - int i; - flags = spin_lock_irqsave(&priv->lock); - - priv->dev.d_buf = NULL; - priv->dev.d_len = 0; - - sq_init(&priv->freeb); - sq_init(&priv->rxb); - sq_init(&priv->txb); - - for (i = 0; i < WLAN_PKTBUF_NUM; i++) - { - sq_addlast(&priv->pktbuf[i].entry, &priv->freeb); - } - - spin_unlock_irqrestore(&priv->lock, flags); -#endif -} - -/**************************************************************************** - * Function: wlan_deinit_buffer - * - * Description: - * De-initialize the buffer list - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None. - * - ****************************************************************************/ - -static inline void wlan_deinit_buffer(struct wlan_priv_s *priv) -{ -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - struct wlan_pktbuf *pktbuf; - while ((pktbuf = (struct wlan_pktbuf *)wlan_recvframe(priv)) != NULL) - { - wlan_free_buffer(priv, (void *)pktbuf->buffer); - } - - while ((pktbuf = (struct wlan_pktbuf *)wlan_txframe(priv)) != NULL) - { - wlan_free_buffer(priv, (void *)pktbuf->buffer); - } - - sq_init(&priv->rxb); - sq_init(&priv->txb); -#endif -} - -/**************************************************************************** - * Function: wlan_alloc_buffer - * - * Description: - * Allocate one buffer from the free buffer queue - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * Pointer to the allocated buffer on success; NULL on failure - * - ****************************************************************************/ - -static inline struct wlan_pktbuf *wlan_alloc_buffer(struct wlan_priv_s *priv) -{ - struct wlan_pktbuf *pktbuf = NULL; - -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - struct mallinfo info = kmm_mallinfo(); - if (info.fordblks < MINIMUM_HEAP_SIZE) - { - return NULL; - } - - pktbuf = kmm_malloc(sizeof(struct wlan_pktbuf) + WLAN_BUF_SIZE); -#else - sq_entry_t *entry; - irqstate_t flags = spin_lock_irqsave(&priv->lock); - - entry = sq_remfirst(&priv->freeb); - if (entry) - { - pktbuf = container_of(entry, struct wlan_pktbuf, entry); - } - - spin_unlock_irqrestore(&priv->lock, flags); - -#endif - return pktbuf; -} - -/**************************************************************************** - * Function: wlan_free_buffer - * - * Description: - * Insert a free Rx buffer into the free queue - * - * Input Parameters: - * priv - Reference to the driver state structure - * buffer - A pointer to the packet buffer to be freed - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_free_buffer(struct wlan_priv_s *priv, - uint8_t *buffer) -{ - struct wlan_pktbuf *pktbuf; - -#ifdef CONFIG_ESP32_WIFI_WLAN_BUFFER_OPTIMIZATION - pktbuf = container_of(buffer, struct wlan_pktbuf, buffer); - kmm_free(pktbuf); -#else - irqstate_t flags = spin_lock_irqsave(&priv->lock); - - pktbuf = container_of(buffer, struct wlan_pktbuf, buffer); - sq_addlast(&pktbuf->entry, &priv->freeb); - - spin_unlock_irqrestore(&priv->lock, flags); -#endif -} - -/**************************************************************************** - * Function: wlan_cache_txpkt_tail - * - * Description: - * Cache packet from dev->d_buf into tail of TX ready queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_cache_txpkt_tail(struct wlan_priv_s *priv) -{ - struct wlan_pktbuf *pktbuf; - irqstate_t flags; - struct net_driver_s *dev = &priv->dev; - - pktbuf = container_of(dev->d_buf, struct wlan_pktbuf, buffer); - pktbuf->len = dev->d_len; - - flags = spin_lock_irqsave(&priv->lock); - sq_addlast(&pktbuf->entry, &priv->txb); - spin_unlock_irqrestore(&priv->lock, flags); - - dev->d_buf = NULL; - dev->d_len = 0; -} - -/**************************************************************************** - * Function: wlan_add_txpkt_head - * - * Description: - * Add packet into head of TX ready queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static inline void wlan_add_txpkt_head(struct wlan_priv_s *priv, - struct wlan_pktbuf *pktbuf) -{ - irqstate_t flags; - - flags = spin_lock_irqsave(&priv->lock); - sq_addfirst(&pktbuf->entry, &priv->txb); - spin_unlock_irqrestore(&priv->lock, flags); -} - -/**************************************************************************** - * Function: wlan_recvframe - * - * Description: - * Try to receive RX packet from RX done packet queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * RX packet if success or NULl if no packet in queue. - * - ****************************************************************************/ - -static struct wlan_pktbuf *wlan_recvframe(struct wlan_priv_s *priv) -{ - irqstate_t flags; - sq_entry_t *entry; - struct wlan_pktbuf *pktbuf = NULL; - - flags = spin_lock_irqsave(&priv->lock); - - entry = sq_remfirst(&priv->rxb); - if (entry) - { - pktbuf = container_of(entry, struct wlan_pktbuf, entry); - } - - spin_unlock_irqrestore(&priv->lock, flags); - - return pktbuf; -} - -/**************************************************************************** - * Function: wlan_txframe - * - * Description: - * Try to receive TX buffer from TX ready buffer queue. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * TX packets buffer if success or NULL if no packet in queue. - * - ****************************************************************************/ - -static struct wlan_pktbuf *wlan_txframe(struct wlan_priv_s *priv) -{ - irqstate_t flags; - sq_entry_t *entry; - struct wlan_pktbuf *pktbuf = NULL; - - flags = spin_lock_irqsave(&priv->lock); - - entry = sq_remfirst(&priv->txb); - if (entry) - { - pktbuf = container_of(entry, struct wlan_pktbuf, entry); - } - - spin_unlock_irqrestore(&priv->lock, flags); - - return pktbuf; -} - -/**************************************************************************** - * Name: wlan_transmit - * - * Description: - * Try to send all TX packets in TX ready queue to Wi-Fi driver. If this - * sending fails, then breaks loop and returns. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_transmit(struct wlan_priv_s *priv) -{ - struct wlan_pktbuf *pktbuf; - int ret; - - while ((pktbuf = wlan_txframe(priv))) - { - ret = priv->ops->send(pktbuf->buffer, pktbuf->len); - if (ret == -ENOMEM) - { - wlan_add_txpkt_head(priv, pktbuf); - wd_start(&priv->txtimeout, WLAN_TXTOUT, - wlan_txtimeout_expiry, (uint32_t)priv); - break; - } - else - { - if (ret < 0) - { - nwarn("WARN: Failed to send pkt, ret: %d\n", ret); - } - - wlan_free_buffer(priv, pktbuf->buffer); - } - } -} - -/**************************************************************************** - * Name: wlan_tx_done - * - * Description: - * Wi-Fi TX done callback function. If this is called, it means sending - * next packet. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_tx_done(struct wlan_priv_s *priv) -{ - wd_cancel(&priv->txtimeout); - - wlan_txavail(&priv->dev); -} - -/**************************************************************************** - * Function: wlan_rx_done - * - * Description: - * Wi-Fi RX done callback function. If this is called, it means receiving - * packet. - * - * Input Parameters: - * priv - Reference to the driver state structure - * buffer - Wi-Fi received packet buffer - * len - Length of received packet - * eb - Wi-Fi receive callback input eb pointer - * - * Returned Value: - * 0 on success or a negated errno on failure - * - ****************************************************************************/ - -static int wlan_rx_done(struct wlan_priv_s *priv, void *buffer, - uint16_t len, void *eb) -{ - struct wlan_pktbuf *pktbuf; - irqstate_t flags; - int ret = 0; - - if (!priv->ifup) - { - goto out; - } - - if (len > WLAN_BUF_SIZE) - { - nwarn("ERROR: Wlan receive %d larger than %d\n", - len, WLAN_BUF_SIZE); - ret = -EINVAL; - goto out; - } - - pktbuf = wlan_alloc_buffer(priv); - if (!pktbuf) - { - ret = -ENOBUFS; - goto out; - } - - memcpy(pktbuf->buffer, buffer, len); - pktbuf->len = len; - - if (eb) - { - esp_wifi_free_eb(eb); - } - - flags = spin_lock_irqsave(&priv->lock); - sq_addlast(&pktbuf->entry, &priv->rxb); - spin_unlock_irqrestore(&priv->lock, flags); - - if (work_available(&priv->rxwork)) - { - work_queue(WLAN_WORK, &priv->rxwork, wlan_rxpoll, priv, 0); - } - - return 0; - -out: - if (eb) - { - esp_wifi_free_eb(eb); - } - - return ret; -} - -/**************************************************************************** - * Function: wlan_rxpoll - * - * Description: - * Try to receive packets from RX done queue and pass packets into IP - * stack and send packets which is from IP stack if necessary. - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_rxpoll(void *arg) -{ - struct wlan_pktbuf *pktbuf; - struct eth_hdr_s *eth_hdr; - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - struct net_driver_s *dev = &priv->dev; -#ifdef WLAN_RX_THRESHOLD - uint32_t rbytes = 0; -#endif - - /* Try to send all cached TX packets for TX ack and so on */ - - wlan_transmit(priv); - - /* Loop while while wlan_recvframe() successfully retrieves valid - * Ethernet frames. - */ - - net_lock(); - - while ((pktbuf = wlan_recvframe(priv)) != NULL) - { - dev->d_buf = pktbuf->buffer; - dev->d_len = pktbuf->len; - -#ifdef WLAN_RX_THRESHOLD - rbytes += pktbuf->len; -#endif - -#ifdef CONFIG_NET_PKT - - /* When packet sockets are enabled, - * feed the frame into the packet tap. - */ - - pkt_input(&priv->dev); -#endif - - /* Check if the packet is a valid size for the network - * buffer configuration (this should not happen) - */ - - if (dev->d_len > WLAN_BUF_SIZE) - { - nwarn("WARNING: DROPPED Too big: %d\n", dev->d_len); - - /* Free dropped packet buffer */ - - if (dev->d_buf) - { - wlan_free_buffer(priv, dev->d_buf); - dev->d_buf = NULL; - dev->d_len = 0; - } - - continue; - } - - eth_hdr = (struct eth_hdr_s *)dev->d_buf; - - /* We only accept IP packets of the configured type and ARP packets */ - -#ifdef CONFIG_NET_IPv4 - if (eth_hdr->type == HTONS(ETHTYPE_IP)) - { - ninfo("IPv4 frame\n"); - - /* Receive an IPv4 packet from the network device */ - - ipv4_input(&priv->dev); - - /* If the above function invocation resulted in data - * that should be sent out on the network, - * the field d_len will set to a value > 0. - */ - - if (priv->dev.d_len > 0) - { - /* And send the packet */ - - wlan_cache_txpkt_tail(priv); - } - } - else -#endif -#ifdef CONFIG_NET_IPv6 - if (eth_hdr->type == HTONS(ETHTYPE_IP6)) - { - ninfo("IPv6 frame\n"); - - /* Give the IPv6 packet to the network layer */ - - ipv6_input(&priv->dev); - - /* If the above function invocation resulted in data - * that should be sent out on the network, the field - * d_len will set to a value > 0. - */ - - if (priv->dev.d_len > 0) - { - /* And send the packet */ - - wlan_cache_txpkt_tail(priv); - } - } - else -#endif -#ifdef CONFIG_NET_ARP - if (eth_hdr->type == HTONS(ETHTYPE_ARP)) - { - ninfo("ARP frame\n"); - - /* Handle ARP packet */ - - arp_input(&priv->dev); - - /* If the above function invocation resulted in data - * that should be sent out on the network, the field - * d_len will set to a value > 0. - */ - - if (priv->dev.d_len > 0) - { - wlan_cache_txpkt_tail(priv); - } - } - else -#endif - { - ninfo("INFO: Dropped, Unknown type: %04x\n", eth_hdr->type); - } - - /* We are finished with the RX buffer. NOTE: If the buffer is - * re-used for transmission, the dev->d_buf field will have been - * nullified. - */ - - if (dev->d_buf) - { - /* Free the receive packet buffer */ - - wlan_free_buffer(priv, dev->d_buf); - dev->d_buf = NULL; - dev->d_len = 0; - } - -#ifdef WLAN_RX_THRESHOLD - /* If received total bytes is larger than receive threshold, - * then do "unlock" to try to active applicantion to receive - * data from low-level buffer of IP stack. - */ - - if (rbytes >= WLAN_RX_THRESHOLD) - { - net_unlock(); - rbytes = 0; - net_lock(); - } -#endif - } - - /* Try to send all cached TX packets */ - - wlan_transmit(priv); - - net_unlock(); -} - -/**************************************************************************** - * Name: wlan_txpoll - * - * Description: - * The transmitter is available, check if the network has any outgoing - * packets ready to send. This is a callback from devif_poll(). - * devif_poll() may be called: - * - * 1. When the preceding TX packets send times out and the interface is - * reset - * 2. During normal TX polling - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * OK on success; a negated errno on failure - * - ****************************************************************************/ - -static int wlan_txpoll(struct net_driver_s *dev) -{ - struct wlan_pktbuf *pktbuf; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - DEBUGASSERT(dev->d_buf != NULL); - - wlan_cache_txpkt_tail(priv); - - pktbuf = wlan_alloc_buffer(priv); - if (!pktbuf) - { - return -ENOMEM; - } - - dev->d_buf = pktbuf->buffer; - dev->d_len = WLAN_BUF_SIZE; - - /* If zero is returned, the polling will continue until - * all connections have been examined. - */ - - return OK; -} - -/**************************************************************************** - * Function: wlan_dopoll - * - * Description: - * The function is called in order to perform an out-of-sequence TX poll. - * This is done: - * - * 1. When new TX data is available (wlan_txavail) - * 2. After a TX timeout to restart the sending process - * (wlan_txtimeout_expiry). - * - * Input Parameters: - * priv - Reference to the driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_dopoll(struct wlan_priv_s *priv) -{ - struct net_driver_s *dev = &priv->dev; - struct wlan_pktbuf *pktbuf; - uint8_t *txbuf; - int ret; - - pktbuf = wlan_alloc_buffer(priv); - if (!pktbuf) - { - return; - } - - dev->d_buf = pktbuf->buffer; - dev->d_len = WLAN_BUF_SIZE; - - /* Try to let TCP/IP to send all packets to netcard driver */ - - do - { - txbuf = dev->d_buf; - ret = devif_poll(dev, wlan_txpoll); - } - while ((ret == 0) && - (dev->d_buf != txbuf)); - - if (dev->d_buf) - { - wlan_free_buffer(priv, dev->d_buf); - - dev->d_buf = NULL; - dev->d_len = 0; - } - - /* Try to send all cached TX packets */ - - wlan_transmit(priv); -} - -/**************************************************************************** - * Function: wlan_txtimeout_work - * - * Description: - * Perform TX timeout related work from the worker thread - * - * Input Parameters: - * arg - The argument passed when work_queue() as called. - * - * Returned Value: - * OK on success - * - ****************************************************************************/ - -static void wlan_txtimeout_work(void *arg) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - - /* Try to send all cached TX packets */ - - wlan_transmit(priv); - - net_lock(); - - wlan_ifdown(&priv->dev); - wlan_ifup(&priv->dev); - - /* Then poll for new XMIT data */ - - wlan_dopoll(priv); - - net_unlock(); -} - -/**************************************************************************** - * Function: wlan_txtimeout_expiry - * - * Description: - * Our TX watchdog timed out. Called from the timer callback handler. - * The last TX never completed. Reset the hardware and start again. - * - * Input Parameters: - * argc - The number of available arguments - * arg - The first argument - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_txtimeout_expiry(wdparm_t arg) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - - /* Schedule to perform the TX timeout processing on the worker thread. */ - - if (work_available(&priv->toutwork)) - { - work_queue(WLAN_WORK, &priv->toutwork, wlan_txtimeout_work, priv, 0); - } -} - -/**************************************************************************** - * Name: wlan_txavail_work - * - * Description: - * Perform an out-of-cycle poll on the worker thread. - * - * Input Parameters: - * arg - Reference to the NuttX driver state structure (cast to void*) - * - * Returned Value: - * None - * - * Assumptions: - * Called on the higher priority worker thread. - * - ****************************************************************************/ - -static void wlan_txavail_work(void *arg) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)arg; - - /* Try to send all cached TX packets even if net is down */ - - wlan_transmit(priv); - - /* Lock the network and serialize driver operations if necessary. - * NOTE: Serialization is only required in the case where the driver work - * is performed on an LP worker thread and where more than one LP worker - * thread has been configured. - */ - - net_lock(); - - /* Ignore the notification if the interface is not yet up */ - - if (priv->ifup) - { - /* Poll the network for new XMIT data */ - - wlan_dopoll(priv); - } - - net_unlock(); -} - -/**************************************************************************** - * Name: wlan_ifup - * - * Description: - * NuttX Callback: Bring up the Ethernet interface when an IP address is - * provided - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static int wlan_ifup(struct net_driver_s *dev) -{ - int ret; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - -#ifdef CONFIG_NET_IPv4 - ninfo("Bringing up: %u.%u.%u.%u\n", - ip4_addr1(dev->d_ipaddr), ip4_addr2(dev->d_ipaddr), - ip4_addr3(dev->d_ipaddr), ip4_addr4(dev->d_ipaddr)); -#endif -#ifdef CONFIG_NET_IPv6 - ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", - dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2], - dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5], - dev->d_ipv6addr[6], dev->d_ipv6addr[7]); -#endif - - net_lock(); - - if (priv->ifup) - { - net_unlock(); - return OK; - } - - wlan_init_buffer(priv); - ret = priv->ops->start(); - if (ret < 0) - { - wlan_deinit_buffer(priv); - net_unlock(); - nerr("ERROR: Failed to start Wi-Fi ret=%d\n", ret); - return ret; - } - - priv->ifup = true; - if (g_callback_register_ref == 0) - { - ret = esp32_register_shutdown_handler(esp_wifi_stop_callback); - if (ret < 0) - { - nwarn("WARN: Failed to register handler ret=%d\n", ret); - } - } - - ++g_callback_register_ref; - - /* We can make sure that the WLAN TX and RX are not doing, because - * the process is in "net_lock()" - */ - - wlan_deinit_buffer(priv); - net_unlock(); - - return OK; -} - -/**************************************************************************** - * Name: wlan_ifdown - * - * Description: - * NuttX Callback: Stop the interface. - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - ****************************************************************************/ - -static int wlan_ifdown(struct net_driver_s *dev) -{ - int ret; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - net_lock(); - - if (!priv->ifup) - { - net_unlock(); - return OK; - } - - /* Cancel the TX poll timer and TX timeout timers */ - - wd_cancel(&priv->txtimeout); - - /* Mark the device "down" */ - - priv->ifup = false; - - ret = priv->ops->stop(); - if (ret < 0) - { - nerr("ERROR: Failed to stop Wi-Fi ret=%d\n", ret); - } - - --g_callback_register_ref; - if (g_callback_register_ref == 0) - { - ret = esp32_unregister_shutdown_handler(esp_wifi_stop_callback); - if (ret < 0) - { - nwarn("WARN: Failed to unregister handler ret=%d\n", ret); - } - } - - net_unlock(); - - return OK; -} - -/**************************************************************************** - * Name: wlan_txavail - * - * Description: - * Driver callback invoked when new TX data is available. This is a - * stimulus perform an out-of-cycle poll and, thereby, reduce the TX - * latency. - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * - * Returned Value: - * None - * - * Assumptions: - * Called in normal user mode - * - ****************************************************************************/ - -static int wlan_txavail(struct net_driver_s *dev) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - if (work_available(&priv->txwork)) - { - /* Schedule to serialize the poll on the worker thread. */ - - work_queue(WLAN_WORK, &priv->txwork, wlan_txavail_work, priv, 0); - } - - return OK; -} - -/**************************************************************************** - * Name: wlan_addmac - * - * Description: - * NuttX Callback: Add the specified MAC address to the hardware multicast - * address filtering - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * mac - The MAC address to be added - * - * Returned Value: - * None - * - ****************************************************************************/ - -#if defined(CONFIG_NET_MCASTGROUP) || defined(CONFIG_NET_ICMPv6) -static int wlan_addmac(struct net_driver_s *dev, const uint8_t *mac) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - /* Add the MAC address to the hardware multicast routing table */ - - return OK; -} -#endif - -/**************************************************************************** - * Name: wlan_rmmac - * - * Description: - * NuttX Callback: Remove the specified MAC address from the - * hardware multicast address filtering - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * mac - The MAC address to be removed - * - * Returned Value: - * None - * - ****************************************************************************/ - -#ifdef CONFIG_NET_MCASTGROUP -static int wlan_rmmac(struct net_driver_s *dev, const uint8_t *mac) -{ - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - - /* Add the MAC address to the hardware multicast routing table */ - - return OK; -} -#endif - -/**************************************************************************** - * Name: wlan_ioctl - * - * Description: - * Handle network IOCTL commands directed to this device. - * - * Input Parameters: - * dev - Reference to the NuttX driver state structure - * cmd - The IOCTL command - * arg - The argument for the IOCTL command - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef CONFIG_NETDEV_IOCTL -static int wlan_ioctl(struct net_driver_s *dev, - int cmd, - unsigned long arg) -{ - int ret; - struct iwreq *iwr = (struct iwreq *)arg; - struct wlan_priv_s *priv = (struct wlan_priv_s *)dev->d_private; - const struct wlan_ops *ops = priv->ops; - - /* Decode and dispatch the driver-specific IOCTL command */ - - switch (cmd) - { -#ifdef CONFIG_NETDEV_PHY_IOCTL -#ifdef CONFIG_ARCH_PHY_INTERRUPT - case SIOCMIINOTIFY: /* Set up for PHY event notifications */ - { - struct mii_ioctl_notify_s *req = (struct mii_ioctl_notify_s *)arg; - ret = ops->event(req->pid, &req->event); - if (ret < 0) - { - nerr("ERROR: Failed to subscribe event\n"); - } - } - break; -#endif -#endif - - case SIOCSIWENCODEEXT: - ret = ops->passwd(iwr, true); - - break; - - case SIOCGIWENCODEEXT: - ret = ops->passwd(iwr, false); - break; - - case SIOCSIWESSID: - if ((iwr->u.essid.flags == IW_ESSID_ON) || - (iwr->u.essid.flags == IW_ESSID_DELAY_ON)) - { - ret = ops->essid(iwr, true); - if (ret < 0) - { - break; - } - - if (iwr->u.essid.flags == IW_ESSID_ON) - { - ret = ops->connect(); - } - } - else - { - ret = ops->disconnect(); - } - - break; - - case SIOCGIWESSID: /* Get ESSID */ - ret = ops->essid(iwr, false); - break; - - case SIOCSIWAP: /* Set access point MAC addresses */ - if (iwr->u.ap_addr.sa_data[0] != 0 && - iwr->u.ap_addr.sa_data[1] != 0 && - iwr->u.ap_addr.sa_data[2] != 0) - { - ret = ops->bssid(iwr, true); - if (ret < 0) - { - nerr("ERROR: Failed to set BSSID\n"); - break; - } - - ret = ops->connect(); - if (ret < 0) - { - nerr("ERROR: Failed to connect\n"); - break; - } - } - else - { - ret = ops->disconnect(); - if (ret < 0) - { - nerr("ERROR: Failed to disconnect\n"); - break; - } - } - - break; - - case SIOCGIWAP: /* Get access point MAC addresses */ - ret = ops->bssid(iwr, false); - break; - - case SIOCSIWSCAN: - ret = esp_wifi_start_scan(iwr); - break; - - case SIOCGIWSCAN: - ret = esp_wifi_get_scan_results(iwr); - break; - - case SIOCSIWCOUNTRY: /* Set country code */ - ret = ops->country(iwr, true); - break; - - case SIOCGIWSENS: /* Get sensitivity (dBm) */ - ret = ops->rssi(iwr, false); - break; - - case SIOCSIWMODE: /* Set operation mode */ - ret = ops->mode(iwr, true); - break; - - case SIOCGIWMODE: /* Get operation mode */ - ret = ops->mode(iwr, false); - break; - - case SIOCSIWAUTH: /* Set authentication mode params */ - ret = ops->auth(iwr, true); - break; - - case SIOCGIWAUTH: /* Get authentication mode params */ - ret = ops->auth(iwr, false); - break; - - case SIOCSIWFREQ: /* Set channel/frequency (MHz) */ - ret = ops->freq(iwr, true); - break; - - case SIOCGIWFREQ: /* Get channel/frequency (MHz) */ - ret = ops->freq(iwr, false); - break; - - case SIOCSIWRATE: /* Set default bit rate (Mbps) */ - wlwarn("WARNING: SIOCSIWRATE not implemented\n"); - ret = -ENOSYS; - break; - - case SIOCGIWRATE: /* Get default bit rate (Mbps) */ - ret = ops->bitrate(iwr, false); - break; - - case SIOCSIWTXPOW: /* Set transmit power (dBm) */ - ret = ops->txpower(iwr, true); - break; - - case SIOCGIWTXPOW: /* Get transmit power (dBm) */ - ret = ops->txpower(iwr, false); - break; - - case SIOCGIWRANGE: /* Get range of parameters */ - ret = ops->channel(iwr, false); - break; - - default: - nerr("ERROR: Unrecognized IOCTL command: %d\n", cmd); - ret = -ENOTTY; /* Special return value for this case */ - break; - } - - return ret; -} -#endif /* CONFIG_NETDEV_IOCTL */ - -/**************************************************************************** - * Name: esp32_net_initialize - * - * Description: - * Initialize the esp32 driver - * - * Input Parameters: - * devno - The device number - * mac_addr - MAC address - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -static int esp32_net_initialize(int devno, uint8_t *mac_addr, - const struct wlan_ops *ops) -{ - int ret; - struct wlan_priv_s *priv; - struct net_driver_s *netdev; - - priv = &g_wlan_priv[devno]; - if (priv->ref) - { - priv->ref++; - return OK; - } - - netdev = &priv->dev; - - /* Initialize the driver structure */ - - memset(priv, 0, sizeof(struct wlan_priv_s)); - - netdev->d_ifup = wlan_ifup; /* I/F down callback */ - netdev->d_ifdown = wlan_ifdown; /* I/F up (new IP address) callback */ - netdev->d_txavail = wlan_txavail; /* New TX data callback */ -#ifdef CONFIG_NET_MCASTGROUP - netdev->d_addmac = wlan_addmac; /* Add multicast MAC address */ - netdev->d_rmmac = wlan_rmmac; /* Remove multicast MAC address */ -#endif -#ifdef CONFIG_NETDEV_IOCTL - netdev->d_ioctl = wlan_ioctl; /* Handle network IOCTL commands */ -#endif - - /* Used to recover private state from dev */ - - netdev->d_private = (void *)priv; - - memcpy(netdev->d_mac.ether.ether_addr_octet, mac_addr, 6); - - ret = netdev_register(netdev, NET_LL_IEEE80211); - if (ret < 0) - { - nerr("ERROR: Initialization of Ethernet block failed: %d\n", ret); - return ret; - } - - priv->ops = ops; - - priv->ref++; - - ninfo("INFO: Initialize Wi-Fi adapter No.%d success\n", devno); - - return OK; -} - -#ifdef ESP32_WLAN_HAS_STA -/**************************************************************************** - * Function: wlan_sta_rx_done - * - * Description: - * Wi-Fi station RX done callback function. If this is called, it means - * station receiveing packet. - * - * Input Parameters: - * buffer - Wi-Fi received packet buffer - * len - Length of received packet - * eb - Wi-Fi receive callback input eb pointer - * - * Returned Value: - * 0 on success or a negated errno on failure - * - ****************************************************************************/ - -static int wlan_sta_rx_done(void *buffer, uint16_t len, void *eb) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32_WLAN_STA_DEVNO]; - - return wlan_rx_done(priv, buffer, len, eb); -} - -/**************************************************************************** - * Name: wlan_sta_tx_done - * - * Description: - * Wi-Fi station TX done callback function. If this is called, it means - * station sending next packet. - * - * Input Parameters: - * data - Pointer to the data transmitted. - * len - Length of the data transmitted. - * status - True if data was transmitted successfully or false if failed. - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_sta_tx_done(uint8_t *data, uint16_t *len, bool status) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32_WLAN_STA_DEVNO]; - - wlan_tx_done(priv); -} -#endif /* ESP32_WLAN_HAS_STA */ - -#ifdef ESP32_WLAN_HAS_SOFTAP -/**************************************************************************** - * Function: wlan_softap_rx_done - * - * Description: - * Wi-Fi softAP RX done callback function. If this is called, it means - * softAP receiveing packet. - * - * Input Parameters: - * buffer - Wi-Fi received packet buffer - * len - Length of received packet - * eb - Wi-Fi receive callback input eb pointer - * - * Returned Value: - * 0 on success or a negated errno on failure - * - ****************************************************************************/ - -static int wlan_softap_rx_done(void *buffer, uint16_t len, void *eb) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32_WLAN_SOFTAP_DEVNO]; - - return wlan_rx_done(priv, buffer, len, eb); -} - -/**************************************************************************** - * Name: wlan_softap_tx_done - * - * Description: - * Wi-Fi softAP TX done callback function. If this is called, it means - * softAP sending next packet. - * - * Input Parameters: - * ifidx - The interface id that the tx callback has been triggered from. - * data - Pointer to the data transmitted. - * len - Length of the data transmitted. - * status - True if data was transmitted successfully or false if failed. - * - * Returned Value: - * None - * - ****************************************************************************/ - -static void wlan_softap_tx_done(uint8_t *data, uint16_t *len, bool status) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32_WLAN_SOFTAP_DEVNO]; - - wlan_tx_done(priv); -} -#endif /* ESP32_WLAN_HAS_SOFTAP */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: esp32_wlan_sta_set_linkstatus - * - * Description: - * Set Wi-Fi station link status - * - * Parameters: - * linkstatus - true Notifies the networking layer about an available - * carrier, false Notifies the networking layer about an - * disappeared carrier. - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef ESP32_WLAN_HAS_STA -int esp32_wlan_sta_set_linkstatus(bool linkstatus) -{ - struct wlan_priv_s *priv = &g_wlan_priv[ESP32_WLAN_STA_DEVNO]; - - if (linkstatus) - { - netdev_carrier_on(&priv->dev); - } - else - { - netdev_carrier_off(&priv->dev); - } - - return OK; -} - -/**************************************************************************** - * Name: esp32_wlan_sta_initialize - * - * Description: - * Initialize the esp32 WLAN station netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32_wlan_sta_initialize(void) -{ - int ret; - uint8_t eth_mac[6]; - - ret = esp_wifi_adapter_init(); - if (ret < 0) - { - nerr("ERROR: Initialize Wi-Fi adapter error: %d\n", ret); - return ret; - } - - ret = esp_wifi_sta_read_mac(eth_mac); - if (ret < 0) - { - nerr("ERROR: Failed to read MAC address\n"); - return ret; - } - - ninfo("Wi-Fi station MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", - eth_mac[0], eth_mac[1], eth_mac[2], - eth_mac[3], eth_mac[4], eth_mac[5]); - - ret = esp32_net_initialize(ESP32_WLAN_STA_DEVNO, eth_mac, &g_sta_ops); - if (ret < 0) - { - nerr("ERROR: Failed to initialize net\n"); - return ret; - } - - ret = esp_wifi_sta_register_recv_cb(wlan_sta_rx_done); - if (ret < 0) - { - nerr("ERROR: Failed to register RX callback\n"); - return ret; - } - - esp_wifi_sta_register_txdone_cb(wlan_sta_tx_done); - - ninfo("INFO: Initialize Wi-Fi station success net\n"); - - return OK; -} -#endif /* ESP32_WLAN_HAS_STA */ - -#ifdef ESP32_WLAN_HAS_SOFTAP -/**************************************************************************** - * Name: esp32_wlan_softap_initialize - * - * Description: - * Initialize the esp32 WLAN softAP netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32_wlan_softap_initialize(void) -{ - int ret; - uint8_t eth_mac[6]; - - ret = esp_wifi_adapter_init(); - if (ret < 0) - { - nerr("ERROR: Initialize Wi-Fi adapter error: %d\n", ret); - return ret; - } - - ret = esp_wifi_softap_read_mac(eth_mac); - if (ret < 0) - { - nerr("ERROR: Failed to read MAC address\n"); - return ret; - } - - ninfo("Wi-Fi softAP MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", - eth_mac[0], eth_mac[1], eth_mac[2], - eth_mac[3], eth_mac[4], eth_mac[5]); - - ret = esp32_net_initialize(ESP32_WLAN_SOFTAP_DEVNO, eth_mac, - &g_softap_ops); - if (ret < 0) - { - nerr("ERROR: Failed to initialize net\n"); - return ret; - } - - ret = esp_wifi_softap_register_recv_cb(wlan_softap_rx_done); - if (ret < 0) - { - nerr("ERROR: Failed to register RX callback\n"); - return ret; - } - - esp_wifi_softap_register_txdone_cb(wlan_softap_tx_done); - - ninfo("INFO: Initialize Wi-Fi softAP net success\n"); - - return OK; -} -#endif /* ESP32_WLAN_HAS_SOFTAP */ - -#endif /* CONFIG_ESP32_WIFI */ diff --git a/arch/xtensa/src/esp32/esp32_wlan.h b/arch/xtensa/src/esp32/esp32_wlan.h deleted file mode 100644 index 70254b98aa39a..0000000000000 --- a/arch/xtensa/src/esp32/esp32_wlan.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_wlan.h - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __ARCH_XTENSA_SRC_ESP32_ESP32_WLAN_H -#define __ARCH_XTENSA_SRC_ESP32_ESP32_WLAN_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include "esp32_wifi_adapter.h" - -#ifndef __ASSEMBLY__ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -#ifdef CONFIG_ESP32_WIFI - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: esp32_wlan_sta_initialize - * - * Description: - * Initialize the esp32 WLAN station netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef ESP32_WLAN_HAS_STA - -/**************************************************************************** - * Name: esp32_wlan_sta_set_linkstatus - * - * Description: - * Set Wi-Fi station link status - * - * Parameters: - * linkstatus - true Notifies the networking layer about an available - * carrier, false Notifies the networking layer about an - * disappeared carrier. - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32_wlan_sta_set_linkstatus(bool linkstatus); - -/**************************************************************************** - * Name: esp32_wlan_sta_initialize - * - * Description: - * Initialize the ESP32 WLAN station netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -int esp32_wlan_sta_initialize(void); -#endif /* ESP32_WLAN_HAS_STA */ - -/**************************************************************************** - * Name: esp32_wlan_softap_initialize - * - * Description: - * Initialize the esp32 WLAN softAP netcard driver - * - * Input Parameters: - * None - * - * Returned Value: - * OK on success; Negated errno on failure. - * - ****************************************************************************/ - -#ifdef ESP32_WLAN_HAS_SOFTAP -int esp32_wlan_softap_initialize(void); -#endif /* ESP32_WLAN_HAS_SOFTAP */ - -#endif /* CONFIG_ESP32_WIFI */ -#ifdef __cplusplus -} -#endif -#undef EXTERN - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_XTENSA_SRC_ESP32_ESP32_WLAN_H */ From 8d9c0f9fc883a721e01c51f75471bfd15a939260 Mon Sep 17 00:00:00 2001 From: Filipe Cavalcanti Date: Mon, 20 Jan 2025 16:17:43 -0300 Subject: [PATCH 4/4] boards/xtensa/esp32: update ESP32 boards wireless symbols Update the wireless symbols from ESP32_* to ESPRESSIF_* for using common layer. --- .../xtensa/esp32/common/include/esp32_board_wlan.h | 4 ++-- .../xtensa/esp32/common/scripts/esp32_aliases.ld | 2 +- .../xtensa/esp32/common/scripts/esp32_sections.ld | 2 +- .../xtensa/esp32/common/scripts/legacy_sections.ld | 2 +- boards/xtensa/esp32/common/src/Make.defs | 2 +- boards/xtensa/esp32/common/src/esp32_board_wlan.c | 14 +++++++------- .../esp32/esp32-2432S028/src/esp32_bringup.c | 6 +++--- .../esp32/esp32-audio-kit/configs/audio/defconfig | 2 +- .../esp32/esp32-audio-kit/configs/wifi/defconfig | 2 +- .../esp32/esp32-audio-kit/src/esp32_bringup.c | 8 ++++---- .../esp32/esp32-devkitc/configs/audio/defconfig | 2 +- .../esp32/esp32-devkitc/configs/autopm/defconfig | 3 +-- .../esp32/esp32-devkitc/configs/ble/defconfig | 2 +- .../esp32/esp32-devkitc/configs/blewifi/defconfig | 7 +++---- .../esp32/esp32-devkitc/configs/efuse/defconfig | 2 +- .../configs/mcuboot_update_agent/defconfig | 2 +- .../esp32/esp32-devkitc/configs/mqttc/defconfig | 2 +- .../esp32/esp32-devkitc/configs/nxlooper/defconfig | 2 +- .../esp32/esp32-devkitc/configs/softap/defconfig | 4 ++-- .../esp32-devkitc/configs/sta_softap/defconfig | 4 ++-- .../configs/wamr_wasi_debug/defconfig | 2 +- .../esp32/esp32-devkitc/configs/wifi/defconfig | 2 +- .../esp32/esp32-devkitc/configs/wifi_smp/defconfig | 2 +- .../esp32/esp32-devkitc/configs/wifinsh/defconfig | 2 +- .../esp32-devkitc/configs/wifishare/defconfig | 4 ++-- .../xtensa/esp32/esp32-devkitc/src/esp32_bringup.c | 12 ++++++------ .../esp32-ethernet-kit/configs/autopm/defconfig | 3 +-- .../esp32-ethernet-kit/configs/wifi/defconfig | 2 +- .../esp32/esp32-ethernet-kit/src/esp32_bringup.c | 8 ++++---- .../esp32/esp32-lyrat/configs/audio/defconfig | 2 +- .../esp32/esp32-lyrat/configs/rtptools/defconfig | 8 ++++---- .../esp32/esp32-lyrat/configs/wifi/defconfig | 2 +- .../xtensa/esp32/esp32-lyrat/src/esp32_bringup.c | 8 ++++---- .../esp32/esp32-pico-kit/src/esp32_bringup.c | 12 ++++++------ .../esp32-sparrow-kit/configs/mqttc/defconfig | 2 +- .../esp32/esp32-sparrow-kit/configs/wifi/defconfig | 2 +- .../esp32/esp32-sparrow-kit/src/esp32_bringup.c | 8 ++++---- .../esp32-wrover-kit/configs/autopm/defconfig | 3 +-- .../esp32/esp32-wrover-kit/configs/wifi/defconfig | 2 +- .../esp32/esp32-wrover-kit/src/esp32_bringup.c | 8 ++++---- .../lilygo_tbeam_lora_gps/src/esp32_bringup.c | 8 ++++---- .../xtensa/esp32/ttgo_eink5_v2/src/esp32_bringup.c | 12 ++++++------ .../esp32/ttgo_lora_esp32/src/esp32_bringup.c | 8 ++++---- .../esp32/ttgo_t_display_esp32/src/esp32_bringup.c | 12 ++++++------ 44 files changed, 102 insertions(+), 106 deletions(-) diff --git a/boards/xtensa/esp32/common/include/esp32_board_wlan.h b/boards/xtensa/esp32/common/include/esp32_board_wlan.h index 5cf66ce5e50e7..951c8ff653516 100644 --- a/boards/xtensa/esp32/common/include/esp32_board_wlan.h +++ b/boards/xtensa/esp32/common/include/esp32_board_wlan.h @@ -48,7 +48,7 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI /**************************************************************************** * Name: board_wlan_init @@ -64,7 +64,7 @@ extern "C" int board_wlan_init(void); -#endif /* CONFIG_ESP32_WIFI */ +#endif /* CONFIG_ESPRESSIF_WIFI */ #undef EXTERN #if defined(__cplusplus) diff --git a/boards/xtensa/esp32/common/scripts/esp32_aliases.ld b/boards/xtensa/esp32/common/scripts/esp32_aliases.ld index 636e272a4daff..b50c16f1424d6 100644 --- a/boards/xtensa/esp32/common/scripts/esp32_aliases.ld +++ b/boards/xtensa/esp32/common/scripts/esp32_aliases.ld @@ -33,7 +33,7 @@ PROVIDE( cache_read_enable = Cache_Read_Enable_rom ); /* Bluetooth needs symbol alias, to be removed after IDF rename it */ -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE api_vhci_host_check_send_available = API_vhci_host_check_send_available; api_vhci_host_send_packet = API_vhci_host_send_packet; api_vhci_host_register_callback = API_vhci_host_register_callback; diff --git a/boards/xtensa/esp32/common/scripts/esp32_sections.ld b/boards/xtensa/esp32/common/scripts/esp32_sections.ld index 3dc66d776f432..a7fd701eae541 100644 --- a/boards/xtensa/esp32/common/scripts/esp32_sections.ld +++ b/boards/xtensa/esp32/common/scripts/esp32_sections.ld @@ -454,7 +454,7 @@ SECTIONS *(.srodata.*) *(.rodata) *(.rodata.*) -#ifdef CONFIG_ESP32_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS *(.rodata_wlog_verbose.*) *(.rodata_wlog_debug.*) *(.rodata_wlog_info.*) diff --git a/boards/xtensa/esp32/common/scripts/legacy_sections.ld b/boards/xtensa/esp32/common/scripts/legacy_sections.ld index b6a7690425a79..f79c4c435c31d 100644 --- a/boards/xtensa/esp32/common/scripts/legacy_sections.ld +++ b/boards/xtensa/esp32/common/scripts/legacy_sections.ld @@ -278,7 +278,7 @@ SECTIONS _srodata = ABSOLUTE(.); *(.rodata) *(.rodata.*) -#ifdef CONFIG_ESP32_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS *(.rodata_wlog_verbose.*) *(.rodata_wlog_debug.*) *(.rodata_wlog_info.*) diff --git a/boards/xtensa/esp32/common/src/Make.defs b/boards/xtensa/esp32/common/src/Make.defs index 276281869f4f5..e6ebe3ad78a46 100644 --- a/boards/xtensa/esp32/common/src/Make.defs +++ b/boards/xtensa/esp32/common/src/Make.defs @@ -74,7 +74,7 @@ ifeq ($(CONFIG_ESP32_SPIFLASH),y) CSRCS += esp32_board_spiflash.c endif -ifeq ($(CONFIG_ESP32_WIFI),y) +ifeq ($(CONFIG_ESPRESSIF_WIFI),y) CSRCS += esp32_board_wlan.c endif diff --git a/boards/xtensa/esp32/common/src/esp32_board_wlan.c b/boards/xtensa/esp32/common/src/esp32_board_wlan.c index 926187559dbd7..b020a6535f31f 100644 --- a/boards/xtensa/esp32/common/src/esp32_board_wlan.c +++ b/boards/xtensa/esp32/common/src/esp32_board_wlan.c @@ -36,7 +36,7 @@ #include #include "esp32_spiflash.h" -#include "esp32_wlan.h" +#include "espressif/esp_wlan.h" /**************************************************************************** * Pre-processor Definitions @@ -66,23 +66,23 @@ int board_wlan_init(void) { int ret = OK; -#ifdef ESP32_WLAN_HAS_STA - ret = esp32_wlan_sta_initialize(); +#ifdef ESPRESSIF_WLAN_HAS_STA + ret = esp_wlan_sta_initialize(); if (ret) { wlerr("ERROR: Failed to initialize Wi-Fi station\n"); return ret; } -#endif /* ESP32_WLAN_HAS_STA */ +#endif /* ESPRESSIF_WLAN_HAS_STA */ -#ifdef ESP32_WLAN_HAS_SOFTAP - ret = esp32_wlan_softap_initialize(); +#ifdef ESPRESSIF_WLAN_HAS_SOFTAP + ret = esp_wlan_softap_initialize(); if (ret) { wlerr("ERROR: Failed to initialize Wi-Fi softAP\n"); return ret; } -#endif /* ESP32_WLAN_HAS_SOFTAP */ +#endif /* ESPRESSIF_WLAN_HAS_SOFTAP */ return ret; } diff --git a/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c index 447f1be519f3a..18b0ead95fa84 100644 --- a/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-2432S028/src/esp32_bringup.c @@ -59,7 +59,7 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -179,7 +179,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -187,7 +187,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-audio-kit/configs/audio/defconfig b/boards/xtensa/esp32/esp32-audio-kit/configs/audio/defconfig index f4548b381a862..089b9c85bf905 100644 --- a/boards/xtensa/esp32/esp32-audio-kit/configs/audio/defconfig +++ b/boards/xtensa/esp32/esp32-audio-kit/configs/audio/defconfig @@ -54,7 +54,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_I2SCHAR=y CONFIG_EXAMPLES_I2SCHAR_TX=y CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2 diff --git a/boards/xtensa/esp32/esp32-audio-kit/configs/wifi/defconfig b/boards/xtensa/esp32/esp32-audio-kit/configs/wifi/defconfig index 5952cf61ab3b5..88b0cf6fed4ab 100644 --- a/boards/xtensa/esp32/esp32-audio-kit/configs/wifi/defconfig +++ b/boards/xtensa/esp32/esp32-audio-kit/configs/wifi/defconfig @@ -33,7 +33,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 CONFIG_INIT_ENTRYPOINT="nsh_main" diff --git a/boards/xtensa/esp32/esp32-audio-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-audio-kit/src/esp32_bringup.c index 6719e203e6d4c..837413a4e7650 100644 --- a/boards/xtensa/esp32/esp32-audio-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-audio-kit/src/esp32_bringup.c @@ -64,11 +64,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -205,7 +205,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -213,7 +213,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig index 18af503120e7b..b36bde109d4f6 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/audio/defconfig @@ -52,7 +52,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_I2SCHAR=y CONFIG_EXAMPLES_I2SCHAR_TX=y CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2 diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/autopm/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/autopm/defconfig index 6da568a6352c5..bfcfacce45f0e 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/autopm/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/autopm/defconfig @@ -27,8 +27,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_EXAMPLE_POWER_SAVE_MIN_MODEM=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/ble/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/ble/defconfig index c10bc7d363b15..abc75760db514 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/ble/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/ble/defconfig @@ -27,10 +27,10 @@ CONFIG_BUILTIN=y CONFIG_DRIVERS_BLUETOOTH=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y -CONFIG_ESP32_BLE=y CONFIG_ESP32_IRAM_ISR_DEBUG=y CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_UART0=y +CONFIG_ESPRESSIF_BLE=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig index 6e792d5d5ffd3..63b647ea5b5c7 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/blewifi/defconfig @@ -31,16 +31,15 @@ CONFIG_DISABLE_MQUEUE_NOTIFICATION=y CONFIG_DRIVERS_BLUETOOTH=y CONFIG_DRIVERS_IEEE80211=y CONFIG_DRIVERS_WIRELESS=y -CONFIG_ESP32_BLE=y CONFIG_ESP32_RT_TIMER_TASK_STACK_SIZE=4096 CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_ESP32_WIFI_STATION_SOFTAP=y +CONFIG_ESPRESSIF_BLE=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP=y CONFIG_EXAMPLES_DHCPD=y -CONFIG_EXAMPLE_POWER_SAVE_MIN_MODEM=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig index d406b86f1b534..0897da12bfadb 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/efuse/defconfig @@ -41,7 +41,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 CONFIG_INIT_ENTRYPOINT="nsh_main" diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig index 692ed1a532aed..bae8bc89e6718 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/mcuboot_update_agent/defconfig @@ -29,7 +29,7 @@ CONFIG_DRIVERS_WIRELESS=y CONFIG_ESP32_APP_FORMAT_MCUBOOT=y CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT=y CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_BUFFER_SIZE=4096 CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/mqttc/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/mqttc/defconfig index e7062fd445771..8335b8d86393b 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/mqttc/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/mqttc/defconfig @@ -26,7 +26,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_MQTTC=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig index 51e87bada48aa..688b1e340c709 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/nxlooper/defconfig @@ -50,7 +50,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_I2SCHAR=y CONFIG_EXAMPLES_I2SCHAR_BUFSIZE=960 CONFIG_EXAMPLES_I2SCHAR_RX=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/softap/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/softap/defconfig index a0f09d4a69f9a..a6843eebe74fc 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/softap/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/softap/defconfig @@ -28,8 +28,8 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_ESP32_WIFI_SOFTAP=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_SOFTAP=y CONFIG_EXAMPLES_DHCPD=y CONFIG_EXPERIMENTAL=y CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/sta_softap/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/sta_softap/defconfig index 26801e67597dc..bc64df1d57fa1 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/sta_softap/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/sta_softap/defconfig @@ -29,8 +29,8 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_ESP32_WIFI_STATION_SOFTAP=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP=y CONFIG_EXAMPLES_DHCPD=y CONFIG_EXPERIMENTAL=y CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig index 9a246da0d7520..b2edcfcba1019 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig @@ -43,7 +43,7 @@ CONFIG_ESP32_RTC_HEAP=y CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x280000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXPERIMENTAL=y CONFIG_FS_LITTLEFS=y CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wifi/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wifi/defconfig index e6f5dd8abef03..3baeffb2bf532 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wifi/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wifi/defconfig @@ -30,7 +30,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 CONFIG_INIT_ENTRYPOINT="nsh_main" diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wifi_smp/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wifi_smp/defconfig index d122d0b99d07c..8fafbbbb53fca 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wifi_smp/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wifi_smp/defconfig @@ -34,7 +34,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_HELLO=y CONFIG_EXAMPLES_WEBSERVER=y CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wifinsh/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wifinsh/defconfig index 0d8e4713fa759..be43ac0b82b29 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wifinsh/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wifinsh/defconfig @@ -27,7 +27,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wifishare/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wifishare/defconfig index 0cb1189c884f0..dae5c4e73b071 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wifishare/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wifishare/defconfig @@ -28,8 +28,8 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_ESP32_WIFI_STATION_SOFTAP=y +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_STATION_SOFTAP=y CONFIG_EXAMPLES_DHCPD=y CONFIG_EXPERIMENTAL=y CONFIG_FS_PROCFS=y diff --git a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c index 149e8cf82dcfb..62207be681c99 100644 --- a/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-devkitc/src/esp32_bringup.c @@ -70,15 +70,15 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32_wifi_adapter.h" #endif @@ -336,7 +336,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32_wifi_bt_coexist_init(); if (ret) { @@ -345,7 +345,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -353,7 +353,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/configs/autopm/defconfig b/boards/xtensa/esp32/esp32-ethernet-kit/configs/autopm/defconfig index a3355a75fba21..e0ebd29234ad5 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/configs/autopm/defconfig +++ b/boards/xtensa/esp32/esp32-ethernet-kit/configs/autopm/defconfig @@ -26,8 +26,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_EXAMPLE_POWER_SAVE_MIN_MODEM=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/configs/wifi/defconfig b/boards/xtensa/esp32/esp32-ethernet-kit/configs/wifi/defconfig index ca1c14249c247..e46947fc25069 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/configs/wifi/defconfig +++ b/boards/xtensa/esp32/esp32-ethernet-kit/configs/wifi/defconfig @@ -25,7 +25,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c index 0045b99a89e42..4e97415ce7685 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-ethernet-kit/src/esp32_bringup.c @@ -63,11 +63,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -166,7 +166,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -174,7 +174,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig b/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig index ab8ed50a010ac..90e5bb1c17055 100644 --- a/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig +++ b/boards/xtensa/esp32/esp32-lyrat/configs/audio/defconfig @@ -51,7 +51,7 @@ CONFIG_ESP32_I2S=y CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_I2SCHAR=y CONFIG_EXAMPLES_I2SCHAR_TX=y CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2 diff --git a/boards/xtensa/esp32/esp32-lyrat/configs/rtptools/defconfig b/boards/xtensa/esp32/esp32-lyrat/configs/rtptools/defconfig index fddd16fc2eb01..c8f9374e8aaf5 100644 --- a/boards/xtensa/esp32/esp32-lyrat/configs/rtptools/defconfig +++ b/boards/xtensa/esp32/esp32-lyrat/configs/rtptools/defconfig @@ -51,10 +51,10 @@ CONFIG_ESP32_I2S0_MCLK=y CONFIG_ESP32_I2S0_WSPIN=25 CONFIG_ESP32_I2S=y CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_ESP32_WIFI_DYNAMIC_RXBUF_NUM=64 -CONFIG_ESP32_WIFI_DYNAMIC_TXBUF_NUM=64 -CONFIG_ESP32_WIFI_STATIC_RXBUF_NUM=16 +CONFIG_ESPRESSIF_WIFI=y +CONFIG_ESPRESSIF_WIFI_DYNAMIC_RXBUF_NUM=64 +CONFIG_ESPRESSIF_WIFI_DYNAMIC_TXBUF_NUM=64 +CONFIG_ESPRESSIF_WIFI_STATIC_RXBUF_NUM=16 CONFIG_EXAMPLES_I2SCHAR=y CONFIG_EXAMPLES_I2SCHAR_TX=y CONFIG_EXAMPLES_I2SCHAR_TXBUFFERS=2 diff --git a/boards/xtensa/esp32/esp32-lyrat/configs/wifi/defconfig b/boards/xtensa/esp32/esp32-lyrat/configs/wifi/defconfig index f71a06372d43d..80aca906a9cc6 100644 --- a/boards/xtensa/esp32/esp32-lyrat/configs/wifi/defconfig +++ b/boards/xtensa/esp32/esp32-lyrat/configs/wifi/defconfig @@ -33,7 +33,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=3072 CONFIG_INIT_ENTRYPOINT="nsh_main" diff --git a/boards/xtensa/esp32/esp32-lyrat/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-lyrat/src/esp32_bringup.c index 41e91a29cd624..d9f381d8d878a 100644 --- a/boards/xtensa/esp32/esp32-lyrat/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-lyrat/src/esp32_bringup.c @@ -64,11 +64,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -206,7 +206,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -214,7 +214,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-pico-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-pico-kit/src/esp32_bringup.c index b974c138c68f5..b27ed9863f8f3 100644 --- a/boards/xtensa/esp32/esp32-pico-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-pico-kit/src/esp32_bringup.c @@ -63,15 +63,15 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32_wifi_adapter.h" #endif @@ -228,7 +228,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32_wifi_bt_coexist_init(); if (ret) { @@ -237,7 +237,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -245,7 +245,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-sparrow-kit/configs/mqttc/defconfig b/boards/xtensa/esp32/esp32-sparrow-kit/configs/mqttc/defconfig index 60ecd9f25af90..996b8aa6f7b50 100644 --- a/boards/xtensa/esp32/esp32-sparrow-kit/configs/mqttc/defconfig +++ b/boards/xtensa/esp32/esp32-sparrow-kit/configs/mqttc/defconfig @@ -56,7 +56,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_EXAMPLES_MQTTC=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y diff --git a/boards/xtensa/esp32/esp32-sparrow-kit/configs/wifi/defconfig b/boards/xtensa/esp32/esp32-sparrow-kit/configs/wifi/defconfig index 2b9d05f7f0824..e63303a4c32fa 100644 --- a/boards/xtensa/esp32/esp32-sparrow-kit/configs/wifi/defconfig +++ b/boards/xtensa/esp32/esp32-sparrow-kit/configs/wifi/defconfig @@ -59,7 +59,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FAT_LCNAMES=y CONFIG_FAT_LFN=y CONFIG_FS_FAT=y diff --git a/boards/xtensa/esp32/esp32-sparrow-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-sparrow-kit/src/esp32_bringup.c index 4e5cdb0dcc44e..dd2c42ab8ecea 100644 --- a/boards/xtensa/esp32/esp32-sparrow-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-sparrow-kit/src/esp32_bringup.c @@ -67,11 +67,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -217,7 +217,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -225,7 +225,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/esp32-wrover-kit/configs/autopm/defconfig b/boards/xtensa/esp32/esp32-wrover-kit/configs/autopm/defconfig index 5e3a9bb23fc66..51ed5b9e1756e 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/configs/autopm/defconfig +++ b/boards/xtensa/esp32/esp32-wrover-kit/configs/autopm/defconfig @@ -27,8 +27,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y -CONFIG_EXAMPLE_POWER_SAVE_MIN_MODEM=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-wrover-kit/configs/wifi/defconfig b/boards/xtensa/esp32/esp32-wrover-kit/configs/wifi/defconfig index ea83c20b0a99c..186c1571557fe 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/configs/wifi/defconfig +++ b/boards/xtensa/esp32/esp32-wrover-kit/configs/wifi/defconfig @@ -26,7 +26,7 @@ CONFIG_ESP32_SPIFLASH=y CONFIG_ESP32_SPIFLASH_SPIFFS=y CONFIG_ESP32_STORAGE_MTD_SIZE=0x80000 CONFIG_ESP32_UART0=y -CONFIG_ESP32_WIFI=y +CONFIG_ESPRESSIF_WIFI=y CONFIG_FS_PROCFS=y CONFIG_HAVE_CXX=y CONFIG_HAVE_CXXINITIALIZE=y diff --git a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c index 747f169aad849..0d249be140d51 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c +++ b/boards/xtensa/esp32/esp32-wrover-kit/src/esp32_bringup.c @@ -63,11 +63,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -205,7 +205,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -213,7 +213,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/lilygo_tbeam_lora_gps/src/esp32_bringup.c b/boards/xtensa/esp32/lilygo_tbeam_lora_gps/src/esp32_bringup.c index c46866819e3b1..ef44edd6e17b8 100644 --- a/boards/xtensa/esp32/lilygo_tbeam_lora_gps/src/esp32_bringup.c +++ b/boards/xtensa/esp32/lilygo_tbeam_lora_gps/src/esp32_bringup.c @@ -71,11 +71,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -210,7 +210,7 @@ int esp32_bringup(void) } #endif /* CONFIG_LPWAN_SX127X */ -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -218,7 +218,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_bringup.c b/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_bringup.c index 0bbcbc10460c8..54b9eb31ece4c 100644 --- a/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_bringup.c +++ b/boards/xtensa/esp32/ttgo_eink5_v2/src/esp32_bringup.c @@ -75,15 +75,15 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS # include "esp32_board_wlan.h" #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32_wifi_adapter.h" #endif @@ -274,7 +274,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32_wifi_bt_coexist_init(); if (ret) { @@ -283,7 +283,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -291,7 +291,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIRELESS +#ifdef CONFIG_ESPRESSIF_WIRELESS ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c index ae6ab94c82b52..1412734f28559 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c +++ b/boards/xtensa/esp32/ttgo_lora_esp32/src/esp32_bringup.c @@ -71,11 +71,11 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif @@ -210,7 +210,7 @@ int esp32_bringup(void) } #endif /* CONFIG_LPWAN_SX127X */ -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -218,7 +218,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) { diff --git a/boards/xtensa/esp32/ttgo_t_display_esp32/src/esp32_bringup.c b/boards/xtensa/esp32/ttgo_t_display_esp32/src/esp32_bringup.c index 9b6057a2d12b8..f285d3aac469a 100644 --- a/boards/xtensa/esp32/ttgo_t_display_esp32/src/esp32_bringup.c +++ b/boards/xtensa/esp32/ttgo_t_display_esp32/src/esp32_bringup.c @@ -71,15 +71,15 @@ # include "esp32_board_spiflash.h" #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE # include "esp32_ble.h" #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI # include "esp32_board_wlan.h" #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST # include "esp32_wifi_adapter.h" #endif @@ -277,7 +277,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI_BT_COEXIST +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST ret = esp32_wifi_bt_coexist_init(); if (ret) { @@ -286,7 +286,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_BLE +#ifdef CONFIG_ESPRESSIF_BLE ret = esp32_ble_initialize(); if (ret) { @@ -294,7 +294,7 @@ int esp32_bringup(void) } #endif -#ifdef CONFIG_ESP32_WIFI +#ifdef CONFIG_ESPRESSIF_WIFI ret = board_wlan_init(); if (ret < 0) {