Home

Awesome

ESP-Hosted-MCU: Espressif SoCs as Communication Co-Processors

Component Registry

1 Introduction

ESP-Hosted-MCU is an open-source solution that allows you to use Espressif Chipsets and modules as a communication co-processor. This solution provides wireless connectivity (Wi-Fi and Bluetooth) to the host microprocessor or microcontroller, enabling it to communicate with other devices. Additionally, the user has complete control over the co-processor's resources.

This high-level block diagram shows ESP-Hosted's relationship with the host MCU and slave co-processor.

<img src="docs/images/ESP-Hosted-FG-MCU_design.svg" alt="ESP-Hosted">

For detailed design diagrams in Wi-Fi and Bluetooth, refer to the following design documents:

This branch, feature/esp_as_mcu_host is dedicated for any host as MCU support. If you are interested in Linux as host, please refer to master branch.

2 Architecture

Hosted Co-Processor

This is an ESP chip that provides Wi-Fi, Bluetooth, and other capabilities. It is also referred as hosted-slave interchangeably.

Host MCU

This can be any generic microcontroller (MCU). We demonstrate any ESP as host. Using port layer, any host can act as host MCU.

Communication

3 Solution Flexibility

4 Quick Demo with ESP32-P4-Function-EV-Board

Impatient to test? We've got you covered! The ESP32-P4-Function-EV-Board can be used as a host MCU with an on-board ESP32-C6 as co-processor, already connected via SDIO as transport. Prerequisite: You need to have an ESP32-P4-Function-EV-Board`

[!NOTE] If you have already set up ESP-IDF (version 5.3 or later), you can skip to 5 Source Code and Dependencies.

4.1 Set-Up ESP-IDF

bash docs/setup_esp_idf__latest_stable__linux_macos.sh
fish docs/setup_esp_idf__latest_stable__linux_macos.fish

4.2 Set-Up P4 with C6

The host, ESP32-P4, lacks native Wi-Fi/Bluetooth support. Our Quick Demo will help you run iperf over P4--SDIO--C6.

4.3 Don't Have ESP32-P4-Function-EV-Board?

No worries if you don't have an ESP32-P4. In fact, most users don't. You can choose and use any two ESP chipsets/SoCs/Modules/DevKits. DevKits are convenient to use as they have GPIO headers already in place. From these two ESP chipsets, one would act as host and another as slave/co-processor. However, as these are not connected directly, you would need to manually connect some transport, which is explained later in the section Detailed Setup.

5 Source Code and Dependencies

5.1 ESP-Hosted-MCU Source Code

git clone --recurse-submodules --branch feature/esp_as_mcu_host --depth 1 \
https://github.com/espressif/esp-hosted esp_hosted_mcu

5.2 Dependencies

ESP-Hosted-MCU Solution is dependent on ESP-IDF, esp_wifi_remote and protobuf-c

ESP-IDF
Wi-Fi Remote
Protobuf
5.2.1 How Dependencies Work Together (short explanation)

6 Decide the communication bus in between host and slave

The communication bus is required to be setup correctly between host and slave. We refer this as transport medium or simply transport.

ESP-Hosted-MCU supports SPI/SDIO/UART transports. User can choose which transport to use. Choosing specific transport depends on factors: high performance, easy and quick to test, number of GPIOs used, or simply co-processor preference

Below is chart for the transport medium comparison.

Legends:

Host can be any ESP chipset or any non-ESP MCU.

Hosted Transports table
TransportTypeNum of GPIOsSetup withCo-processor supportedHost Tx iperfHost Rx iperfRemarks
Standard SPIFD6jumper or PCBAny_Slaveudp: 24 tcp: 22udp: 25 tcp: 22Simplest solution for quick test
Dual SPIHD5jumper or PCBAny_Slave [1]udp: 32 tcp: 26 (O)udp: 33 tcp: 25 (O)Better throughput, but half duplex
Quad SPIHD7PCB onlyAny_Slave [1]udp: 41 tcp: 29 (O)udp: 42 tcp: 28 (O)Due to signal integrity, PCB is mandatory
SDIO 1-BitHD4jumper or PCBESP32, ESP32-C6TBDTBDStepping stone for PCB based SDIO 4-bit
SDIO 4-BitHD6PCB onlyESP32, ESP32-C6udp: 79.5 tcp: 53.4 (S)udp: 68.1 tcp: 44 (S)Highest performance
Only BT over UARTFD2 or 4jumper or PCBAny_SlaveNANADedicated Bluetooth over UART pins
UARTFD2jumper or PCBAny_Slaveudp: 0.68 tcp: 0.67 (O)udp: 0.68 tcp: 0.60 (O)UART dedicated for BT & Wi-Fi [2]
Dedicated platformsFDExtra 2 or 4jumper or PCBAny_SlaveNANAUART dedicated for BT & Wi-Fi on any other transport

[!NOTE]

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)

7 ESP-Hosted-MCU Header

7.1 ESP Hosted header

Host and slave always populate below header at the start of every frame, irrespective of actual or dummy data in payload.

FieldTypeBitsMandatory?Description
if_typeuint8_t4MInterface type
if_numuint8_t4MInterface number
flagsuint8_t8MFlags for additional information
lenuint16_t16MLength of the payload
offsetuint16_t16MOffset for the payload
checksumuint16_t16MChecksum for error detection (0 if checksum disabled)
seq_numuint16_t16OSequence number for tracking packets (Useful in debugging)
throttle_cmduint8_t0 or 2OFlow control command
reserved2uint8_t6 or 8MReserved bits
reserved3uint8_t8MReserved byte (union field)
hci_pkt_type or priv_pkt_typeuint8_t8MPacket type for HCI interface (union field)

7.2 Interface Types

Start of header states which type of frame is being carried.

Interface TypeValueDescription
ESP_INVALID_IF0Invalid interface
ESP_STA_IF1Station frame
ESP_AP_IF2SoftAP frame
ESP_SERIAL_IF3Control frame
ESP_HCI_IF4Bluetooth vHCI frame
ESP_PRIV_IF5Private communication between slave and host
ESP_TEST_IF6Transport throughput test
ESP_ETH_IF7Invalid
ESP_MAX_IF8type mentioned in dummy or empty frame

8 Detailed Setup

Once you decided the transport to use, this section should guide how to set this transport, with hardware connections, configurations and verification. Users can evaluate one transport first and then move to other.

[!IMPORTANT]

Design Considerations that could be reffered to, before you stick to any transport option. Referring to these consideration would help to get you faster to solution, make your design stable and less error-prone.

Irrespective of transport chosen, following steps are needed, which are step-wise explained in each transport.

  1. Set-up the hosted-transport
  2. Slave Flashing
  1. Host flashing

9 Examples

Check examples directory for sample applications using ESP-Hosted.

10 Troubleshooting

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

11 References