Skip to content
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

esp_tinyuf2 example crashes upon reenabling USB-Serial-JTAG. (AEGHB-940) #454

Open
3 tasks done
wormyrocks opened this issue Jan 6, 2025 · 1 comment
Open
3 tasks done

Comments

@wormyrocks
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

5.3.2

Espressif SoC revision.

ESP32-S3 v0.2

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

CMD

Development Kit.

Custom Board

Power Supply used.

Battery

What is the expected behavior?

Upon completion of UF2 bootloader, correctly reset the USB-Serial-JTAG peripheral before resetting MCU.

What is the actual behavior?

Hits a panic handler while trying to reset the peripheral, somewhere inside usb_new_phy().
https://github.com/espressif/esp-iot-solution/blob/master/components/usb/esp_tinyuf2/esp_tinyuf2.c#L116

Steps to reproduce.

Code is based on the uf2_ota and uf2_nvs examples: (https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_uf2_ota; https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_uf2_nvs) on an ESP32-S3 custom PCB.

The USB Serial/JTAG peripheral is normally used for all debugging the main firmware, but wanted to add a user-facing USB firmware update mode.

My modified code both allows a uf2 update, and a config.ini file to update NVS parameters.

UF2 code all runs in userspace - no bootloader hooks installed.

There is also code to manipulate debug LEDs: WS2812Bs using the RMT peripheral. All calls to the RMT peripheral are synchronous and linked to the callback handler (no dedicated LED control task).

The crash is difficult to debug because when it occurs, both the TinyUSB console and USJ peripheral are being reset. I just know that we are entering a panic handler. Not sure if it is a watchdog timeout, stack overflow, or some other kind of issue.

And - i can only tell that the panic handler is triggered because I am using __wrap_esp_panic_handler() to blink a red LED when an error occurs.

By placing a GPIO toggle on either side of the call to usb_ne, i can tell that the error occurs in the call to usb_new_phy().

If the device enters the panic handler and reboots, I can see that the USJ peripheral has been reset correctly. If the call to usb_new_phy() on line 116 of esp_tinyuf2.c is disabled, we avoid the panic handler and esp_reset() properly starts the new firmware. However, after booting the new firmware, the USB device no longer enumerates.

If I enter and leave deep sleep from the firmware, the USJ device enumerates properly again.

This occurs on a Windows host.

Debug Logs.

No response

More Information.

No response

@github-actions github-actions bot changed the title esp_tinyuf2 example crashes upon reenabling USB-Serial-JTAG. esp_tinyuf2 example crashes upon reenabling USB-Serial-JTAG. (AEGHB-940) Jan 6, 2025
@wormyrocks
Copy link
Author

BTW: this happens both with and without CONFIG_ENABLE_UF2_USB_CONSOLE enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants