Skip to content

If boot.py doesn't exit then rp2 port will never initialise USB (soft-bricked) #15230

@TRadigk

Description

@TRadigk

Port, board and/or hardware

Raspberry Pico

MicroPython version

MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040

Reproduction

I took my program code and stripped it down to a working repro. There are more lines that could be deleted but help with visualization. The content is saved to boot.py. There is no other file saved on the microcontroller.
With any version prior 1.23 this will yield a serial device in device manager, whenever the device is connected to the computer. With version 1.23 it will not and can only recovered by flashing a firmware version prior 1.23:

import _thread
import asyncio  # type: ignore
from time import sleep
import gc
import machine

synchronousLoopAlive: bool = True
anyLoopAlive: bool = True
led = machine.Pin(25, machine.Pin.OUT)


async def yieldingBackgroundTaskOne():
    while anyLoopAlive:
        print("One")
        led.value(not led.value())

        await asyncio.sleep_ms(1000)


def synchronousTask():
    while synchronousLoopAlive:
        sleep(2)


if __name__ == "__main__":
    try:
        sleep(3)
        loop = asyncio.get_event_loop()
        gc.collect()

        programThread = _thread.start_new_thread(synchronousTask, ())
        print("program thread started")
        taskOne = loop.create_task(yieldingBackgroundTaskOne())
        print("task One started")

        loop.run_forever()
    except KeyboardInterrupt:
        synchronousLoopAlive = False
        anyLoopAlive = False
        loop.stop()
        print("INTERRUPTED - STOPPING EVERYTHING")
    except Exception as e:
        print(f"error occurred: {e}")

Expected behaviour

Expected a serial device in device manager as in all versions prior 1.23.

Observed behaviour

No serial device in device manager with micropython 1.23, but with any version prior 1.23.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions