-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
tools/pyboard.py: Fix RTS esp32 lockups. #13455
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: gitcnd <cnd@geek.net.au>
Signed-off-by: gitcnd <cnd@geek.net.au>
Signed-off-by: gitcnd <cnd@geek.net.au>
Code size report:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #13455 +/- ##
=======================================
Coverage 98.36% 98.36%
=======================================
Files 159 159
Lines 21088 21088
=======================================
Hits 20743 20743
Misses 345 345 ☔ View full report in Codecov by Sentry. |
@NoosaHydro Which ESP boards are you finding that lock up or reset with the current mpremote/pyboard behaviour, and with which host OS? Most ESP8266/ESP32 development boards have some version of the "automatic bootloader" circuit, meaning that default serial port behaviour (assert RTS and DTR together) shouldn't trigger a reset. In recent years I don't recall too many where this doesn't work as expected, except for when wiring RTS and DTR pins directly to the chip. |
@projectgus There's more context to this change in the original PR it was included in: #13253 (comment) |
@andrewleech Thanks Andrew, that's useful context. I'm still curious how widespread this problem is. I have an embarrassing number of ESP32 boards and some ESP8266 ones, and I debugged these kind of issues a lot when I was the esptool maintainer at Espressif (and before). My impression is that it was more common back around 2016/2017, when more of the cheaper development boards weren't implementing the automatic reset circuit properly. These days I had the impression it was quite rare. I'm not denying it happens, it's quite likely there are some families of boards that have this problem and maybe it's more widespread than I know. However, I'm curious exactly which boards do exhibit it, on which host OSes. That helps everyone understand how important it is to work around. |
wtr this discussion and the inquiry as to how impactful the matter is: a couple of days ago I wanted to play with a ESP32_CAM board with an ambition to get to object detection & recognition and had a difficult time getting it to work icw Thonny. I managed - in the end - following up on a suggestion somewhere on the net to add RTS / DTR settings in Thonny's configuration file. Then I had some ESP8266 Wemos D1's lying (ESP8266EX chips), once bought to supplement my collection of RPI Pico's with WIFI connectivity (now obsolete given the Pico_W availability) and ran into the same issue as the ESP32_CAM: flashing works but the Micropython prompt never shows up. Played with RTS etc here too but have not gotten the ESP8266 to run Micropython (tried different images, Thonny settings, several boards). Logged it as issue at Thonny (#3083). Thx for the efforts all you guys continue to make to improve Micropython ! |
For additional reference, here is some previous work on this as done by @Josverl and discussed on Discord recently. Note that according to Jos' research there are some (non-ESP) boards where de-asserting DTR may break functionality, and we'd need to ensure any blanket change here doesn't have similar regressions (or make it a command line option). |
Thank you for sharing! The info below connects to the references you provided. After having put the matter to rest for some days, I tried again, last evening, and with success. I have now two W10 PC's ("current" wrt Windows releases/updates), with the latest Thonny (4.1.4) giving me "MicroPython v1.22.1 on 2024-01-05; ESP module with ESP8266". Tried again with both rts = false and dtr = false in the Thonny Configuration file, flashing with the Thonny integrated ESPTOOL with install settings Flash mode = DIO and size = detect, made the micropython show up. |
It is the ESP8266 which send the first boot message at 78440 baud, which decodes at 115200 baud to gibberish. |
self.serial.exclusive = serial_kwargs["exclusive"] | ||
self.serial.open() | ||
|
||
if hard_reset: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No port reset on Windows ?
@gitcnd My fixes determine based on OS=="win" and portinfo[0].manufacturer != "Microsoft" as that was the best rule i could make based on my hardware. I ask as I spend quite a lot of time in determining, then fixing and and validating across ports and OSSes. So before merging any changes I would propose to:
|
this workaround prevents python .Serial(...) from unwantedly pulsing the RTS line and/or holding it high (which resets or locks up many ESP32/ESP8266 boards)