← index #18213PR #16236
Related · high · value 0.119
QUERY · ISSUE

ESP32C6: USB not in board.json `features` but GPIO pins are disabled anyway

openby smurfixopened 2025-10-05updated 2025-10-08
enhancementport-esp32

Description

IMHO the default value for MICROPY_HW_ESP_USB_SERIAL_JTAG should be "is the USB feature turned on in the board.json file".

An even better default might be "micropython checks the EFuse flags and enables the pins iff these flags are set".

The relevant efuse bits are DIS_PAD_JTAG and DIS_USB_JTAG, see tech manual 9.2.4 "JTAG Signal Source Control" page 378/379.

Code Size

No response

Implementation

I would like to sponsor development of this feature

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

esp32/machine_pin.c: Fix the logic when to clear USB_SERIAL_JTAG_USB_PAD_ENABLE

mergedby garywillopened 2024-11-14updated 2025-03-13
port-esp32

<!-- 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/blob/master/CODEOFCONDUCT.md
 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. -->

When we don't use USB JTAG, we want to use the two USB pins (D+/D-) as GPIO. So, do clear USB_SERIAL_JTAG_USB_PAD_ENABLE when USB SERIAL JTAG is not enabled

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 empty then your Pull Request may be closed. -->

I was trying to build and use mpy v1.24.0 on ESP32-C3 (IDF 5.2.2).

The code below shows GPIO 18 19 shoud be usable when MICROPY_HW_ESP_USB_SERIAL_JTAG is false:
https://github.com/micropython/micropython/blob/611d8f9ce82ab5e04fb86ab6cfc28d5ed98f33bf/ports/esp32/machine_pin.h#L90-L93

So I tried commenting out this:
https://github.com/micropython/micropython/blob/611d8f9ce82ab5e04fb86ab6cfc28d5ed98f33bf/ports/esp32/mpconfigport.h#L257-L261
to make sure MICROPY_HW_ESP_USB_SERIAL_JTAG is false.

Then the result is I could use Pin(18)/Pin(19) to get GPIO object, but could not do real GPIO output.

So I think we should apply this fix, which works for me on ESP32-C3

I don't have ESP32-C6 to test

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied