← index #16511Issue #18213
Related · high · value 2.071
QUERY · ISSUE

esp32s3/c3 hardware JTAG control to external pins

openby emardopened 2025-01-01updated 2025-03-30
enhancementport-esp32

Description

Allows routing of ESP32C3 and ESP32S3 internal hardware usb-jtag
to external gpio pins making ESP32S3/C3 cheap and fast JTAG for
programming other devices.

Once enabled this ESP32 hardware services JTAG by itself
so no other software interrupts or any server running
is needed.

Code Size

12 lines of code to enable, 6 lines to disable here is arduino example

#if CONFIG_IDF_TARGET_ESP32S3
#define OMATRIX_TCK 85
#define OMATRIX_TMS 86
#define OMATRIX_TDI 87
#define OMATRIX_SRST 251
#define IMATRIX_TDO 251
#endif

#if CONFIG_IDF_TARGET_ESP32C3
#define OMATRIX_TCK 36
#define OMATRIX_TMS 37
#define OMATRIX_TDI 38
#define OMATRIX_SRST 127
#define IMATRIX_TDO 39
#endif

void route_usb_jtag_to_gpio()
{
digitalWrite(LED_BUILTIN, LED_ON);
pinMode(PIN_TCK, OUTPUT);
pinMode(PIN_TMS, OUTPUT);
pinMode(PIN_TDI, OUTPUT);
pinMode(PIN_TDO, INPUT);
pinMode(PIN_SRST, OUTPUT);
WRITE_PERI_REG(USB_SERIAL_JTAG_CONF0_REG,
READ_PERI_REG(USB_SERIAL_JTAG_CONF0_REG)
| USB_SERIAL_JTAG_USB_JTAG_BRIDGE_EN);
// esp_rom_gpio_connect_out_signal(GPIO, IOMATRIX, false, false);
esp_rom_gpio_connect_out_signal(PIN_TCK, OMATRIX_TCK, false, false);
esp_rom_gpio_connect_out_signal(PIN_TMS, OMATRIX_TMS, false, false);
esp_rom_gpio_connect_out_signal(PIN_TDI, OMATRIX_TDI, false, false);
esp_rom_gpio_connect_out_signal(PIN_SRST, OMATRIX_SRST, false, false);
esp_rom_gpio_connect_in_signal (PIN_TDO, IMATRIX_TDO, false);
}

void unroute_usb_jtag_to_gpio()
{
WRITE_PERI_REG(USB_SERIAL_JTAG_CONF0_REG,
READ_PERI_REG(USB_SERIAL_JTAG_CONF0_REG)
& ~USB_SERIAL_JTAG_USB_JTAG_BRIDGE_EN);
pinMode(PIN_TCK, INPUT);
pinMode(PIN_TMS, INPUT);
pinMode(PIN_TDI, INPUT);
pinMode(PIN_TDO, INPUT);
pinMode(PIN_SRST, INPUT);
digitalWrite(LED_BUILTIN, LED_OFF);
}

Implementation

I hope the MicroPython maintainers or community will implement this feature

Code of Conduct

Yes, I agree

CANDIDATE · 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

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