-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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 does not reset after upload #6762
Comments
@me-no-dev I assume this is not the intended behaviour? And the S3 boards should reset after flashing them like the S2 boards do right? |
@UnexpectedMaker not if you are using TinyUSB while booted. It works if the integrated CDC+JTAG is used, but the other USB no. |
Hmm, but it works correctly with the S2, so why not with the S3? It's really confusing people - they think their boards didn't flash, as no other ESP32 has this issue (original, S2, C3 etc) - so people are complaining about HW faults. If we use CDC+JTAG, then the board doesn't enumerate with the custom device name, which also confuses people, so it seems like the S3 has the worst of both situations, rather than any improvement in either. How do we get this behaviour changed? |
Yes this has become a painful issue. Have tested from Arduino and ESP-IDF with same behaviour. This also means you have to reconnect serial monitor after every firmware upload for proper update. |
This seems worth improving and documenting as well? cc @me-no-dev & @pedrominatel |
Surely if we could we would have :) I went through ROM code and everything, but could not figure out what is preventing the board/download mode to reboot the firmware. When booting into download from TinyUSB, we first stop TinyUSB, then init CDC+JTAG and then reboot into download, so in reality it should have been the same as rebooting from CDC+JTAG, but it is not. We might find a way in the future, but this has taken too much resources already as it is. |
This is pain, I'm having to use the Boot pin after every upload. And that has the side effect of closing Arduino IDE Serial Monitor randomly. I'm glad to volunteer my hours with direction. Just tell me what to do. Background: I'm working on the open-source Reflections wrist watch project, including an ESP32-S3-Mini based main board. I'm building this using the Adafruit Feather ESP32-S3 as a reference and using their Arduino IDE 12.3.1 board definition "Adafruit Feather ESP32-S3 No PSRAM". I'm using ESP32 version 2.0.3, installed through the Boards Manager. Repository for my project is at https://github.com/frankcohen/ReflectionsOS/tree/main/Devices/Hoober |
@frankcohen |
Thanks, the UM boards look great. I'd be glad for UM to carry my board too. I will open-source the board. -Frank |
Not sure if this is helpful but ... My ESP32-S3-DevKitC-1-N8R2 does reset after upload if I use the UART USB jack but it will not reset after upload when using the OTG USB jack UNLESS I upload right after I erase flash. My UM Feather S2 does reset after upload. My UM TinyS3 does not reset after upload. |
@me-no-dev Is this issue caused by security advisory AR2022-004 ? |
@UnexpectedMaker yes and no. You can think of this as two separate issues:
AR2022-004 talks about issue 1 |
@me-no-dev So if issue 1 is resolved, then you could use USB-OTG and not have to switch to CDC, bypassing issue 2? So that would also fix this problem on newer silicon? |
@UnexpectedMaker exactly :) |
My understanding [EDITED based on subsequent investigations] BackgroundThere are multiple ways to connect from a a host (Mac/PC) USB port to an ESP32-S3 for bootloading (download) and serial terminal purposes:
If using option (1) there is no problem. (For example this is the UART USB jack on the ESP32-S3 DevKit board.) However, that requires an extra part and it's otherwise nice to use the integrated USB controller. So, let's assume option (2). This requires configuring the ESP32-S3 to act as a serial port device. There are again multiple ways to do that:
Using the dedicated USB Serial/JTAG controller is simpler for software, since the hardware takes care of most of the details of USB. However, the USB-OTG controller is more general, allowing other device classes (such as mass storage) in addition to being a serial port. Importantly, the bootloader (used to upload code) and the application (which wants to IssuesSo far this is all lovely but now there are some wrinkles. As @me-no-dev noted above, the bootloader cannot use the USB-OTG controller. This is related to a spot of confusion over one-time-programmable EFUSE bits as described in security advisory AR2022. Basically, for many ESP32-S3 parts, bootloader USB-OTG access is permanently disabled. So, the bootloader uses the USB Serial/JTAG controller instead (if allowed). This works just fine and allows the flash to be programmed in the normal way. HOWEVER, it is observed that sometimes the bootloader is unable to exit into the application, and a manual reset is required to start the app. This appears to happen if the bootloader (download mode) is entered (by reboot-to-bootloader typically triggered by DTR/RTS wiggles) FROM an application using the USB-OTG controller (not hardware USB Serial/JTAG), which is the Arduino runtime's default. Per @me-no-dev's comment above, the reasons for this are not entirely understood, but it's thought to be something about switching between the two controllers? WorkaroundsThere are two known ways to work around this:
To switch the Arduino runtime to the USB Serial/JTAG controller (workaround (ii)):
Both workarounds are somewhat unfortunate, which is why this bug exists and people are grumpy. As a third approach, some people have had luck with patches to Investigation notesAs noted above, success/failure seems to be triggered not by what app we're loading but by what app was running before resetting to the bootloader:
So somehow, when resetting back to the bootloader, a running OTG-using app leaves state in the system that prevents the bootloader from jumping to start ANY program it loads. Maybe the reboot-to-bootloader code in the OTG-based driver is somehow doing things slightly wrong? For reference, the USB Serial/JTAG controller can be distinguished from the USB-OTG controller externally; it shows up as "Espressif USB JTAG/serial debug unit" with VID:PID 303A:1001. Rebooting from app to bootloader and bootloader to app (the path that fails) is generally managed by wiggling DTR and RTS serial control lines -- this is the "Hard resetting via RTS pin..." message from in The USB Serial/JTAG controller manages DTR/RTS wiggle detection directly. This is described in section 30.3.2 in the technical reference: Here is the further discussion in section 30.4.2: The reset-to-app code in esptool.py does this, assuming DTR=0 and RTS=0 on entry:
(Tangent: DTR and RTS can be wiggled manually for testing with miniterm, with ^T^D and ^T^R respectively. After reproducing this problem (successfully flashing an app, but failing to reboot-to-app), we can see this:
So it does reboot on wiggle, but the
When reboot-to-app does work (after running the
Going from app back to bootloader:
Note the As a final note, fixing
Apparently Esptool detects another method of software reboot-into-bootloader ( The main relevance of the above is that there seems to be a bunch of subtle/hidden chip state controlling whether or not the system starts in the bootloader or jumps to the app. The logic is hard to observe, hidden in the obscurities of the closed-source ROM, and thus hard to debug from outside. |
Just a note of appreciation to Egnor, thank you. And a question, have you seen JTAG with platform IO and esp32s3 working? |
@frankcohen wrote:
I have not tried! I am curious about it but figured I'd open one can of worms at a time. If you do try, or have tried, I'd like to know how it goes. |
I'll let you know. The bigger problem to solve first is getting Platform IO
to recognize the Adafruit Feather ESP32-S3 board definition file. That's
next.
…On Wed, Jul 13, 2022, 5:55 PM Daniel Egnor ***@***.***> wrote:
@frankcohen <https://github.com/frankcohen> wrote:
Just a note of appreciation to Egnor, thank you. And a question, have you
seen JTAG with platform IO and esp32s3 working?
I have not tried! I am curious about it but figured I'd open one can of
worms at a time. If you do try, or have tried, I'd like to know how it goes.
—
Reply to this email directly, view it on GitHub
<#6762 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABUEWMKREROROZRVCZXFXPTVT5QP5ANCNFSM5WDKDUNA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@egnor This is great investigative work Daniel! Thanks very much for the awesome effort. |
@Jason2866 testet it local and now it compiles but fail with resetting:
i will create the pr but think it wouldnt make much sense if we have this problem? the flash was successfull and i can see in terminal that it works, its just the reset not working, im using the develop branch |
@wuast94 I think you have a general problem with the port. Anyways the PR for the boards.json is not related to this. |
Enables support for the ESP standard DTR/RTS based reboot to bootloader. Switches from OTG to Serial/Jtag mode to workaround issue discussed in: espressif/arduino-esp32#6762 Signed-off-by: Andrew Leech <[email protected]>
Hello, Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket. Thanks. |
Hello. Definitely still an issue. Could we reopen? |
Enables support for the ESP standard DTR/RTS based reboot to bootloader. Switches from OTG to Serial/Jtag mode to workaround issue discussed in: espressif/arduino-esp32#6762 Signed-off-by: Andrew Leech <[email protected]>
Enables support for the ESP standard DTR/RTS based reboot to bootloader. Switches from OTG to Serial/Jtag mode to workaround issue discussed in: espressif/arduino-esp32#6762 Signed-off-by: Andrew Leech <[email protected]>
I have the same issue, trying to build the lvgl demo example with ESP32-S3 Edit: Waveshare ESP32-S3-Touch-LCD-4.3 controller - I have this model, that has a touch LCD 4.3 and my connection is to USB of my PC. Could it be that there is not enough power to power the esp32 and the lcd? --- Warning: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM11 instead...
--- esp-idf-monitor 1.5.0 on \\.\COM11 115200
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x0 (DOWNLOAD(USB/UART0))
Saved PC:0x40041a79
--- 0x40041a79: ets_delay_us in ROM
waiting for download````
|
esp32-s2 doesn't have this problem at all. Is there anything we can learn from its implementation? |
|
So do you mean that in arduino-esp32 version 3.1.0 and up, which uses esptool v4.8.1, this issue should be fixed? I have been watching this thread for awhile, I'll be interested to test this tonight. |
For anyone still struggling, watchdog_reset has been added. When using Platformio add: Not sure how to inject the "watchdog_reset" command into Arduino IDE. |
@FunDeckHermit Does a "watchdog_reset" clear the If it doesn't, then you will keep entering bootloader mode after reset, if you used this method to enter boot, which is what the ESP32-S3 Arduino framework does via the native USB serial interface when you perform the "upload" command. That register bit mask is reset by the "hard_reset" command in recent esptool releases, exactly to address this issue. I am curious, then what is "watchdog_reset" for? |
@ppescher WDT resets works for S3 when TinyUSB is used. |
So it works for USB OTG, not CDC/JTAG? I thought that to enter bootmode you had to still perform the switch to USB CDC and use |
WDT reset:
Not sure about the TinyUSB specifics in Arduino. |
@FunDeckHermit that works PERFECTLY, thank you so much |
Board
esp32s3
Device Description
esp32s3 devkitc n8r8
Hardware Configuration
Native USB port plugged into computer, serial convert USB port not plugged in.
Version
v2.0.3
IDE Name
Arduino IDE, Platformio
Operating System
Windows 10, MacOS
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
921600
Description
Uploading a sketch over usb otg should reset the chip after upload, but it does not.
Other Steps to Reproduce
Tested on s3 devkitc and all UnexpectedMaker s3 boards.
Notes:
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: