Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
mpremote: Introduce timeout_overall to prevent endless loops#16616
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
mpremote: Introduce timeout_overall to prevent endless loops#16616
Uh oh!
There was an error while loading.Please reload this page.
Conversation
9b6c4a7
to4ab2df9
CompareCode size report:
|
4ab2df9
toa190608
Comparecodecovbot commentedJan 21, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## master #16616 +/- ##======================================= Coverage 98.58% 98.58% ======================================= Files 167 167 Lines 21590 21590 ======================================= Hits 21285 21285 Misses 305 305 ☔ View full report in Codecov by Sentry. |
1d812e7
tobaf69d1
Compare@@ -142,7 +151,7 @@ def enter_raw_repl(self, soft_reset=True): | |||
self.serial.write(b"\r\x01") # ctrl-A: enter raw REPL | |||
if soft_reset: | |||
data = self.read_until(1, b"raw REPL; CTRL-B to exit\r\n>") | |||
data = self.read_until(1, b"raw REPL; CTRL-B to exit\r\n>", timeout_overall=10) |
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.
I thinktimeout_overall=10
should be passed to both of the other calls toread_until
below in thisenter_raw_repl
function. That will prevent waiting forever in the case (1) triggering the soft reset does not work correctly but does print out data continuously (rare but could happen); and (2) boot.py forever prints out data and never exits.
Also, I suggest making a global constant for this timeout, eg at the top of this file just after the imports:
_ENTER_RAW_REPL_TIMEOUT=10
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.
I added a commit but did it slightly different: I added a default parameter 'timeout_overall' to 'enter_raw_repl()' - it is consistent with the rest of the code. But I am also open for your proposal:-)
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.
Looks good!
070b6dd
to266d2c3
CompareAnd use it in `enter_raw_repl()`. This prevents waiting forever for aserial device that does not respond to the Ctrl-C/Ctrl-D/etc commands andis constantly outputting data.Signed-off-by: Hans Maerki <buhtig.hans.maerki@ergoinfo.ch>
266d2c3
to03fe9c5
Compare03fe9c5
intomicropython:masterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Summary
This is a follow up of#16531.
Testing
In this situation, mpremote blocks forever:
Turning the LED ON!
every second.mpremote u0 eval 42
mpremote
blocks forever.read_until()
is reset every second.read_unit()
should return after 10s.It might not be a problem when mpremote hangs forever on the command line. However it is a severe problem when
read_until()
is called in octoprobe andread_until()
hangs forever. This PR fixes both situations.Compile/flash the firmware to reproduce above situation
Connect a esp32s3 and flash using below command:
docker run --rm -v /dev:/dev --privileged -t docker.io/espressif/idf:v5.2.2 bash -c"git clone --depth 1 https://github.com/espressif/esp-idf.git && cd esp-idf/examples/get-started/blink && idf.py set-target esp32s3 && idf.py flash -p /dev/ttyUSB0"
Fix
timeout_overall
inread_until()
.This is a new optional parameter and defaults to NONE (infinite). It does not break existing code.