Page 1 of 1

ESP32-S3 USB JTAG bridge ?

Posted: Thu Jan 20, 2022 1:28 pm
by adrien_m
I understand from the TRM that it should be possible to use the USB JTAG controller as a bridge to an external device by setting this register :
USB_SERIAL_JTAG_USB_JTAG_BRIDGE_EN Set this bit usb_jtag, the connection between
usb_jtag and internal JTAG is disconnected, and MTMS, MTDI, MTCK are output through GPIO
Matrix, MTDO is input through GPIO Matrix. (R/W)
However I was not able to get this to work.
Is this possible ? Am I missing something here ? (maybe some setup needed related to the GPIO matrix ?)

Thanks

Re: ESP32-S3 USB JTAG bridge ?

Posted: Fri Jan 21, 2022 2:12 am
by ESP_Sprite
Yes. You need to route the signals out through the GPIO matrix. Here's some code (note: it's a modified example of test code for another chip; I haven't tested it on an actual C3, but it should get you on the way)

Code: Select all

	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(3, 36, false, false); //tck
    esp_rom_gpio_connect_out_signal(4, 37, false, false); //tms
    esp_rom_gpio_connect_out_signal(5, 38, false, false); //tdi
    esp_rom_gpio_connect_out_signal(8, 127, false, false); //srst, wire to reset or EN of target
    esp_rom_gpio_connect_in_signal(9, 39, false); //tdo
    
(Note that this uses GPIO 3,4,5,8,9, but you can pick any GPIO for any signal.)

I'd be interested to hear if you get this to work, I can't remember if we tested this functionality after tapeout.

Re: ESP32-S3 USB JTAG bridge ?

Posted: Fri Jan 21, 2022 9:02 am
by adrien_m
Thanks, however this is for the C3, I'm looking at the S3 and in the TRM the only signal numbers documented are usb_jtag_tdo_bridge (as an input, seems strange ?) and usb_jtag_trst.
Do you know if the other signals are missing from the documentation ? Or if it's just not possible to route them on this device ?

Re: ESP32-S3 USB JTAG bridge ?

Posted: Fri Jan 21, 2022 9:15 am
by ESP_Sprite
Whoops, you're right, in my mind there's less of a reason to use that functionality in the 'big' S3 so my mind automagically assumed it was about the C3.
Looks like it's not in the TRM, we probably need to fix that. TCK, TMS and TDI are signal 85-87; TRST is 251 (in the output matrix), TDO is 251 (in the input matrix). You should use the same code I posted earlier, simply substitute the numbers.

Re: ESP32-S3 USB JTAG bridge ?

Posted: Fri Jan 21, 2022 10:27 am
by adrien_m
Great, doing a very quick test I can see what looks like correct signals output from the pins with my logic analyzer, I will report after doing a full test.