🛠 Boot sur SD ou USB et procédure de recouvrement
Objectives
Understand the 3B+ boot chain: unlike the Pi 4/5, it has no boot EEPROM — the first stage bootcode.bin is read from the microSD card's boot partition, and the BCM2837B0 ROM can also boot from USB storage and over the network (PXE enabled by default). You will learn how to write an image, switch from SD to USB, and recover a card with a corrupted boot partition.
Hardware
- Raspberry Pi 3 Model B+ type board + 2.5 A power supply
- 1 microSD card (8 GB+) and/or 1 powered USB drive/disk
- Another computer with Raspberry Pi Imager (or Etcher/
dd) - USB card reader for recovery
Complete code
# 1. Ecrire une image (depuis le poste de travail)
imager write --device /dev/sdX raspberry-pi-os-lite.img # ou Imager graphique
# Verifier le device AVANT : lsblk ; dd efface sans prevenir.
# 2. Boot USB : la 3B+ tente le microSD puis le stockage USB.
# Graver la meme image sur la cle ; retirer la carte SD pour forcer l'USB.
# 3. Recouvrement d'une partition boot corrompue :
# - monter la partition FAT sur le poste de secours
sudo mount /dev/sdX1 /mnt
# - restaurer uniquement les fichiers de boot (kernel + bootcode.bin)
sudo cp -n /mnt-recouvre/boot/* /mnt/ 2>/dev/null || true
# - ou réécrire bootcode.bin / start.elf depuis une image propre
sync && sudo umount /mnt
# 4. PXE (boot reseau) : actif par defaut sur 3B+ (ROM BCM2837B0).
# Cote serveur : dnsmasq + TFTP avec les fichiers de boot en racine TFTP.
Expected verification
With the written image, the board boots (activity LED, SSH accessible). Without an SD card but with the written USB drive, it also boots. After recovery, the green LED eventually shows a normal pattern and uname -a responds over SSH. A green LED that is off = no bootcode.bin read; regular blinking = kernel not found.
Common errors
- Writing the image to /dev/sdX1 (partition) instead of the whole disk: the partition table is destroyed.
- Counterfeit or worn-out microSD card: random boot failures, corruption — test with
f3or a new branded card. - Believing there is an EEPROM:
rpiboot/EEPROM recovery does not apply to the 3B+; recovery is done via files on the boot partition. - USB drive drawing too much power: the total budget for the 4 USB ports is 1.2 A; a 2.5" disk without external power causes voltage drops.
- Leaving the old /etc/machine-id duplicated across dozens of cloned images: run
sudo systemd-machine-id-setupafter cloning. - Shutting down during an SD write: corruption most often comes from this — use
sudo poweroff.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython