It is easy to have micropython code in boot.py or main.py that prevents USB and/or UART working.
I have some personal strategies to avoid lockup due to bad micropython code.
I use thonny so some details may need to be adjusted for other IDE's.
When I am developing new code I avoid using boot.py.
As much as I can, I delay testing with main.py uploaded to the PICO.
With Thonny you can execute a file that is in an editor window.
If the code locks up the PICO you can just power cycle it and you are back.
Once I get to the point where I am uploading main.py I add a sleep of 10 seconds at the beginning of main.py.
With the sleep in place you have 10 seconds after a power cycle to hit the thonny stop button (or equivalent for your IDE).
Then you can delete main.py on the PICO.
The sleep is a little irritating when I'm testing but it makes it easier to recover.
I have some personal strategies to avoid lockup due to bad micropython code.
I use thonny so some details may need to be adjusted for other IDE's.
When I am developing new code I avoid using boot.py.
As much as I can, I delay testing with main.py uploaded to the PICO.
With Thonny you can execute a file that is in an editor window.
If the code locks up the PICO you can just power cycle it and you are back.
Once I get to the point where I am uploading main.py I add a sleep of 10 seconds at the beginning of main.py.
With the sleep in place you have 10 seconds after a power cycle to hit the thonny stop button (or equivalent for your IDE).
Then you can delete main.py on the PICO.
The sleep is a little irritating when I'm testing but it makes it easier to recover.
Statistics: Posted by cpottle9 — Tue Jan 14, 2025 7:48 pm