From: Herman Rimm via Guix-patches via <guix-patches@gnu.org>
To: 74842@debbugs.gnu.org
Subject: [bug#74842] [PATCH 2/4] gnu: bootloader: u-boot: Add write-u-boot-image procedure.
Date: Thu, 12 Dec 2024 22:07:09 +0100 [thread overview]
Message-ID: <adf0881c40af75083672b79df37d74f7de023b03.1734037218.git.herman@rimm.ee> (raw)
In-Reply-To: <6a1609d369654f967bdcb42bec27357b5f522ebf.1734037218.git.herman@rimm.ee>
* gnu/bootloader/u-boot.scm (write-u-boot-image): Add procedure.
(install-beaglebone-black-u-boot, install-allwinner-u-boot,
install-allwinner64-u-boot, install-imx-u-boot,
install-puma-rk3399-u-boot, install-rockchip-u-boot,
install-sifive-unmatched-u-boot, install-starfive-visionfive2-u-boot):
Use write-u-boot-image.
Change-Id: Icb73534bfc5b9ab7c8874176f649c29275c388cf
---
gnu/bootloader/u-boot.scm | 84 ++++++++++++++-------------------------
1 file changed, 29 insertions(+), 55 deletions(-)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 5ea5f418b4..5d5fc1bff2 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -66,6 +66,22 @@ (define (make-u-boot-installer file)
(let ((install-dir (string-append mount-point "/boot")))
#$@file))))
+(define (write-u-boot-image files block-size)
+ "FILES is a list of (FILE COUNT OFFSET) tuples. Each FILE is written
+to the target image at BLOCK-SIZE * OFFSET. The number of bytes written
+is BLOCK-SIZE * COUNT, or FILE size if COUNT is not given."
+ (define (write-file-to-image file)
+ (match file
+ ((file count ... offset)
+ (let* ((file #~(string-append bootloader "/libexec/" #$file))
+ (size (match count
+ (() #~(stat:size (stat #$file)))
+ ((count) (* count block-size)))))
+ #~(write-file-on-device #$file #$size image
+ #$(* offset block-size))))))
+ #~(lambda (bootloader _ image)
+ #$@(map write-file-to-image files)))
+
(define install-u-boot
#~(lambda (bootloader root-index image)
(if bootloader
@@ -78,75 +94,33 @@ (define install-beaglebone-black-u-boot
;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
;; specified DEVICE.
- #~(lambda (bootloader root-index image)
- (let ((mlo (string-append bootloader "/libexec/MLO"))
- (u-boot (string-append bootloader "/libexec/u-boot.img")))
- (write-file-on-device mlo (* 256 512)
- image (* 256 512))
- (write-file-on-device u-boot (* 1024 512)
- image (* 768 512)))))
+ (write-u-boot-image '(("MLO" 256 256) ("u-boot.img" 768 1024)) 512))
(define install-allwinner-u-boot
- #~(lambda (bootloader root-index image)
- (let ((u-boot (string-append bootloader
- "/libexec/u-boot-sunxi-with-spl.bin")))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 8 1024)))))
+ (write-u-boot-image '(("u-boot-sunxi-with-spl.bin" 8)) 1024))
(define install-allwinner64-u-boot
- #~(lambda (bootloader root-index image)
- (let ((spl (string-append bootloader "/libexec/u-boot-sunxi-with-spl.bin"))
- (u-boot (string-append bootloader "/libexec/u-boot-sunxi-with-spl.fit.itb")))
- (write-file-on-device spl (stat:size (stat spl))
- image (* 8 1024))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 40 1024)))))
+ (write-u-boot-image '(("u-boot-sunxi-with-spl.bin" 8)
+ ("u-boot-sunxi-with-spl.fit.itb" 40))
+ 1024))
(define install-imx-u-boot
- #~(lambda (bootloader root-index image)
- (let ((spl (string-append bootloader "/libexec/SPL"))
- (u-boot (string-append bootloader "/libexec/u-boot.img")))
- (write-file-on-device spl (stat:size (stat spl))
- image (* 1 1024))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 69 1024)))))
+ (write-u-boot-image '(("SPL" 1) ("u-boot.img" 69)) 1024))
(define install-puma-rk3399-u-boot
- #~(lambda (bootloader root-index image)
- (let ((spl (string-append bootloader "/libexec/idbloader.img"))
- (u-boot (string-append bootloader "/libexec/u-boot.itb")))
- (write-file-on-device spl (stat:size (stat spl))
- image (* 64 512))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 512 512)))))
+ (write-u-boot-image '(("idbloader.img" 64) ("u-boot.itb" 512)) 512))
(define install-rockchip-u-boot
- #~(lambda (bootloader root-index image)
- (let ((idb (string-append bootloader "/libexec/idbloader.img"))
- (u-boot (string-append bootloader "/libexec/u-boot.itb")))
- (write-file-on-device idb (stat:size (stat idb))
- image (* 64 512))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 16384 512)))))
+ (write-u-boot-image '(("idbloader.img" 64) ("u-boot.itb" 16384)) 512))
(define install-sifive-unmatched-u-boot
- #~(lambda (bootloader root-index image)
- (let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin"))
- (u-boot (string-append bootloader "/libexec/u-boot.itb")))
- (write-file-on-device spl (stat:size (stat spl))
- image (* 34 512))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 2082 512)))))
+ (write-u-boot-image '(("spl/u-boot-spl.bin" 34) ("u-boot.itb" 2082))
+ 512))
(define install-starfive-visionfive2-u-boot
- #~(lambda (bootloader root-index image)
- (let ((spl (string-append
- bootloader "/libexec/spl/u-boot-spl.bin.normal.out"))
- (u-boot (string-append bootloader "/libexec/u-boot.itb")))
- (write-file-on-device spl (stat:size (stat spl))
- image (* 34 512))
- (write-file-on-device u-boot (stat:size (stat u-boot))
- image (* 2082 512)))))
+ (write-u-boot-image '(("spl/u-boot-spl.bin.normal.out" 34)
+ ("u-boot.itb" 2082))
+ 512))
(define install-starfive-visionfive2-uEnv.txt
(make-u-boot-installer
--
2.45.2
next prev parent reply other threads:[~2024-12-12 21:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 21:03 [bug#74842] [PATCH 1/4] gnu: bootloader: u-boot: Add u-boot-rockchip-bootloader Herman Rimm via Guix-patches via
2024-12-12 21:07 ` Herman Rimm via Guix-patches via [this message]
2024-12-12 21:07 ` [bug#74842] [PATCH 3/4] gnu: u-boot-rockpro64-rk3399: Remove obsolete substitute Herman Rimm via Guix-patches via
2024-12-12 21:07 ` [bug#74842] [PATCH 4/4] gnu: Add make-u-boot-rockchip-package procedure Herman Rimm via Guix-patches via
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adf0881c40af75083672b79df37d74f7de023b03.1734037218.git.herman@rimm.ee \
--to=guix-patches@gnu.org \
--cc=74842@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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.