🛠 Boot sur SD, USB, et récupération d'une carte muette
Objectives
Master the end-to-end startup of the Raspberry Pi 2: burn an image, understand the FAT-partition bootloader (bootcode.bin, start.elf, config.txt — no EEPROM as on the Pi 4), know the USB boot limitation depending on the revision (v1.1: SD only; later revisions can boot from USB), and know how to repair a card that no longer boots by editing the boot partition from a PC.
Hardware
- Raspberry Pi 2 Model B (identify the revision engraved on the PCB)
- 8 GB+ microSD card and card reader
- USB flash drive (later revisions only)
- PC with Raspberry Pi Imager (Raspberry Pi OS Legacy/Bullseye 32-bit image)
Complete code
# 1. Graver l'image (cote PC, ou en ligne de commande)
sudo dd if=2024-xx-raspios-bullseye.img of=/dev/sdX bs=4M status=progress conv=fsync
# (le plus simple reste Raspberry Pi Imager, cible : Raspberry Pi OS 32 bits)
# 2. Preparer la carte sans ecran : SSH + Wi-Fi (dongle) via partition boot
sudo mount /dev/sdX1 /mnt/boot
sudo touch /mnt/boot/ssh
printf '[wifi]\ncountry=FR\nssid="Box"\npsk="motdepasse"\n' | sudo tee /mnt/boot/wpa_supplicant.conf
# 3. Diagnostic apres un echec de boot : lire la partition boot depuis un PC
# fichiers cles : bootcode.bin, start.elf, config.txt, cmdline.txt
sudo sed -i 's/ rootwait rw/ rootwait ro/' /mnt/boot/cmdline.txt # lecture seule
# 4. Verifier la chaine d'amorce sur la carte
ls /mnt/boot | grep -E 'bootcode|start|config|cmdline'
Expected verification
A healthy card displays the rainbow screen followed by text boot on HDMI; the green LED blinks irregularly during SD access. In case of a corrupted cmdline.txt, modifying it from the PC (mounting the FAT partition) allows the card to reboot without reburning. On v1.1, a USB drive remains ignored at boot: this is expected.
Common errors
- Red LED off: insufficient or poorly inserted micro-USB power supply; the polyfuse provides protection but does not replace a good 5 V charger.
- Green LED stuck or absent: image burned to the wrong device (incorrect /dev/sdX) or dead microSD card.
- Attempting to boot v1.1 from USB: not available on early versions; treat v1.1 as SD-only.
- Editing cmdline.txt with a line break: this file must remain a single line, otherwise the kernel will not boot.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython