Skip to content

espressif: add P4 USB host and Hosted Wi-Fi, fix P4 bring-up - #11497

Closed
ladyada-eagleclaw wants to merge 1 commit into
mainfrom
metro-p4-core-support
Closed

ladyada-eagleclaw wants to merge 1 commit into
mainfrom
metro-p4-core-support

Conversation

@ladyada-eagleclaw

@ladyada-eagleclaw ladyada-eagleclaw commented Oct 3, 2026 •

Copy link
Copy Markdown

Superseded by issue-specific PRs #11492, #11493, #11494, #11495, #11499, #11500, #11501 and #11502. Board definition #11498 remains separate. This branch is retained as the board PR's current integration base.


AI-assisted with Codex, asked to bring up the Metro ESP32-P4 and separate reusable core support from its board definition. Validation below comes from compiler output, serial captures, and the physical board; no model-generated measurements are used. ## What and why Complete the ESP32-P4 support exercised during Metro bring-up: - Add the existing usb_host.Port API for the P4's dedicated high-speed PHY, alongside a full-speed USB device. Poll TinyUSB's delayed enumeration work so a keyboard can enumerate without a new interrupt. - Restore ROM USB PHY routing when resetting into the downloader; initialize the P4 UID from its factory MAC; correct GPIO49–54 to ADC2 channels 0–5. - Set MIPI DSI output color format explicitly and preserve fractional MHz pixel-clock requests. - Add optional ESP-Hosted Wi-Fi through the standard wifi and socketpool APIs. Boards opt in with CIRCUITPY_ESP_HOSTED and their SDIO wiring. - Allow sdioio and Hosted to share the SDMMC controller: select the actual slot, reserve the Hosted slot, release only the card's slot, and report frequency in Hz. The board definition is the separate dependent PR #11498. No new Python API is introduced. Panel initialization remains in Python. ## SDK dependency The ESP-IDF pin includes two small SDMMC fixes on the existing CircuitPython SDK base: 1. Backport Espressif's controller reinitialization fix, originating at espressif/esp-idf@df53e6a. 2. Serialize interrupt handling with slot removal. A pending DMA interrupt dereferenced a removed slot during repeated card teardown (MCAUSE=5, MTVAL=0x94, in sd_host_get_free_descriptors_count). The fix also dispatches SDIO callbacks to the interrupting slot. Both commits are available from adafruit/esp-idf:metro-p4-sdmmc-reinit. ESP-Hosted is pinned to v2.12.13 and esp-wifi-remote to its recorded upstream commit (component 1.6.5). Dependency fetching uses the existing Espressif CI mechanism. ## Hardware tested Metro ESP32-P4 Rev A, silicon v0.1, 16 MB flash/16 MB PSRAM; Windows; ESP32-C6 running ESP-Hosted 2.12.11; USB keyboard 1c4f:0002; 7-inch Raspberry Pi Touch Display 2; 7,948,206,080-byte SD card. - USB-C CDC/MSC remained available with USB-A keyboard input on the 1280x720 DSI console. Ladyada confirmed typing on the display. NeoPixel colors were checked on the webcam. - All A0–A5 inputs constructed/read; floating readings verify channel access, not voltage accuracy. - Stable UID 6055f9f990fd; unattended ROM entry, verified flashing, and ordinary reboot worked. - RGB888 color bars/text and display release/recreation passed. The 83,330,000 Hz pixel-clock conversion was checked in code, not measured with an instrument. - SD-first startup, 8 MiB patterned file write/read verification at 20 and 40 MHz, 64 buffer offsets with garbage collection, and 24 mount/read/unmount/deinit cycles while Wi-Fi scanned passed. Final read+verify rates were 6.37 and 8.98 MB/s respectively; these include Python verification overhead and are not raw bus benchmarks. - C6 scans found APs; connection, DHCP, gateway ping, DNS, and HTTP 200 passed after a normal reboot. Final safe-mode reason was NONE. Minimal shared-bus exercise (run with an inserted card and compatible C6 firmware): python import board, sdioio, storage, wifi for frequency in (20_000_000, 40_000_000): sd = sdioio.SDCard( clock=board.SD_CLK, command=board.SD_CMD, data=(board.SD_DATA0, board.SD_DATA1, board.SD_DATA2, board.SD_DATA3), frequency=frequency, ) storage.mount(storage.VfsFat(sd), '/sd') print(sd.frequency, sd.count()) storage.umount('/sd') sd.deinit() networks = wifi.radio.start_scanning_networks() print(sum(1 for network in networks)) wifi.radio.stop_scanning_networks() ## Build checks Built against current main (eec31fea92) with make -C ports/espressif BOARD=<board> -j6: - adafruit_p4gpio - espressif_esp32p4_function_ev - espressif_esp32p4x_function_ev - m5stack_tab5 - solderparty_esp32p4_stamp_xl - adafruit_feather_esp32s3_4mbflash_2mbpsram (shared-code regression build) The dependent Metro board also passed with BOARD=adafruit_metro_esp32p4 BUILD=build-metro-p4-c6-final -j4: 1,536,176 bytes used, 560,976 bytes free in the 2 MiB firmware partition. Changed-file pre-commit and git diff --check pass. A separate read-only code audit found no blocking issue; it is not hardware evidence. Hardware evidence is from the integrated development tree; these PRs separate the same board/core changes onto current main. Other boards were compile-tested only. ## Scope BLE, ESP-NOW, camera support, TLS validation, USB hubs and high-speed throughput are not claimed. Other boards are compile-tested only. The first prototype's card-detect fault is a known hardware limitation. This consolidates the unreviewed core work from #11492, #11493, #11494, #11495 and the USB host part of #11496.

Include the ADC mapping, stable UID, ROM USB reset, DSI output and shared SDMMC fixes verified during Metro P4 bring-up. Keep board wiring and configuration in a separate dependent commit.

Co-authored-by: Limor Fried <ladyada@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant