🛠 Boot sur SD/USB et procédure de recouvrement
Objectives
Understand the boot chain of the Raspberry Pi 3 Model B (SoC ROM → files on FAT partition → Linux kernel), boot from a USB mass storage device, and know how to restore a card after a corrupted image. Specificity of the 3B: no updatable boot EEPROM (unlike the 3B+/4); USB boot exists but booting from host is disabled by default and enabled by a permanent OTP bit.
Hardware
- Raspberry Pi 3 Model B
- Healthy microSD card (for booting and troubleshooting)
- Powered USB 2.0 drive/disk if possible
- Card reader + Raspberry Pi Imager on a computer
- Ethernet cable + another machine for emergency SSH
Complete code
# 1) Démarrer sur SD, puis activer le boot USB (OTP PERMANENT, irréversible)
echo 'program_usb_boot_mode=1' | sudo tee -a /boot/firmware/config.txt
sudo reboot
sudo vcgencmd otp_dump | grep 17: # doit afficher 17:3020000a
# Penser à retirer la ligne de config.txt après le redémarrage.
# 2) Copier le contenu de la SD vers le disque USB
sudo apt install -y rsync
sudo rsync -aax --exclude '/dev' --exclude '/proc' --exclude '/sys' \
/media/$USER/rootfs/ /media/$USER/usbdrive/
# Adapter /etc/fstab du disque (root=PARTUUID...) puis éteindre proprement.
# 3) Tester sans SD : le Pi doit booter sur l'USB.
# 4) Recouvrement : carte SD illisible ou config.txt cassée
# a) dépannage léger : monter la partition FAT sur le PC, éditer config.txt,
# retirer dtoverlay/over_voltage suspects, rajouter « initramfs » si besoin
# b) solution radicale : réécrire Raspberry Pi OS avec Imager,
# puis restaurer la partition home depuis une sauvegarde.
Expected verification
After enabling OTP, vcgencmd otp_dump | grep 17: returns 17:3020000a and the Pi boots from USB without any SD card inserted. The disk activity LED blinks during boot. In case of a deliberately broken config.txt (bad dtoverlay), mounting the FAT partition from a computer allows you to fix the file and reboot normally — the Pi comes back to life without rewriting.
Common errors
- Ignoring the "permanent OTP" warning: once written, the bit cannot be removed; SD boot remains possible but the option is permanently enabled.
- Forgetting to remove
program_usb_boot_mode=1from config.txt: unnecessary in the long term. - USB disk drawing too much power from the single port: brownouts and random boot failures; prefer a powered disk.
fstabnot adapted after rsync: the kernel panics with "unable to mount root fs"; check thePARTUUIDwithblkid.- Confusing it with the 3B+/4: those have a boot EEPROM, the
rpiboot/recovery procedures do not apply to the 3B. - Corrupting the SD card with hard power cuts: shut down with
sudo poweroffand back up your data.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython