← index #16554Issue #15721
Related · high · value 1.604
QUERY · ISSUE

Multithread breaks file operations on pico2w.

openby tudorapoopened 2025-01-08updated 2025-03-03
bugport-rp2

Port, board and/or hardware

RPI_PICO2_W

MicroPython version

MicroPython v1.25.0-preview.180.g495ce91ca on 2025-01-06; Raspberry Pi Pico 2 W with RP2350

Reproduction

  1. copy the below threads using code and run it:
import time
import _thread

global killme

def threadtest():
    global killme
    print("Other starts")
    while True:
        if killme:
            break
        print("másik thread")
        time.sleep(3.17)
    print("Other ends")

killme = False

try:
    new_thread = _thread.start_new_thread(threadtest, ())
    print("Main starts")
    while True:
        print("Main thread")
        time.sleep(1)
except KeyboardInterrupt as theInterrupt:
    print("Main ends")
    killme = True
  1. run it
  2. stop it
  3. try to copy or delete any file with mpremote, it will hang
  4. powercycle (pull out the usb conenctor and back) and things will work until I run the above code again.

Expected behaviour

Expected to be able to upload code.

Observed behaviour

Was not able to upload code.

Additional Information

When I copied/ran non-threaded code, a simple hello world the problem did not happen.

Code of Conduct

Yes, I agree

CANDIDATE · ISSUE

TinyUSB callback can't recurse 20014b10

closedby tudorapoopened 2024-08-26updated 2025-07-01
bug

Port, board and/or hardware

raspberry pico pi w

MicroPython version

MicroPython v1.24.0-preview.224.g6c3dc0c0b on 2024-08-22; Raspberry Pi Pico W with RP2040

Reproduction

import time
import _thread

global killme

def threadtest():
    global killme
    print("Other starts")
    while True:
        if killme:
            break
        print("Other thread")
        time.sleep(1)
    print("Other ends")

killme = False

try:
    new_thread = _thread.start_new_thread(threadtest, ())
    print("Main starts")
    while True:
        print("Main thread")
        time.sleep(1)
except KeyboardInterrupt as theInterrupt:
    print("Main ends")
    killme = True

Expected behaviour

I expect it to run just like it does with MicroPython v1.21.0 on 2023-10-06; Raspberry Pi Pico W with RP2040

Observed behaviour

Starts to run, then when I press ctrl-c it dies:

Main ends
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'main.py'
>>> FATAL: uncaught exception 20014b10
OSError: TinyUSB callback can't recurse

And from this point the pico is bricked, I have to nuke the flash and reinstall the firmware.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied