Skip to content

Latest commit

 

History

History
286 lines (220 loc) · 10.2 KB

File metadata and controls

286 lines (220 loc) · 10.2 KB

Wi-Fi softap (wifi/softap)

Run a Wi-Fi SoftAP (access point) with the radio on the coprocessor and the application on the host. mcu_host/main/softap_example_main.c is a byte-for-byte copy of upstream IDF wifi/getting_started/softAP. Starting the AP netif auto-spawns a DHCP server (dnsmasq / udhcpd) on 192.168.4.1/24 so client STAs get an address out of the box.

Supported Platforms and Transports

Supported Coprocessors

Coprocessor ESP32 ESP32-C Series ESP32-S Series
Support Yes Yes Yes

Supported Host Devices

Host Device ESP32-P4 ESP32-H2 Other MCUs Linux
Support Yes Yes Yes Yes

Supported Connection buses

Connection bus SDIO SPI Full-Duplex SPI Half-Duplex UART
Linux host Yes Yes No No
MCU host Yes Yes Yes Yes

Directory layout

wifi/softap/
├── cp/                  ESP coprocessor firmware
├── mcu_host/            ESP-IDF MCU host app
└── linux_802_3_host/    Linux host
     ├── c_app/          native C app
     └── kmod/           kernel module

1. Coprocessor
2. Linux Host

1. Coprocessor
2. MCU Host


Scenario

The host starts a SoftAP on the co-processor's radio; clients associate to it and the host is notified per client.

sequenceDiagram
    participant App as Host app
    participant CP as Co-processor (Wi-Fi)
    participant STA as Wi-Fi client
    App->>CP: start SoftAP (RPC)
    STA->>CP: associate to SoftAP
    CP-->>App: AP_STACONNECTED (RPC event)
    Note over App,STA: client obtains an IP
Loading

Important

New here? Get a base example working first. Follow Getting Started: Linux or Getting Started: MCU to wire the boards, install tools, choose a transport, and confirm the host↔co-processor handshake. The steps below only add what is specific to this example.

Linux Linux Host Setup

1. Coprocessor

Set up the tools once (from the repo root):

cd /path/to/esp_hosted
./install.sh      # install.fish for the fish shell
. ./export.sh     # . ./export.fish for the fish shell

The Wi-Fi radio runs on the co-processor firmware — no extra option to enable. Select the transport:

cd examples/wifi/softap/cp
eh.py set-target esp32c6
eh.py menuconfig
Component config
└── ESP-Hosted
     └── Configure coprocessor
          └── CP transport
               ├── Communication bus (co-processor <== bus ==> host)
               │    ├── ( ) SPI Full Duplex
               │    ├── (X) SDIO                    <── default
               │    ├── ( ) SPI Half Duplex         ← MCU host only
               │    └── ( ) UART                    ← MCU host only
               └── SDIO Configuration               ← clock, GPIOs, checksum (defaults OK)

Each bus has its own settings submenu (pins, clock, checksum) — defaults are fine for bring-up.

Wi-Fi is the default CP feature — no extra dependency config (CONFIG_ESP_HOSTED_CP_FEAT_WIFI=y is already set in cp/sdkconfig.defaults). Then flash and monitor:

eh.py -p <cp_usb_serial_port> flash monitor

2. Linux Host

Note

Base wiring, OS setup, and transport bring-up live in Getting Started: Linux. This section assumes that already works.

Set up the tools once (from the repo root):

cd /path/to/esp_hosted
./install.sh      # install.fish for the fish shell
. ./export.sh     # . ./export.fish for the fish shell

Kernel module (creates ethsta0 / ethap0 and /dev/esps0):

cd examples/wifi/softap/linux_802_3_host/kmod
./build.sh --bus sdio --reload --reset-gpio 518 --clock-mhz 50
# SPI instead: ./build.sh --bus spi --reload --reset-gpio 518 --clock-mhz 10 --spi-mode 3

--reload builds, unloads, and reloads with the given module params. On SPI, start at --clock-mhz 10; once stable, raise it in steps to the co-processor's max SPI clock (see Performance).

Native C app — set the SoftAP credentials:

cd examples/wifi/softap/linux_802_3_host/c_app
eh.py set-target linux
eh.py menuconfig
Example Configuration
├── [ ] Use legacy esp_hosted_* compat-surface main
├── (myssid) WiFi SoftAP SSID
├── (mypassword) WiFi SoftAP Password
├── (1) WiFi SoftAP Channel
└── (4) Max station connections

Host dependency config is pre-set in linux_802_3_host/c_app/sdkconfig.defaults (do not remove):

CONFIG_ESP_HOSTED_HOST_FEAT_RPC=y              # RPC control path to the CP
CONFIG_ESP_HOSTED_HOST_FEAT_RPC_EXT_V2=y       # RPC ext-v2 wire (required)
CONFIG_ESP_HOSTED_HOST_FEAT_WIFI=y             # host Wi-Fi feature
CONFIG_ESP_HOSTED_HOST_AUTO_FEAT_INIT=y        # auto-init features at boot (Linux host)
CONFIG_ESP_HOSTED_HOST_FEAT_SYSTEM=y   # host System feature (FW version / heartbeat / OTA)
CONFIG_ESP_HOSTED_HOST_FEAT_WIFI_AUTO_INIT=y   # auto-init Wi-Fi feature

Then build and run:

eh.py build
eh.py run

3. Verify

  • The Linux C app exists in two flavours sharing main/: native (main.c, eh_host_*) and legacy esp_hosted compat (legacy/main.c), selected by CONFIG_EH_USE_LEGACY_API.
  • AP DHCP server is auto-spawned on the host the moment the AP netif starts; no extra commands needed.
  • linux_802_3_host/py_app/ ctypes binding still needs a make_ap_config() helper before it can set SoftAP SSID / auth — tracked as a follow-up.

MCU MCU Host Setup

1. Coprocessor

Set up the tools once (from the repo root):

cd /path/to/esp_hosted
./install.sh      # install.fish for the fish shell
. ./export.sh     # . ./export.fish for the fish shell

The Wi-Fi radio runs on the co-processor firmware — no extra option to enable. Select the transport:

cd examples/wifi/softap/cp
eh.py set-target esp32c6
eh.py menuconfig
Component config
└── ESP-Hosted
     └── Configure coprocessor
          └── CP transport
               ├── Communication bus (co-processor <== bus ==> host)
               │    ├── ( ) SPI Full Duplex
               │    ├── (X) SDIO                    <── default
               │    ├── ( ) SPI Half Duplex         ← MCU host only
               │    └── ( ) UART                    ← MCU host only
               └── SDIO Configuration               ← clock, GPIOs, checksum (defaults OK)

Each bus has its own settings submenu (pins, clock, checksum) — defaults are fine for bring-up.

Wi-Fi is the default CP feature — no extra dependency config (CONFIG_ESP_HOSTED_CP_FEAT_WIFI=y is already set in cp/sdkconfig.defaults). Then flash and monitor:

eh.py -p <cp_usb_serial_port> flash monitor

2. MCU Host

Set up the tools once (from the repo root):

cd /path/to/esp_hosted
./install.sh      # install.fish for the fish shell
. ./export.sh     # . ./export.fish for the fish shell

Select the transport (must match the co-processor) and set the SoftAP credentials:

cd examples/wifi/softap/mcu_host
eh.py set-target esp32p4
eh.py menuconfig
Component config
└── ESP-Hosted
     └── Configure host
          └── Host transport
               ├── Communication bus (co-processor <== bus ==> host)
               │    ├── ( ) SPI Full Duplex
               │    ├── (X) SDIO                    <── default (match the co-processor)
               │    ├── ( ) SPI Half Duplex
               │    └── ( ) UART
               └── SDIO Configuration               ← slot, bus width, GPIOs (defaults OK)
Example Configuration
├── (myssid) WiFi SSID
├── (mypassword) WiFi Password
├── (1) WiFi Channel
├── (4) Maximal STA connections
├── [*] Enable GTK Rekeying
└── (600) GTK rekey interval                  ← when GTK rekeying enabled

Host dependency config is pre-set in mcu_host/sdkconfig.defaults (do not remove):

CONFIG_ESP_HOSTED_HOST_FEAT_RPC=y          # RPC control path to the CP
CONFIG_ESP_HOSTED_HOST_FEAT_RPC_EXT_V2=y   # RPC ext-v2 wire (required)
CONFIG_ESP_HOSTED_HOST_FEAT_SYSTEM=y       # system RPCs
CONFIG_ESP_HOSTED_HOST_FEAT_WIFI=y         # host Wi-Fi feature — routes esp_wifi_* to the CP

Then flash and monitor:

eh.py -p <host_usb_serial_port> flash monitor

3. Verify

  • The host boots and receives the co-processor init event.
  • The SoftAP starts with the configured SSID / auth; a client can associate.
  • The host auto-spawns the AP DHCP server when the AP netif comes up, so associated clients get a lease with no extra commands.