P4-Nano: controller port with the C6 as ESP-NOW radio, and the simulator
The controller now builds for the Waveshare ESP32-P4-Nano only (plus the linux sim and the desktop); the S3 stays for the USB/network bridge in bridge/. - radio-c6/: C6 firmware, esp-hosted plus ESP-NOW over peer data. The P4 loads it from the slave_fw partition when the C6 runs another version (c6_update.c) - bridge_hosted.c: the C6 as the always-on "c6" bridge, and the P4 as a network bridge on UDP 8766 for the desktop - Ethernet on the P4's EMAC, ES8311 mic; default address 192.168.50.20. The W5500, INMP441 and direct ESP-NOW code is gone - The simulated rig at /sim/ is built into the board image, with an always-on "browser" bridge. Its frames go through a queue so a slow page cannot hold up the radio, and frames for simulated bars are not sent over the C6. Receiver buffers are on the heap; a bar's flash file is only written when it changes - HTTP server: more handlers, sockets and stack for the rig - docs/P4_NANO.md, README and Makefile updated; graphify output Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ba8e160aee
commit
4ab0c7c6d7
101 files changed
+3284
-971
No files matched your search
@@ -0,0 +1,98 @@
|
||||
# Controller on the Waveshare ESP32-P4-Nano
|
||||
|
||||
The v2 controller (`main/`) runs on the Waveshare ESP32-P4-Nano; it no longer builds for the ESP32-S3, which is
|
||||
now only a bridge board (`bridge/`). The P4 has no radio. The ESP32-C6
|
||||
on the board supplies Wi-Fi through esp-hosted over SDIO, and ESP-NOW through `radio-c6/`, our firmware for
|
||||
the C6.
|
||||
|
||||
```
|
||||
Ethernet (IP101, RMII) SDIO (esp-hosted 3.1)
|
||||
PC <-------------------------------> ESP32-P4 <-------------------------------> ESP32-C6 ~~ ESP-NOW ~~> drivers
|
||||
192.168.50.10 web UI, API, controller Wi-Fi RPC + peer data radio-c6/
|
||||
UDP bridge (main/) (bridge/main/radio_proto.h)
|
||||
```
|
||||
|
||||
- **Wi-Fi** (the access point, Wi-Fi drivers): `esp_wifi_remote` runs the C6's Wi-Fi from the P4 as if it were
|
||||
local.
|
||||
- **ESP-NOW:** esp-hosted does not forward it. The controller treats the C6 as a bridge called `c6`, which is
|
||||
always present on this target, in `main/bridge_hosted.c`. Frames go to the C6 in batches over esp-hosted's
|
||||
peer-data channel. `radio-c6/main/radio_now.c` sends them one at a time and sends every frame it hears back
|
||||
to the P4. It does the same job as the USB bridge in `bridge/`, but over SDIO.
|
||||
- **Microphone:** the on-board mic goes through the ES8311 codec, set up over I2C with `esp_codec_dev`. The
|
||||
rest of the mic path (levels, beat detection, streaming) runs on the P4.
|
||||
- **Status:** `GET /status` lists the `c6` bridge (kind `c6`). It shows whether the C6 is linked, its MAC and
|
||||
channel, its counters, and which desktop is using the radio, if any.
|
||||
|
||||
## Build and flash
|
||||
|
||||
Use ESP-IDF v6.1 (`espressif/idf:v6.1`). The settings are `sdkconfig.defaults` and the partition table is
|
||||
`partitions.csv`.
|
||||
|
||||
```bash
|
||||
make build # the web UI, radio-c6/ (C6) and the controller (P4)
|
||||
make flash PORT=/dev/ttyACM0 # the controller, plus the C6 image into the slave_fw partition
|
||||
make log PORT=/dev/ttyACM0 # the console for 10 s (the board's USB-C port is a CH343 UART)
|
||||
make ota HOST=192.168.50.20 # later updates over Ethernet (not the C6 image: flash for that)
|
||||
```
|
||||
|
||||
`radio-c6/` takes its version (`rc6-<hash>`) from its sources. At boot, the controller compares that version
|
||||
with what the C6 reports (`main/c6_update.c`). When they differ, it sends the image from `slave_fw` to the C6
|
||||
over esp-hosted OTA and restarts the board. This takes about 10 seconds, and only happens on the first boot
|
||||
after a change. Never put the one-off updater in `scripts/c6-ota/host-v2` on the board again: it updates the
|
||||
C6 on every boot.
|
||||
|
||||
## Network
|
||||
|
||||
The board sits on a cable straight to the PC (192.168.50.10), so there is no DHCP server. At boot it tries:
|
||||
1. the settings `static_ips`
|
||||
2. DHCP, for 5 seconds
|
||||
3. **192.168.50.20/24**, with no gateway (menuconfig "ESP32-P4-Nano")
|
||||
|
||||
The web UI is at http://192.168.50.20/.
|
||||
|
||||
## Using it as a network bridge from the desktop
|
||||
|
||||
The P4 also speaks the network bridge protocol, the same one as a bridge board with Ethernet (see
|
||||
`bridge/README.md`):
|
||||
- UDP 8766 carries frames.
|
||||
- UDP 8767 carries HELLO/INFO and the microphone.
|
||||
|
||||
In the desktop led-controller, add the bridge `192.168.50.20:8766` (settings
|
||||
`"bridges": ["192.168.50.20:8766"]`). The desktop's drivers then go out over the C6, and the desktop can use
|
||||
the Nano's microphone as the bridge board's mic.
|
||||
|
||||
While a desktop is sending, the P4's own controller frames are dropped, so the drivers only hear the desktop.
|
||||
The P4 logs the hand-over. When the desktop has been quiet for 2 seconds, the P4's controller takes the radio
|
||||
back.
|
||||
|
||||
## Pins (from the Waveshare wiki and BSP)
|
||||
|
||||
| What | GPIO |
|
||||
| --- | --- |
|
||||
| Ethernet: MDC, MDIO, PHY reset, 50 MHz REF_CLK in | 31, 52, 51, 50 |
|
||||
| RMII: TXD0, TXD1, TX_EN, RXD0, RXD1, CRS_DV | 34, 35, 49, 30, 29, 28 (IDF's P4 defaults) |
|
||||
| ES8311: I2C SDA, SCL (address 0x18) | 7, 8 |
|
||||
| ES8311: I2S MCLK, BCLK, WS, ADC data in | 13, 12, 10, 11 |
|
||||
| C6 over SDIO: CLK, CMD, D0-D3, C6 reset | 18, 19, 14-17, 54 |
|
||||
|
||||
The board has no user button or user LED, so the AP button and beat LED are off.
|
||||
|
||||
## Back to the factory demo
|
||||
|
||||
The board's original 16 MB flash is saved in `~/esp-backups/p4-nano-factory-e8f60ae851f8.bin`:
|
||||
|
||||
```bash
|
||||
docker run --rm --device=/dev/ttyACM0 -v ~/esp-backups:/b espressif/idf:v6.1 esptool -p /dev/ttyACM0 -b 921600 write-flash 0 /b/p4-nano-factory-e8f60ae851f8.bin
|
||||
```
|
||||
|
||||
The C6 keeps running `radio-c6`. Waveshare's demo uses an older esp-hosted, which may not work with it.
|
||||
|
||||
## Simulator
|
||||
|
||||
The board serves the same simulated rig as the desktop at `/sim/` (Menu > Simulator). The bars run in the browser and
|
||||
get the controller's frames from the `browser` bridge, which is always on next to `c6`. Frames addressed to simulated
|
||||
bars (MACs starting 02:51:4d) are not sent over the C6. A page that reads too slowly loses frames; the radio does not
|
||||
wait for it. Rooms and the bars' flash are in `/db/sim`.
|
||||
|
||||
`make build` packs the page from `led-simulator/web`. The bars' WebAssembly comes from `make sim-wasm`; without it
|
||||
`/sim/` only says how to build it.
|
||||
Reference in new issue
Block a user