Files
guix-router/rpi4-image.scm
ssmithxandClaude Opus 5.5 20e0322b13 Phase 2: WISP router (WiFi WAN, bridged Ethernet LAN)
wlan0 joins upstream WiFi via wpa_supplicant (credentials on the FAT
partition, outside git and the store) + dhcpcd; eth0 in br-lan at
192.168.10.1/24 with dnsmasq; nftables masquerade; ip_forward.  SSH key
auth for root.  Work around dnsmasq not cross-building in guix 1.5.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 12:14:24 -04:00

72 lines
2.5 KiB
Scheme

;; Flashable SD-card image for the Raspberry Pi 4B router testbed.
;;
;; p1 FAT32 "RPI-BOOT" start4.elf, fixups, config.txt, u-boot.bin, DTB,
;; upstream overlays (read by the Pi firmware),
;; wpa_supplicant.conf(.example) for the WAN WiFi
;; p2 ext4 "Guix" the system, with /boot/extlinux/extlinux.conf
;;
;; Build: ./build-rpi-image.sh (guix system image rpi4-image.scm)
;; The image platform is aarch64, so Guix cross-builds from x86_64.
(use-modules (gnu image)
(gnu system image)
(guix gexp)
(guix platforms arm)
(rpi-boot-firmware)
(u-boot-rpi-arm64-guix-router))
;; Evaluates rpi4.scm in this module, defining %rpi4-os.
(primitive-load (string-append (or (and=> (current-filename) dirname) ".")
"/rpi4.scm"))
(define MiB (expt 2 20))
(define GiB (expt 2 30))
(define %rpi4-config.txt
(plain-file "config.txt" "\
# Generated by rpi4-image.scm.
arm_64bit=1
enable_uart=1
# Mainline device tree + firmware's upstream overlay.
upstream_kernel=1
kernel=u-boot.bin
"))
(define rpi4-boot-partition
(partition
(size (* 256 MiB))
(offset (* 4 MiB))
(label "RPI-BOOT")
(file-system "fat32")
(initializer
#~(lambda* (root #:key #:allow-other-keys)
(mkdir-p root)
(copy-recursively #+rpi-boot-firmware root)
(copy-file #+(file-append u-boot-rpi-arm64-guix-router
"/libexec/u-boot.bin")
(string-append root "/u-boot.bin"))
;; Same DTB the kernel ships; U-Boot and Linux both use it.
(copy-file #$(file-append (operating-system-kernel %rpi4-os)
"/lib/dtbs/broadcom/bcm2711-rpi-4-b.dtb")
(string-append root "/bcm2711-rpi-4-b.dtb"))
(copy-file #+%rpi4-config.txt
(string-append root "/config.txt"))
;; Template for the WAN WiFi credentials; copy to
;; wpa_supplicant.conf after flashing (see rpi4.scm).
(copy-file #+(local-file "files/wpa_supplicant.conf.example")
(string-append root "/wpa_supplicant.conf.example"))))))
(define rpi4-root-partition
(partition
(inherit root-partition)
(label "Guix")
(size (* 6 GiB))))
(image
(name 'guix-rpi4)
(format 'disk-image)
(partition-table-type 'mbr)
(platform aarch64-linux)
(operating-system %rpi4-os)
(partitions (list rpi4-boot-partition rpi4-root-partition)))