Factory reset or hard reset is the process of restoring a device to its original system state. When we perform a factory reset on Pico, all the internal files and data will be deleted. The onboard flash memory will be erased entirely.
Factory reset trough bootmode erase memory #
There is a special UF2 file, called flash_nuke.uf2, that can be loaded into the Pico board to wipe its flash memory. This file will wipe both Raspberry Pi Pico & Pico W.
Download the flash_nuke.uf2 file to your computer from this link: https://datasheets.raspberrypi.com/soft/flash_nuke.uf2
raspberry pi pico (w) flash_nuke.zip #
Press the BOOTSEL button on Pico and while keeping it pressed, connect it to your computer via a USB cable. The Pico should now appear as a mass storage device on your computer with the label RPI-RP2.
Copy and paste the flash_nuke.uf2 file into this new drive. Your Pico/Pico W will now restart and all the files in its Flash memory will be erased.
Usage after factory reset
Raspberry Pi Pico’s documentation mentions – “BOOTSEL mode lives in read-only memory inside the RP2040 chip, and it can’t be overwritten accidentally. There is no way to brick the board through software.” So you do not need to worry if formatting the Flash memory will damage or brick your Pico.
If you wish to program your Pico using MicroPython again, you will need to re-flash the MicroPython UF2 file by visiting the link https://micropython.org/download and selecting the appropriate UF2 file for your board.
Reset By Renaming Main.py #
If you do not wish to lose all the files in your Pico as shown in the factory reset method, you can try to rename the main.py file. Sometimes, your Pico may be stuck due to the main.py script. A specific UF2 file will help you to rename the main.py file.
Download the MicroPython_RenameMainDotPy.uf2.zip from here: https://forums.raspberrypi.com/download/file.php?id=45227&sid=0f009ae87782b728201af0c42cf83be6
MicroPython_RenameMainDotPy.uf2.zip #
Extract the UF2 file to your computer.
Like the steps described earlier, connect Pico to the computer while pressing the BOOTSEL button. Paste the MicroPython_RenameMainDotPy.uf2 file into Pico. You Pico will reboot after that.
The main.py in Pico will be renamed to main-1.py. The image below shows the renamed main.py file in Thonny IDE’s file explorer.
If the main.py file was causing your Pico to get stuck, this solution will allow you to access Raspberry Pi Pico over the REPL again. But if this method fails, then follow the instructions in Method 3 to erase the flash memory of Pi Pico entirely.
Example of hanging code in main.py
We had reports on our repo that users were having issues with their Pico W locking up: pimoroni/pimoroni-pico#392
I can recreate this issue (using an M1 Macbook Air) with a very simple script:
import time
from machine import Pin
onboard = Pin("LED", Pin.OUT, value=0)
for i in range(0, 40000):
onboard.on()
time.sleep(0.025)
onboard.off()
time.sleep(0.025)
If that is saved as main.py
then when the Pico starts up it will run for perhaps 20-30 iterations of the loop and then lock up hard every single time. Weirdly if I remotely execute the script using the mpremote
tool then it runs flawlessly every time.
- occurs both with the official MicroPython build (currently
rp2-pico-w-20220712-unstable-v1.19.1-127-g74794d42b.uf2
) and also our build (pimoroni-picow-v1.19.2-micropython.uf2
) - definitely happens with MacOS (M1 specifically perhaps? not sure) but we think it may affect other platforms with less consistency
- does not occur on a Pico (sans wireless)
- does not occur if the device is plugged into a microB AC adaptor
I’m pretty sure something is causing the USB stack to fall over on the Pico W which is then causing it to hang completely.