diff --git a/doc/guix.texi b/doc/guix.texi index e81dcdb695..005455edba 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -42251,6 +42251,12 @@ modules. In particular, @code{(gnu bootloader u-boot)} contains definitions of bootloaders for a wide range of ARM and AArch64 systems, using the @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}. +@itemize +@vindex depthcharge-veyron-speedy-bootloader +@item @code{depthcharge-veyron-speedy-bootloader} +For the Asus C201. Requires a @code{'part} target, denoting the partition to +install the kernel blob as a @code{device}, @code{label}, or @code{uuid}. + @vindex grub-bootloader @code{grub-bootloader} allows you to boot in particular Intel-based machines in ``legacy'' BIOS mode. diff --git a/gnu/bootloader/depthcharge.scm b/gnu/bootloader/depthcharge.scm index 0a50374bd9..b727874a40 100644 --- a/gnu/bootloader/depthcharge.scm +++ b/gnu/bootloader/depthcharge.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Timothy Sample +;;; Copyright © 2024 Lilah Tascheter ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,92 +18,87 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu bootloader depthcharge) - #:use-module (gnu bootloader extlinux) #:use-module (gnu bootloader) #:use-module (gnu packages bootloaders) + #:use-module (gnu system boot) #:use-module (guix gexp) + #:use-module (guix deprecation) + #:use-module (guix diagnostics) + #:use-module (guix i18n) + #:use-module (guix records) #:use-module (guix utils) - #:use-module (ice-9 match) - #:export (depthcharge-bootloader)) + #:use-module (srfi srfi-26) + #:use-module (srfi srfi-35) + #:export (depthcharge-veyron-speedy-bootloader + depthcharge-bootloader)) -(define (signed-kernel kernel kernel-arguments initrd) - (define builder - (with-imported-modules '((guix build utils)) - #~(begin - (use-modules (guix build utils) - (ice-9 binary-ports) - (rnrs bytevectors)) - (set-path-environment-variable "PATH" '("bin") (list #$dtc)) +(define* (install-depthcharge arch dtb + #:key bootloader-config current-boot-alternative + #:allow-other-keys) + (when (not (null? (bootloader-configuration-menu-entries bootloader-config))) + (raise (formatted-message + (G_ "extra menu-entries are not supported for depthcharge!")))) + (with-targets (bootloader-configuration-targets bootloader-config) + ;; use 'part instead of 'disk, cause we write an image directly into a + ;; partition instead of the extra-partition disk space + (('part => (disk :device)) + (match-menu-entry + (boot-alternative->menu-entry current-boot-alternative) + (linux linux-arguments initrd) + #~(begin + (use-modules (ice-9 binary-ports) (rnrs bytevectors)) + (set-path-environment-variable "PATH" '("bin") (list #$dtc)) - ;; TODO: These files have to be writable, so we copy them. - ;; This can probably be fixed by using a ".its" file, just - ;; be careful not to break initrd loading. - (copy-file #$kernel "zImage") - (chmod "zImage" #o755) - (copy-file (string-append (dirname #$kernel) "/lib/dtbs/" - "rk3288-veyron-speedy.dtb") - "rk3288-veyron-speedy.dtb") - (chmod "rk3288-veyron-speedy.dtb" #o644) - (copy-file #$initrd "initrd") - (chmod "initrd" #o644) + ;; TODO: These files have to be writable, so we copy them. + ;; This can probably be fixed by using a ".its" file, just + ;; be careful not to break initrd loading. + (copy-file #$linux "zImage") + (chmod "zImage" #o755) + (copy-file (string-append (dirname #$linux) "/lib/dtbs/" #$dtb) + "dtb") + (chmod "dtb" #o644) + (copy-file #$initrd "initrd") + (chmod "initrd" #o644) - (invoke (string-append #$u-boot-tools "/bin/mkimage") - "-D" "-I dts -O dtb -p 2048" - "-f" "auto" - "-A" "arm" - "-O" "linux" - "-T" "kernel" - "-C" "None" - "-d" "zImage" - "-a" "0" - "-b" "rk3288-veyron-speedy.dtb" - "-i" "initrd" - "image.itb") - (call-with-output-file "bootloader.bin" - (lambda (port) - (put-bytevector port (make-bytevector 512 0)))) - (with-output-to-file "kernel-arguments" - (lambda () - (display (string-join (list #$@kernel-arguments))))) - (invoke (string-append #$vboot-utils "/bin/vbutil_kernel") - "--pack" #$output - "--version" "1" - "--vmlinuz" "image.itb" - "--arch" "arm" - "--keyblock" (string-append #$vboot-utils - "/share/vboot-utils/devkeys/" - "kernel.keyblock") - "--signprivate" (string-append #$vboot-utils - "/share/vboot-utils/devkeys/" - "kernel_data_key.vbprivk") - "--config" "kernel-arguments" - "--bootloader" "bootloader.bin")))) - (computed-file "vmlinux.kpart" builder)) + (invoke #+(file-append u-boot-tools "/bin/mkimage") + "-D" "-I dts -O dtb -p 2048" + "-f" "auto" ; format + "-A" #$arch ; architecture + "-O" "linux" ; os + "-T" "kernel" ; image type + "-C" "None" ; compression + "-d" "zImage" ; image data + "-a" "0" ; load address (hex) + "-b" "dtb" ; dtb for device + "-i" "initrd" ; initrd + "image.itb") + (call-with-output-file "bootloader.bin" + (lambda (port) + (put-bytevector port (make-bytevector 512 0)))) + (call-with-output-file "kernel-arguments" + (lambda (port) + (display (string-join (list #$@linux-arguments)) port))) + (invoke #+(file-append vboot-utils "/bin/vbutil_kernel") + "--version" "1" + "--vmlinuz" "image.itb" + "--arch" #$arch + "--keyblock" + #$(file-append vboot-utils + "/share/vboot-utils/devkeys/kernel.keyblock") + "--signprivate" + #$(file-append vboot-utils + "/share/vboot-utils/devkeys/kernel_data_key.vbprivk") + "--config" "kernel-arguments" + "--pack" "vmlinux.kpart") + (write-file-on-device "vmlinux.kpart" + (stat:size (stat "vmlinux.kpart")) + #$disk 0)))))) -(define* (depthcharge-configuration-file config entries - #:key - (system (%current-system)) - (old-entries '()) - #:allow-other-keys) - (match entries - ((entry) - (let ((kernel (menu-entry-linux entry)) - (kernel-arguments (menu-entry-linux-arguments entry)) - (initrd (menu-entry-initrd entry))) - ;; XXX: Make this a symlink. - (signed-kernel kernel kernel-arguments initrd))) - (_ (error "Too many bootloader menu entries!")))) - -(define install-depthcharge - #~(lambda (bootloader device mount-point) - (let ((kpart (string-append mount-point - "/boot/depthcharge/vmlinux.kpart"))) - (write-file-on-device kpart (stat:size (stat kpart)) device 0)))) - -(define depthcharge-bootloader +(define depthcharge-veyron-speedy-bootloader (bootloader (name 'depthcharge) - (package #f) - (installer install-depthcharge) - (configuration-file "/boot/depthcharge/vmlinux.kpart") - (configuration-file-generator depthcharge-configuration-file))) + (installer (cute install-depthcharge "arm" "rk3288-veyron-speedy.dtb" + <...>)))) + +(define-deprecated/alias depthcharge-bootloader + depthcharge-veyron-speedy-bootloader)