Adding BPI-R4 support to Guix

my goal is to port guix to the BPI-R4.

i’ll report progress and ask questions here in the comments below.

current status: researching.

1 Like

as a first experiment, i tried to grab a working debian sdcard, and copied the files from a guix aarch64 root fs to the debian root fs.

my plan was to use the kernel on the debian image, and give it the guix initrd.

but i can’t find the initrd… i found the kernel, but not the initrd:

# mkimage -l bpi-r4.itb 
FIT description: U-Boot fitImage for bpi-r4 aarch64 kernel
Created:         Thu May 23 21:27:18 2024
 Image 0 (kernel-1)
  Description:  Linux Kernel 6.9.0-main
  Created:      Thu May 23 21:27:18 2024
  Type:         Kernel Image
[...]

i would appreciate some guidance on what to read and in general a bird’s eye view map of what i’d need to do to boot up a guix this way. this is the first time i’m dealing with uboot, and arm boards in general, but i’m experienced in hacking on the bare metal (well, on decades old hw).

once i can make this working, then i’ll hopefully understand the boot process enough so that i can look into writing up the necessary code in guix to natively generate an install image for the R4.

any help/hints are appreciated.

What kind of initrd do you expect? Kernel can use an external built initrd,but it is not part of it. Why do you need an initrd (rootfs in lvm2 or similar)? When you have rootfs in “normal partition” you normally do not need initrd.

well, it looks like guix unconditionally generates an initrd, and i wrongly assumed that is the general case.

sidenote: guix is written in scheme (a lisp dialect) and even its init process is a scheme program (called Shepherd). the statically linked guile binary that runs shepherd is also in the initrd. i think they simply don’t bother optimizing for the rarely sufficient case of not needing an initrd.

so, i built a generic aarch64 guix install image, and this is the extlinux.conf that was generated in it:

# This file was generated from your Guix configuration.  Any changes
# will be lost upon reconfiguration.
UI menu.c32
MENU TITLE GNU Guix Boot Options
PROMPT 1
TIMEOUT 50
LABEL GNU Guix installation 1.4.0-22.1a34b9b
  MENU LABEL GNU Guix installation 1.4.0-22.1a34b9b
  KERNEL /gnu/store/wnyinfhdhm54jcnc5zavppgg5608rpny-linux-libre-6.9.8/Image
  FDTDIR /gnu/store/wnyinfhdhm54jcnc5zavppgg5608rpny-linux-libre-6.9.8/lib/dtbs
  INITRD /gnu/store/b2lan1n99b88r3paqwjim5anjcqlxhz0-raw-initrd/initrd.cpio.gz
  APPEND root=416bf41b-f6b1-2062-9d36-dd7c416bf41b gnu.system=/gnu/store/3cbxqrbifhs4k50600ar12azzg4hlkng-system gnu.load=/gnu/store/3cbxqrbifhs4k50600ar12azzg4hlkng-system/boot quiet modprobe.blacklist=radeon,amdgpu

now that i’m aware that i shouldn’t be looking for an initrd, next time i’ll have some hacking time i’ll try to add this^ initrd into the bpi-r4.itb, and try to boot the BPI-R4 kernel with the guix initrd… which contains kernel modules, so i have little hope that it’ll fully boot guix, but it’s a good first step.

if that indeed fails, then i’ll try to find an upstream kernel version that both contains the R4 commits, and is already included in guix. i think there exists already such version. if i cannot find one, then i’ll add the R4 kernel repo as a guix package and try to build and package it through the guix build infrastructure, which will be a more adventurous path.

FTR, the initrd chapter in the guix manual: GNU Guix Reference Manual

If you want to have it in itb i have prepared initrd section in the its file…

@frank-w, i’ve read a lot of the forum yesterday, but it is not clear to me:

should the v6.10 mainline kernel be usable/bootable on the R4? or only the 6.10-main branch in your repo?

Only my repo…mainline linux miss many patches yet.

But i’ve noticed an issue with usb/xhci in 6.10 where i do not know rootcause yet. Did not see this with 6.9.