🛠 Boot UF2, mode BOOTSEL et recovery d'une carte briquée
Objectives
Understand the RP2350 boot chain: the USB boot code resides in ROM and cannot be overwritten — making a Pico 2 nearly impossible to permanently brick. You will learn about BOOTSEL mode, the UF2 format, the picotool/MSD tools, and how to recover a card that no longer boots (bad firmware, RP2040 binary, misconfigured secure boot).
Hardware
- 1 × Raspberry Pi Pico 2 (optionally "bricked" on purpose)
- Micro-USB data cable; picotool (host build from the SDK or GitHub release)
- Optional: SWD debugger (CMSIS-DAP / pico-probe) for debugging without using the button
Full Code
/* saut_vers_bootsel.c — depuis le programme, retourne au mode UF2
Utile pour un produit : mise a jour sans ouvrir le boitier. */
#include "pico/stdlib.h"
#include "pico/bootrom.h"
#define BTN_PIN 22
int main(void) {
gpio_init(BTN_PIN); gpio_set_dir(BTN_PIN, GPIO_IN); gpio_pull_up(BTN_PIN);
stdio_init_all;
sleep_ms(2000); /* fenetre pour ouvrir le terminal */
printf("Appui long sur GP22 -> mode BOOTSEL (lecteur RPI-RP2)\n");
while (gpio_get(BTN_PIN)) sleep_ms(10);
rom_reset_to_bootsel; /* ne revient jamais */
}
Recovery procedure without code: 1) Hold BOOTSEL and plug in USB; 2) The RPI-RP2 drive appears (the ROM always responds); 3) Copy a valid UF2 (pico2!) to overwrite the flash; 4) The card restarts. Inventory: picotool info -a and picotool reboot -u (USB reboot) from any UF2 firmware.
Expected Verification
Regardless of what garbage is flashed (RP2040 binary, looping program, saturated RAM), holding BOOTSEL while plugging in makes the RPI-RP2 drive reappear, and a valid pico2 UF2 restores the card. picotool info displays the Pico 2 (RP2350) in USB boot mode.
Common Errors
- Believing the card is dead: if BOOTSEL produces the drive, the ROM is healthy — it is structurally impossible to brick via software (except for OTP).
- Copying a UF2 compiled for pico (RP2040): the card restarts into a void; redo BOOTSEL then flash a real pico2 build.
- Charge-only cable or finicky hub: the drive never appears, test another port/cable first.
- On Linux, forgetting udev permissions or using
picotool loadwithout an appropriate--boot2when flashing raw binaries via SWD. - Secure boot accidentally enabled in OTP: only a correctly signed firmware will restart — document your keys, OTP is irreversible.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-interruption.pyPythonpwm-servo.pyPythonlecture-adc.pyPythonneopixel.pyPythonoled-i2c.pyPython