🛠 Boot UF2, BOOTSEL et récupération d'une carte « briquée »

Raspberry Pi Pico · avance · Schéma : IMG-pico-avance-2-pico-boot-uf2-recovery.svg — cycle de boot du RP2040 : broche BOOTSEL, bootrom en ROM, choix flash QSPI externe ou USB, lecteur RPI-RP2 et fichier uf2 déposé

Objectives

Understand the atypical boot chain of the RP2040 — no internal flash: after reset, the bootrom (in ROM, uncopyable) loads the firmware either from the external 2 MB QSPI flash (XIP) or via USB if the BOOTSEL pin is held. You will learn how to enter BOOTSEL mode, understand the UF2 format (a "sparse" image in 256-byte blocks), and recover a board whose program crashes immediately at startup — the RP2040 cannot be bricked by software via this path.

Hardware

Complete Code

// canary.c — programme volontairement « méchant » à récupérer
// Écrase le vecteur de reset : au prochain boot, plus rien ne démarre
// (sauf BOOTSEL, qui court-circuite la flash !)
#include "pico/stdlib.h"

int main(void) {
    // efface la table des vecteurs en tête de flash (zone 0x10000000)
    flash_range_erase(0, 4096);
    uint32_t junk[64];
    for (int i = 0; i < 64; i++) junk[i] = 0xDEADBEEF;
    flash_range_program(0, (const uint8_t *)junk, 256);
    while (true) { }   // le prochain reset partira dans le vide
}
// Rebuild avec pico_stdlib + hardware/flash, flash, laisse le programme
// tourner une fois, reset : la carte est « morte »… jusqu'au BOOTSEL.

Expected Verification

After running the canary and resetting, the board no longer responds (no REPL, no blink). Hold BOOTSEL and reconnect: the RPI-RP2 drive always reappears — the bootrom is intact. Drop a healthy .uf2 file: the board comes back to life. Note: a misaligned UF2 may be written erratically (RP2040 datasheet errata E14); if the flash appears random, retry with a UF2 generated by the SDK.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials