- 1. Introduction
- 2. Design
- 3. Get Started
- 4. Throughput Performance
- 5. Coming soon
- 6. Want to support?
This is a Next-Generation ESP-Hosted specifically designed for a sophisticated hosts that run Linux operating system. This flavour of the solution takes more standard approach while providing a network interface to the host. User space applications such as wpa_supplicant, iw etc, can be used with this interface.
This solution offers following:
- 802.11 network interface which is a standard Wi-Fi interface on Linux host
- Configuration of Wi-Fi is supported through standard cfg80211 interface of Linux
- A standard HCI interface
This solution provides following WLAN and BT/BLE features to the host:
- WLAN Features:
- 802.11b/g/n
- WLAN Station
- Security Modes: Open, WPA/WPA2
- BT/BLE
- Classic Bluetooth
- BLE 4.2
ESP-Hosted-NG solution is supported on following ESP boards:
- ESP32
Looking for other chipset? Please do check Coming Soon section.
- ESP-Hosted-NG solution showcase examples for following Linux based hosts out of the box.
- Raspberry-Pi 3 Model B
- Raspberry-Pi 3 Model B+
- Raspberry-Pi 4 Model B
- This solution is aimed for Linux based hosts only. For microcontroller(MCU) based hosts (like STM32 etc), ESP-Hosted-FG flavour should be used.
- Although we try to help in porting, We expect users to get the transport interfaces like SDIO/SPI/UART configured on your Linux platform. Device tree configuration and device drivers could be some times tricky as every Linux platform has it different.
- It is relatively easy to port this solution to other Linux based platforms. Please refer Porting Guide for the common steps.
ESP-Hosted-NG uses SDIO and SPI and optionally UART bus for interfacing ESP boards and host platform. Mostly all Linux based host support this transport. Further section depicts supported host platforms and corresponding transport interface, ESP boards and feature set.
The below table explains which feature is supported on which transport interface for Linux based host.
| ESP device | Transport Interface | Wi-Fi support | Bluetooth support |
|---|---|---|---|
| ESP32 | SDIO | ✓ | ✓ |
| SPI | ✓ | ✓ | |
| UART | ✕ | ✓ | |
| SDIO(WiFi) + UART(BT) | ✓ | ✓ | |
| SPI(WiFi) + UART(BT) | ✓ | ✓ |
This section explains building blocks of the solution. Following is the detailed system architecture diagram:
Following are the key building blocks of the system:
-
ESP-Hosted-NG Driver
-
ESP-Hosted-NG Firmware
-
Third party components
This runs on host platform and it implements following.
- Transport driver
- Implements transport layer over SDIO/SPI interface.
Communication protocol is explained in further section.
- Implements transport layer over SDIO/SPI interface.
- Network Interface
- Registers Wi-Fi interface
espsta0with Linux kernel.- This allows exchange of network data packets between Linux kernel and ESP firmware.
- Implements needed cfg80211_ops to support configuration through wpa_supplicant or iw utility
- Registers Wi-Fi interface
- HCI Interface
- Applicable only when SDIO/SPI interface is being used for Bluetooth/BLE support
- Registers HCI interface with the Bluetooth stack running on Linux host
- This facilitates exchange of HCI packets between Linux kernel and ESP firmware
This implements ESP application that runs on ESP boards. It consists of the following.
- ESP-Hosted-NG Application
This implements following:- SDIO/SPI transport layer
- Custom command/response implementation for configuration of Wi-Fi interface
- Data path between Wi-Fi driver of ESP and Host platform
- ESP-IDF Components
ESP firmware mainly uses following components from ESP-IDF. Please check ESP-IDF documentation for more details.- SDIO/SPI/UART slave driver
- Wi-Fi driver
- HCI controller driver
Third components such as following are essential for end to end working of this solution. Implementation or porting of these third party component is not in scope of this project.
- TCP/IP stack
- Bluetooth/BLE stack
- nl80211/cfg80211 kernel module
- User space applications
- Linux UART driver
This section explains transport layer protocol used for communication over SDIO/SPI bus. Please refer following to know more:
This section explains the header that encapsulates the data packets exchanged over SDIO and SPI interfaces.
- Host and peripheral makes use of 12 byte payload header which precedes every data packet.
- This payload header provides additional meta data about the packet. Based on this header, host/peripheral consumes the transmitted data packet.
- Payload format is as below
| Field | Length | Description |
|---|---|---|
| Interface type | 4 bits | Possible values: STA(0), SoftAP(1), HCI (2), Priv interface(3). Rest all values are reserved |
| Interface number | 4 bits | Unused |
| Flags | 1 byte | Additional flags like MORE_FRAGMENT in fragmentation |
| Packet type | 1 byte | Type of packet Data(0), Command_req(1), Command_resp(2), Event(3), EAPOL_frame(4) |
| Reserved1 | 1 byte | Not in use |
| Packet length | 2 bytes | Actual length of data packet |
| Offset to packet | 2 bytes | Offset to the start of the data payload |
| Checksum | 2 bytes | Unused as if now |
| Reserved2 | 1 byte | Not in use |
Refer Porting Guide which explains how one can port the solution to other Linux host platforms.
ESP-Hosted uses SDIO/SPI/UART interfaces to connect ESP chipset to host platform. This section explains the setup needed for each of the interface type and it also covers software configuration part. The host side setup instructions are specific to Raspberry Pi.
Please check Hardware and Software Setup.
This section explains how to setup and use Wi-Fi and BT/BLE.
User space tool such as wpa_supplicant/iw is used to setup Wi-Fi.
Following operations supported as of now:
- Scanning
- Connect to AP
- Disconnect from AP
-
To scan nearby APs available, please use
$ sudo iw dev espsta0 scan
-
Two types of security modes are supported
-
Connect to AP in
openmode$ sudo iw dev espsta0 connect <ssid>
-
Connect to AP in
WPA/WPA2 security modewpa_supplicantalready running on host operating system can interfere in testing. Execute following commands to prevent this.
$ sudo killall wpa_supplicant
- Start supplicant with expected config
$ wpa_passphrase <ssid> <password> > ~/my_wpa_config.conf # This creates config file with security settings $ sudo wpa_supplicant -D nl80211 -i espsta0 -c ~/my_wpa_config.conf # connect to specified AP
-
-
Verify the connection status using following command and verify
ESSID:<ssid>in output$ iwconfig espsta0 espsta0 IEEE 802.11 ESSID:<ssid> Mode:Managed Frequency:2.412 GHz Access Point: XX:XX:XX:XX:XX:XX Bit Rate=XXX Mb/s Tx-Power=XX dBm Retry short limit:X RTS thr:off Fragment thr:off Power Management:on Link Quality=70/70 Signal level=-20 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:25 Missed beacon:0
-
Use dhclient command to get IP and verify data path using ping command
$ sudo dhclient -v espsta0 Internet Systems Consortium DHCP Client 4.4.1 Copyright 2004-2018 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Listening on LPF/espsta0/24:6f:28:80:2c:34 Sending on LPF/espsta0/24:6f:28:80:2c:34 Sending on Socket/fallback . DHCPDISCOVER on espsta0 to 255.255.255.255 port 67 interval 7 DHCPOFFER of 192.168.43.32 from 192.168.43.1 DHCPREQUEST for 192.168.43.32 on espsta0 to 255.255.255.255 port 67 DHCPACK of 192.168.43.32 from 192.168.43.1 bound to 192.168.43.32 -- renewal in 1482 seconds. $ ping <ip address of AP>
-
Execute following command to disconnect from AP
$ sudo iw dev espsta0 disconnect
-
Verify status using
$ iwconfig espsta0
Refer Bluetooth/BLE Guide which explains how one can setup and use Bluetooth/BLE.
| ESP device | Transport Interface | TCP Tx | TCP Rx | UDP Tx | UDP Rx |
|---|---|---|---|---|---|
| ESP32 | SDIO | 22.9 Mbps | 15.6 Mbps | 45.6 Mbps | 20.4 Mbps |
| SPI | 7.47 Mbps | 7.30 Mbps | 7.39 Mbps | 7.32 Mbps |
Tremendous work to be done ahead! Below is glimpse of upcoming release:
- Functionality
- cfg802.11 support for ESP as SoftAP
- Bluetooth (BT/BLE) connectivity
- Chipsets
- ESP32-S3, ESP32-C3 support
That's right. Being open source, we really appreciate the pull requests. Already raised pull request? Please be patient. We will review and merge your commit into the master.
