esp32/machine_pin: ESP32-P4 pin 54 can't be set to output
Port, board and/or hardware
esp32 port, generic ESP32-P4 board
MicroPython version
MicroPython v1.27.0 on 2025-12-09; Generic ESP32P4 module with ESP32P4
Reproduction
MicroPython v1.27.0 on 2025-12-09; Generic ESP32P4 module with ESP32P4
Type "help()" for more information.
>>> import machine
>>> machine.Pin(53, machine.Pin.OUT)
Pin(53)
>>> machine.Pin(54, machine.Pin.OUT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: pin can only be input
Expected behaviour
machine.Pin(54, machine.Pin.OUT) should work, because all GPIO pins on the ESP32-P4 are output capable.
Observed behaviour
machine.Pin(54, machine.Pin.OUT) states pin can only be input, which is false.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
esp32/machine_pin: Make all pins on ESP32-P4 output capable.
<!-- Thanks for submitting a Pull Request! We appreciate you spending the
time to improve MicroPython. Please provide enough information so that
others can review your Pull Request.
Before submitting, please read:
https://github.com/micropython/micropython/wiki/ContributorGuidelines
Please check any CI failures that appear after your Pull Request is opened.
-->
Summary
<!-- Explain the reason for making this change. What problem does the pull request
solve, or what improvement does it add? Add links if relevant,
especially links to open issues. -->
All GPIO pins on the ESP32-P4 are output capable, so there is no need to define GPIO_FIRST_NON_OUTPUT.
Also fixes #18982, since GPIO_FIRST_NON_OUTPUT was incorrectly set to 54, preventing that pin from being configured as an output.
Testing
<!-- Explain what testing you did, and on which boards/ports. If there are
boards or ports that you couldn't test, please mention this here as well.
If you leave this section empty then your Pull Request may be closed. -->
Tested on an ESP32-P4 board. Before this change, pin 54 could not be configured as an output. After this change, it can. Tested with an LED to verify it toggles correctly.
Generative AI
<!-- Please delete the answer below which doesn't apply, or write your own
answer with more details. -->
I did not use generative AI tools when creating this PR.
<!-- We require everyone to answer this question. If you delete this section or
ignore it then your PR may be closed.
For more information, consult the MicroPython Generative AI Policy:
https://github.com/micropython/micropython/wiki/ContributorGuidelines#generative-ai-policy
-->