GNU bug report logs - #63766
[PATCH 0/4] Image for HiFive Unmatched

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Sun, 28 May 2023 09:41:02 UTC

Severity: normal

Tags: patch

Done: Efraim Flashner <efraim <at> flashner.co.il>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 63766 in the body.
You can then email your comments to 63766 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Sun, 28 May 2023 09:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 28 May 2023 09:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH 0/4] Image for HiFive Unmatched
Date: Sun, 28 May 2023 12:41:45 +0300
I've gotten an image built for the HiFive Unmatched board and it's
currently the image I'm running for that machine. The unformatted
partition and the specific UUID for the first two partitions in the
unmatched.scm are apparently necessary for the bring-up of the board,
and likely will be necessary for other riscv64 boards in the future.

Efraim Flashner (4):
  gnu: bootloader: Add u-boot-sifive-unmatched-bootloader.
  gnu: image: Add support for unformatted partitions.
  system: images: Add unmatched module.
  gnu: glibc-2.33: Fix building for riscv64-linux.

 gnu/bootloader/u-boot.scm                     | 17 ++++
 gnu/build/image.scm                           |  8 ++
 gnu/local.mk                                  |  2 +
 gnu/packages/base.scm                         | 16 ++--
 .../glibc-2.33-rawmemchr-miscompilation.patch | 57 +++++++++++
 gnu/system/image.scm                          | 10 +-
 gnu/system/images/unmatched.scm               | 94 +++++++++++++++++++
 7 files changed, 197 insertions(+), 7 deletions(-)
 create mode 100644 gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch
 create mode 100644 gnu/system/images/unmatched.scm


base-commit: b96b82bcd4bc24529941ff74a91432481f1a71b5
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Information forwarded to , guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Sun, 28 May 2023 09:44:01 GMT) Full text and rfc822 format available.

Message #8 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: 63766 <at> debbugs.gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH 1/4] gnu: bootloader: Add u-boot-sifive-unmatched-bootloader.
Date: Sun, 28 May 2023 12:44:18 +0300
* gnu/bootloader/u-boot.scm (install-sifive-unmatched-u-boot,
u-boot-sifive-unmatched-bootloader): New variables.
---
 gnu/bootloader/u-boot.scm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 65d7923465..712db15b02 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2020 Julien Lepiller <julien <at> lepiller.eu>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -43,6 +44,7 @@ (define-module (gnu bootloader u-boot)
             u-boot-puma-rk3399-bootloader
             u-boot-rock64-rk3328-bootloader
             u-boot-rockpro64-rk3399-bootloader
+            u-boot-sifive-unmatched-bootloader
             u-boot-ts7970-q-2g-1000mhz-c-bootloader
             u-boot-wandboard-bootloader))
 
@@ -135,6 +137,15 @@ (define install-u-boot-ts7970-q-2g-1000mhz-c-u-boot
             (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"))
+            (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)))))
+
 
 
 ;;;
@@ -273,3 +284,9 @@ (define u-boot-ts7970-q-2g-1000mhz-c-bootloader
    (package u-boot-ts7970-q-2g-1000mhz-c)
    (installer install-u-boot-ts7970-q-2g-1000mhz-c-u-boot)
    (disk-image-installer #f)))
+
+(define u-boot-sifive-unmatched-bootloader
+  (bootloader
+   (inherit u-boot-bootloader)
+   (package u-boot-sifive-unmatched)
+   (disk-image-installer install-sifive-unmatched-u-boot)))
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Information forwarded to , guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Sun, 28 May 2023 09:44:02 GMT) Full text and rfc822 format available.

Message #11 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: 63766 <at> debbugs.gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH 2/4] gnu: image: Add support for unformatted partitions.
Date: Sun, 28 May 2023 12:44:19 +0300
* gnu/build/image.scm (make-unformatted-image): New procedure.
(make-partition-image): Add support for unformatted partition.
* gnu/system/image.scm (system-disk-image)[partition->gpt-type]: Add
case for using unformatted partition uuid.
[partition-image]: Add coreutils to image-builder closure.
---
 gnu/build/image.scm  |  8 ++++++++
 gnu/system/image.scm | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gnu/build/image.scm b/gnu/build/image.scm
index 65a0373980..d47cb31aa0 100644
--- a/gnu/build/image.scm
+++ b/gnu/build/image.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe <at> gmail.com>
 ;;; Copyright © 2022 Pavel Shlyak <p.shlyak <at> pantherx.org>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
+;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -122,6 +123,11 @@ (define* (make-vfat-image partition target root fs-bits)
                           (string-append "::" file))))
               (scandir root))))
 
+(define* (make-unformatted-image partition target)
+  "Make an unformatted partition of a certain size."
+  (let ((size (partition-size partition)))
+    (invoke "truncate" "--size" (number->string size) target)))
+
 (define* (make-partition-image partition-sexp target root)
   "Create and return the image of PARTITION-SEXP as TARGET.  Use the given
 ROOT directory to populate the image."
@@ -134,6 +140,8 @@ (define* (make-partition-image partition-sexp target root)
       (make-vfat-image partition target root 16))
      ((string=? type "fat32")
       (make-vfat-image partition target root 32))
+     ((string=? type "unformatted")
+      (make-unformatted-image partition target))
      (else
       (raise (condition
               (&message
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index afef79185f..3fe813f096 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2022 Pavel Shlyak <p.shlyak <at> pantherx.org>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo <at> cyberdimension.org>
 ;;; Copyright © 2022 Alex Griffin <a <at> ajgrf.com>
+;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -390,6 +391,9 @@ (define* (system-disk-image image
          ((or (string=? file-system "vfat")
               (string=? file-system "fat16")
               (string=? file-system "fat32")) "F")
+         ((and (string=? file-system "unformatted")
+               (partition-uuid partition))
+          (uuid->string (partition-uuid partition)))
          (else
           (raise (condition
                   (&message
@@ -414,7 +418,11 @@ (define* (system-disk-image image
               (with-imported-modules*
                (let ((initializer (or #$(partition-initializer partition)
                                       initialize-root-partition))
-                     (inputs '#+(list e2fsprogs fakeroot dosfstools mtools))
+                     (inputs '#+(list e2fsprogs     ; ext2/3/4
+                                      fakeroot
+                                      dosfstools    ; vfat
+                                      mtools        ; vfat
+                                      coreutils))   ; truncate
                      (image-root "tmp-root"))
                  (sql-schema #$schema)
 
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Information forwarded to , guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Sun, 28 May 2023 09:44:02 GMT) Full text and rfc822 format available.

Message #14 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: 63766 <at> debbugs.gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH 3/4] system: images: Add unmatched module.
Date: Sun, 28 May 2023 12:44:20 +0300
* gnu/system/images/unmatched.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add it.
---
 gnu/local.mk                    |  1 +
 gnu/system/images/unmatched.scm | 94 +++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)
 create mode 100644 gnu/system/images/unmatched.scm

diff --git a/gnu/local.mk b/gnu/local.mk
index 18e8235140..50d65a3dba 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -741,6 +741,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/system/images/pine64.scm			\
   %D%/system/images/pinebook-pro.scm		\
   %D%/system/images/rock64.scm			\
+  %D%/system/images/unmatched.scm		\
   %D%/system/images/wsl2.scm			\
 						\
   %D%/machine.scm				\
diff --git a/gnu/system/images/unmatched.scm b/gnu/system/images/unmatched.scm
new file mode 100644
index 0000000000..06d8d876d1
--- /dev/null
+++ b/gnu/system/images/unmatched.scm
@@ -0,0 +1,94 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2023 Efraim Flashner <efraim <at> flashner.co.il>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu system images unmatched)
+  #:use-module (gnu bootloader)
+  #:use-module (gnu bootloader u-boot)
+  #:use-module (gnu image)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu services)
+  #:use-module (gnu services base)
+  #:use-module (gnu services networking)
+  #:use-module (gnu system)
+  #:use-module (gnu system file-systems)
+  #:use-module (gnu system image)
+  #:use-module (guix platforms riscv)
+  #:use-module (srfi srfi-26)
+  #:export (unmatched-barebones-os
+            unmatched-image-type
+            unmatched-barebones-raw-image))
+
+(define unmatched-barebones-os
+  (operating-system
+    (host-name "unmatched")
+    (timezone "Asia/Jerusalem")
+    (locale "en_US.utf8")
+    (bootloader (bootloader-configuration
+                 (bootloader u-boot-sifive-unmatched-bootloader)
+                 (targets '("/dev/vda"))))
+    (initrd-modules '())
+    (kernel linux-libre-riscv64-generic)
+    (file-systems (cons (file-system
+                          (device (file-system-label "my-root"))
+                          (mount-point "/")
+                          (type "ext4"))
+                        %base-file-systems))
+    (services
+      (append (list (service agetty-service-type
+                             (agetty-configuration
+                              (extra-options '("-L")) ; no carrier detect
+                              (baud-rate "115200")
+                              (term "vt100")
+                              (tty "ttySIF0")))
+                    (service dhcp-client-service-type))
+              %base-services))))
+
+(define unmatched-disk-image
+  (image-without-os
+   (format 'disk-image)
+   (partition-table-type 'gpt)
+   ;; https://source.denx.de/u-boot/u-boot/-/blob/master/doc/board/sifive/unmatched.rst
+   (partitions (list
+                (partition
+                 (size (* 1 (expt 2 20)))
+                 (label "spl")
+                 (offset (* 34 512))
+                 (file-system "unformatted")
+                 (uuid (uuid "5b193300-fc78-40cd-8002-e86c45580b47"))) ; HiFive FSBL
+                (partition
+                 (size (* 4 (expt 2 20)))
+                 (label "uboot")
+                 (offset (* 2082 512))
+                 (file-system "unformatted")
+                 (uuid (uuid "2e54b353-1271-4842-806f-e436d6af6985"))) ; HiFive BBL
+                root-partition))))
+
+(define unmatched-image-type
+  (image-type
+   (name 'unmatched-raw)
+   (constructor (cut image-with-os unmatched-disk-image <>))))
+
+(define unmatched-barebones-raw-image
+  (image
+   (inherit
+    (os+platform->image unmatched-barebones-os riscv64-linux
+                        #:type unmatched-image-type))
+   (name 'unmatched-barebones-raw-image)))
+
+;; Return the default image.
+unmatched-barebones-raw-image
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Information forwarded to , guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Sun, 28 May 2023 09:44:02 GMT) Full text and rfc822 format available.

Message #17 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: 63766 <at> debbugs.gnu.org
Cc: Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH 4/4] gnu: glibc-2.33: Fix building for riscv64-linux.
Date: Sun, 28 May 2023 12:44:21 +0300
* gnu/packages/base.scm (glibc-2.33)[source]: Add patch.
* gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch: New
file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/base.scm                         | 16 ++++--
 .../glibc-2.33-rawmemchr-miscompilation.patch | 57 +++++++++++++++++++
 3 files changed, 68 insertions(+), 6 deletions(-)
 create mode 100644 gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 50d65a3dba..e8770a3f2a 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1235,6 +1235,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/glib-appinfo-watch.patch			\
   %D%/packages/patches/glib-networking-gnutls-binding.patch	\
   %D%/packages/patches/glib-skip-failing-test.patch		\
+  %D%/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch	\
   %D%/packages/patches/glibc-CVE-2019-7309.patch		\
   %D%/packages/patches/glibc-CVE-2019-9169.patch		\
   %D%/packages/patches/glibc-CVE-2019-19126.patch		\
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index d2f276c447..dbf1b0edcb 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -1066,12 +1066,13 @@ (define-public glibc-2.33
                (base32
                 "1zvp0qdfbdyqrzydz18d9zg3n5ygy8ps7cmny1bvsp8h1q05c99f"))
               (patches
-               ;; Remove a patch that's become irrelevant and that does not
-               ;; apply to this version.
-               (remove (lambda (patch)
-                         (string=? (basename patch)
-                                   "glibc-hurd-clock_gettime_monotonic.patch"))
-                       (origin-patches (package-source glibc))))))
+               (cons* (search-patch "glibc-2.33-rawmemchr-miscompilation.patch")
+                 ;; Remove a patch that's become irrelevant and that does not
+                 ;; apply to this version.
+                 (remove (lambda (patch)
+                           (string=? (basename patch)
+                                     "glibc-hurd-clock_gettime_monotonic.patch"))
+                         (origin-patches (package-source glibc)))))))
     (arguments
      (substitute-keyword-arguments (package-arguments glibc)
        ((#:configure-flags flags ''())
@@ -1379,6 +1380,9 @@ (define-public glibc-utf8-locales
    (make-glibc-utf8-locales glibc)))
 
 ;; Packages provided to ease use of binaries linked against the previous libc.
+(define-public glibc-locales-2.33
+  (package (inherit (make-glibc-locales glibc-2.33))
+           (name "glibc-locales-2.33")))
 (define-public glibc-locales-2.32
   (package (inherit (make-glibc-locales glibc-2.32))
            (name "glibc-locales-2.32")))
diff --git a/gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch b/gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch
new file mode 100644
index 0000000000..bcf297be94
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch
@@ -0,0 +1,57 @@
+This patch is from upstream glibc after 2.33 and is needed in Guix to
+fix glibc-2.33 compilation for riscv64-linux.
+
+From 044e603b698093cf48f6e6229e0b66acf05227e4 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer <at> redhat.com>
+Date: Fri, 19 Feb 2021 13:29:00 +0100
+Subject: [PATCH] string: Work around GCC PR 98512 in rawmemchr
+
+---
+ string/rawmemchr.c | 26 +++++++++++++++-----------
+ 1 file changed, 15 insertions(+), 11 deletions(-)
+
+diff --git a/string/rawmemchr.c b/string/rawmemchr.c
+index 59bbeeaa42..b8523118e5 100644
+--- a/string/rawmemchr.c
++++ b/string/rawmemchr.c
+@@ -22,24 +22,28 @@
+ # define RAWMEMCHR __rawmemchr
+ #endif
+ 
++/* The pragmata should be nested inside RAWMEMCHR below, but that
++   triggers GCC PR 98512.  */
++DIAG_PUSH_NEEDS_COMMENT;
++#if __GNUC_PREREQ (7, 0)
++/* GCC 8 warns about the size passed to memchr being larger than
++   PTRDIFF_MAX; the use of SIZE_MAX is deliberate here.  */
++DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow=");
++#endif
++#if __GNUC_PREREQ (11, 0)
++/* Likewise GCC 11, with a different warning option.  */
++DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread");
++#endif
++
+ /* Find the first occurrence of C in S.  */
+ void *
+ RAWMEMCHR (const void *s, int c)
+ {
+-  DIAG_PUSH_NEEDS_COMMENT;
+-#if __GNUC_PREREQ (7, 0)
+-  /* GCC 8 warns about the size passed to memchr being larger than
+-     PTRDIFF_MAX; the use of SIZE_MAX is deliberate here.  */
+-  DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow=");
+-#endif
+-#if __GNUC_PREREQ (11, 0)
+-  /* Likewise GCC 11, with a different warning option.  */
+-  DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread");
+-#endif
+   if (c != '\0')
+     return memchr (s, c, (size_t)-1);
+-  DIAG_POP_NEEDS_COMMENT;
+   return (char *)s + strlen (s);
+ }
+ libc_hidden_def (__rawmemchr)
+ weak_alias (__rawmemchr, rawmemchr)
++
++DIAG_POP_NEEDS_COMMENT;
+-- 
-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





Information forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Fri, 09 Jun 2023 20:44:02 GMT) Full text and rfc822 format available.

Message #20 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, paren <at> disroot.org,
 Christopher Baines <mail <at> cbaines.net>, 63766 <at> debbugs.gnu.org,
 Ricardo Wurmus <rekado <at> elephly.net>,
 Raghav Gururajan <rg <at> raghavgururajan.name>, jgart <jgart <at> dismail.de>,
 Mathieu Othacehe <othacehe <at> gnu.org>
Subject: Re: bug#63766: [PATCH 0/4] Image for HiFive Unmatched
Date: Fri, 09 Jun 2023 22:42:37 +0200
Efraim Flashner <efraim <at> flashner.co.il> skribis:

> * gnu/build/image.scm (make-unformatted-image): New procedure.
> (make-partition-image): Add support for unformatted partition.
> * gnu/system/image.scm (system-disk-image)[partition->gpt-type]: Add
> case for using unformatted partition uuid.
> [partition-image]: Add coreutils to image-builder closure.

[...]

> +(define* (make-unformatted-image partition target)
> +  "Make an unformatted partition of a certain size."
> +  (let ((size (partition-size partition)))
> +    (invoke "truncate" "--size" (number->string size) target)))

Simply: (truncate-file target size).

> -                     (inputs '#+(list e2fsprogs fakeroot dosfstools mtools))
> +                     (inputs '#+(list e2fsprogs     ; ext2/3/4
> +                                      fakeroot
> +                                      dosfstools    ; vfat
> +                                      mtools        ; vfat
> +                                      coreutils))   ; truncate

And this can be dropped.

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Fri, 09 Jun 2023 20:47:02 GMT) Full text and rfc822 format available.

Message #23 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, paren <at> disroot.org,
 Christopher Baines <mail <at> cbaines.net>, 63766 <at> debbugs.gnu.org,
 Ricardo Wurmus <rekado <at> elephly.net>,
 Raghav Gururajan <rg <at> raghavgururajan.name>, jgart <jgart <at> dismail.de>,
 Mathieu Othacehe <othacehe <at> gnu.org>
Subject: Re: bug#63766: [PATCH 0/4] Image for HiFive Unmatched
Date: Fri, 09 Jun 2023 22:46:25 +0200
Efraim Flashner <efraim <at> flashner.co.il> skribis:

> * gnu/system/images/unmatched.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.

[...]

> +(define unmatched-disk-image
> +  (image-without-os
> +   (format 'disk-image)
> +   (partition-table-type 'gpt)
> +   ;; https://source.denx.de/u-boot/u-boot/-/blob/master/doc/board/sifive/unmatched.rst
> +   (partitions (list
> +                (partition
> +                 (size (* 1 (expt 2 20)))
> +                 (label "spl")
> +                 (offset (* 34 512))
> +                 (file-system "unformatted")
> +                 (uuid (uuid "5b193300-fc78-40cd-8002-e86c45580b47"))) ; HiFive FSBL
> +                (partition
> +                 (size (* 4 (expt 2 20)))
> +                 (label "uboot")
> +                 (offset (* 2082 512))
> +                 (file-system "unformatted")
> +                 (uuid (uuid "2e54b353-1271-4842-806f-e436d6af6985"))) ; HiFive BBL
> +                root-partition))))

Could you add a comment explaining what these two “unformatted”
partitions are, and what FSBL and BBL mean?  It looks odd to the
untrained eye.  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Fri, 09 Jun 2023 20:50:01 GMT) Full text and rfc822 format available.

Message #26 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, paren <at> disroot.org,
 Christopher Baines <mail <at> cbaines.net>, 63766 <at> debbugs.gnu.org,
 Ricardo Wurmus <rekado <at> elephly.net>,
 Raghav Gururajan <rg <at> raghavgururajan.name>, jgart <jgart <at> dismail.de>,
 Mathieu Othacehe <othacehe <at> gnu.org>
Subject: Re: bug#63766: [PATCH 0/4] Image for HiFive Unmatched
Date: Fri, 09 Jun 2023 22:49:30 +0200
Efraim Flashner <efraim <at> flashner.co.il> skribis:

> * gnu/packages/base.scm (glibc-2.33)[source]: Add patch.
> * gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch: New
> file.
> * gnu/local.mk (dist_patch_DATA): Register it.

[...]

> +               (cons* (search-patch "glibc-2.33-rawmemchr-miscompilation.patch")
> +                 ;; Remove a patch that's become irrelevant and that does not
> +                 ;; apply to this version.
> +                 (remove (lambda (patch)
> +                           (string=? (basename patch)
> +                                     "glibc-hurd-clock_gettime_monotonic.patch"))
> +                         (origin-patches (package-source glibc)))))))

The indentation is off.  You can use ‘cons’ rather than ‘cons*’.

> +++ b/gnu/packages/patches/glibc-2.33-rawmemchr-miscompilation.patch
> @@ -0,0 +1,57 @@
> +This patch is from upstream glibc after 2.33 and is needed in Guix to
> +fix glibc-2.33 compilation for riscv64-linux.

Maybe rename it ‘glibc-2.33-riscv-compilation.patch’ to make the goal
clearer?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Fri, 09 Jun 2023 20:51:01 GMT) Full text and rfc822 format available.

Message #29 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 63766 <at> debbugs.gnu.org
Subject: Re: bug#63766: [PATCH 0/4] Image for HiFive Unmatched
Date: Fri, 09 Jun 2023 22:50:20 +0200
Efraim Flashner <efraim <at> flashner.co.il> skribis:

> I've gotten an image built for the HiFive Unmatched board and it's
> currently the image I'm running for that machine. The unformatted
> partition and the specific UUID for the first two partitions in the
> unmatched.scm are apparently necessary for the bring-up of the board,
> and likely will be necessary for other riscv64 boards in the future.

Nice patch series!  It’s exciting to know that this thing runs on actual
HiFive boards.  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Tue, 13 Jun 2023 09:55:01 GMT) Full text and rfc822 format available.

Message #32 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, paren <at> disroot.org,
 Christopher Baines <mail <at> cbaines.net>, 63766 <at> debbugs.gnu.org,
 Ricardo Wurmus <rekado <at> elephly.net>,
 Raghav Gururajan <rg <at> raghavgururajan.name>, jgart <jgart <at> dismail.de>,
 Mathieu Othacehe <othacehe <at> gnu.org>
Subject: Re: bug#63766: [PATCH 0/4] Image for HiFive Unmatched
Date: Tue, 13 Jun 2023 12:53:47 +0300
[Message part 1 (text/plain, inline)]
On Fri, Jun 09, 2023 at 10:42:37PM +0200, Ludovic Courtès wrote:
> Efraim Flashner <efraim <at> flashner.co.il> skribis:
> 
> > * gnu/build/image.scm (make-unformatted-image): New procedure.
> > (make-partition-image): Add support for unformatted partition.
> > * gnu/system/image.scm (system-disk-image)[partition->gpt-type]: Add
> > case for using unformatted partition uuid.
> > [partition-image]: Add coreutils to image-builder closure.
> 
> [...]
> 
> > +(define* (make-unformatted-image partition target)
> > +  "Make an unformatted partition of a certain size."
> > +  (let ((size (partition-size partition)))
> > +    (invoke "truncate" "--size" (number->string size) target)))
> 
> Simply: (truncate-file target size).

Almost.

Backtrace:
           1 (primitive-load "/gnu/store/v9kg0qwyws5s5m07klzkfqc9dmf…")
           0 (truncate-file "/gnu/store/rcillf8ni077l9fi2cy2gdzzpqv…" …)

ERROR: In procedure truncate-file:
In procedure truncate-file: No such file or directory

I changed it to:

(let ((size (partition-size partition)))
  ;; Create the file and then truncate it to the desired size.
  (with-output-to-file target
    (lambda _ (display "")))
  (truncate-file target size)))

And that got me the empty partition/block device as needed.

> > -                     (inputs '#+(list e2fsprogs fakeroot dosfstools mtools))
> > +                     (inputs '#+(list e2fsprogs     ; ext2/3/4
> > +                                      fakeroot
> > +                                      dosfstools    ; vfat
> > +                                      mtools        ; vfat
> > +                                      coreutils))   ; truncate
> 
> And this can be dropped.

Not for this review, but I'd like to make the inputs dependant on which
partition type is being made. There's no need to have dosfstools and
mtools when making an ext4 partition. And if we add a btrfs partition
option there's a large possibility that someone using that won't need
e2fsprogs at all while creating their image.

> Ludo’.

Thanks

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

Reply sent to Efraim Flashner <efraim <at> flashner.co.il>:
You have taken responsibility. (Wed, 14 Jun 2023 12:00:02 GMT) Full text and rfc822 format available.

Notification sent to Efraim Flashner <efraim <at> flashner.co.il>:
bug acknowledged by developer. (Wed, 14 Jun 2023 12:00:02 GMT) Full text and rfc822 format available.

Message #37 received at 63766-done <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: 63766-done <at> debbugs.gnu.org
Subject: Re: [PATCH 0/4] Image for HiFive Unmatched
Date: Wed, 14 Jun 2023 14:59:20 +0300
[Message part 1 (text/plain, inline)]
Patches pushed!

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#63766; Package guix-patches. (Wed, 21 Jun 2023 22:09:02 GMT) Full text and rfc822 format available.

Message #40 received at 63766 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>,
 Simon Tournier <zimon.toutoune <at> gmail.com>, paren <at> disroot.org,
 Christopher Baines <mail <at> cbaines.net>, 63766 <at> debbugs.gnu.org,
 Ricardo Wurmus <rekado <at> elephly.net>,
 Raghav Gururajan <rg <at> raghavgururajan.name>, jgart <jgart <at> dismail.de>,
 Mathieu Othacehe <othacehe <at> gnu.org>
Subject: Re: bug#63766: [PATCH 0/4] Image for HiFive Unmatched
Date: Thu, 22 Jun 2023 00:08:16 +0200
Hi,

Efraim Flashner <efraim <at> flashner.co.il> skribis:

> I changed it to:
>
> (let ((size (partition-size partition)))
>   ;; Create the file and then truncate it to the desired size.
>   (with-output-to-file target
>     (lambda _ (display "")))
>   (truncate-file target size)))
>
> And that got me the empty partition/block device as needed.

A slight improvement would be:

  (catch 'system-error
    (lambda ()
      (truncate-file target size))
    (lambda args
      (if (= ENOENT (system-error-errno args))
          (call-with-output-file target (const #t))
          (apply throw args))))

It’s more verbose but makes the intent clearer.

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 20 Jul 2023 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 253 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.