-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32-S3: USB-JTAG not working after esp32_reset() or Watchdog-Reset when TinyUSB CDC was initialized in application once (IDFGH-8354) #9826
Comments
Also running into this. I wonder if there's a bit in a register somewhere we could flip before calling |
Things i've tried (that haven't worked):
I made a minimal repro case to demonstrate the issue: https://github.com/johnboiles/esp32-tinyusb-reset-bug The only workaround we've found is to hook up a GPIO to the RESET pin and force the chip to reset itself. But it seems like there's probably just some register somewhere that needs to get reset at shutdown time. I've been doing my testing on IDF 5.1 (cbce221). The problem seems to be where in |
I think I got it! TL;DR is something like this: #include <esp_private/usb_phy.h>
extern usb_phy_handle_t *phy_hdl_ptr; usb_del_phy(*phy_hdl_ptr);
usb_phy_config_t phy_conf = {
.controller = USB_PHY_CTRL_SERIAL_JTAG,
};
usb_phy_handle_t jtag_phy;
usb_new_phy(&phy_conf, &jtag_phy); Where
So now the question is how to we productionize this. Probably if there were a |
PR to propose |
@rikaiot thank you for reporting and @johnboiles thank you for your thorough investigation! |
Hello @johnboiles here is some update: The restart behavior you see is actually intentional. If a user wants to perform a software reset, he usually does not want to re-enumerate as different device (JTAG debug) during the process. Moreover, changing this would be a functional breaking change, so we will fix this with the changes you proposed in Even more info: |
Makes sense to me that it's not the typical case to re-enumerate the USB/JTAG device after configuring TinyUSB. Is there anywhere in the documentation that mentions which peripherals maintain their state across calls to |
All of them, except Wi-Fi, BT, UART0, SPI1, and legacy timers EDIT: Documentation is actually not entirely correct, as on ESP32-S2 and newer chips, if memory protection was enabled (and it was enabled by default) we did reset all the digital peripherals. |
esp_tinyusb v1.4.1 relased https://components.espressif.com/components/espressif/esp_tinyusb |
Answers checklist.
IDF version.
v4.4.2
Operating System used.
Windows
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
CMD
Development Kit.
ESP32-S3-DevKitM-1
Power Supply used.
USB
What is the expected behavior?
USB-JTAG is enabled by default, so when connecting the device via USB-Plug (not UART) to the PC the board is recognized as a JTAG-Interface in the device manager.
As soon as using TinyUSB CDC driver in the application by calling
tinyusb_driver_install()
and
tusb_cdc_acm_init()
the USB-JTAG is disabled and the device is recognized as a serial device.
When pressing the reset button or calling esp_reset() the board should again be recognized as USB-JTAG until the TinyUSB driver is loaded in the application.
What is the actual behavior?
When the TinyUSB has been loaded once, calling esp_reset() or forcing a watchdog reset does not make the device to be recognized as USB-JTAG any more.
Only when the reset button is pressed, the device is recognized as USB-JTAG again.
Steps to reproduce.
Connect the ESP32-S3-DevKitM-1 dev board to the pc via USB-Plug (not UART) - the device is recognized as USB-JTAG.
Initialize TinyUSB in the application by calling
tinyusb_driver_install()
and
tusb_cdc_acm_init()
after some delay.
The board is recognized as serial device.
Call esp_restart() or force and watchdog reset.
The board is not recognized as USB-JTAG again.
Press reset button - the board is recognized as USB-JTAG again until the TinyUSB initialization is done.
Debug Logs.
No response
More Information.
It seems that the USB-JTAG is disabled by TinyUSB and is not reactivated again when calling esp_restart().
The text was updated successfully, but these errors were encountered: