-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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. |
Wouldn't it be possible to just invoke the RUN_USER_CODE command (found in the stub loader)? Edit: It looks like the ESP32-S3 would support it, ESPtool however prevents it from executing on this type of chip: |
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
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 <andrew@alelec.net>
@me-no-dev This should be fixed with latest development esptool.py. There is a new reset way introduced WDT RTC reset. espressif/esptool@8298cdc |
@Jason2866 we haven't released a dev release containing that commit yet, so it's only available on master for now. It is a potential fix for this and other USB-related resets in Arduino, but I haven't tested that yet. Thanks for looking into it and for confirming it works! |
@radimkarnis Thx for the fix! Already ported in my Tasmota Esp Flasher. Now the S2 / S3 manual reset is history :-) |
@radimkarnis if you do not forget, please ping us here when the fix makes it to IDF 5.3 |
The updated esptool.py is used in develop branch of pioarduino (community Platformio fork, in pioarduino branch EDIT: pioarduino Arduino release core 3.0.7 uses the new esptool.py with WDT RTC |
when i do this i get
my platform.ini
|
Seems the name for the partitions.csv has changed. No one provided a PR for this change. |
i searched for this partition file but didnt find anything sadly |
Yes, because it is not correct in the Platformio/pioarduino boards.manifest.
|
can u point me what i have to do to get it working? i tried diffrent partiotion.csv files i found for the board but none of them worked, the upload works but then i get an io error. but thanks for that insight, i now understand why its always a **** to work with such boards/projects |
@wuast94 Fix this boards.json https://github.com/pioarduino/platform-espressif32/blob/develop/boards/adafruit_matrixportal_esp32s3.json The Arduino change was done with this PR #8894 Would be very happy if a volunteer is providing a PR in pioarduino fork whenever a change for boards is done in this repo. Speaking as maintainer of pioarduino |
Should fix espressif/arduino-esp32#6762 (comment) *** [.pio\build\adafruit_matrixportal_esp32s3\partitions.bin] Source `partitions-8MB-tinyuf2.csv' not found, needed by target `.pio\build\adafruit_matrixportal_esp32s3\partitions.bin'.
@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. |
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: