Skip to content

Commit

Permalink
Merge branch 'feature/uart_transport' into 'feature/esp_as_mcu_host'
Browse files Browse the repository at this point in the history
feature/uart_transport Added UART as a Hosted Transport

See merge request app-frameworks/esp_hosted!513
  • Loading branch information
mantriyogesh committed Sep 27, 2024
2 parents 19d4cde + 8455066 commit bcfd914
Show file tree
Hide file tree
Showing 22 changed files with 2,404 additions and 26 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ else()
list(APPEND COMPONENT_SRCS "${host_dir}/drivers/transport/sdio/sdio_drv.c" "${host_dir}/port/sdio_wrapper.c")
elseif(CONFIG_ESP_SPI_HD_HOST_INTERFACE)
list(APPEND COMPONENT_SRCS "${host_dir}/drivers/transport/spi_hd/spi_hd_drv.c" "${host_dir}/port/spi_hd_wrapper.c")
else(CONFIG_ESP_SPI_HOST_INTERFACE)
elseif(CONFIG_ESP_SPI_HOST_INTERFACE)
list(APPEND COMPONENT_SRCS "${host_dir}/drivers/transport/spi/spi_drv.c" "${host_dir}/port/spi_wrapper.c")
elseif(CONFIG_ESP_UART_HOST_INTERFACE)
list(APPEND COMPONENT_SRCS "${host_dir}/drivers/transport/uart/uart_drv.c" "${host_dir}/port/uart_wrapper.c")
endif()
endif()

Expand Down
163 changes: 154 additions & 9 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,43 @@ menu "ESP-Hosted config"
bool "SPI Half-duplex"
help
Enable/Disable SPI Half-duplex host interface

config ESP_UART_HOST_INTERFACE
bool "UART"
help
Enable/Disable UART host interface
endchoice

choice ESP_HOSTED_SLAVE_CHIPSET_USED
bool "Slave chipset to be used"
default SLAVE_CHIPSET_ESP32C6

config SLAVE_CHIPSET_ESP32
depends on ESP_SPI_HOST_INTERFACE || ESP_SDIO_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SDIO_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32"

config SLAVE_CHIPSET_ESP32S2
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32S2"

config SLAVE_CHIPSET_ESP32S3
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32S3"

config SLAVE_CHIPSET_ESP32C2
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32C2"

config SLAVE_CHIPSET_ESP32C3
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32C3"

config SLAVE_CHIPSET_ESP32C6
depends on ESP_SPI_HOST_INTERFACE || ESP_SDIO_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SDIO_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32C6"

config SLAVE_CHIPSET_ESP32C5
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE
depends on ESP_SPI_HOST_INTERFACE || ESP_SPI_HD_HOST_INTERFACE || ESP_UART_HOST_INTERFACE
bool "Slave as ESP32C5"
endchoice

Expand Down Expand Up @@ -664,16 +669,146 @@ ESP32XX_SPI_HD_CLK_FREQ_RANGE_MAX := 40
ENABLE/DISABLE software checksum
endmenu

menu "UART Configuration"
depends on ESP_UART_HOST_INTERFACE

choice ESP_UART_RESET_GPIO_CONFIG
bool "RESET GPIO Config"
default ESP_UART_RESET_ACTIVE_HIGH
help
"If Active High, High->Low->High will trigger reset (Low will trigger reset)
If Active Low, Low->High->Low will trigger reset (High will trigger reset)"

config ESP_UART_RESET_ACTIVE_HIGH
bool "RESET: Active High"
config ESP_UART_RESET_ACTIVE_LOW
bool "RESET: Active Low"
endchoice

config ESP_UART_PORT
int "UART Port to Use"
default 1
range 0 2 if IDF_TARGET_ESP32
range 0 1 if IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C5 || IDF_TARGET_ESP32C6
range 0 2 if IDF_TARGET_ESP32C61
range 0 1 if IDF_TARGET_ESP32S2
range 0 2 if IDF_TARGET_ESP32S3
range 0 4 if IDF_TARGET_ESP32P4
help
Select UART Port to Use. Do not select the UART Port used for console output (if enabled)

config ESP_UART_PIN_TX
int "TX GPIO number"
default 13 if IDF_TARGET_ESP32
default 5 if IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32C3
default 14 if IDF_TARGET_ESP32C5
default 21 if IDF_TARGET_ESP32C6
default 5 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 14 if IDF_TARGET_ESP32P4
help
GPIO used for UART TX

config ESP_UART_PIN_RX
int "RX GPIO number"
default 12 if IDF_TARGET_ESP32
default 4 if IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32C3
default 13 if IDF_TARGET_ESP32C5
default 20 if IDF_TARGET_ESP32C6
default 4 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
default 15 if IDF_TARGET_ESP32P4
help
GPIO used for UART RX

config ESP_UART_BAUDRATE
int "Baud Rate"
default 921600
range 9600 3500000
help
Baud Rate to Use. Make sure Hardware supports the rate. Standard rates are 9600, 19200, 38400, 57600, 115200, 460800, 921600

config ESP_UART_NUM_DATA_BITS
int "Number of Data Bits"
default 8
range 5 8
help
Number of Data Bits to use

choice ESP_UART_PRIV_PARITY
bool "Parity"

config ESP_UART_PRIV_PARITY_NONE
bool "None"

config ESP_UART_PRIV_PARITY_EVEN
bool "Even"

config ESP_UART_PRIV_PARITY_ODD
bool "Odd"
endchoice

config ESP_UART_PARITY
int
default 0 if ESP_UART_PRIV_PARITY_NONE
default 1 if ESP_UART_PRIV_PARITY_EVEN
default 2 if ESP_UART_PRIV_PARITY_ODD

choice ESP_UART_PRIV_STOP_BITS
bool "Number of Stop Bits"

config ESP_UART_PRIV_STOP_BITS_1
bool "1"

config ESP_UART_PRIV_STOP_BITS_1_5
bool "1.5"

config ESP_UART_PRIV_STOP_BITS_2
bool "2"
endchoice

config ESP_UART_STOP_BITS
int
default 0 if ESP_UART_PRIV_STOP_BITS_1
default 1 if ESP_UART_PRIV_STOP_BITS_1_5
default 2 if ESP_UART_PRIV_STOP_BITS_2

config ESP_UART_GPIO_RESET_SLAVE
int "GPIO pin for Reseting slave ESP"
default 54 if IDF_TARGET_ESP32P4
default 42 if IDF_TARGET_ESP32S3
default 5
help
GPIO pin for Resetting ESP SDIO slave device. Should be connected to RST/EN of ESP SDIO slave device.

config ESP_UART_TX_Q_SIZE
int "Tx Queue Size"
default 5
help
Very small RX queue will lower ESP -- UART --> Host data rate

config ESP_UART_RX_Q_SIZE
int "Rx Queue Size"
default 5
help
Very small RX queue will lower ESP <-- UART -- Host data rate

config ESP_UART_CHECKSUM
bool "UART checksum ENABLE/DISABLE"
default y
help
ENABLE/DISABLE software UART checksum
endmenu

config ESP_GPIO_SLAVE_RESET_SLAVE
int
default ESP_SPI_GPIO_RESET_SLAVE if ESP_SPI_HOST_INTERFACE
default ESP_SDIO_GPIO_RESET_SLAVE if ESP_SDIO_HOST_INTERFACE
default ESP_SPI_HD_GPIO_RESET_SLAVE if ESP_SPI_HD_HOST_INTERFACE
default ESP_UART_GPIO_RESET_SLAVE if ESP_UART_HOST_INTERFACE

config RESET_GPIO_ACTIVE_LOW
bool
default n if SDIO_RESET_ACTIVE_HIGH || SPI_RESET_ACTIVE_HIGH || SPI_HD_RESET_ACTIVE_HIGH
default y if SDIO_RESET_ACTIVE_LOW || SPI_RESET_ACTIVE_LOW || SPI_HD_RESET_ACTIVE_LOW
default n if SDIO_RESET_ACTIVE_HIGH || SPI_RESET_ACTIVE_HIGH || SPI_HD_RESET_ACTIVE_HIGH || ESP_UART_RESET_ACTIVE_HIGH
default y if SDIO_RESET_ACTIVE_LOW || SPI_RESET_ACTIVE_LOW || SPI_HD_RESET_ACTIVE_LOW || ESP_UART_RESET_ACTIVE_LOW

menu "Bluetooth Support"

Expand Down Expand Up @@ -824,12 +959,22 @@ ESP32XX_SPI_HD_CLK_FREQ_RANGE_MAX := 40
Host will throttle incoming data if the slave datapath Rx load goes beyond this threshold
0 value will disable this function

config PRIV_WIFI_TX_UART_HIGH_THRESHOLD
depends on HOST_TO_ESP_WIFI_DATA_THROTTLE && ESP_UART_HOST_INTERFACE
int "High threshold to report host to drop data when wifi highly loaded"
range 0 100
default 80
help
Host will throttle incoming data if the slave datapath Rx load goes beyond this threshold
0 value will disable this function

config TO_WIFI_DATA_THROTTLE_HIGH_THRESHOLD
depends on HOST_TO_ESP_WIFI_DATA_THROTTLE
int
default PRIV_WIFI_TX_SPI_HIGH_THRESHOLD if ESP_SPI_HOST_INTERFACE
default PRIV_WIFI_TX_SDIO_HIGH_THRESHOLD if ESP_SDIO_HOST_INTERFACE
default PRIV_WIFI_TX_SPI_HD_HIGH_THRESHOLD if ESP_SPI_HD_HOST_INTERFACE
default PRIV_WIFI_TX_UART_HIGH_THRESHOLD if ESP_UART_HOST_INTERFACE

config TO_WIFI_DATA_THROTTLE_LOW_THRESHOLD
depends on HOST_TO_ESP_WIFI_DATA_THROTTLE
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,19 @@ Legends:
| Transport | Type | Num of GPIOs | Setup with | Co-processor supported | Host Tx iperf | Host Rx iperf | Remarks |
|:---------------:|:-----:|:------------:|:----------------:|:--------------:|:------------:|:-----------:|:--------------------------:|
| Standard SPI | FD | 6 | jumper or PCB | Any_Slave | udp: 24 tcp: 22 | udp: 25 tcp: 22| Simplest solution for quick test |
| Dual SPI | HD | 5 | jumper or PCB | Any_Slave | udp: 32 tcp: 26 (O) | udp: 33 tcp: 25 (O) | Better throughput, but half duplex |
| Quad SPI | HD | 7 | PCB only | Any_Slave | udp: 41 tcp: 29 (O) | udp: 42 tcp: 28 (O) | Due to signal integrity, PCB is mandatory |
| Dual SPI | HD | 5 | jumper or PCB | Any_Slave [1] | udp: 32 tcp: 26 (O) | udp: 33 tcp: 25 (O) | Better throughput, but half duplex |
| Quad SPI | HD | 7 | PCB only | Any_Slave [1] | udp: 41 tcp: 29 (O) | udp: 42 tcp: 28 (O) | Due to signal integrity, PCB is mandatory |
| SDIO 1-Bit | HD | 4 | jumper or PCB | ESP32, ESP32-C6 | TBD | TBD | Stepping stone for PCB based SDIO 4-bit |
| SDIO 4-Bit | HD | 6 | PCB only | ESP32, ESP32-C6 | udp: 79.5 tcp: 53.4 (S) | udp: 68.1 tcp: 44 (S) | Highest performance |
| Only BT over UART | FD | 2 or 4 | jumper or PCB | Any_Slave | NA | NA | Dedicated Bluetooth over UART pins |
| UART | FD | 2 | jumper or PCB | Any_Slave | udp: 0.68 tcp: 0.67 (O) | udp: 0.68 tcp: 0.60 (O) | UART dedicated for BT & Wi-Fi [2] |
| Dedicated platforms | FD | Extra 2 or 4 | jumper or PCB | Any_Slave | NA | NA | UART dedicated for BT & Wi-Fi on any other transport |

> [!NOTE]
> - [1] Dual/Quad SPI is not supported on ESP32
>
> - [2] UART is only suitable for low throughput environments
With jumper cables, 'Standard SPI' and 'Dual SPI' solutions are easiest to evaluate, without much of hardware dependencies. SDIO 1-Bit can be tested with jumper cables, but it needs some additional hardware config, such as installation of external pull-up registers.

In case case of dedicated platforms, Blutooth uses standard HCI over UART. In rest of cases, Bluetooth and Wi-Fi uses same transport and hence less GPIOs and less complicated. In shared mode, bluetooth runs as vHCI (multiplexed mode)
Expand Down Expand Up @@ -235,7 +241,7 @@ Irrespective of transport chosen, following steps are needed, which are step-wis

- [**SDIO (1-Bit / 4-Bit)**](docs/sdio.md)

- [**UART**](docs/uart.md)
- [**UART for Wi-Fi and Bluetooth**](docs/uart.md)

## 9 Examples
Check [examples](./examples) directory for sample applications using ESP-Hosted.
Expand Down
7 changes: 6 additions & 1 deletion common/include/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ typedef enum {

typedef enum {
ESP_WLAN_SDIO_SUPPORT = (1 << 0),
ESP_BT_UART_SUPPORT = (1 << 1),
ESP_BT_UART_SUPPORT = (1 << 1), // HCI over UART
ESP_BT_SDIO_SUPPORT = (1 << 2),
ESP_BLE_ONLY_SUPPORT = (1 << 3),
ESP_BR_EDR_ONLY_SUPPORT = (1 << 4),
Expand All @@ -182,6 +182,11 @@ typedef enum {
// features supported
ESP_WLAN_SUPPORT = (1 << 4),
ESP_BT_INTERFACE_SUPPORT = (1 << 5), // bt supported over current interface
// leave a gap for future expansion

// Hosted UART interface
ESP_WLAN_UART_SUPPORT = (1 << 8),
ESP_BT_VHCI_UART_SUPPORT = (1 << 9), // VHCI over UART
} ESP_EXTENDED_CAPABILITIES;

typedef enum {
Expand Down
1 change: 1 addition & 0 deletions docs/design_consideration.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ solution to your problem may have already been provided.
- SPI Full Duplex interface documentation: [spi_full_duplex.md](spi_full_duplex.md)
- SDIO interface documentation: [sdio.md](sdio.md)
- SPI Half Duplex interface documentation: [spi_half_duplex.md](spi_half_duplex.md)
- UART documentation: [uart.md](uart.md)
- Troubleshooting Guide: [troubleshooting.md](troubleshooting.md)
Loading

0 comments on commit bcfd914

Please sign in to comment.