Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

tools/pyboard.py: Port recent patchs from mpremote serial transport, to add timeouts for non-responsive serial ports#17330

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

Conversation

dpgeorge
Copy link
Member

Summary

This applies#16513 and#16616 (made for mpremote) totools/pyboard.py. They add timeouts to the initial connection phase to a target board, to help with non-responsive serial ports. Without these patchespyboard.py can hang indefinitely waiting for a board to respond.

Testing

To be tested by@hmaerki on Octoprobe.

Trade-offs and Alternatives

The test runners still usepyboard.py. Eventually it would be good to change them to usempremote as the backend, but that's a lot more effort.

@dpgeorgedpgeorge added the toolsRelates to tools/ directory in source, or other tooling labelMay 20, 2025
@github-actionsGitHub Actions
Copy link

Code size report:

   bare-arm:    +0 +0.000% minimal x86:    +0 +0.000%    unix x64:    +0 +0.000% standard      stm32:    +0 +0.000% PYBV10     mimxrt:    +0 +0.000% TEENSY40        rp2:    +0 +0.000% RPI_PICO_W       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS  qemu rv32:    +0 +0.000% VIRT_RV32

@codecovCodecov
Copy link

codecovbot commentedMay 20, 2025
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base(f5d10c3) to head(dea3035).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@##           master   #17330   +/-   ##=======================================  Coverage   98.54%   98.54%           =======================================  Files         169      169             Lines       21898    21898           =======================================  Hits        21579    21579             Misses        319      319

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hmaerki
Copy link
Contributor

hmaerki commentedMay 26, 2025
edited
Loading

I reviewed this PR and it looks fine.
The testruns look much better - this is the newest one:https://reports.octoprobe.org/github_selfhosted_testrun_1/octoprobe_summary_report.html

I would propose to merge this PR!

@hmaerki
Copy link
Contributor

In the summary, you write:

This applies#16513 and#16616 (made for mpremote) to tools/pyboard.py.

It looks like a typo: 16513 should be 16531!

@hmaerki
Copy link
Contributor

hmaerki commentedMay 27, 2025
edited
Loading

However, there is still a situation where the test time out with aOSError: [Errno 5] Input/output error. See:

The problem was most probably that python multiprocessing terminated the processed and unpowered the tentacle. However, the terminating process still could see the powerdown and this is the ioctl error we see in above logs.

This behaviour was fixed inoctoprobe/testbed_micropython@02ce3a6.
Now we may clearly see that the processes time out:

* https://reports.octoprobe.org/github_selfhosted_testrun_9/RUN-TESTS_STANDARD_NATIVE@2731-RPI_PICO2/testresults.txt* https://reports.octoprobe.org/github_selfhosted_testrun_9/RUN-TESTS_STANDARD_NATIVE@2731-RPI_PICO2-RISCV/testresults.txt

The second link might be related to this PR: The test was hanging without even executing one test.

@hmaerki
Copy link
Contributor

https://reports.octoprobe.org/github_selfhosted_testrun_13/RUN-TESTS_EXTMOD_HARDWARE_NATIVE@2731-RPI_PICO2-RISCV/testresults.txt

This command still timeouts after 90s as pyboard hangs somehow.
@dpgeorge : Do you have an ideal where pyboard hangs? Or how to get a stacktrace at the moment of timeout..

@dpgeorge
Copy link
MemberAuthor

I was unable to reproduce that error, even with exactly the same hardware (I think?) and using thefirmware.uf2 downloaded from that octoprobe run.

Anyway, I could force a similar error by making the board lock up during a test run. That lead to a lock-up duringserial.write(). So I've now added awrite_timeout=5 parameter to the serial initialisation, and caught such errors duringenter_raw_repl(). My testing shows that this helps to catch such cases of the board locking up, although it's still quite slow because it will try to run every test after the lock-up and each one takes about 10 seconds. Then it takes another 30 seconds or so to even exitrun-tests.py due to the serial port having locked up.

This is not really an issue we can fix, because it's the OS that is blocking, waiting for the USB serial port to respond, and it never does respond.

@dpgeorge
Copy link
MemberAuthor

@hmaerki I tried to trigger a run of this PR, but failed:https://reports.octoprobe.org/github_testbed_micropython_15

Can you please test this PR out (now with the addedwrite_timeout=5 bit)?

@hmaerki
Copy link
Contributor

@hmaerki I tried to trigger a run of this PR, but failed:https://reports.octoprobe.org/github_testbed_micropython_15

Can you please test this PR out (now with the addedwrite_timeout=5 bit)?

I started this job#16 for you:https://github.com/octoprobe/testbed_micropython/actions/runs/15342563400

@dpgeorge
Copy link
MemberAuthor

Thanks for triggering the new run. It seems to have worked, output is here:https://reports.octoprobe.org/github_selfhosted_testrun_16

It shows that the problem with test timeout is now resolved:

In summary:

  • the "write timeout" introduced in this PR is needed
  • even with a write timeout, the failing tests still take a while because the USB serial is broken
  • I don't know why the test is failing, locally it works for me

@hmaerki
Copy link
Contributor

hmaerki commentedJun 2, 2025
edited
Loading

Started another batchhttps://reports.octoprobe.org/github_selfhosted_testrun_18 and got timeouts:https://reports.octoprobe.org/github_selfhosted_testrun_18/RUN-TESTS_STANDARD_NATIVE@2731-RPI_PICO2-RISCV/basics_0prelim.py.out


Intersting observation: Inhttps://reports.octoprobe.org/github_selfhosted_testrun_18/RUN-TESTS_STANDARD_VIA_MPY@2731-RPI_PICO2-RISCV/testresults.txt

pass  micropython/kbd_intr.py FAIL  micropython/native_closure.py (timeout waiting for first EOF reception)

From now on, all tests fail! It is probably the RPI_PICO2-RISCV which locks up!


Run WITHOUT multiprocessing (results not stored):
testresults/RUN-TESTS_STANDARD_NATIVE@2731-RPI_PICO2-RISCV/testresults.txtpass  thread/stress_recurse.py FAIL  thread/stress_schedule.py (timeout waiting for first EOF reception)testresults/RUN-TESTS_STANDARD_NATIVE@2731-RPI_PICO2/testresults.txtpass  thread/stress_recurse.py FAIL  thread/stress_schedule.py (timeout waiting for first EOF reception)

In both cases, onlythread/stress_schedule.py failed.


@dpgeorge: To me, this MR is resolved as pyboard does always recover from timeout! Please merge into master.

@dpgeorge
Copy link
MemberAuthor

From now on, all tests fail! It is probably the RPI_PICO2-RISCV which locks up!

Yes, I have seen this happen with this PR, if the device locks up then all tests from then on fail. That's an improvement though! Previouslyrun-tests.py would just halt forever. At least now it makes progress.

This applies the mpremote commit0d46e45to pyboard.py.If the target does not return any data then `read_until()` will blockindefinitely.  Fix this by making the initial read part of the general readlook, which always checks `inWaiting() > 0` before reading from the serialdevice.Also added the UART timeout to the constructor.  This is not currently usedbut may be used as an additional safeguard.Signed-off-by: Damien George <damien@micropython.org>
This applies the mpremote commit03fe9c5to pyboard.py.The `timeout_overall` is used in `enter_raw_repl()`.  It prevents waitingforever for a serial device that does not respond to the Ctrl-C/Ctrl-D/etccommands and is constantly outputting data.Signed-off-by: Damien George <damien@micropython.org>
If the USB serial device locks up, then writes to that device can hangforever.  That can make the test runner `tests/run-tests.py` lock up, amongother problems.This commit introduces a 5 second write-timeout, and catches any OSError'sraised during `enter_raw_repl()`.  Now, if a USB serial device locks up,`enter_raw_repl()` will eventually raise an exception.Signed-off-by: Damien George <damien@micropython.org>
@dpgeorgedpgeorgeforce-pushed thetools-pyboard-add-serial-timeout branch from3b66b8c todea3035CompareJune 2, 2025 07:05
@dpgeorgedpgeorge merged commitdea3035 intomicropython:masterJun 2, 2025
66 checks passed
@dpgeorgedpgeorge deleted the tools-pyboard-add-serial-timeout branchJune 2, 2025 07:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
toolsRelates to tools/ directory in source, or other tooling
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@dpgeorge@hmaerki

[8]ページ先頭

©2009-2025 Movatter.jp