Merge branch 'feature/hosted_examples' into 'master'

feat(hosted_examples): Added ESP-Hosted to Wi-Fi examples

See merge request espressif/esp-idf!37624
This commit is contained in:
Jiang Jiang Jian
2025-07-22 17:48:26 +08:00
16 changed files with 180 additions and 87 deletions

View File

@@ -16,8 +16,16 @@
examples/wifi:
<<: *wifi_depends_default
enable:
- if: IDF_TARGET == "esp32h2"
disable:
- if: SOC_WIFI_SUPPORTED != 1
- if: (SOC_WIFI_SUPPORTED != 1) and (SOC_WIRELESS_HOST_SUPPORTED != 1)
examples/wifi/fast_scan:
enable:
- if: IDF_TARGET == "esp32h2"
disable:
- if: (SOC_WIFI_SUPPORTED != 1) and (SOC_WIRELESS_HOST_SUPPORTED != 1)
examples/wifi/ftm:
<<: *wifi_depends_default
@@ -27,12 +35,16 @@ examples/wifi/ftm:
examples/wifi/getting_started:
<<: *wifi_depends_default
enable:
- if: IDF_TARGET == "esp32h2"
disable:
- if: SOC_WIFI_SUPPORTED != 1
- if: (SOC_WIFI_SUPPORTED != 1) and (SOC_WIRELESS_HOST_SUPPORTED != 1)
depends_filepatterns:
- examples/wifi/getting_started/**/*
examples/wifi/iperf:
enable:
- if: IDF_TARGET == "esp32h2"
disable:
- if: (SOC_WIFI_SUPPORTED != 1) and (SOC_WIRELESS_HOST_SUPPORTED != 1)
- if: (IDF_TARGET == "esp32p4") and CONFIG_NAME in ["defaults", "99"]
@@ -70,6 +82,18 @@ examples/wifi/power_save:
- wpa_supplicant
- esp_driver_uart
examples/wifi/scan:
enable:
- if: IDF_TARGET == "esp32h2"
disable:
- if: (SOC_WIFI_SUPPORTED != 1) and (SOC_WIRELESS_HOST_SUPPORTED != 1)
examples/wifi/softap_sta:
enable:
- if: IDF_TARGET == "esp32h2"
disable:
- if: (SOC_WIFI_SUPPORTED != 1) and (SOC_WIRELESS_HOST_SUPPORTED != 1)
examples/wifi/wifi_aware:
disable:
- if: SOC_WIFI_NAN_SUPPORT != 1

View File

@@ -1,10 +1,14 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
# Wi-Fi Examples
This directory contains a range of examples ESP-IDF projects. These are intended to demonstrate the Wi-Fi functionality, and to provide code that you can copy and adapt into your own projects.
ESP Chips with Wi-Fi can use the examples as is.
ESP Chips without Wi-Fi (e.g., ESP32-P4 and ESP32-H2) can work with a [**two-chip solution**](#wi-fi-examples-with-two-chip-solution) described below.
# Example Layout
The examples are grouped into sub-directories by category. Each category directory contains one or more example projects:
@@ -23,6 +27,60 @@ The examples are grouped into sub-directories by category. Each category directo
* `wpa2_enterprise` shows how ESP connects to AP with WPA2 enterprise encryption.
* `wps` contains a how to use the Wi-Fi Protected Setup protocol.
## Wi-Fi Examples with Two-Chip Solution
Some ESP chips like the ESP32-P4 or ESP32-H2, without built-in Wi-Fi or Bluetooth, can still use these features through a **two-chip solution** via ESP-Hosted.
The two chip solution needs:
- Communication bus like SDIO or SPI between the host and co-processor
- Co-processor flashed with ESP-Hosted co-processor (slave) software
- Host processor flashed with additional software components: [esp-hosted](https://components.espressif.com/components/espressif/esp_hosted/) and [esp-wifi-remote](https://components.espressif.com/components/espressif/esp_wifi_remote/). This is handled by `idf_component.yml`. See the `idf_component.yml` in [iperf](iperf/main/idf_component.yml) for an example.
The ESP32-P4-Function-EV-Board is used here as a demonstration on how to run a Wi-Fi example.
### Running a Wi-Fi example on the ESP32-P4-Function-EV-Board
On this board,
* The ESP32-P4 is connected with the on-board ESP32-C6 (co-processor) using SDIO communication bus. See this ESP-Hosted ESP32-P4 EV Board [documentation](https://github.com/espressif/esp-hosted-mcu/blob/main/docs/esp32_p4_function_ev_board.md) for more information.
* The ESP32-C6 on the ESP32-P4 EV Board is pre-flashed with ESP-Hosted co-processor (slave) software.
* Only the example code needs to be built & flashed on the Host using the steps below.
#### Host Flashing
* Set ESP32-P4 as the target
```sh
idf.py set-target esp32p4
```
* Run Configure
```sh
idf.py menuconfig
```
Set `Component config` -> `Wi-Fi Remote` -> `choose slave target` to `esp32c6`.
Do any other project configuration required for the example.
* Build and Flash
```sh
idf.py -p <host serial port> flash monitor
```
### Co-processor Flashing
**(Optional, but recommended)**
The ESP32-C6 on the ESP32-P4 EV Board is already pre-flashed with ESP-Hosted co-processor software. Host software on the ESP-Hosted component is backward compatible with this co-processor software. It is recommended to upgrade to the latest software via [simplified co-processor OTA](https://github.com/espressif/esp-hosted-mcu/blob/main/docs/esp32_p4_function_ev_board.md#51-ota-updates) or by [manual flashing with ESP-Prog](https://github.com/espressif/esp-hosted-mcu/blob/main/docs/esp32_p4_function_ev_board.md#52-using-esp-prog).
### Troubleshooting
For any technical queries on the two-chip solution, please open an [ESP-Hosted issue](https://github.com/espressif/esp-hosted-mcu/issues) on GitHub.
# More
See the [README.md](../README.md) file in the upper level [examples](../) directory for more information about examples.

View File

@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
# Wi-Fi Fast Scan Example
@@ -92,6 +92,10 @@ I (2086) esp_netif_handlers: sta ip: 192.168.68.110, mask: 255.255.255.0, gw: 19
```
## Running the example on ESP Chips without Wi-Fi
This example can run on ESP Chips without Wi-Fi using ESP-Hosted. See the [Two-Chip Solution](../README.md#wi-fi-examples-with-two-chip-solution) section in the upper level `README.md` for information.
## Troubleshooting
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -67,7 +67,7 @@ menu "Example Configuration"
config EXAMPLE_FAST_SCAN_RSSI_5G_ADJUSTMENT
int "fast scan rssi 5g adjustment"
depends on EXAMPLE_FAST_SCAN_THRESHOLD && SOC_WIFI_SUPPORT_5G
depends on EXAMPLE_FAST_SCAN_THRESHOLD && (SOC_WIFI_SUPPORT_5G || SLAVE_SOC_WIFI_SUPPORT_5G)
range 0 128
default 10
help

View File

@@ -61,7 +61,7 @@
#else
#define DEFAULT_AUTHMODE WIFI_AUTH_OPEN
#endif
#if CONFIG_SOC_WIFI_SUPPORT_5G
#if CONFIG_SOC_WIFI_SUPPORT_5G || CONFIG_SLAVE_SOC_WIFI_SUPPORT_5G
#define DEFAULT_RSSI_5G_ADJUSTMENT CONFIG_EXAMPLE_FAST_SCAN_RSSI_5G_ADJUSTMENT
#else
#define DEFAULT_RSSI_5G_ADJUSTMENT 0

View File

@@ -0,0 +1,10 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_wifi_remote:
version: ">=0.10,<2.0"
rules:
- if: "target in [esp32p4, esp32h2]"
espressif/esp_hosted:
version: "~2"
rules:
- if: "target in [esp32p4, esp32h2]"

View File

@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- | -------- |
# Wi-Fi SoftAP Example
@@ -51,6 +51,10 @@ I (26467) wifi softAP: station:70:ef:00:43:96:67 join, AID=1
I (27657) esp_netif_lwip: DHCP server assigned IP to a station, IP is: 192.168.4.2
```
## Running the example on ESP Chips without Wi-Fi
This example can run on ESP Chips without Wi-Fi using ESP-Hosted. See the [Two-Chip Solution](../../README.md#wi-fi-examples-with-two-chip-solution) section in the upper level `README.md` for information.
## Troubleshooting
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -0,0 +1,10 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_wifi_remote:
version: ">=0.10,<2.0"
rules:
- if: "target in [esp32p4, esp32h2]"
espressif/esp_hosted:
version: "~2"
rules:
- if: "target in [esp32p4, esp32h2]"

View File

@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- | -------- |
# Wi-Fi Station Example
@@ -116,6 +116,10 @@ I (10299) wifi station: connect to the AP fail
I (10299) wifi station: Failed to connect to SSID:myssid, password:mypassword
```
## Running the example on ESP Chips without Wi-Fi
This example can run on ESP Chips without Wi-Fi using ESP-Hosted. See the [Two-Chip Solution](../../README.md#wi-fi-examples-with-two-chip-solution) section in the upper level `README.md` for information.
## Troubleshooting
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -0,0 +1,9 @@
dependencies:
espressif/esp_wifi_remote:
version: ">=0.10,<2.0"
rules:
- if: "target in [esp32p4, esp32h2]"
espressif/esp_hosted:
version: "~2"
rules:
- if: "target in [esp32p4, esp32h2]"

View File

@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-P4 | ESP32-S2 | ESP32-S3 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
# Iperf Example
@@ -77,68 +77,10 @@ Steps to test station/soft-AP TCP/UDP RX/TX throughput are similar as test steps
See the README.md file in the upper level 'examples' directory for more information about examples.
## ESP Chips without Native Wi-Fi
## Running the example on ESP Chips without Wi-Fi
Some ESP chips like the ESP32-P4 or ESP32-H2, without built-in Wi-Fi or Bluetooth, can still use these features through a **two-chip solution** via ESP-Hosted. The host chip, when connected to a ESP chip as a Wi-Fi co-processor, can invoke Wi-Fi APIs over a communication bus like SPI or SDIO.
This example can run on ESP Chips without Wi-Fi using ESP-Hosted. See the [Two-Chip Solution](../README.md#wi-fi-examples-with-two-chip-solution) section in the upper level `README.md` for information.
The two chip solution needs:
## Troubleshooting
- Communication bus like SDIO or SPI between the host and co-processor
- Co-processor flashed with ESP-Hosted co-processor (slave) software
- Host processor flashed with additional software components: [esp-hosted](https://components.espressif.com/components/espressif/esp_hosted/) and [esp-wifi-remote](https://components.espressif.com/components/espressif/esp_wifi_remote/)
### Running iperf on the ESP32-P4-Function-EV-Board
On this board,
* The ESP32-P4 is already connected with the on-board ESP32-C6 (co-processor) using SDIO communication bus. See this ESP-Hosted EV Board [documentation](https://github.com/espressif/esp-hosted-mcu/blob/main/docs/esp32_p4_function_ev_board.md) for more information.
* The ESP32-C6 is pre-flashed with ESP-Hosted slave software.
* Optionally, you can re-flash the ESP32-C6 using [ESP-Hosted Slave Flashing Steps](https://github.com/espressif/esp-hosted-mcu/blob/main/docs/esp32_p4_function_ev_board.md#5-flashing-esp32-c6)
* Only the example code on the Host needs to be built & flashed using the steps below.
#### Host Flashing Steps
* Set the ESP32-P4 as the target
```sh
idf.py set-target esp32p4
```
You may see lines similar to this:
```
NOTICE: Processing 11 dependencies:
NOTICE: [1/11] cmd_system (*) (/home/esp/esp-idf/examples/system/console/advanced/components/cmd_system)
NOTICE: [2/11] esp-qa/ping-cmd (1.0.0)
NOTICE: [3/11] esp-qa/wifi-cmd (0.1.10)
NOTICE: [4/11] espressif/eppp_link (0.2.0)
NOTICE: [5/11] espressif/esp-extconn (0.1.0)
NOTICE: [6/11] espressif/esp_hosted (1.1.1)
NOTICE: [7/11] espressif/esp_serial_slave_link (1.1.0)
NOTICE: [8/11] espressif/esp_wifi_remote (0.5.3)
NOTICE: [9/11] espressif/iperf (0.1.3)
NOTICE: [10/11] espressif/iperf-cmd (0.1.3)
NOTICE: [11/11] idf (5.5.0)
```
The Wi-Fi Remote and ESP-Hosted components are automatically fetched during the configuration.
* Build
```sh
idf.py build
```
* Flash
```sh
idf.py -p <host_serial_port> flash
```
* Monitor
```sh
idf.py -p <host_serial_port> monitor
```
### Using ESP-Hosted with other hosts
As the other hosts may not have prior hardware communication bus set-up, the hardware connections and co-processor flashing with slave firmware need to be done explicitly. See the [ESP-Hosted Repository](https://github.com/espressif/esp-hosted-mcu/) for step-by-step instructions on setting up ESP-Hosted.
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -2,13 +2,13 @@
# ESP32-P4 specific
#
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_TX_BA_WIN=32
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
CONFIG_ESP_WIFI_RX_BA_WIN=32
CONFIG_WIFI_RMT_STATIC_RX_BUFFER_NUM=16
CONFIG_WIFI_RMT_DYNAMIC_RX_BUFFER_NUM=64
CONFIG_WIFI_RMT_DYNAMIC_TX_BUFFER_NUM=64
CONFIG_WIFI_RMT_AMPDU_TX_ENABLED=y
CONFIG_WIFI_RMT_TX_BA_WIN=32
CONFIG_WIFI_RMT_AMPDU_RX_ENABLED=y
CONFIG_WIFI_RMT_RX_BA_WIN=32
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
CONFIG_LWIP_TCP_WND_DEFAULT=65534

View File

@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- | -------- |
# Wi-Fi Scan Example
@@ -87,6 +87,10 @@ I (2903) scan: Channel 11
...
```
## Running the example on ESP Chips without Wi-Fi
This example can run on ESP Chips without Wi-Fi using ESP-Hosted. See the [Two-Chip Solution](../README.md#wi-fi-examples-with-two-chip-solution) section in the upper level `README.md` for information.
## Troubleshooting
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -0,0 +1,10 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_wifi_remote:
version: ">=0.10,<2.0"
rules:
- if: "target in [esp32p4, esp32h2]"
espressif/esp_hosted:
version: "~2"
rules:
- if: "target in [esp32p4, esp32h2]"

View File

@@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 | ESP32-P4 | ESP32-H2 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
# Wi-Fi SoftAP & Station Example
@@ -65,6 +65,10 @@ I (3920) esp_netif_handlers: sta ip: 192.168.5.2, mask: 255.255.255.0, gw: 192.1
I (3920) WiFi Sta: connected to ap SSID:myssid_c3 password:mypassword_c3
```
## Running the example on ESP Chips without Wi-Fi
This example can run on ESP Chips without Wi-Fi using ESP-Hosted. See the [Two-Chip Solution](../README.md#wi-fi-examples-with-two-chip-solution) section in the upper level `README.md` for information.
## Troubleshooting
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.

View File

@@ -0,0 +1,10 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_wifi_remote:
version: ">=0.10,<2.0"
rules:
- if: "target in [esp32p4, esp32h2]"
espressif/esp_hosted:
version: "~2"
rules:
- if: "target in [esp32p4, esp32h2]"