Skip to content

Commit 09739e5

Browse files
committed
Merge branch 'feature/add_esp32c6_spi_ym2_18feb' into 'master'
Add ESP32-C6 SPI support for Linux and MCU See merge request app-frameworks/esp_hosted!281
2 parents fe0b105 + 5ade5ec commit 09739e5

File tree

23 files changed

+213
-98
lines changed

23 files changed

+213
-98
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Following table summarizes this entire discussion.
118118
</tr>
119119
<tr>
120120
<td>Chipsets supported</td>
121-
<td>ESP32, <span>ESP32-C2/C3/S2/S3</span></td>
121+
<td>ESP32, <span>ESP32-C2/C3/C6/S2/S3</span></td>
122122
<td>ESP32, <span>ESP32-C3</span></td>
123123
</tr>
124124
</table>

esp_hosted_fg/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ ESP-Hosted-FG solution provides following WLAN and BT/BLE features to the host:
4242
- WLAN Soft AP
4343
- BT/BLE Features:
4444
- ESP32 supports BR/EDR and BLE with v4.2
45-
- ESP32-C3/ESP32-S3 supports BLE v4.2 and v5.0
45+
- ESP32-C2/C3/C6/ESP32-S3 supports BLE v4.2 and v5.0
4646

4747
### 1.2 Supported ESP boards
4848

4949
ESP-Hosted-FG solution is supported on following ESP boards:
5050
- ESP32
5151
- ESP32-S2
52-
- ESP32-C3
5352
- ESP32-S3
5453
- ESP32-C2
54+
- ESP32-C3
55+
- ESP32-C6
5556

5657
### 1.3 Supported Hosts
5758

@@ -85,6 +86,9 @@ The below table explains which feature is supported on which transport interface
8586
| ESP32-C3 | SDIO | NA | NA | NA |
8687
| ESP32-C3 | SPI | Yes | Yes | BLE 5.0 |
8788
| ESP32-C3 | UART | No | No | BLE 5.0 |
89+
| ESP32-C6 | SDIO | ComingSoon | ComingSoon | ComingSoon |
90+
| ESP32-C6 | SPI | Yes | Yes | WIP |
91+
| ESP32-C6 | UART | No | No | WIP |
8892
| ESP32-S3 | SDIO | NA | NA | NA |
8993
| ESP32-S3 | SPI | Yes | Yes | BLE 5.0 |
9094
| ESP32-S3 | UART | No | No | BLE 5.0 |
@@ -113,6 +117,9 @@ The below table explains which feature is supported on which transport interface
113117
| ESP32-C3 | SDIO | NA | NA | NA |
114118
| ESP32-C3 | SPI | Yes | Yes | BLE 5.0\* |
115119
| ESP32-C3 | UART | No | No | BLE 5.0\*\* |
120+
| ESP32-C6 | SDIO | ComingSoon | ComingSoon | ComingSoon |
121+
| ESP32-C6 | SPI | Yes | Yes | WIP |
122+
| ESP32-C6 | UART | No | No | WIP |
116123
| ESP32-S3 | SDIO | NA | NA | NA |
117124
| ESP32-S3 | SPI | Yes | Yes | BLE 5.0\* |
118125
| ESP32-S3 | UART | No | No | BLE 5.0\*\* |
@@ -138,6 +145,12 @@ Note: BT stands for Bluetooth BR/EDR and BLE stands for Bluetooth Low Energy spe
138145
> With the help of this UART interface, BT/BLE stack can directly interact with BT controller present on ESP bypassing host driver and firmware
139146
> ESP Hosted host driver and a firmware plays no role in this communication
140147
148+
WIP
149+
> Work In progress
150+
151+
ComingSoon
152+
> Will be scheduled after WIP
153+
141154
* Linux hosts support OTA update (Over The Air ESP firmware update) in C and python. MCU hosts can refer to the same for their development. For detailed documentation, please read
142155
[ota_update.md](docs/Linux_based_host/ota_update.md).
143156

esp_hosted_fg/docs/Linux_based_host/SPI_setup.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Setup image is here.
5454
![alt text](rpi_esp32_c2_setup.jpeg "setup of Raspberry-Pi as host and ESP32-C2 as ESP peripheral")
5555

5656

57-
#### 1.1.3 ESP32-C3 setup
57+
#### 1.1.4 ESP32-C3 setup
5858
| Raspberry-Pi Pin | ESP32-C3 Pin | Function |
5959
|:----------------:|:------------:|:--------:|
6060
| 24 | IO10 | CS0 |
@@ -70,7 +70,24 @@ Setup image is here.
7070

7171
![alt text](rpi_esp32_c3_setup.jpg "setup of Raspberry-Pi as host and ESP32-C3 as ESP peripheral")
7272

73-
#### 1.1.4 ESP32-S3 setup
73+
#### 1.1.5 ESP32-C6 setup
74+
| Raspberry-Pi Pin | ESP32-C6 Pin | Function |
75+
|:----------------:|:------------:|:--------:|
76+
| 24 | IO10 | CS0 |
77+
| 23 | IO06 | SCLK |
78+
| 21 | IO02 | MISO |
79+
| 19 | IO07 | MOSI |
80+
| 25 | GND | Ground |
81+
| 15 | IO03 | Handshake |
82+
| 13 | IO04 | Data ready |
83+
| 31 | RST | ESP Reset |
84+
85+
Setup image is here.
86+
87+
![alt text](rpi_esp32_c6_setup.jpg "setup of Raspberry-Pi as host and ESP32-C6 as ESP peripheral")
88+
89+
90+
#### 1.1.6 ESP32-S3 setup
7491
- For ESP32-S3, microUSB power is expected to insert in [UART port](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html#description-of-components)
7592

7693
| Raspberry-Pi Pin | ESP32-S3 Pin | Function |
Loading

esp_hosted_fg/docs/MCU_based_host/Getting_started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Wi-Fi can be configured as either as `STATION` mode or `SOFTAP` mode or `STATION
2828
* **STATION+SOFTAP Mode**
2929
- This is combination of both the modes. In this mode, host behaves as station and connects to external AP. At the same time, host with help of ESP device, can create the Wi-Fi network.
3030

31-
Host firmware provides Wi-Fi connectivity using control path and data path. Control path commands uses `protocomm` layer of ESP-IDF to serialize structured control data and communicates using SPI transport interface between Host(MCU based Host) and ESP peripheral (ESP32/ESP32-C2/ESP32-C3/ESP32-S2/ESP32-S3). User can use control commands to build application.
31+
Host firmware provides Wi-Fi connectivity using control path and data path. Control path commands uses `protocomm` layer of ESP-IDF to serialize structured control data and communicates using SPI transport interface between Host(MCU based Host) and ESP peripheral (ESP32/ESP32-C2/ESP32-C3/ESP32-C6/ESP32-S2/ESP32-S3). User can use control commands to build application.
3232

3333

3434
### 2.1 Start Project with STM32
@@ -39,7 +39,7 @@ We have tested project for `SPI` transport with STM32F469I-Discovery board and `
3939
| ESP32 Board | STM32 Board | Transport |
4040
|:---------:|:------:|:----------:|
4141
| ESP32 | STM32F412ZGT6-Nucleo 144 | SDIO |
42-
| ESP32/S2/S3/C2/C3 | STM32F469I-Discovery | SPI |
42+
| ESP32/S2/S3/C2/C3/C6 | STM32F469I-Discovery | SPI |
4343

4444
:warning: <code>**Note1:** For SDIO, please check [pull up requirements](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/sd_pullup_requirements.html) while choosing ESP module</code>
4545

@@ -51,7 +51,7 @@ We have tested project for `SPI` transport with STM32F469I-Discovery board and `
5151
* For SPI transport:
5252
```
5353
For ESP32 peripheral: Select stm_spi_host_v1.ioc file
54-
For ESP32-C2/ESP32-C3/ESP32-S2/ESP32-S3 peripheral: Select stm_spi_host_v2.ioc file
54+
For ESP32-C2/ESP32-C3/ESP32-C6/ESP32-S2/ESP32-S3 peripheral: Select stm_spi_host_v2.ioc file
5555
```
5656
* For SDIO transport:
5757
```

esp_hosted_fg/docs/MCU_based_host/MCU_based_readme.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,19 @@ We recommend STM32CubeIDE version 1.4 IDE from STMicroelectronics on host machin
2828
* **Serial port communication program**:
2929
For Linux and Mac development hosts, minicom is needed. For Windows based hosts Tera Term is needed.
3030

31-
### 1.1.3 ESP-Hosted Code Repository
31+
### 1.1.3 Things worth noting
32+
* **Porting solution to Non-STM32 MCUs**
33+
ESP-Hosted solution using one ESP chipset and host and other as slave can be found at [ESP as Host](https://github.com/espressif/esp-hosted/issues/186#issuecomment-1429252815)
34+
This solution can be checked for easy porting to non-STM32 based MCUs. Port layer is much simplified here. Formal support is coming soon in upcoming releases.
35+
36+
* **Network stack integration**
37+
Although currently network stack is kept open to port for user, in the upcoming releaes, we plan to showcase lwip as example network stack.
38+
Sample example of porting done by [Dror Gluska](https://github.com/drorgl) can be referred at https://github.com/drorgl/stm32-lwip-esp-hosted
39+
40+
* **Clock considerations for STM32**
41+
For STM32 based hosts, the default clocks are intentionally kept smaller for simplicity. Once base solution is working, It is recommended to increase/tune the SPI clock using ioc in STM32CubeIDE or STM32CubeMX.
42+
43+
### 1.1.4 ESP-Hosted Code Repository
3244
Clone ESP-Hosted repository on machine, where STM32CubeIDE used to connect/flash to host.
3345
```
3446
$ git clone --recurse-submodules <url_of_esp_hosted_repository>

esp_hosted_fg/docs/MCU_based_host/SPI_setup.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ Setup image is here.
6969

7070
![alt text](stm_esp32_c3_setup.jpg "Setup of STM32F469I as host and ESP32-C3 as peripheral")
7171

72+
#### Hardware connections for ESP32-C6
73+
| STM32 Pin | ESP32-C6 Pin | Function |
74+
|:---------:|:-----------:|:--------:|
75+
| PB4 (pin5) | IO02 | MISO |
76+
| PA5 (pin7) | IO06 | CLK |
77+
| PB5 (pin9) | IO07 | MOSI |
78+
| PA15 (pin11)| IO10 | CS |
79+
| GND (pin2) | GND | GND |
80+
| PC6 (pin6) | IO03 | Handshake |
81+
| PC7 (pin8) | IO04 | Data ready from ESP |
82+
| PB13 (pin10) | RST | Reset ESP |
83+
84+
Setup image is here.
85+
86+
![alt text](stm_esp32_c6_setup.jpg "Setup of STM32F469I as host and ESP32-C6 as peripheral")
87+
7288
#### Hardware connections for ESP32-S3
7389
| STM32 Pin | ESP32-S3 Pin | Function |
7490
|:---------:|:-----------:|:--------:|
@@ -89,7 +105,8 @@ Setup image is here.
89105
## 2.1 ESP-IDF requirement
90106
:warning:`Note: ESP-IDF is needed to compile ESP-Hosted firmware source. Skip this step if you are planning to use pre-built release binaries.`
91107

92-
- Clone the ESP-IDF [release/v5.0](https://github.com/espressif/esp-idf/tree/release/v5.0) and checkout to `release/v5.0` branch.
108+
- For chipsets except ESP32-C6, Clone the ESP-IDF [release/v5.0](https://github.com/espressif/esp-idf/tree/release/v5.0) and checkout to `release/v5.0` branch.
109+
- For chipset ESP32-C6, Clone the ESP-IDF [master](https://github.com/espressif/esp-idf) branch
93110
- The control path between MCU host and ESP peripheral is based on `protobuf`. For that, corresponding stack layer, `protocomm` from ESP-IDF is used. It will be already present in ESP-IDF, no extra setup required for that.
94111

95112
### 2.2 Setup
@@ -102,34 +119,29 @@ Setup image is here.
102119
#### 2.2.2 Compilation using source
103120

104121
- Note: Please use the same git commit both at ESP and Host
105-
- Clone the ESP-IDF [release/v5.0](https://github.com/espressif/esp-idf/tree/release/v5.0) and git checkout to `release/v5.0` branch.
106-
- [Set-up the ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/release-v5.0/esp32/get-started/index.html)
122+
- For chipsets except ESP32-C6
123+
- Clone the ESP-IDF [release/v5.0](https://github.com/espressif/esp-idf/tree/release/v5.0) and git checkout to `release/v5.0` branch.
124+
- [Set-up the ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/release-v5.0/esp32/get-started/index.html)
125+
- For chipset ESP32-C6
126+
- Clone the ESP-IDF [master](https://github.com/espressif/esp-idf)
127+
- [Set-up the ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html)
107128
- Navigate to `esp_hosted_fg/esp/esp_driver/network_adapter` directory.
108129

109130
##### Using cmake
110131

111132
```
112133
$ idf.py fullclean
134+
$ idf.py --preview set-target <esp_chipset>
113135
```
114-
:warning: Skip this step for ESP32. Run for ESP32-S2 / ESP32-C2 / ESP32-C3
115-
```
116-
$ idf.py set-target esp32s2
117-
```
118-
or
119-
```
120-
$ idf.py set-target esp32c2
121-
```
122-
or
123-
```
124-
$ idf.py set-target esp32c3
125-
```
136+
where <esp_chipset> could be one from "esp32", "esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6"
137+
126138

127139
Run following command and navigate to `Example Configuration -> Transport layer -> SPI interface -> select` and exit from menuconfig. Read more about [idf.py](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-guides/build-system.html#using-the-build-system) here.
128140
```
129141
$ idf.py menuconfig
130142
```
131143

132-
:warning: Skip below step for ESP32-S2 / ESP32-C2 / ESP32-C3. Run for ESP32 only.
144+
:warning: Skip below step for ESP32-S2/S3/C2/C3/C6. Run for ESP32 only.
133145

134146
Change SPI controller to VSPI. Please navigate to `Example Configuration → SPI Configuration` and change value of `SPI controller to use` to `3`
135147

Loading
55.2 KB
Loading

esp_hosted_fg/esp/esp_driver/network_adapter/main/Kconfig.projbuild

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ menu "Example Configuration"
55
default ESP_SDIO_HOST_INTERFACE if IDF_TARGET_ESP32
66
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32S2
77
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32S3
8+
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C2
9+
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C3
10+
default ESP_SPI_HOST_INTERFACE if IDF_TARGET_ESP32C6
811
help
912
Bus interface to be used for communication with the host
1013

@@ -35,6 +38,7 @@ menu "Example Configuration"
3538
int "GPIO pin for handshake"
3639
default 3 if IDF_TARGET_ESP32C2
3740
default 3 if IDF_TARGET_ESP32C3
41+
default 3 if IDF_TARGET_ESP32C6
3842
default 2
3943
help
4044
GPIO pin to use for handshake with other spi controller
@@ -47,15 +51,17 @@ menu "Example Configuration"
4751

4852
config ESP_SPI_TX_Q_SIZE
4953
int "ESP to Host SPI queue size"
50-
default 10
54+
default 10 if IDF_TARGET_ESP32
55+
default 20
5156
help
52-
Very small tx queue will lower ESP -- SPI --> Host data rate (Only ESP32-C2)
57+
Very small tx queue will lower ESP == SPI ==> Host data rate
5358

5459
config ESP_SPI_RX_Q_SIZE
5560
int "Host to ESP SPI queue size"
56-
default 10
61+
default 10 if IDF_TARGET_ESP32
62+
default 20
5763
help
58-
Very small RX queue will lower ESP <-- SPI -- Host data rate (Only ESP32-C2)
64+
Very small RX queue will lower ESP <== SPI == Host data rate
5965

6066
config ESP_SPI_CHECKSUM
6167
bool "SPI checksum ENABLE/DISABLE"
@@ -77,11 +83,11 @@ menu "Example Configuration"
7783
config EXAMPLE_HCI_UART_BAUDRATE
7884
int "UART Baudrate for HCI: Only applicable for ESP32-C3/ESP32-S3"
7985
range 115200 921600
80-
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3
86+
depends on IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32C6
8187
depends on BT_CTRL_HCI_MODE_UART_H4
8288
default 921600
8389
help
84-
UART Baudrate for HCI over ESP32C3/ESP32S3. Please use standard baudrate.
90+
UART Baudrate for HCI over ESP32C2/C3/C6/S3. Please use standard baudrate.
8591

8692
config ESP_DEFAULT_TASK_STACK_SIZE
8793
int "ESP-Hosted task stack size"

esp_hosted_fg/esp/esp_driver/network_adapter/main/app_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ void app_main()
777777

778778
ESP_ERROR_CHECK(initialise_wifi());
779779

780-
ESP_TCPIP_INIT();
780+
//ESP_TCPIP_INIT(); //Not needed
781781

782782
ESP_LOGI(TAG,"Initial set up done");
783783

esp_hosted_fg/esp/esp_driver/network_adapter/main/spi_slave_api.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ static const char TAG[] = "SPI_DRIVER";
111111
* */
112112
#define SPI_CLK_MHZ 30
113113

114+
#elif defined CONFIG_IDF_TARGET_ESP32C6
115+
116+
#define ESP_SPI_CONTROLLER 1
117+
#define GPIO_MOSI 7
118+
#define GPIO_MISO 2
119+
#define GPIO_SCLK 6
120+
#define GPIO_CS 10
121+
#define DMA_CHAN SPI_DMA_CH_AUTO
122+
123+
/* Max supported SPI slave Clock for ESP32-C6 = **60MHz**
124+
* Below value could be fine tuned to achieve highest
125+
* data rate in accordance with SPI Master
126+
* */
127+
#define SPI_CLK_MHZ 30
128+
114129
#elif defined CONFIG_IDF_TARGET_ESP32S3
115130

116131
#define ESP_SPI_CONTROLLER 1
@@ -135,17 +150,9 @@ static const char TAG[] = "SPI_DRIVER";
135150
/* SPI internal configs */
136151
#define SPI_BUFFER_SIZE 1600
137152
#define SPI_QUEUE_SIZE 3
138-
#ifdef CONFIG_IDF_TARGET_ESP32
139-
#define SPI_RX_QUEUE_SIZE 10
140-
#define SPI_TX_QUEUE_SIZE 10
141-
#elif CONFIG_IDF_TARGET_ESP32C2
142-
/* TODO: Use this for all the chipsets */
143-
#define SPI_RX_QUEUE_SIZE CONFIG_ESP_SPI_RX_Q_SIZE
144-
#define SPI_TX_QUEUE_SIZE CONFIG_ESP_SPI_TX_Q_SIZE
145-
#else
146-
#define SPI_RX_QUEUE_SIZE 20
147-
#define SPI_TX_QUEUE_SIZE 20
148-
#endif
153+
154+
#define SPI_RX_QUEUE_SIZE CONFIG_ESP_SPI_RX_Q_SIZE
155+
#define SPI_TX_QUEUE_SIZE CONFIG_ESP_SPI_TX_Q_SIZE
149156

150157
static interface_context_t context;
151158
static interface_handle_t if_handle_g;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CONFIG_SDIO_DAT2_DISABLED=
2+
3+
# BT Configuration
4+
CONFIG_BT_ENABLED=y
5+
CONFIG_BT_CONTROLLER_ONLY=y
6+
CONFIG_BT_BLUEDROID_ENABLED=
7+
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
8+
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
9+
CONFIG_BTDM_CTRL_MODE_BTDM=n
10+
11+
# SPI/SDIO only
12+
CONFIG_BT_LE_HCI_INTERFACE_USE_RAM=y
13+
14+
# #WLAN over SPI + BLE over UART
15+
# #UART pins, Enable below config, delete sdkconfig and rebuild
16+
# CONFIG_BT_LE_HCI_INTERFACE_USE_UART=y
17+
# CONFIG_BT_LE_HCI_UART_TX_PIN=5
18+
# CONFIG_BT_LE_HCI_UART_RX_PIN=18
19+
# CONFIG_BT_LE_HCI_UART_FLOWCTRL=n
20+
# # 4 pin solution is not stable for c6
21+
# #CONFIG_BT_LE_HCI_UART_RTS_PIN=19
22+
# #CONFIG_BT_LE_HCI_UART_CTS_PIN=8
23+
24+
CONFIG_ESP32_WIFI_NVS_ENABLED=
25+
26+
CONFIG_ESP_CACHE_MALLOC=y

esp_hosted_fg/host/linux/host_control/rpi_init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ usage()
9999
echo " spi: sets ESP32<->RPi communication over SPI"
100100
echo " sdio: sets ESP32<->RPi communication over SDIO"
101101
echo " btuart: Set GPIO pins on RPi for HCI UART operations with TX, RX, CTS, RTS (defaulted to option btuart_4pins)"
102-
echo " btuart_2pins: Set GPIO pins on RPi for HCI UART operations with only TX & RX pins configured (only for ESP32-C2)"
102+
echo " btuart_2pins: Set GPIO pins on RPi for HCI UART operations with only TX & RX pins configured (only for ESP32-C2/C6)"
103103
echo " resetpin=6: Set GPIO pins on RPi connected to EN pin of ESP32, used to reset ESP32 (default:6 for BCM6)"
104104
echo "\nExample:"
105105
echo " - Prepare RPi for WLAN operation on SDIO. sdio is default if no interface mentioned"

0 commit comments

Comments
 (0)