diff --git a/iot/Kconfig b/iot/Kconfig index 730cbc21f7..54519f43e0 100644 --- a/iot/Kconfig +++ b/iot/Kconfig @@ -15,6 +15,7 @@ source "$PKGS_DIR/packages/iot/WebTerminal/Kconfig" source "$PKGS_DIR/packages/iot/freemodbus/Kconfig" source "$PKGS_DIR/packages/iot/nanopb/Kconfig" source "$PKGS_DIR/packages/iot/wifi-host-driver/Kconfig" +source "$PKGS_DIR/packages/iot/esp-hosted/Kconfig" source "$PKGS_DIR/packages/iot/WiFi/Kconfig" source "$PKGS_DIR/packages/iot/coap/Kconfig" source "$PKGS_DIR/packages/iot/nopoll/Kconfig" diff --git a/iot/esp-hosted/Kconfig b/iot/esp-hosted/Kconfig new file mode 100644 index 0000000000..72fa49d1ae --- /dev/null +++ b/iot/esp-hosted/Kconfig @@ -0,0 +1,574 @@ + +# Kconfig file for package esp-hosted +menuconfig PKG_USING_ESP_HOSTED + bool "ESP-Hosted for RT-Thread" + select RT_USING_WIFI + select RT_USING_SAL + select RT_USING_SPI + select BSP_USING_SPI + default n + + if PKG_USING_ESP_HOSTED + + menu "ESP-Hosted Configure" + + choice + prompt "Select the transport interface" + default ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_SPI_HOST_INTERFACE + bool "SPI" + + # config ESP_HOSTED_SDIO_HOST_INTERFACE + # bool "SDIO" + endchoice + + choice + prompt "Slave chipset to be used" + default ESP_HOSTED_SLAVE_CHIPSET_ESP32 + + config ESP_HOSTED_SLAVE_CHIPSET_ESP32 + depends on ESP_HOSTED_SPI_HOST_INTERFACE || ESP_HOSTED_SDIO_HOST_INTERFACE + bool "Slave as ESP32" + + config ESP_HOSTED_SLAVE_CHIPSET_ESP32S2 + depends on ESP_HOSTED_SPI_HOST_INTERFACE + bool "Slave as ESP32S2" + + config ESP_HOSTED_SLAVE_CHIPSET_ESP32S3 + depends on ESP_HOSTED_SPI_HOST_INTERFACE + bool "Slave as ESP32S3" + + config ESP_HOSTED_SLAVE_CHIPSET_ESP32C2 + depends on ESP_HOSTED_SPI_HOST_INTERFACE + bool "Slave as ESP32C2" + + config ESP_HOSTED_SLAVE_CHIPSET_ESP32C3 + depends on ESP_HOSTED_SPI_HOST_INTERFACE + bool "Slave as ESP32C3" + + config ESP_HOSTED_SLAVE_CHIPSET_ESP32C6 + depends on ESP_HOSTED_SPI_HOST_INTERFACE || ESP_HOSTED_SDIO_HOST_INTERFACE + bool "Slave as ESP32C6" + endchoice + + menuconfig ESP_HOSTED_RAW_THROUGHPUT_TRANSPORT + bool "Enable raw throughput transport" + default n + help + Find max transport performance which helps to assess stability of porting done + + if ESP_HOSTED_RAW_THROUGHPUT_TRANSPORT + choice + prompt "Select raw throughput direction" + default ESP_HOSTED_RAW_THROUGHPUT_TX_TO_SLAVE + + config ESP_HOSTED_RAW_THROUGHPUT_TX_TO_SLAVE + bool "TX to slave" + + config ESP_HOSTED_RAW_THROUGHPUT_RX_FROM_SLAVE + bool "RX from slave" + + config ESP_HOSTED_RAW_THROUGHPUT_BIDIRECTIONAL + bool "Bidirectional" + endchoice + + config ESP_HOSTED_RAW_TP_REPORT_INTERVAL + int "The report interval of raw throughput in sec" + default 10 + + config ESP_HOSTED_RAW_TP_HOST_TO_ESP_PKT_LEN + int "The length of the data to be sent in raw throughput" + range 1 1500 + default 1460 + endif + + config ESP_HOSTED_PKT_STATS + bool "Enable Transport level packet statistics" + default n + help + On comparing with slave packet stats helps to understand any packet loss at hosted + + config ESP_HOSTED_MAX_SIMULTANEOUS_SYNC_RPC_REQUESTS + int "The maximum number of simultaneous sync rpc requests" + range 1 20 + default 8 + + config ESP_HOSTED_MAX_SIMULTANEOUS_ASYNC_RPC_REQUESTS + int "The maximum number of simultaneous async rpc requests" + range 1 20 + default 8 + + config ESP_HOSTED_RPC_THREAD_PRIORITY + int "The priority of the esp-hosted rpc thread" + range 0 32 + default 20 + + config ESP_HOSTED_RPC_THREAD_STACK_SIZE + int "The stack size of the esp-hosted rpc thread" + range 0 8192 + default 5120 + + config ESP_HOSTED_TRANSPORT_THREAD_PRIORITY + int "The priority of the esp-hosted transport thread" + range 0 32 + default 20 + + config ESP_HOSTED_TRANSPORT_THREAD_STACK_SIZE + int "The stack size of the esp-hosted SPI thread" + range 0 4096 + default 1024 + + config ESP_HOSTED_TRANSPORT_QUEUE_NUMBER + int "The number for esp-hosted SPI queue" + range 0 32 + default 8 + + config ESP_HOSTED_SPI_DEVICE_NAME + string "Set the spi device name" + default "esp-hosted" + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_SPI_BUS_NAME + string "Set the spi bus name" + default "spi1" + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_SPI_MAX_HZ + int "Set the maximum spi frequency(Hz)" + default 30000000 + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + choice + prompt "Select the pin name or number" + default ESP_HOSTED_USING_PIN_NAME + + config ESP_HOSTED_USING_PIN_NAME + bool "Name" + + config ESP_HOSTED_USING_PIN_NUMBER + bool "Number" + endchoice + + if ESP_HOSTED_USING_PIN_NAME + config ESP_HOSTED_SPI_CS_PIN_NAME + string "Set the SPI CS pin name" + default "PA.0" + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_DATA_READY_PIN_NAME + string "Set the data ready pin name" + default "PA.0" + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_HANDSHAKE_PIN_NAME + string "Set the handshake pin name" + default "PA.0" + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_RESET_PIN_NAME + string "Set the reset pin name" + default "PA.0" + endif + + if ESP_HOSTED_USING_PIN_NUMBER + config ESP_HOSTED_SPI_CS_PIN + int "Set the SPI CS pin" + default -1 + depends on ESP_HOSTED_SPI_HOST_INTERFACE + + config ESP_HOSTED_DATA_READY_PIN + int "Set the data ready pin" + default -1 + + config ESP_HOSTED_HANDSHAKE_PIN + int "Set the handshake pin" + default -1 + + config ESP_HOSTED_RESET_PIN + int "Set the reset pin" + default -1 + endif + + config ESP_HOSTED_THREAD_INIT + bool "Use thread initialization" + default y + + if ESP_HOSTED_THREAD_INIT + config ESP_HOSTED_INIT_THREAD_STACK_SIZE + int "The stack size of the init thread" + range 0 4096 + default 2048 + + config ESP_HOSTED_INIT_THREAD_PRIORITY + int "The priority of the init thread" + range 0 32 + default 20 + endif + endmenu # ESP-Hosted Configure + + menuconfig ESP_HOSTED_BT_ENABLED + bool "Enable Bluetooth" + default n + + if ESP_HOSTED_BT_ENABLED + choice + prompt "Select hci interface" + default ESP_HOSTED_BT_USING_VHCI_DEVICE_DRIVER + + config ESP_HOSTED_BT_USING_VHCI_DEVICE_DRIVER + bool "Using vhci device drivers" + + config ESP_HOSTED_BT_USING_NIMBLE_STACK + bool "Using NimBLE hci drivers" + endchoice + + if ESP_HOSTED_BT_USING_VHCI_DEVICE_DRIVER + config ESP_HOSTED_VHCI_DEVICE_NAME + string "The vhci device name" + default "vhci" + + config ESP_HOSTED_VHCI_DEVICE_BUF_SIZE + int "The vhci device buffer size" + default 512 + endif + endif + + menu "Wi-Fi Configure" + + config SOC_WIFI_HE_SUPPORT + bool + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C6 + + config SOC_WIFI_HE_SUPPORT_5G + bool + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C5 + + config SOC_WIFI_CSI_SUPPORT + bool + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C3 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C5 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C6 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32S2 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32S3 + + config SOC_WIFI_FTM_SUPPORT + bool + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C2 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C3 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C6 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32S2 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32S3 + + config SOC_WIFI_GCMP_SUPPORT + bool + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C3 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C5 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32C6 + default y if ESP_HOSTED_SLAVE_CHIPSET_ESP32S3 + + config ESP_WIFI_STATIC_RX_BUFFER_NUM + int "Max number of WiFi static RX buffers" + range 2 25 if !SOC_WIFI_HE_SUPPORT + range 2 128 if SOC_WIFI_HE_SUPPORT + default 10 + help + Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM. + The static rx buffers are allocated when esp_wifi_init is called, they are not freed + until esp_wifi_deinit is called. + + WiFi hardware use these buffers to receive all 802.11 frames. + A higher number may allow higher throughput but increases memory use. If ESP_WIFI_AMPDU_RX_ENABLED + is enabled, this value is recommended to set equal or bigger than ESP_WIFI_RX_BA_WIN in order to + achieve better throughput and compatibility with both stations and APs. + + config ESP_WIFI_DYNAMIC_RX_BUFFER_NUM + int "Max number of WiFi dynamic RX buffers" + range 0 128 if !LWIP_WND_SCALE + range 0 1024 if LWIP_WND_SCALE + default 32 + help + Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers will be allocated + (provided sufficient free RAM). The size of each dynamic RX buffer depends on the size of + the received data frame. + + For each received data frame, the WiFi driver makes a copy to an RX buffer and then delivers + it to the high layer TCP/IP stack. The dynamic RX buffer is freed after the higher layer has + successfully received the data frame. + + For some applications, WiFi data frames may be received faster than the application can + process them. In these cases we may run out of memory if RX buffer number is unlimited (0). + + If a dynamic RX buffer limit is set, it should be at least the number of static RX buffers. + + choice ESP_WIFI_TX_BUFFER + prompt "Type of WiFi TX buffers" + default ESP_WIFI_DYNAMIC_TX_BUFFER + help + Select type of WiFi TX buffers: + + If "Static" is selected, WiFi TX buffers are allocated when WiFi is initialized and released + when WiFi is de-initialized. The size of each static TX buffer is fixed to about 1.6KB. + + If "Dynamic" is selected, each WiFi TX buffer is allocated as needed when a data frame is + delivered to the Wifi driver from the TCP/IP stack. The buffer is freed after the data frame + has been sent by the WiFi driver. The size of each dynamic TX buffer depends on the length + of each data frame sent by the TCP/IP layer. + + If PSRAM is enabled, "Static" should be selected to guarantee enough WiFi TX buffers. + If PSRAM is disabled, "Dynamic" should be selected to improve the utilization of RAM. + + config ESP_WIFI_STATIC_TX_BUFFER + bool "Static" + config ESP_WIFI_DYNAMIC_TX_BUFFER + bool "Dynamic" + + endchoice + + config ESP_WIFI_TX_BUFFER_TYPE + int + default 0 if ESP_WIFI_STATIC_TX_BUFFER + default 1 if ESP_WIFI_DYNAMIC_TX_BUFFER + + config ESP_WIFI_STATIC_TX_BUFFER_NUM + int "Max number of WiFi static TX buffers" + depends on ESP_WIFI_STATIC_TX_BUFFER + range 1 64 + default 16 + help + Set the number of WiFi static TX buffers. Each buffer takes approximately 1.6KB of RAM. + The static RX buffers are allocated when esp_wifi_init() is called, they are not released + until esp_wifi_deinit() is called. + + For each transmitted data frame from the higher layer TCP/IP stack, the WiFi driver makes a + copy of it in a TX buffer. For some applications especially UDP applications, the upper + layer can deliver frames faster than WiFi layer can transmit. In these cases, we may run out + of TX buffers. + + config ESP_WIFI_CACHE_TX_BUFFER_NUM + int "Max number of WiFi cache TX buffers" + range 16 128 + default 0 + help + Set the number of WiFi cache TX buffer number. + + For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to allocate a static TX + buffer and makes a copy of uplayer packet. If WiFi driver fails to allocate the static TX buffer, + it caches the uplayer packets to a dedicated buffer queue, this option is used to configure the + size of the cached TX queue. + + config ESP_WIFI_DYNAMIC_TX_BUFFER_NUM + int "Max number of WiFi dynamic TX buffers" + depends on ESP_WIFI_DYNAMIC_TX_BUFFER + range 1 128 + default 32 + help + Set the number of WiFi dynamic TX buffers. The size of each dynamic TX buffer is not fixed, + it depends on the size of each transmitted data frame. + + For each transmitted frame from the higher layer TCP/IP stack, the WiFi driver makes a copy + of it in a TX buffer. For some applications, especially UDP applications, the upper layer + can deliver frames faster than WiFi layer can transmit. In these cases, we may run out of TX + buffers. + + config ESP_WIFI_CSI_ENABLED + bool "WiFi CSI(Channel State Information)" + depends on SOC_WIFI_CSI_SUPPORT + default n + help + Select this option to enable CSI(Channel State Information) feature. CSI takes about + ESP_WIFI_STATIC_RX_BUFFER_NUM KB of RAM. If CSI is not used, it is better to disable + this feature in order to save memory. + + config ESP_WIFI_AMPDU_TX_ENABLED + bool "WiFi AMPDU TX" + default y + help + Select this option to enable AMPDU TX feature + + + config ESP_WIFI_TX_BA_WIN + int "WiFi AMPDU TX BA window size" + depends on ESP_WIFI_AMPDU_TX_ENABLED + range 2 32 if !SOC_WIFI_HE_SUPPORT + range 2 64 if SOC_WIFI_HE_SUPPORT + default 6 + help + Set the size of WiFi Block Ack TX window. Generally a bigger value means higher throughput but + more memory. Most of time we should NOT change the default value unless special reason, e.g. + test the maximum UDP TX throughput with iperf etc. For iperf test in shieldbox, the recommended + value is 9~12. + + config ESP_WIFI_AMPDU_RX_ENABLED + bool "WiFi AMPDU RX" + default y + help + Select this option to enable AMPDU RX feature + + config ESP_WIFI_RX_BA_WIN + int "WiFi AMPDU RX BA window size" + depends on ESP_WIFI_AMPDU_RX_ENABLED + range 2 32 if !SOC_WIFI_HE_SUPPORT + range 2 64 if SOC_WIFI_HE_SUPPORT + default 6 + help + Set the size of WiFi Block Ack RX window. Generally a bigger value means higher throughput and better + compatibility but more memory. Most of time we should NOT change the default value unless special + reason, e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in shieldbox, the + recommended value is 9~12. If PSRAM is used and WiFi memory is prefered to allocat in PSRAM first, + the default and minimum value should be 16 to achieve better throughput and compatibility with both + stations and APs. + + config ESP_WIFI_AMSDU_TX_ENABLED + bool "WiFi AMSDU TX" + depends on SPIRAM + default n + help + Select this option to enable AMSDU TX feature + + config ESP_WIFI_SOFTAP_BEACON_MAX_LEN + int "Max length of WiFi SoftAP Beacon" + range 752 1256 + default 752 + help + ESP-MESH utilizes beacon frames to detect and resolve root node conflicts (see documentation). However the + default length of a beacon frame can simultaneously hold only five root node identifier structures, + meaning that a root node conflict of up to five nodes can be detected at one time. In the occurence of + more root nodes conflict involving more than five root nodes, the conflict resolution process will detect + five of the root nodes, resolve the conflict, and re-detect more root nodes. This process will repeat + until all root node conflicts are resolved. However this process can generally take a very long time. + + To counter this situation, the beacon frame length can be increased such that more root nodes can be + detected simultaneously. Each additional root node will require 36 bytes and should be added ontop of the + default beacon frame length of + 752 bytes. For example, if you want to detect 10 root nodes simultaneously, you need to set the beacon + frame length as + 932 (752+36*5). + + Setting a longer beacon length also assists with debugging as the conflicting root nodes can be identified + more quickly. + + config ESP_WIFI_MGMT_SBUF_NUM + int "WiFi mgmt short buffer number" + range 6 32 + default 32 + help + Set the number of WiFi management short buffer. + + config ESP_WIFI_ENABLE_WPA3_SAE + bool "Enable WPA3-Personal" + default y + help + Select this option to allow the device to establish a WPA3-Personal 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 ESP_WIFI_FTM_ENABLE + bool "WiFi FTM" + default n + depends on SOC_WIFI_FTM_SUPPORT + help + Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT). + + config ESP_WIFI_FTM_INITIATOR_SUPPORT + bool "FTM Initiator support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_FTM_RESPONDER_SUPPORT + bool "FTM Responder support" + default y + depends on ESP_WIFI_FTM_ENABLE + + config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE + bool "Power Management for station at 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 any more. + + config ESP_WIFI_GCMP_SUPPORT + bool "WiFi GCMP Support(GCMP128 and GCMP256)" + default n + depends on SOC_WIFI_GCMP_SUPPORT + 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 ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM + int "Maximum espnow encrypt peers number" + range 0 4 if ESP_HOSTED_SLAVE_CHIPSET_ESP32C2 + range 0 17 if (!ESP_HOSTED_SLAVE_CHIPSET_ESP32C2) + default 2 if ESP_HOSTED_SLAVE_CHIPSET_ESP32C2 + default 7 if (!ESP_HOSTED_SLAVE_CHIPSET_ESP32C2) + help + Maximum number of encrypted peers supported by espnow. + The number of hardware keys for encryption is fixed. And the espnow and SoftAP share the same + hardware keys. So this configuration will affect the maximum connection number of SoftAP. + Maximum espnow encrypted peers number + maximum number of connections of SoftAP = Max hardware keys number. + When using ESP mesh, this value should be set to a maximum of 6. + + config ESP_WIFI_11R_SUPPORT + bool "Enable 802.11R (Fast Transition) Support" + default n + help + Select this option to enable WiFi Fast Transition Support. + + endmenu # Wi-Fi Configure + + config PKG_ESP_HOSTED_PATH + string + default "/packages/iot/esp-hosted" + + if PKG_ESP_HOSTED_VER_NUM >= 0x10200 + choice + prompt "Select the log level" + default CY_WIFI_LOG_LEVEL_INFO + + config CY_WIFI_LOG_LEVEL_NONE + bool "None" + + config CY_WIFI_LOG_LEVEL_ERROR + bool "Error" + + config CY_WIFI_LOG_LEVEL_INFO + bool "Info" + + config CY_WIFI_LOG_LEVEL_DEBUG + bool "Debug" + + config CY_WIFI_LOG_LEVEL_DATA_TRACE + bool "Data Trace" + endchoice + endif + + choice + prompt "Version" + default PKG_USING_ESP_HOSTED_LATEST_VERSION + help + Select the package version + + config PKG_USING_ESP_HOSTED_V100 + bool "v1.0.0" + + config PKG_USING_ESP_HOSTED_LATEST_VERSION + bool "latest" + endchoice + + config PKG_ESP_HOSTED_VER + string + default "v1.0.0" if PKG_USING_ESP_HOSTED_V100 + default "latest" if PKG_USING_ESP_HOSTED_LATEST_VERSION + + config PKG_ESP_HOSTED_VER_NUM + hex + default 0x10000 if PKG_USING_ESP_HOSTED_V100 + default 0x99999 if PKG_USING_ESP_HOSTED_LATEST_VERSION + + endif diff --git a/iot/esp-hosted/package.json b/iot/esp-hosted/package.json new file mode 100644 index 0000000000..7d815fe606 --- /dev/null +++ b/iot/esp-hosted/package.json @@ -0,0 +1,33 @@ +{ + "name": "esp-hosted", + "description": "ESP-Hosted for RT-Thread.", + "description_zh": "将ESP32作为协处理器的WiFi主机驱动程序。", + "enable": "PKG_USING_ESP_HOSTED", + "keywords": [ + "esp-hosted" + ], + "category": "iot", + "author": { + "name": "Evlers", + "email": "1425295900@qq.com", + "github": "Evlers" + }, + "license": "MIT", + "repository": "https://github.com/Evlers/rt-thread_esp-hosted", + "icon": "unknown", + "homepage": "https://github.com/Evlers/rt-thread_esp-hosted#readme", + "doc": "unknown", + "site": [ + { + "version": "latest", + "URL": "https://github.com/Evlers/rt-thread_esp-hosted.git", + "filename": "", + "VER_SHA": "master" + }, + { + "version": "v1.0.0", + "URL": "https://github.com/Evlers/rt-thread_esp-hosted/archive/v1.0.0.zip", + "filename": "rt-thread_esp-hosted-1.0.0.zip" + } + ] +}