<!--order=2-->


<h1>Getting Started with Raspberry Pi 5 on Debian</h1>
<p>The Raspberry Pi 5 is a genuine leap over the Pi 4 — faster CPU, PCIe, a real power button, and an RTC header. Running it on Raspberry Pi OS (Debian Bookworm underneath) is the path of least resistance. This covers initial setup, what's different from older Pi's, and the gotchas worth knowing before you sink time into a project.</p>

<h2>What's New in the Pi 5</h2>

<table>
  <thead><tr><th>Feature</th><th>Pi 4</th><th>Pi 5</th><th>Notes</th></tr></thead>
  <tbody>
    <tr><td>CPU</td><td>Cortex-A72, 4-core 1.8GHz</td><td>Cortex-A76, 4-core 2.4GHz</td><td>Roughly 2–3× faster in practice</td></tr>
    <tr><td>PCIe</td><td>None (USB 3 only)</td><td>PCIe 2.0 x1 via M.2 HAT</td><td>NVMe SSDs, proper disk I/O</td></tr>
    <tr><td>Power</td><td>USB-C, no button</td><td>USB-C 5A, physical power button</td><td>Needs 5V/5A supply; 5V/3A works at reduced speed</td></tr>
    <tr><td>RTC</td><td>No</td><td>Yes (with backup battery connector)</td><td>Keeps time without NTP if you add the coin cell</td></tr>
    <tr><td>PMIC</td><td>Separate from SoC</td><td>Integrated RP1 I/O chip</td><td>GPIO is now via RP1, not directly SoC</td></tr>
    <tr><td>Active cooling</td><td>Optional</td><td>Required for sustained load</td><td>The official active cooler fits the mounting holes</td></tr>
  </tbody>
</table>

<h2>Flashing the SD Card</h2>
<pre>
# Use Raspberry Pi Imager (easiest — can pre-configure SSH, hostname, wifi)
# https://www.raspberrypi.com/software/

# Or flash manually with rpi-imager CLI / dd:
$ xzcat 2024-11-19-raspios-bookworm-arm64.img.xz | dd of=/dev/sdX bs=4M status=progress

# After flashing, the boot partition is FAT32 — mountable on any OS.
# For headless setup, create an empty file called 'ssh' on the boot partition:
$ touch /mnt/boot/ssh

# For wifi, create wpa_supplicant.conf on the boot partition.
# On Bookworm this moved to /etc/NetworkManager/ — use Imager instead.
</pre>
<p>Raspberry Pi Imager's "advanced options" (gear icon) lets you set hostname, SSH key, and wifi before writing the image — this is the smoothest headless path and avoids touching config files on the boot partition.</p>

<h2>First Boot</h2>
<pre>
# Find the Pi on your network
$ nmap -sn 192.168.1.0/24 | grep -i raspberry
# Or check your router's DHCP table

# SSH in (default user is now 'pi' only if you set it in Imager)
$ ssh pi@raspberrypi.local     # mDNS works on most networks
$ ssh pi@192.168.1.xxx         # or use the IP directly

# Update immediately — Bookworm ships with older package snapshots
$ sudo apt update && sudo apt full-upgrade -y
$ sudo reboot
</pre>

<h2>raspi-config</h2>
<pre>
$ sudo raspi-config
</pre>

<table>
  <thead><tr><th>Section</th><th>What to set</th></tr></thead>
  <tbody>
    <tr><td>System Options → Hostname</td><td>Something meaningful — you'll have multiple Pi's</td></tr>
    <tr><td>Interface Options → SSH</td><td>Enable if not done at imaging time</td></tr>
    <tr><td>Interface Options → I2C / SPI</td><td>Enable what your HATs need</td></tr>
    <tr><td>Interface Options → Serial Port</td><td>Enable hardware UART, disable login shell on serial</td></tr>
    <tr><td>Performance Options → GPU Memory</td><td>Set to 16MB for headless (saves RAM)</td></tr>
    <tr><td>Localisation → Timezone</td><td>Set correctly — matters for logs and the RTC</td></tr>
  </tbody>
</table>

<h2>Power Supply</h2>
<p>The Pi 5 is fussier about power than older models. The official 27W USB-C supply (5V/5A) is the only one that fully satisfies it. A 5V/3A supply works but triggers an undervoltage warning in <code>dmesg</code> and throttles the CPU under load. Check with:</p>
<pre>
$ vcgencmd get_throttled
# 0x0 = all good
# 0x50000 = throttled (under-voltage has occurred)
# 0x50005 = currently throttled

$ vcgencmd measure_temp
# Keep it below 80°C under sustained load
# The active cooler holds it around 50-60°C typically
</pre>

<h2>GPIO Differences</h2>
<p>On Pi 5, GPIO is handled by the RP1 I/O controller chip rather than directly by the SoC. The 40-pin header pinout is identical to previous Pi's, but the underlying driver changed. Libraries that speak directly to BCM registers (like some older versions of RPi.GPIO) don't work. Use the updated libraries:</p>
<pre>
# RPi.GPIO — older, works via the new kernel driver on Pi 5 with recent updates
$ pip3 install RPi.GPIO

# gpiozero — higher-level, recommended for most uses
$ pip3 install gpiozero

# lgpio — the new recommended low-level library for Pi 5
$ pip3 install lgpio

# Test GPIO is working (LED on GPIO 17):
$ python3 -c "
from gpiozero import LED
from time import sleep
led = LED(17)
led.on(); sleep(1); led.off()
"
</pre>

<h2>NVMe via M.2 HAT</h2>
<p>The Pi 5's PCIe slot makes NVMe SSDs viable as the primary disk for the first time. The official M.2 HAT+ mounts under the Pi and connects to the PCIe FPC connector:</p>
<pre>
# After fitting the HAT and NVMe drive, check it's visible:
$ lspci
# Should show something like: 01:00.0 Non-Volatile memory controller: ...

$ ls /dev/nvme*
# /dev/nvme0  /dev/nvme0n1

# Enable PCIe Gen 3 (faster, but official rating is Gen 2 — test stability):
# In /boot/firmware/config.txt:
dtparam=pciex1_gen=3

# To boot from NVMe, flash the NVMe with the OS image and set boot order:
$ sudo raspi-config → Advanced Options → Boot Order → NVMe/USB Boot
</pre>

<h2>References</h2>
<ul>
  <li><a href="https://www.raspberrypi.com/documentation/computers/raspberry-pi-5.html" target="_blank" rel="noopener">Raspberry Pi 5 Documentation ↗</a></li>
  <li><a href="https://gpiozero.readthedocs.io/" target="_blank" rel="noopener">gpiozero documentation ↗</a></li>
  <li><a href="https://www.raspberrypi.com/products/raspberry-pi-5/" target="_blank" rel="noopener">Pi 5 product page ↗</a></li>
</ul>
