Crash GDBStub over ESP32S3's built-in USB JTAG when TinyUSB CDC is in use

wuyuanyi
Posts: 28
Joined: Wed Mar 09, 2022 11:54 am

Crash GDBStub over ESP32S3's built-in USB JTAG when TinyUSB CDC is in use

Postby wuyuanyi » Thu Oct 20, 2022 8:14 am

If TinyUSB CDC is enabled, the built-in USB JTAG interface is disabled. When the program crashes, the crash core dump or GDB Stub does not work in this case. Is it possible to configure ESP32S3 to automatically switch back to the USB JTAG interface on crash, so that the ESP32S3 could be easily debugged without using another UART interface?

Thanks

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: Crash GDBStub over ESP32S3's built-in USB JTAG when TinyUSB CDC is in use

Postby ESP_igrr » Thu Oct 20, 2022 12:07 pm

I think this would be a bit difficult for the following reason. After switching to the USB_SERIAL_JTAG, the host would need to re-enumerate the device. However this will require some time. The panic handler code would have to wait for the enumeration to finish, but it's not clear how long we need to wait for that to happen. If the host is not connected (or enumeration doesn't happen for some reason) then we might end up getting stuck in the panic handler.
Besides, the serial port created by the OS for the usb_serial_jtag will not be the same as the one created by the OS for TinyUSB CDC device, so your terminal program will not automatically show you the panic handler output — it will be sent to a different serial port.
I would suggest doing one of the following, instead:
  • Use the internal PHY for one USB port (e.g. USB_OTG peripheral with tinyusb) and an external USB PHY for another (e.g. USB_SERIAL_JTAG). In the final product, don't populate one of the ports (debugging) on the PCB.
  • Use UART for diagnostics and the built-in USB port for the USB functionality with tinyusb.

wuyuanyi
Posts: 28
Joined: Wed Mar 09, 2022 11:54 am

Re: Crash GDBStub over ESP32S3's built-in USB JTAG when TinyUSB CDC is in use

Postby wuyuanyi » Fri Oct 21, 2022 10:36 am

ESP_igrr wrote:
Thu Oct 20, 2022 12:07 pm
I think this would be a bit difficult for the following reason. After switching to the USB_SERIAL_JTAG, the host would need to re-enumerate the device. However this will require some time. The panic handler code would have to wait for the enumeration to finish, but it's not clear how long we need to wait for that to happen. If the host is not connected (or enumeration doesn't happen for some reason) then we might end up getting stuck in the panic handler.
Besides, the serial port created by the OS for the usb_serial_jtag will not be the same as the one created by the OS for TinyUSB CDC device, so your terminal program will not automatically show you the panic handler output — it will be sent to a different serial port.
I would suggest doing one of the following, instead:
  • Use the internal PHY for one USB port (e.g. USB_OTG peripheral with tinyusb) and an external USB PHY for another (e.g. USB_SERIAL_JTAG). In the final product, don't populate one of the ports (debugging) on the PCB.
  • Use UART for diagnostics and the built-in USB port for the USB functionality with tinyusb.
Thank you for the explanation!

Who is online

Users browsing this forum: No registered users and 86 guests