Edit code on PyCharm Pro -> use Thonny to send file to Pico -> Use Thonny to run the file (not necessarily main.py).
Today I added a "main.py" that simply imports "app.py" from a release directory on the Pico. It's a two line program:
Code: Select all
from v1_0_0 import app
app.run()
The app has a very tight loop that is scheduling tasks and doing a bunch of work, including communicating via both serial ports. That works fine.
The issue is that the Pico runs the app immediately and, I think, Windows has no time to connect to and initialize the USB serial port Thonny uses to talk to it. The port (com 3) never shows up in devices. Thonny can't connect to it and, of course, can't interrupt the program if it can't connect.
My first thought was to just reinstall the MicroPython UF2, load all of the software again and, this time, add something like a 30 second delay in main.py before it calls app.run().
I can reset the board and use the bootsel button to bring it up as a USB flash drive.
To my surprise, dragging and dropping the MicroPython UF2 file does NOT seem to erase my code. As soon as the UF2 is copied over and Pico reboots, my main.py runs again and it calls app.run() instantly.
I thought uploading a new UF2 would flash over any user python code on reboot. Clean slate. Not the case?
How do I get rid of this code?