Skip to content

espressif: correct ESP32-P4 ADC2 channel mapping - #11492

Merged
dhalbert merged 1 commit into
adafruit:mainfrom
ladyada-eagleclaw:fix-esp32p4-adc2-mapping
Oct 5, 2026
Merged

dhalbert merged 1 commit into
adafruit:mainfrom
ladyada-eagleclaw:fix-esp32p4-adc2-mapping

Conversation

@ladyada-eagleclaw

Copy link
Copy Markdown

AI-assisted with Codex during Metro ESP32-P4 bring-up; the results below come from local builds and serial captures.

GPIO49–54 map to ADC2 channels 0–5, but the P4 pin table used channels 2–7. Correct the six entries. Before this change, A4 and A5 failed with IDFError('Invalid argument') and IDFError('Requested resource not found').

Tested on Adafruit Metro ESP32-P4 Rev A, silicon v0.1, running the 10.3.0-alpha.4 development tree:

import analogio, board
for name in ('A0', 'A1', 'A2', 'A3', 'A4', 'A5'):
    with analogio.AnalogIn(getattr(board, name)) as pin:
        print(name, pin.value)

All six inputs constructed and read successfully. Recorded values were 49210, 59656, 60629, 61305, 61205, and 61046. These were floating inputs, so this verifies channel access, not voltage accuracy.

The combined bring-up tree built for Metro, P4 GPIO, both Espressif P4 function EV variants, M5Stack Tab5, and Solder Party P4 Stamp XL using make -C ports/espressif BOARD=<board> -j6. Hardware testing used the combined tree; this PR isolates the mapping correction on current main. Changed-file pre-commit and git diff --check pass. Other boards were compile-tested only.

GPIO49 through GPIO54 are ADC2 channels 0 through 5. The previous offset selected neighboring inputs and invalid channels for GPIO53 and GPIO54. Match ESP-IDF adc_channel.h.

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

🟢 Approval recommended

The focused mapping correction is consistent, complete, and supported by hardware and compile testing.

Review effort: Balanced
Findings: None

What changed in this PR

Corrects ESP32-P4 ADC2 pin metadata to match the GPIO49–54 hardware channel mapping.

Changes:

  • Remaps GPIO49–54 from ADC2 channels 2–7 to channels 0–5.
  • Restores analog input access for affected ESP32-P4 boards.
File Description
ports/​espressif/​peripherals/​esp32p4/​pins.c Corrects six ADC2 channel assignments.

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

@mikeysklar

mikeysklar commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Reviewed, looks good to me.

@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.

👍

@dhalbert
dhalbert merged commit 8e7f58d into adafruit:main Oct 5, 2026
549 checks passed
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