Skip to content

Commit c1e1e70

Browse files
committed
Merge branch 'doc/fix_1' into 'feature/esp_as_mcu_host'
Update spi_full_duplex.md See merge request app-frameworks/esp_hosted!502
2 parents ddf29e1 + 2ed13d3 commit c1e1e70

12 files changed

+2297
-840
lines changed

README.md

Lines changed: 213 additions & 364 deletions
Large diffs are not rendered by default.
File renamed without changes.

docs/design_consideration.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,27 @@ connected together. Verify that the correct GPIOs are set-up in
5858
> under Hosted. Check the ESP datasheet to verify the GPIOs you select
5959
> can be used as a Hosted interface.
6060
61-
### 2.2. Using SPI insted of SDIO
61+
### 2.2. Evaluate with jumpers first
6262

63-
In general, SPI imposes fewer hardware requirements compared to
63+
It is flexible to evaluate with jumper cables or bread board than full-fledged PCB.
64+
In general, SPI (Standard & Dual SPI) imposes fewer hardware requirements compared to
6465
SDIO. SPI is easier to prototype, and available on more ESP chips and
6566
MCUs compared to SDIO.
66-
67-
However, if you need a high-speed interface, SDIO should be
68-
considered.
67+
Before going to SDIO 4 bit mode PCB, it's better to evaluate SDIO 1-Bit mode.
68+
69+
Once you evaluate the solution on jumper cables, you can move to PCB solutions with same or high performance transport.
70+
71+
###### Jumper cable considerations
72+
- Use high quality jumper cables
73+
- Use jumper cables as small as possible. you can cut and solder the joints if need be.
74+
- Use equal length jumper cables for all the connections
75+
- Grounds: Connect as many grounds as possible, this lowers the interference.
76+
- Jumper cable lengths
77+
- Standard SPI: At max 10cm, lower the better
78+
- Dual SPI: At max 10cm, lower the better
79+
- SDIO 1 Bit: At max 5cm, lower the better
80+
- Quad SPI : jumpers not supported, only PCB
81+
- SDIO 4 Bit: Jumpers not supported, only PCB
6982

7083
### 2.3. Whenever possible, Use `IO_MUX` GPIOs.
7184

@@ -102,7 +115,7 @@ For jumper cables, you can try surrounding the signals, especially the
102115

103116
> [!NOTE]
104117
> For SDIO, external pull-up resistors (recommended value: 51 kOhms)
105-
> are required. Using jumper cable are not recommended for SDIO. You
118+
> are required. Using jumper cable are **not** recommended for SDIO. You
106119
> may be able to get SDIO working with jumper cables by using a lower
107120
> `CLK` frequency and using 1-bit SDIO mode.
108121
@@ -130,7 +143,7 @@ be used to light a LED or trigger a capture on an oscilloscope or
130143
logic analyzer, for example. This is useful for capturing rare or
131144
intermittent conditions while testing Hosted.
132145

133-
In the future, Hosted may also offer more features, like controlling
146+
In the future, Hosted may also offer newer transport options or more features, like controlling
134147
power modes on the Host and Slave. These may require additional GPIOs
135148
for control, so it would be good to keep some additional GPIOs
136149
available and accesable for future use.

docs/esp32_p4_function_ev_board.md

Lines changed: 161 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,127 @@
11
# ESP-Hosted on the ESP32-P4-Function-EV-Board DevKit
22

3-
**Table of Contents**
4-
5-
- [1. Introduction](#1-introduction)
6-
- [2. Building ESP-Hosted as Host for the P4](#2-building-esp-hosted-as-host-for-the-p4)
7-
- [2.1. Adding Wifi Remote and Hosted Components](#21-adding-wifi-remote-and-hosted-components)
8-
- [2.2. Building the Firmware](#22-building-the-firmware)
9-
- [3. Checking that ESP-Hosted is Running](#3-checking-that-esp-hosted-is-running)
10-
- [4. Flashing the On-board ESP32-C6 using ESP-Prog](#4-flashing-the-on-board-esp32-c6-using-esp-prog)
11-
- [5. Troubleshooting](#5-troubleshooting)
12-
- [6. Flashing the On-board ESP32-P4 through the Serial Interface](#6-flashing-the-on-board-esp32-p4-through-the-serial-interface)
13-
- [7. References](#7-references)
3+
<details>
4+
<summary>**Table of Contents**</summary>
5+
6+
- [Introduction](#1-introduction)
7+
- [Set-Up ESP-IDF](#2-set-up-esp-idf)
8+
- [Building Host for the P4](#3-building-host-for-the-p4)
9+
- [Adding Components](#31-adding-components)
10+
- [Configuring Defaults](#32-configuring-defaults)
11+
- [Building Firmware](#33-building-firmware)
12+
- [Checking ESP-Hosted](#4-checking-esp-hosted)
13+
- [Flashing ESP32-C6](#5-flashing-esp32-c6)
14+
- [Using ESP-Prog](#51-using-esp-prog)
15+
- [OTA Updates](#52-ota-updates)
16+
- [Troubleshooting](#6-troubleshooting)
17+
- [Flashing the On-board ESP32-P4 through the ESP-Prog](#7-flashing-esp32-p4)
18+
- [References](#8-references)
19+
20+
</details>
1421

1522
## 1. Introduction
1623

17-
This page documents using ESP-Hosted on the
18-
ESP32-P4-Function-EV-Board. The board comes with an on-board ESP32-C6
19-
module, pre-flashed with ESP-Hosted slave code (v0.0.6). The board
20-
provides a Wi-Fi connection to the on-board ESP32-P4, which acts as
21-
the host.
24+
This page documents using ESP-Hosted-MCU on the ESP32-P4-Function-EV-Board. The board comes with an on-board ESP32-C6 module, pre-flashed with ESP-Hosted-MCU slave code (v0.0.6). The board provides a Wi-Fi connection to the on-board ESP32-P4, which acts as the host.
2225

2326
The image below shows the board.
2427

25-
<img src="images/esp32-p4-function-ev-board.jpg"
26-
alt="ESP32-P4-Function-EV-Board" width="800" />
28+
<img src="images/esp32-p4-function-ev-board.jpg" alt="ESP32-P4-Function-EV-Board" width="800" />
2729

2830
*ESP32-P4-Function-EV-Board*
2931

3032
The ESP32-P4 communicates with the ESP32-C6 module using SDIO.
3133

32-
## 2. Building ESP-Hosted as Host for the P4
34+
## 2. Set-Up ESP-IDF
35+
36+
As you have reached here, it is highly likely that you have already setup ESP-IDF.
37+
38+
If not done, Please set up ESP-IDF:
39+
40+
#### Option 1: Installer Way
41+
42+
- **Windows**
43+
- Install and setup ESP-IDF on Windows as documented in the [Standard Setup of Toolchain for Windows](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html).
44+
- Use the ESP-IDF [Powershell Command Prompt](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/windows-setup.html#using-the-command-prompt) for subsequent commands.
45+
46+
- **Linux or MacOS**
47+
- For bash:
48+
```bash
49+
bash docs/setup_esp_idf__latest_stable__linux_macos.sh
50+
```
51+
- For fish:
52+
```fish
53+
fish docs/setup_esp_idf__latest_stable__linux_macos.fish
54+
```
55+
56+
#### Option 2: Manual Way
3357

34-
### 2.1. Adding Wifi Remote and Hosted Components
58+
Please follow the [ESP-IDF Get Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) for manual installation.
3559

36-
The Wi-Fi service is provided to the ESP32-P4 using the
37-
`esp_wifi_remote` component. Check your project's `idf_component.yml`
38-
file) to see if it is already present. If not, you can add this
39-
component to your project:
60+
## 3. Building Host for the P4
61+
62+
### 3.1. Adding Components
63+
64+
Add `esp_wifi_remote` and `esp_hosted` components to the project:
4065

4166
```
4267
idf.py add-dependency "espressif/esp_wifi_remote"
68+
idf.py add-dependency "espressif/esp_hosted"
69+
```
70+
71+
Remove 'esp-extconn' if present in `main/idf_component.yml`, as esp-extconn and esp-hosted cannot work together.
72+
Open the `main/idf_component.yml` file and remove/comment the following block if present:
73+
74+
```
75+
# ------- Delete or comment this block ---------
76+
espressif/esp-extconn:
77+
version: "~0.1.0"
78+
rules:
79+
- if: "target in [esp32p4]"
80+
# -----------------------------------
4381
```
4482
45-
The `esp_wifi_remote` component has a dependency on ESP-Hosted and
46-
will also add the `esp_hosted` component to your build.
83+
It is always good to use `esp_wifi_remote` as it provides all the Wi-Fi config and a wrapper abstraction layer.
84+
But you can also evaluate without using it.
4785
48-
### 2.2. Building the Firmware
86+
### 3.2. Configuring Defaults
87+
88+
Edit the `sdkconfig.defaults.esp32p4` file such that, it would have following content:
89+
90+
```
91+
#### Comment below two lines if present:
92+
# CONFIG_ESP_HOST_WIFI_ENABLED=y
93+
# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
94+
95+
#### Add Wi-Fi Remote config for better performance:
96+
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=16
97+
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=64
98+
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=64
99+
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
100+
CONFIG_ESP_WIFI_TX_BA_WIN=32
101+
CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y
102+
CONFIG_ESP_WIFI_RX_BA_WIN=32
103+
104+
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
105+
CONFIG_LWIP_TCP_WND_DEFAULT=65534
106+
CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
107+
CONFIG_LWIP_UDP_RECVMBOX_SIZE=64
108+
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64
109+
110+
CONFIG_LWIP_TCP_SACK_OUT=y
111+
```
112+
113+
### 3.3. Building Firmware
49114
50115
Set the ESP32-P4 as the target, build, flash the firmware and
51116
(optionally) monitor ESP32-P4 console output:
52117
53118
```sh
54119
idf.py set-target esp32p4
55120
idf.py build
56-
idf.py -p <Serial Port> flash monitor`
121+
idf.py -p <Serial Port> flash monitor
57122
```
58123

59-
## 3. Checking that ESP-Hosted is Running
124+
## 4. Checking ESP-Hosted
60125

61126
When the P4 is running with Hosted, you should see console output similar to this after start-up:
62127

@@ -114,17 +179,68 @@ I (1848) H_SDIO_DRV: Received INIT event
114179
I (1868) rpc_wrap: Received Slave ESP Init
115180
```
116181

117-
## 4. Flashing the On-board ESP32-C6 using ESP-Prog
182+
## 5. Flashing ESP32-C6
183+
ESP32-C6 flashing is totally **optional**, as C6 is expected to be pre-flashed with ESP-Hosted slave firmware, 0.0.6. If you wish to get updated ESP-Hosted slave firmware, you can flash it using two ways, Either with ESP-Prog on ESP32-C6, or using OTA update configured using web server.
184+
185+
### 5.1 OTA Updates
186+
187+
To update the ESP32-C6 slave module using Over-The-Air (OTA) updates, follow these steps:
188+
189+
1. Build the ESP-Hosted slave firmware for the ESP32-C6 module:
190+
191+
```
192+
idf.py create-project-from-example "espressif/esp_hosted:slave"
193+
```
194+
195+
2. Set the target and start `Menuconfig`:
196+
197+
```sh
198+
idf.py set-target esp32c6
199+
idf.py menuconfig
200+
```
201+
202+
3. Under **Example Configuration**, ensure that the Hosted transport
203+
selected is `SDIO`.
204+
205+
4. Build the firmware:
206+
207+
```sh
208+
idf.py build
209+
```
210+
211+
5. Upload the firmware (the build/network_adapter.bin file) to a server or a local directory accessible via HTTP.
212+
213+
6. On the ESP32-P4 host, add the following code to your application to initiate the OTA update:
214+
215+
```
216+
#include "esp_hosted.h"
217+
218+
esp_err_t esp_hosted_ota_start(const char *url);
219+
```
220+
221+
7. Call the `esp_hosted_ota_start` function with the URL of the firmware binary:
222+
223+
```
224+
esp_err_t err = esp_hosted_ota_start("http://example.com/path/to/network_adapter.bin");
225+
if (err != ESP_OK) {
226+
ESP_LOGE(TAG, "Failed to start OTA update: %s", esp_err_to_name(err));
227+
}
228+
```
229+
230+
8. Monitor the console output to see the OTA update progress.
231+
232+
### 5.2 Using ESP-Prog
118233

119234
> [!NOTE]
120235
> ESP-Prog is only required if you want to flash firmware to the
121236
> ESP32-C6 module using the standard ESP Tools.
122237
238+
This step is optional, as C6 is expected to be pre-flashed with ESP-Hosted slave firmware, 0.0.6.
239+
123240
The image below shows the board with an ESP-Prog connected to the
124241
header to communicate with the on-board ESP32-C6..
125242

126-
<img src="images/esp32-p4-function-ev-board-esp-prog.jpg"
127-
alt="ESP32-P4-Function-EV-Board with ESP-Prog Connected to ESP32-C6" width="800" />
243+
<img src="images/esp32-p4-function-ev-board-esp-prog.jpg" alt="ESP32-P4-Function-EV-Board with ESP-Prog Connected to ESP32-C6" width="800" />
128244

129245
*ESP32-P4-Function-EV-Board with ESP-Prog Connected to ESP32-C6*
130246

@@ -133,7 +249,6 @@ ESP32-C6 module using ESP-Prog, follow these steps:
133249

134250
1. Check out the ESP-Hosted slave example project:
135251

136-
137252
```
138253
idf.py create-project-from-example "espressif/esp_hosted:slave"
139254
```
@@ -174,28 +289,36 @@ prevent the P4 interfering with the C6 while flashing (by asserting
174289
the C6 Reset signal during the firmware download), set the P4 into
175290
Bootloader mode before flashing the firmware to the C6:
176291

292+
###### Manual Way
177293
1. hold down the `BOOT` button on the board
178294
2. press and release the `RST` button on the board
179295
3. release the `BOOT` button
180296

297+
###### Script Way
298+
299+
```sh
300+
esptool.py -p <host_serial_port> --before default_reset --after no_reset run
301+
```
302+
181303
You can now flash the firmware to the C6 (and monitor the console
182304
output):
183305

184306
```sh
185307
idf.py -p <Serial Port> flash monitor
186308
```
187309

188-
## 5. Troubleshooting
310+
311+
312+
## 6. Troubleshooting
189313

190314
If you encounter issues with using ESP-Hosted, see the following guide:
191315

192316
- [Troubleshooting Guide](troubleshooting.md)
193317

194318
<details>
195-
196319
<summary>Flashing the On-board ESP32-P4 through the Serial Interface</summary>
197320

198-
## 6. Flashing the On-board ESP32-P4 through the Serial Interface
321+
## 7. Flashing the On-board ESP32-P4 through the ESP-Prog
199322

200323
The USB connector on the board is the standard method for flashing the
201324
firmware to the P4. An alternative method is to flash the P4 through
@@ -204,8 +327,7 @@ its serial interface using a ESP-Prog.
204327
The image below shows the connection between the ESP-Prog and the
205328
serial port pins on the P4 header for programming.
206329

207-
<img src="images/esp32-p4-esp-prog.jpg"
208-
alt="ESP32-P4 Serial Connection with ESP-Prog" width="600" />
330+
<img src="images/esp32-p4-esp-prog.jpg" alt="ESP32-P4 Serial Connection with ESP-Prog" width="600" />
209331

210332
*ESP32-P4 Serial Connection with ESP-Prog*
211333

@@ -236,7 +358,7 @@ on the board.
236358

237359
</details>
238360

239-
## 7. References
361+
## 8. References
240362

241363
- ESP32-P4-Function-EV-Board: https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/
242364
- ESP-Prog: https://docs.espressif.com/projects/esp-iot-solution/en/latest/hw-reference/ESP-Prog_guide.html

docs/images/ESP-Hosted-FG-MCU_design.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)