Subject: [bug#44543] [PATCH] gnu: raspberry-pi: Add helpers for config.txt file generation.

From: Léo Le Bouter <[email-masked]>
Date: Sat, 27 Mar 2021 20:51:10 +0100

On Sat, 2021-03-27 at 20:43 +0100, Stefan wrote:
> Hi Léo!
> 
> > I have a Raspberry Pi 3B+ here at home, how can I test these
> > changes?
> > 
> > I don't feel capable to review this without testing something as a
> > whole verifying that it works then inspecting these things that
> > make it
> > work.
> 
> The support for the Raspberry is still not complete. I’m using mine
> without an SD card, booting it over TFTP with an NFS root mount.
> 
> Installing on an SD card is not tested and certainly not working yet.
> 
> One of my next patches will be several u-boot packages for different
> Raspberry models. To build them I need to do changes to the defconfig
> file of u-boot. Therefore another ticket is pending, which eases
> defconfig modifications (<http://issues.guix.gnu.org/45046>;, and I
> hope this can also be used to modify Linux). When that one is done,
> then I will send that next patch to add the u-boot packages. 
> 
> My bootloader currently looks like this, but I’m using already
> further modifications, mainly for GRUB, so this will not work for
> you, but you can get an impression of the final intended use of all
> patches:
> 
>   (bootloader
>     (bootloader-configuration
>       (target "/boot")
>       (bootloader (efi-bootloader-chain
>                    grub-efi-netboot-removable-bootloader
>                    ;; Packages needed to boot the Raspberry.
>                    #:packages (list raspberrypi-firmware 
>                                     u-boot-rpi-efi-64)
>                    ;; Additional files for configuration.
>                    #:files (list ;; Detects 32 or 64 bit, includes
> other txt files.
>                                  raspi-config-txt
>                                  ;; Use the downstream device tree
> (upstream is bcm28).
>                                  raspi-bcm27-dtb-txt
>                                  ;; This is the next boot stage.
>                                  raspi-u-boot-bootloader-txt 
>                                  ;; Additional configurations to use.
>                                  (raspi-custom-txt
> '("disable_overscan=1"
>                                                      "hdmi_force_hotp
> lug=1"
>                                                      "audio=on"
>                                                      "dtoverlay=gpio-
> ir"
>                                                      "dtoverlay=disab
> le-wifi"
>                                                      "dtoverlay=vc4-
> fkms-v3d,cma-64")))))))
> 
> Your bootloader configuration would need to look like this, and you
> may get it running from an SD card:
> 
>   (bootloader
>     (bootloader-configuration
>       (target "/boot")
>       (bootloader
>         (efi-bootloader-chain
>           (list (file-append firmware "/boot/")
>                 (file-append u-boot-my-scb "/libexec/u-boot.bin")
>                 raspi-config-txt
>                 raspi-bcm27-dtb-txt
>                 raspi-u-boot-bootloader-txt)
>           grub-efi-netboot-bootloader
>           #:installer
>            (chain-efi-bootloader-installer (install-grub-efi-netboot
> "efi/boot")))))
> 
> So you need to provide firmware and u-boot (still) yourself. As a
> short cut you may omit both (file-append …) functions and copy both
> parts by hand from some other distribution, maybe openSUSE – this is
> basically how I got started.
> 
> If you mount an ext4-partition of an SD card to e.g. /my-target/ and
> the FAT partition to /my-target/boot, then you may try a ‘guix system
> init … /my-target’.
> 
> If this succeeds, then it may be possible that adding the file /my-
> target/boot/efi/boot/grub.cfg with this content gets you to a system
> booting from an SD card:
> 
> search --file /boot/grub/grub.cfg
> configfile /boot/grub/grub.cfg
> 
> But this is all untested, it certainly fails. :-)
> 
> At least – regarding this patch – I can ensure that the three config
> files as used in these bootloader examples are properly generated
> working.
>  
> 
> Bye
> 
> Stefan

Thanks for all your work!

I would prefer if you opened one single bug with all the changes so I
can test the whole thing, right now I don't feel at ease reviewing
things like this. How can I be sure what you are submitting is the
right abstraction for your future work? Are you sure that abstraction
will be right for your future patches? If anything needs to be changed
I feel like one big patchset about Raspberry Pi 3B+ support will be
easier to review (at least for me).

Léo