🛠 Remettre une Zero 2 W en état de boot : usbboot et boot files
Objectives
Master the recovery of a card that no longer boots. The Zero 2 W does NOT have an EEPROM: the boot flow reads OTP then “bootcode.bin” on the SD card’s FAT partition. An erroneous config.txt = no image; a corrupted SD card = nothing works. But the Zero line has a way out: without an SD card, it boots in USB device mode and rpiboot then exposes the microSD as mass storage — everything can be repaired from a PC.
Hardware
- 1 Raspberry Pi Zero 2 W (broken or in preparation)
- 1 Linux PC (or Windows with the libusb/WinUSB driver) + micro-USB data cable
- 1 microSD card reader
- The compiled raspberrypi/usbboot project (provides rpiboot)
Complete code
# 1) Récupération via USB device mode (aucune SD dans la Zero 2 W) :
git clone --depth=1 https://github.com/raspberrypi/usbboot
cd usbboot && make
sudo ./rpiboot
# La Zero 2 W (OTGID flottant) énumère 0a5c:2711 et la microSD interne
# apparaît comme un disque de masse sur le PC.
# 2) Réparer le contenu de la partition boot (FAT) :
sudo mkdir -p /mnt/sdboot && sudo mount /dev/sdX1 /mnt/sdboot
ls /mnt/sdboot # bootcode.bin, start.elf, config.txt...
# config.txt douteux ? Restaurer une ligne minimale ou retirer l'overlay fautif :
sudo cp /mnt/sdboot/config.txt /mnt/sdboot/config.txt.bak
sudo sed -i 's/^dtoverlay=pas-bon/# dtoverlay=pas-bon/' /mnt/sdboot/config.txt
# 3) Recopier une image neuve par-dessus la carte (dernier recours) :
sudo dd if=2024-*raspberry-pi-os-lite.img of=/dev/sdX bs=4M status=progress conv=fsync
Expected verification
With “lsusb” you see “0a5c:2711” before rpiboot, then a new disk appears after launching rpiboot: the card’s microSD is accessible. After repairing config.txt and rebooting the card, the activity LED blinks at startup and SSH comes back. Full test: “vcgencmd versioncheck” confirms consistent boot files.
Common errors
- Looking for an EEPROM / network recovery as on Pi 4/5: the Zero 2 W uses the legacy BCM2837 flow — everything happens in the files on the FAT partition.
- Believing under-voltage warnings: the Zero range has no under-voltage detection; “unexplained” corruption often comes from the power supply.
- Editing the wrong partition: only the FAT partition (the smallest one) contains config.txt; the ext4 root partition is invisible under Windows.
- Forgetting the power cable on the POWER port during rpiboot: device mode alone is not enough to power the card.
- Not backing up config.txt before editing: always keep the .bak, the file is small and precious.
Other tutorials for this board
- Premier démarrage de la Zero 2 W sans écran (headless)
- Se connecter au Wi-Fi (et comprendre les limites 2,4 GHz / WPA2)
- Surveiller la température et la fréquence de la Zero 2 W
- GPIO en Python : LED et bouton avec gpiozero
- Le tour de passe-passe « clé USB Linux » : Ethernet sur USB (g_ether)
- Serveur de blocage de pub réseau avec Pi-hole
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash