When the time “I bricked my Raspberry Pi Pico, how to solve?” comes, what to do? I found a neat solution for when you are using microPython and lock/brick you Pi Pico.
How was my experience? I stated noticing that after a while of my Pico connected via USB cable to a computer, its program stopped running. Searching the internet I found something about memory leakage.
At the time I was running a simple blink from this past article, nothing fancy. Some folks on the link above commented about using watchdog to reset the board from time to time.
I then found this link on using the watchdog, but with no explation on how to use it properly.
from machine import WDT
wdt = WDT(timeout=2000) # enable it with a timeout of 2s
wdt.feed()
I then paste the entire code (as is above) before the “while True:” of my code, that was my mistake. Now the “wdt.feed()” is never reached, therefore resetting the uC every two seconds.
My Pico vanished form the USB COM ports with no sign of coming back. Couldn’t program it via Thonny IDE.
On Windows’ device manager the COM port would come and go every two seconds. First thing I tried was to re-flash the microPython .UF2 bootloader, to no avail.
This is done by pressing and holding BOOTSEL button while you plug the Pi Pico via USB to the computer. A “drive” will show up in Windows, then you drag the .UF2 bootloader file into it.
Even then the Pi Pico would still reset after two seconds. I tried burning an Arduino bootloader to it, but when the microPython one was flashed back, the corrupted file was still there.
The solution
After some internet research I found out about this “flash_nuke” UF2 file, that supposedly would clear the entire Pi Pico flash. Flashing the “flash_nuke.uf2” file to my Pi Pico actually solved the problem, the offending main.py file was gone.
The lesson I learned is to put the “wdt.feed()” function inside the “while True:” loop. This is in order to the “wdt.feel()” be called in less than two seconds and prevent a system reset.
Do you have any briking history with microcontrollers? tell me in the comments below.
Leave a Reply