As a genius in programming I was interrested in how PI Pico will deal with infinite loop of some math (may to be hot?), so I made a "code" with While True :
. Right after I press "Run" in Thonny, it saves program into memory, so a second after Pico disappear from device list. BOOM.
You can put any new .uf2 sketch and it will works fine. You can start in BOOTSEL mode, but here is no "wrong" file - just initial files with help, which doesn't help much. As soon as you put python' .uf2 back (say instead of blink), it returns to infinite loop.
This wasn't my plan.
Well, if Pico works with any other program, the thing is in code of python interpretator, which runs main.py
right after start. This file doesn't exists in "file" folder, so here have to be other one - probably virtual - disk with files visible from Thonny (which can't be used now as soon as Pico cannot communicate via virtual comport).
So how does Pico stores files for python?
Well, if You will scroll down the page "Getting started with Pico" you will found uf2 for Resetting Flash memory.
OR you can read below
- Go to picotool and install it (you can find detailed instruction in Pico books)
- Find what HEX-editor is suitable for you, in my case it is "Sublime Text" and viewer (in my case MC)
- A terminal window
- Put python' .uf2 back to Pico using BOOTSEL mode. Pico will restart and hangs, but in our case it is OK
- Reboot Pico in BOOTSEL mode again to operate with picotool
- Use
picotool info -a
and find address info ofembedded drive
, in my caseembedded drive: 0x100a0000-0x10200000 (1408K): MicroPython
- Lets dump it using
picotool save -r 0x100a0000 0x10200000 ~/Desktop/pico.bin
this will give us 1441792 bytes file - Make copy:
cp ~/Desktop/pico.bin ~/Desktop/pico.bak
just for a case - Open .bin file in HEX viewer to be sure you see something like 6C69 7474 6C65 6673 2FE0 (which is
littlefs/
btw) - Scroll through file to find your wrong code
- Simple edit your code, may be overwriting first letters of each row with hash (# is 23 in HEX) OR do as I did: put FF instead whole code
- Save binary file and check its size (must be same!)
- Now it is time to return file to Pico:
picotool load ~/Desktop/pico.bin -t bin -o 0x100a0000
- Reboot:
picotool reboot
Well, I make it brick right in 11th minute of the very first try. I tried to find a solution in internet but wasn't succeed. So I've documented what found in next 40 minutes. It was FUN!