I'm developing an embedded application that receives TCP commands from a client. Whenever a disconnect command is received, the application closes the connection.Though it isn't common knowledge, hasn't been widely advertised, and it used to be recommended; casual use of 'boot.py' is no longer recommended and may prove problematic. This is because of a MicroPython change where USB services on an RP2 board are no longer made available until after 'boot.py' completes execution.
How consequential or problematic using 'boot,py' will be depends on what its code does. If it never exits the RP2 board will never deliver USB services, won't ever be seen as a USB device.
The only way to currently recover when MicroPython 'hangs' because 'boot.py' never exits, it or 'main.py' locks out the REPL, is to nuke Flash and re-install MicroPython. There is currently no other way to remove 'boot.py', 'main.py', or any other file, if Thonny cannot see it, and you can't access the REPL.
Why things are not working for you may become clearer if you can show us what code you placed in 'boot.py' and 'main.py'.
How should I structure boot.py so that the application automatically runs on startup and properly restarts after disconnection, releasing all resources correctly?
Also, is there a way to make the program automatically start again when the Pico is powered off and then reconnected?
Thank you. What is a better way to proceed in this situation?The "import main" in 'boot.py' prevents it from completing, prevents USB being activated, until 'main.py' completes.
Statistics: Posted by alien77 — Mon Nov 10, 2025 8:55 am