From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id QMJdJxJRW2dQHQAAqHPOHw:P1 (envelope-from ) for ; Thu, 12 Dec 2024 21:09:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id QMJdJxJRW2dQHQAAqHPOHw (envelope-from ) for ; Thu, 12 Dec 2024 22:09:38 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=sOSDkbeV; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=NsanLdv6; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1734037778; a=rsa-sha256; cv=none; b=QC134vnS3cxir5T2M6wSobfgP0XvjppCL0N/vHOvmZQ50dydLdavcHu/GTmpp5UPcpjqKh mYtKHHb/G3tTUvJgtb4k/jhpFON+vpHO4iGFYDrbjhOjvP4bTNfhd9y0c3yS0x1Sg6RM6g /GEiKFKMispm/eqNqihj7LII9J6SrdVJI/bfFKj0OB4syi3RWEzi+uXpiqVQ9/ZAl3zD1U uFcg1ZABC+sqFbwMsncvr+BhaytXJK81HsZG0iYxpg56U/rnNtAa8xIUusixv4sCtsoA8v y9xIs93elnuuGsM1nPrJYQcuJZypc7v2yal+8HlNuJINft/azBZutCx2DmEQMg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=sOSDkbeV; dkim=fail ("headers rsa verify failed") header.d=rimm.ee header.s=herman header.b=NsanLdv6; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1734037778; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=NQU/7gsM9r12YHNgXaYibpEq2xn/NSq/OiBjd4dy32I=; b=pDfuTCic1ZKQaPv5jt3p07x0B9dMuNxRtybMuDRsff/mnucK0xkf58tFAVwUvz3ROZP8ii xufeUNcIxuUmBV1mfPs1eVRZx3OZePveDMZvtpFNMcJ+6XA2HICyWEF2666X3TNygS7oOe cxXRcuo84MCf39q1NEOQP61UmPua9Gfu1+EJQvieWHadHuwAGHv8jrokVTwfIxUE9c0uTO IsLFKXMk1SGxvXI+eYQq+OYbln5b7SOQDhndMtYAMW0K0up7z+a9cgazpO7t5kwMbg06Tk yPHpR1fkoRFRxuDIAVGK6K0G6vzUKb8J3pwMPwvGSU5uJ21v8Ado73RvMOLDLA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6EDBB5400 for ; Thu, 12 Dec 2024 22:09:38 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLqQm-0005t8-3Z; Thu, 12 Dec 2024 16:09:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLqQh-0005sV-Sh for guix-patches@gnu.org; Thu, 12 Dec 2024 16:09:05 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLqQg-0007fS-MF for guix-patches@gnu.org; Thu, 12 Dec 2024 16:09:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=NQU/7gsM9r12YHNgXaYibpEq2xn/NSq/OiBjd4dy32I=; b=sOSDkbeVi+TA1EIcrxYxCQmH6R4WJhq3obzDmsUJXaQ2YVkgqAEs7CXn0q2qb0lPw84TvMcLwUNYrVPC6bllFGOKs6OvVNsw9ODYCjsTK/u2r/VejV9VQ09LGZ5TNw3/iLDBpZEjQInwR9sCoq2CI0lEKyyumCVDPBCECbxXqaboIJqobqungs9QrXg9HNHyY2jBKcSxiPzNFfYehYQMxNYSig6LMm3TKLB/ghuUQObCcAta9EvRhqBF9EqqnQQH4zFA/SzAmW5OjTdP03fw0qNcGAquP6GHsFPM6HxlUQV1MO0LQ8xn3hG+shwq9ojZ6HfdORLRxd6iRFBRvHRM/A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLqQg-0000wz-84 for guix-patches@gnu.org; Thu, 12 Dec 2024 16:09:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74842] [PATCH 2/4] gnu: bootloader: u-boot: Add write-u-boot-image procedure. Resent-From: Herman Rimm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Dec 2024 21:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74842 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74842@debbugs.gnu.org Received: via spool by 74842-submit@debbugs.gnu.org id=B74842.17340376913548 (code B ref 74842); Thu, 12 Dec 2024 21:09:02 +0000 Received: (at 74842) by debbugs.gnu.org; 12 Dec 2024 21:08:11 +0000 Received: from localhost ([127.0.0.1]:40603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLqPq-0000v4-Au for submit@debbugs.gnu.org; Thu, 12 Dec 2024 16:08:11 -0500 Received: from 81-205-150-117.fixed.kpn.net ([81.205.150.117]:37851 helo=email.rimm.ee) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLqPm-0000uH-7a for 74842@debbugs.gnu.org; Thu, 12 Dec 2024 16:08:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rimm.ee; s=herman; t=1734037671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NQU/7gsM9r12YHNgXaYibpEq2xn/NSq/OiBjd4dy32I=; b=NsanLdv6irU7OnmIjoTJ5EXVq5PgTs5WSZiP3uye4pkOEfZIPoSy2dzpsMK/zfm0bhrcZX O3iXRCmabFL/9Kz5KbuMDmC75i5WQt7/lU27qPS/rLi7VRnu+QdpuWh8iZxD/kdiBpjm54 MRKoTKzcyFr/F5VZjbLATWJDRg4B3w0TBZPJTyhKOFCcaMAhDnJt7i5MygWE8avyhKQx4n n8dtXL9/AOjtcTnWv8roqsL/p3Rh97ZA+hQKQKZfAen77+9P+BtmuYfgYIg6OQIHshgaVA x7+w8Zag2njK8eUpbFnuLyOyTxA+Ry5KnBbX9wRQudTyMeygbC1AAJrWnAKDMQ== Received: by 81-205-150-117.fixed.kpn.net (OpenSMTPD) with ESMTPSA id f8d8cfb7 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO) for <74842@debbugs.gnu.org>; Thu, 12 Dec 2024 21:07:51 +0000 (UTC) Date: Thu, 12 Dec 2024 22:07:09 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: <6a1609d369654f967bdcb42bec27357b5f522ebf.1734037218.git.herman@rimm.ee> References: <6a1609d369654f967bdcb42bec27357b5f522ebf.1734037218.git.herman@rimm.ee> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Herman Rimm X-ACL-Warn: , Herman Rimm via Guix-patches From: Herman Rimm via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 0.83 X-Spam-Score: 0.83 X-Migadu-Queue-Id: 6EDBB5400 X-Migadu-Scanner: mx12.migadu.com X-TUID: F9kFMDx+AXBL * 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