Skip to content

Add Adafruit Metro ESP32-P4 board - #11498

Merged
dhalbert merged 3 commits into
metro-p4-core-supportfrom
metro-esp32p4-board
Oct 5, 2026
Merged

dhalbert merged 3 commits into
metro-p4-core-supportfrom
metro-esp32p4-board

Conversation

@ladyada-eagleclaw

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

Copy link
Copy Markdown

AI-assisted with Codex, asked to add the Metro ESP32-P4 board and validate it on the physical prototype. The core changes are submitted separately; this PR contains only the five board-definition files.

Board

Adafruit Metro ESP32-P4 with 16 MB flash, 16 MB PSRAM, and an ESP32-C6 Wi-Fi coprocessor. USB VID/PID is the allocated Adafruit pair 239a:817c, recorded for Metro ESP32-P4 CircuitPython in Adafruit's boards repository.

  • USB-C: full-speed device on GPIO24/25, shared with the ROM Serial/JTAG downloader.
  • USB-A: dedicated high-speed host PHY; switched power on GPIO14.
  • Enable VO4 at 3.3 V for GPIO39–48, used by microSD and C6 control.
  • Configure C6 ESP-Hosted on SDMMC slot 1, leaving slot 0 for microSD.
  • Expose labelled header pins, A0–A5, NeoPixel, voltage monitor, SDIO/card detect, USB power, C6, and camera/display control aliases.

Dependency

This five-file PR remains based on the tested metro-p4-core-support integration branch so its diff stays board-only and buildable. Core changes are now reviewed separately:

After the dependencies merge, rebase the board commit onto main and retarget this PR. The aggregate core PR #11497 has been replaced by those issue-specific PRs; its branch is retained only as this PR's current integration base.

Validation

Metro Rev A, silicon v0.1, Windows; ESP-Hosted 2.12.11 on the C6; 7-inch Raspberry Pi Touch Display 2 and USB keyboard 1c4f:0002.

Hardware checks passed for the USB keyboard driving the DSI console, NeoPixel colors, all six analog input constructors/reads, pin aliases, an 8 MiB PSRAM allocation/pattern check, software entry to the ROM downloader, ordinary reboot, SDIO read/write verification at 20/40 MHz, and C6 Wi-Fi scanning/connection/ping/DNS/HTTP. Ladyada confirmed keyboard text on the display. The first prototype's SD card-detect hardware fault remains; this PR does not claim that signal passed.

The exact combined PR tree builds on current main with make -C ports/espressif BOARD=adafruit_metro_esp32p4 BUILD=build-metro-p4-c6-final -j4: 1,536,176 bytes used and 560,976 bytes free in the 2 MiB firmware partition. Changed-file pre-commit and git diff --check pass. The hardware checks above used the integrated development tree containing the identical board/core support.

Minimal USB host check:

import board, digitalio, time, usb.core, usb_host
power = digitalio.DigitalInOut(board.USB_HOST_POWER)
power.switch_to_output(value=True)
host = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM)
time.sleep(2)
print(['%04x:%04x' % (d.idVendor, d.idProduct)
       for d in usb.core.find(find_all=True)])

Observed: ['1c4f:0002']. The keyboard test does not measure high-speed USB throughput. BLE and camera integration are outside this board addition. Replaces the board portion of #11496.

Review follow-up c04d6043c8 makes VO4 acquisition idempotent. The dependency-fetch fix from #11502 is merged through the retained base, preserving the five-file board diff. The updated board PR build uses 1,536,160 bytes with 560,992 bytes free. A host-side test of the actual board source called board_init() 100 times and observed one acquisition. The identical board files were flashed in integration tree ba6cace243 (built before commit, reporting 3732760035-dirty): five SD initialization/read/deinit cycles, 100 sector reads, a C6 scan finding 23 networks, demo restart and USB-C echo passed. Repeated hardware simulated-sleep cycles were not tested.

Configure USB-C device, USB-A host, SDIO storage and the C6 Hosted coprocessor with the allocated Adafruit USB ID.

Co-authored-by: Limor Fried <ladyada@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

VO4 is reacquired whenever board_init() repeats, leaving the LDO reference count unbalanced.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds the Adafruit Metro ESP32-P4 board definition with USB host, ESP-Hosted Wi-Fi, PSRAM, SDIO, and board pin mappings.

Changes:

  • Configures ESP32-P4 flash, PSRAM, USB, and C6 Hosted Wi-Fi.
  • Exposes board peripherals and enables the VO4 I/O rail.
File Description
board.c Enables the 3.3 V VO4 rail.
mpconfigboard.h Defines board buses and USB controllers.
mpconfigboard.mk Configures memory and enabled features.
pins.c Exposes board pin aliases and buses.
sdkconfig Configures silicon revision and C6 SDIO Hosted transport.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ports/espressif/boards/adafruit_metro_esp32p4/board.c
@mikeysklar

mikeysklar commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Reviewed, looks good to me. The board CI build fails until esp-hosted's nested submodule is fetched, see #11502.

ladyada-eagleclaw and others added 2 commits October 5, 2026 10:32
Co-authored-by: Limor Fried <ladyada@users.noreply.github.com>
Retain the existing LDO handle across simulated deep-sleep wakes instead of adding another reference each time board_init runs.

Co-authored-by: Limor Fried <ladyada@users.noreply.github.com>
@ladyada-eagleclaw

Copy link
Copy Markdown
Author

@mikeysklar The nested dependency fix from #11502 is now included in the retained integration base (edeb01cc20) and merged into this branch without rewriting history. The PR diff remains the five board files.

The updated board PR builds with make -C ports/espressif BOARD=adafruit_metro_esp32p4 BUILD=build-metro-p4-c6-final -j6: 1,536,160 bytes used, 560,992 bytes free. Changed-file pre-commit passed. Fresh ESP-Hosted dependency fetching was checked separately as described on #11502. Hosted CI is left to run on the new head.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The board configuration is internally consistent, validated on hardware, and the previously identified LDO lifecycle issue is fixed.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@dhalbert dhalbert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine!

@dhalbert
dhalbert merged commit 70500eb into metro-p4-core-support Oct 5, 2026
18 checks passed
@dhalbert
dhalbert deleted the metro-esp32p4-board branch October 5, 2026 15:49
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.

4 participants