unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Herman Rimm via Guix-patches via <guix-patches@gnu.org>
To: 74109@debbugs.gnu.org
Subject: [bug#74109] [PATCH v2 2/2] gnu: bootloader: u-boot: Add procedure to share installer code.
Date: Thu, 31 Oct 2024 22:15:50 +0100	[thread overview]
Message-ID: <19a389de12d56ef271ab7c7637b3f5fcab2d0cd6.1730408855.git.herman@rimm.ee> (raw)
In-Reply-To: <cover.1730408855.git.herman@rimm.ee>

* 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
---
 gnu/bootloader/u-boot.scm | 47 ++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index c5437a7b63..5e149eaea0 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; 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>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -28,6 +28,7 @@ (define-module (gnu bootloader u-boot)
   #:use-module (gnu bootloader)
   #:use-module (gnu packages bootloaders)
   #:use-module (guix gexp)
+  #:use-module (ice-9 match)
   #:export (u-boot-bootloader
             u-boot-a20-olinuxino-lime-bootloader
             u-boot-a20-olinuxino-lime2-bootloader
@@ -53,6 +54,18 @@ (define-module (gnu bootloader u-boot)
             u-boot-ts7970-q-2g-1000mhz-c-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
   #~(lambda (bootloader root-index image)
       (if bootloader
@@ -145,12 +158,6 @@ (define 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
   #~(lambda (bootloader root-index image)
       (let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin"))
@@ -171,24 +178,14 @@ (define install-starfive-visionfive2-u-boot
                               image (* 2082 512)))))
 
 (define install-starfive-visionfive2-uEnv.txt
-  #~(lambda (bootloader device mount-point)
-      (mkdir-p (string-append mount-point "/boot"))
-      (call-with-output-file (string-append mount-point "/boot/uEnv.txt")
-        (lambda (port)
-          (format port
-                  ;; if board SPI use vender's u-boot, will find
-                  ;; ""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))))
+  (make-u-boot-installer
+    ;; If the board SPI uses the vendor's U-Boot, it will find starfive/
+    ;; starfive_visionfive2.dtb.  We cannot guarantee that users will
+    ;; update this U-Boot, so set the FDT explicitly.
+    (plain-file "uEnv.txt"
+      "fdtfile=starfive/jh7110-starfive-visionfive-2-v1.3b.dtb~%")))
 
 \f
-
 ;;;
 ;;; Bootloader definitions.
 ;;;
@@ -329,7 +326,7 @@ (define u-boot-ts7970-q-2g-1000mhz-c-bootloader
   (bootloader
    (inherit u-boot-bootloader)
    (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)))
 
 (define u-boot-sifive-unmatched-bootloader
@@ -349,5 +346,5 @@ (define u-boot-qemu-riscv64-bootloader
   (bootloader
    (inherit u-boot-bootloader)
    (package u-boot-qemu-riscv64)
-   (installer install-qemu-riscv64-u-boot)
+   (installer (make-u-boot-installer "libexec/u-boot.bin"))
    (disk-image-installer #f)))
-- 
2.45.2





      parent reply	other threads:[~2024-10-31 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 15:01 [bug#74109] [PATCH] gnu: bootloader: grub: Add procedure to share EFI installer code Herman Rimm via Guix-patches via
2024-10-31 21:15 ` [bug#74109] [PATCH v2 0/2] Reduce duplicate bootloader " Herman Rimm via Guix-patches via
2024-10-31 21:15   ` [bug#74109] [PATCH v2 1/2] gnu: bootloader: grub: Add procedure to share EFI " Herman Rimm via Guix-patches via
2024-10-31 21:15   ` Herman Rimm via Guix-patches via [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19a389de12d56ef271ab7c7637b3f5fcab2d0cd6.1730408855.git.herman@rimm.ee \
    --to=guix-patches@gnu.org \
    --cc=74109@debbugs.gnu.org \
    --cc=herman@rimm.ee \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).