DEV Community

l5y
l5y

Posted on

Enabling SPI on Arch Linux ARM (Raspberry Pi 4, aarch64)

You add dtparam=spi=on to /boot/config.txt, reboot, and... there's no /dev/spidev*. On the AArch64 Arch Linux ARM image this is expected, and the fix isn't more config.txt tweaking. Here's the clean way.

TL;DR

The AArch64 ALARM image boots the mainline kernel via U-Boot, which ignores config.txt. Switch to the Foundation kernel (linux-rpi) and SPI + overlays work natively. One board-specific trap to watch: the shipped cmdline.txt has the wrong root=.

ℹ️ Tested on: Raspberry Pi 4B, Arch Linux ARM aarch64, /boot on a separate FAT partition.

Why dtparam=spi=on does nothing

The GPU firmware reads config.txt and patches its own device tree, but U-Boot then loads a different mainline DTB from /boot/dtbs and boots that, throwing the firmware's edit away. Forcing the firmware DTB doesn't help either: the mainline spidev driver won't bind to its compatible = "spidev" nodes.

The Foundation kernel sidesteps all of it: the firmware boots it directly and applies config.txt + overlays the way every Pi guide assumes.

⚠️ This swaps your kernel and removes U-Boot. Keep a serial/HDMI console or SD-card access handy in case of a bad boot.

0. Prep

# Note your real root partition, you'll need this exact value in step 2.
cat /proc/cmdline                       # grab the root=PARTUUID=... part
lsblk -o NAME,PARTUUID,MOUNTPOINT

# Back up /boot and cache the current packages for rollback.
sudo tar czf /root/boot-backup.tar.gz -C /boot .
sudo pacman -Sw linux-aarch64 uboot-raspberrypi
Enter fullscreen mode Exit fullscreen mode

1. Install the Foundation kernel

sudo pacman -S linux-rpi
Enter fullscreen mode Exit fullscreen mode

It conflicts with uboot-raspberrypi and linux-aarch64 and removes both, that's expected. It drops in the Foundation kernel as /boot/kernel8.img, ~360 overlays, and fresh config.txt / cmdline.txt.

2. Fix cmdline.txt, the one guaranteed gotcha

The shipped /boot/cmdline.txt hardcodes root=/dev/mmcblk0p2. If your card enumerates differently (mine is mmcblk1), that's an instant no-boot. Replace the root= with your value from step 0:

# /boot/cmdline.txt  (single line)
root=PARTUUID=xxxxxxxx-02 rw rootwait fsck.repair=yes console=serial0,115200 console=tty1
Enter fullscreen mode Exit fullscreen mode

Use blkid to determine UUID.

3. Re-enable SPI in config.txt

The new config.txt ships with SPI commented out. Add:

# /boot/config.txt
enable_uart=1
dtparam=spi=on
Enter fullscreen mode Exit fullscreen mode

4. Sanity-check before rebooting

Can't hurt to run mkinitcpio -p linux-rpi again.

ls -l /boot/kernel8.img            # multi-MB = Foundation kernel (U-Boot was ~700 KB)
grep root= /boot/cmdline.txt       # YOUR PARTUUID, not mmcblk0p2
grep -E 'spi|initramfs' /boot/config.txt
ls -l /boot/initramfs-linux.img    # freshly rebuilt
ls /lib/modules/                   # e.g. 6.x-rpi
Enter fullscreen mode Exit fullscreen mode

5. Reboot & verify

sudo reboot
# once it's back:
uname -r                           # ...-rpi
ls -l /dev/spidev*                 # spidev0.0  spidev0.1
Enter fullscreen mode Exit fullscreen mode

6. Optional: use SPI without root

# /etc/udev/rules.d/99-spi.rules
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
Enter fullscreen mode Exit fullscreen mode
sudo groupadd -f spi && sudo usermod -aG spi "$USER"   # re-login to apply
Enter fullscreen mode Exit fullscreen mode

Quick loopback test: jumper pin 19 ↔ pin 21 (MOSI↔MISO) and run spidev_test, TX should equal RX.

SPI0 pinout (40-pin header)

Signal BCM Pin
MOSI GPIO10 19
MISO GPIO9 21
SCLK GPIO11 23
CE0 GPIO8 24 → spidev0.0
CE1 GPIO7 26 → spidev0.1

Rollback

If it won't boot: pull the SD card, restore /boot from boot-backup.tar.gz, and reinstall linux-aarch64 + uboot-raspberrypi from the pacman cache.

Bonus: now that the firmware honors config.txt, other peripherals are one line away too, dtparam=i2c_arm=on for I2C, or any overlay in /boot/overlays via dtoverlay=.... No device-tree surgery required.

Top comments (0)