bootloader: u-boot: Add procedure to share installer code.

* gnu/bootloader/u-boot.scm (make-u-boot-installer): Add procedure.
(install-u-boot-ts7970-q-2g-1000mhz-c-u-boot,
install-qemu-riscv64-u-boot): Remove variables.
(install-starfive-visionfive2-uEnv.txt,
u-boot-ts7970-q-2g-1000mhz-c-bootloader,
u-boot-qemu-riscv64-bootloader): Use make-u-boot-installer.

Change-Id: I0b0b507925a7c8ca608f7307d442d9588862ae91
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Herman Rimm 2024-10-31 22:15:50 +01:00 committed by Ludovic Courtès
parent ca748392ce
commit 2348283dab
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -5,7 +5,7 @@
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023 Herman Rimm <herman_rimm@protonmail.com> ;;; Copyright © 2023-2024 Herman Rimm <herman@rimm.ee>
;;; Copyright © 2024 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@ -28,6 +28,7 @@
#:use-module (gnu bootloader) #:use-module (gnu bootloader)
#:use-module (gnu packages bootloaders) #:use-module (gnu packages bootloaders)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (ice-9 match)
#:export (u-boot-bootloader #:export (u-boot-bootloader
u-boot-a20-olinuxino-lime-bootloader u-boot-a20-olinuxino-lime-bootloader
u-boot-a20-olinuxino-lime2-bootloader u-boot-a20-olinuxino-lime2-bootloader
@ -53,6 +54,18 @@
u-boot-ts7970-q-2g-1000mhz-c-bootloader u-boot-ts7970-q-2g-1000mhz-c-bootloader
u-boot-wandboard-bootloader)) u-boot-wandboard-bootloader))
(define (make-u-boot-installer file)
(let ((file
(match file
((? string?)
(list #~(install-file (string-append bootloader #$file)
install-dir)))
((? file-like?) (list #~(install-file #$file install-dir)))
(#f '()))))
#~(lambda (bootloader device mount-point)
(let ((install-dir (string-append mount-point "/boot")))
#$@file))))
(define install-u-boot (define install-u-boot
#~(lambda (bootloader root-index image) #~(lambda (bootloader root-index image)
(if bootloader (if bootloader
@ -145,12 +158,6 @@
(define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot) (define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
(define install-u-boot-ts7970-q-2g-1000mhz-c-u-boot
#~(lambda (bootloader device mount-point)
(let ((u-boot.imx (string-append bootloader "/libexec/u-boot.imx"))
(install-dir (string-append mount-point "/boot")))
(install-file u-boot.imx install-dir))))
(define install-sifive-unmatched-u-boot (define install-sifive-unmatched-u-boot
#~(lambda (bootloader root-index image) #~(lambda (bootloader root-index image)
(let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin")) (let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin"))
@ -171,24 +178,14 @@
image (* 2082 512))))) image (* 2082 512)))))
(define install-starfive-visionfive2-uEnv.txt (define install-starfive-visionfive2-uEnv.txt
#~(lambda (bootloader device mount-point) (make-u-boot-installer
(mkdir-p (string-append mount-point "/boot")) ;; If the board SPI uses the vendor's U-Boot, it will find starfive/
(call-with-output-file (string-append mount-point "/boot/uEnv.txt") ;; starfive_visionfive2.dtb. We cannot guarantee that users will
(lambda (port) ;; update this U-Boot, so set the FDT explicitly.
(format port (plain-file "uEnv.txt"
;; if board SPI use vender's u-boot, will find "fdtfile=starfive/jh7110-starfive-visionfive-2-v1.3b.dtb~%")))
;; ""starfive/starfive_visionfive2.dtb"", We cannot guarantee
;; that users will update this u-boot, so set it.
"fdtfile=starfive/jh7110-starfive-visionfive-2-v1.3b.dtb~%")))))
(define install-qemu-riscv64-u-boot
#~(lambda (bootloader device mount-point)
(let ((u-boot.bin (string-append bootloader "/libexec/u-boot.bin"))
(install-dir (string-append mount-point "/boot")))
(install-file u-boot.bin install-dir))))
;;; ;;;
;;; Bootloader definitions. ;;; Bootloader definitions.
;;; ;;;
@ -329,7 +326,7 @@
(bootloader (bootloader
(inherit u-boot-bootloader) (inherit u-boot-bootloader)
(package u-boot-ts7970-q-2g-1000mhz-c) (package u-boot-ts7970-q-2g-1000mhz-c)
(installer install-u-boot-ts7970-q-2g-1000mhz-c-u-boot) (installer (make-u-boot-installer "libexec/u-boot.imx"))
(disk-image-installer #f))) (disk-image-installer #f)))
(define u-boot-sifive-unmatched-bootloader (define u-boot-sifive-unmatched-bootloader
@ -349,5 +346,5 @@
(bootloader (bootloader
(inherit u-boot-bootloader) (inherit u-boot-bootloader)
(package u-boot-qemu-riscv64) (package u-boot-qemu-riscv64)
(installer install-qemu-riscv64-u-boot) (installer (make-u-boot-installer "libexec/u-boot.bin"))
(disk-image-installer #f))) (disk-image-installer #f)))