You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks @scruss for that additional test. I can confirm that it displays similar symptoms to the original issue: it seems to hang (no output is printed), but if you press a key at the REPL it does start printing. That's consistent with the RP2040 being blocked in a WFE with no interrupt to wake it, and pressing a key sends a USB packet and wakes it up.
Initial investigation by @projectgus and myself have us suspecting a bug in pico-sdk's alarm pool / pairing heap, when there are multiple timers some of them get dropped. (Note that each machine.Timer allocates a new alarm pool timer, each call to sleep_us and sleep_ms use the alarm pool, and also sitting idle at the REPL uses the alarm pool to wait efficiently.)
This should now be fixed in MicroPython as #13329 was cherry-picked in 74fb42a.
(The root cause in the alarm pool of pico-sdk probably still exists, and MicroPython still uses the alarm pool however now it is only used for longer timeouts that don't seem to trigger this bug. See the linked commit for more details about removing alarm pool from MP entirely.)
Activity
scruss commentedon Nov 3, 2023
see also related issue [Resolved - MicroPython is broken] Timers plus sleep_ms and sleep_us oddness - Raspberry Pi Forums, where poster's code with
sleep_ms()works but when replaced withsleep_us()fails.(OP on Raspberry Pi forum is unable to use github, for some reason.)
dpgeorge commentedon Nov 14, 2023
I can reproduce the issue. It's apparent only with Pico W firmware and seems to be related to having the lwIP 64ms alarm running.
scruss commentedon Nov 14, 2023
This code hangs on both Pico W and Pico (both v1.21.0):
Substituting the commented-out
time.sleep_ms(1_000)runs as expected.dpgeorge commentedon Nov 14, 2023
Thanks @scruss for that additional test. I can confirm that it displays similar symptoms to the original issue: it seems to hang (no output is printed), but if you press a key at the REPL it does start printing. That's consistent with the RP2040 being blocked in a WFE with no interrupt to wake it, and pressing a key sends a USB packet and wakes it up.
Initial investigation by @projectgus and myself have us suspecting a bug in pico-sdk's alarm pool / pairing heap, when there are multiple timers some of them get dropped. (Note that each
machine.Timerallocates a new alarm pool timer, each call tosleep_usandsleep_msuse the alarm pool, and also sitting idle at the REPL uses the alarm pool to wait efficiently.)dpgeorge commentedon Nov 20, 2023
I reported this issue to pico-sdk: raspberrypi/pico-sdk#1552
projectgus commentedon Jun 4, 2024
This should now be fixed in MicroPython as #13329 was cherry-picked in 74fb42a.
(The root cause in the alarm pool of pico-sdk probably still exists, and MicroPython still uses the alarm pool however now it is only used for longer timeouts that don't seem to trigger this bug. See the linked commit for more details about removing alarm pool from MP entirely.)