all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
@ 2022-12-02  5:29 Maxim Cournoyer
  2022-12-02  5:30 ` [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-02  5:29 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

Hello!

This makes our make-u-boot-package procedure more flexible, and builds on it
to add a new U-Boot bootloader package for an i.MX6 embedded board.

Thanks,

Maxim Cournoyer (2):
  gnu: make-u-boot-package: Add a u-boot argument.
  gnu: Add u-boot-ts7970-q-2g-1000mhz-c.

 gnu/packages/bootloaders.scm | 238 +++++++++++++++++++++++------------
 1 file changed, 155 insertions(+), 83 deletions(-)


base-commit: 4781f0458de7419606b71bdf0fe56bca83ace910
-- 
2.38.1





^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument.
  2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
@ 2022-12-02  5:30 ` Maxim Cournoyer
  2022-12-02  5:30   ` [bug#59761] [PATCH 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  2022-12-07 15:01 ` [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-02  5:30 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

And have that u-boot argument used as the complete base of the template, so
that a user can override it.

* gnu/packages/bootloaders.scm (make-u-boot-package): New U-BOOT argument.
Document it.
[native-inputs]: Move the native-inputs of U-BOOT first, so that the
cross compilation tools can be overridden via U-BOOT.
[arguments]: Rewrite using substitute-keyword-arguments, extending rather than
overriding most arguments.  Use gexps.
---
 gnu/packages/bootloaders.scm | 180 +++++++++++++++++++----------------
 1 file changed, 97 insertions(+), 83 deletions(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 8888c51736..7ec9bbb543 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -782,11 +783,13 @@ (define*-public (make-u-boot-package board triplet
                                      defconfig
                                      configs
                                      name-suffix
-                                     append-description)
+                                     append-description
+                                     (u-boot u-boot))
   "Return a U-Boot package for BOARD cross-compiled for TRIPLET with the
 optional DEFCONFIG file and optional configuration changes from CONFIGS.
 NAME-SUFFIX is appended to the package name, while APPEND-DESCRIPTION is
-appended to the package description."
+appended to the package description.  U-BOOT can be used when a fork or a
+different version of U-Boot must be used."
   (let ((same-arch? (lambda ()
                       (string=? (%current-system)
                                 (gnu-triplet->nix-system triplet)))))
@@ -801,90 +804,101 @@ (define*-public (make-u-boot-package board triplet
                                       "\n\n" append-description)
                        (package-description u-boot)))
       (native-inputs
-       `(,@(if (not (same-arch?))
+       ;; Note: leave the native u-boot inputs first, so that a user can
+       ;; override the cross-gcc and cross-binutils packages.
+       `(,@(package-native-inputs u-boot)
+         ,@(if (not (same-arch?))
                `(("cross-gcc" ,(cross-gcc triplet))
                  ("cross-binutils" ,(cross-binutils triplet)))
-               `())
-         ,@(package-native-inputs u-boot)))
+               `())))
       (arguments
-       `(#:modules ((ice-9 ftw)
-                    (srfi srfi-1)
-                    (guix build gnu-build-system)
-                    (guix build kconfig)
-                    (guix build utils))
-         #:imported-modules (,@%gnu-build-system-modules
-                             (guix build kconfig))
-         #:test-target "test"
-         #:make-flags
-         (list "HOSTCC=gcc"
-               ,@(if (not (same-arch?))
-                     `((string-append "CROSS_COMPILE=" ,triplet "-"))
-                     '()))
-         #:phases
-         (modify-phases %standard-phases
-           (replace 'configure
-             (lambda* (#:key outputs make-flags #:allow-other-keys)
-               (let* ((config-name (string-append ,board "_defconfig"))
-                      (config-file (string-append "configs/" config-name))
-                      (defconfig ,defconfig)
-                      (configs ',configs))
-                 (when defconfig
-                   ;; Replace the board-specific defconfig with the given one.
-                   (copy-file defconfig config-file))
-                 (if (file-exists? config-file)
-                     (begin
-                       (when configs
-                         (modify-defconfig config-file configs))
-                       (apply invoke "make" `(,@make-flags ,config-name))
-                       (verify-config ".config" config-file))
-                     (begin
-                       (display "invalid board name; valid board names are:"
-                                (current-error-port))
-                       (let ((suffix-len (string-length "_defconfig"))
-                             (entries (scandir "configs")))
-                         (for-each (lambda (file-name)
-                                     (when (string-suffix? "_defconfig" file-name)
-                                       (format (current-error-port)
-                                               "- ~A\n"
-                                               (string-drop-right file-name
-                                                                  suffix-len))))
-                                   (sort entries string-ci<)))
-                       (error "invalid boardname ~s" ,board))))))
-           (add-after 'configure 'disable-tools-libcrypto
-             ;; Disable libcrypto due to GPL and OpenSSL license
-             ;; incompatibilities
-             (lambda _
-               (substitute* ".config"
-                 (("CONFIG_TOOLS_LIBCRYPTO=.*$") "CONFIG_TOOLS_LIBCRYPTO=n"))))
-           (replace 'install
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (libexec (string-append out "/libexec"))
-                      (uboot-files (append
-                                    (remove
-                                     ;; Those would not be reproducible
-                                     ;; because of the randomness used
-                                     ;; to produce them.
-                                     ;; It's expected that the user will
-                                     ;; use u-boot-tools to generate them
-                                     ;; instead.
-                                     (lambda (name)
-                                       (string-suffix?
-                                        "sunxi-spl-with-ecc.bin"
-                                        name))
-                                     (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
-                                    (find-files "." "^(MLO|SPL)$"))))
-                 (mkdir-p libexec)
-                 (install-file ".config" libexec)
-                 ;; Useful for "qemu -kernel".
-                 (install-file "u-boot" libexec)
-                 (for-each
-                  (lambda (file)
-                    (let ((target-file (string-append libexec "/" file)))
-                      (mkdir-p (dirname target-file))
-                      (copy-file file target-file)))
-                  uboot-files)
-                 #t)))))))))
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:modules modules '())
+          `((ice-9 ftw)
+            (srfi srfi-1)
+            (guix build gnu-build-system)
+            (guix build kconfig)
+            (guix build utils)
+            ,@modules))
+         ((#:imported-modules imported-modules '())
+          `((guix build kconfig)
+            ,@%gnu-build-system-modules
+            ,@imported-modules))
+         ((#:test-target _ "test")
+          "test")
+         ((#:make-flags make-flags '())
+          #~(list "HOSTCC=gcc"
+                  #$@(if (not (same-arch?))
+                         (list (string-append "CROSS_COMPILE=" triplet "-"))
+                         '())
+                  #$@make-flags))
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (replace 'configure
+                (lambda* (#:key outputs make-flags #:allow-other-keys)
+                  (let* ((config-name (string-append #$board "_defconfig"))
+                         (config-file (string-append "configs/" config-name))
+                         (defconfig #$defconfig)
+                         (configs '#$configs))
+                    (when defconfig
+                      ;; Replace the board-specific defconfig with the given
+                      ;; one.
+                      (copy-file defconfig config-file))
+                    (if (file-exists? config-file)
+                        (begin
+                          (when configs
+                            (modify-defconfig config-file configs))
+                          (apply invoke "make" `(,@make-flags ,config-name))
+                          (verify-config ".config" config-file))
+                        (begin
+                          (display "invalid board name; valid board names are:"
+                                   (current-error-port))
+                          (let ((suffix-len (string-length "_defconfig"))
+                                (entries (scandir "configs")))
+                            (for-each (lambda (file-name)
+                                        (when (string-suffix? "_defconfig"
+                                                              file-name)
+                                          (format (current-error-port)
+                                                  "- ~A\n"
+                                                  (string-drop-right
+                                                   file-name suffix-len))))
+                                      (sort entries string-ci<)))
+                          (error "invalid boardname ~s" #$board))))))
+              (add-after 'configure 'disable-tools-libcrypto
+                ;; Disable libcrypto due to GPL and OpenSSL license
+                ;; incompatibilities
+                (lambda _
+                  (substitute* ".config"
+                    (("CONFIG_TOOLS_LIBCRYPTO=.*$")
+                     "CONFIG_TOOLS_LIBCRYPTO=n"))))
+              (replace 'install
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let ((libexec (string-append #$output "/libexec"))
+                        (uboot-files
+                         (append
+                          (remove
+                           ;; Those would not be reproducible
+                           ;; because of the randomness used to
+                           ;; produce them.  It's expected that the
+                           ;; user will use u-boot-tools to generate
+                           ;; them instead.
+                           (lambda (name)
+                             (string-suffix?
+                              "sunxi-spl-with-ecc.bin"
+                              name))
+                           (find-files "."
+                                       ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
+                          (find-files "." "^(MLO|SPL)$"))))
+                    (mkdir-p libexec)
+                    (install-file ".config" libexec)
+                    ;; Useful for "qemu -kernel".
+                    (install-file "u-boot" libexec)
+                    (for-each
+                     (lambda (file)
+                       (let ((target-file (string-append libexec "/" file)))
+                         (mkdir-p (dirname target-file))
+                         (copy-file file target-file)))
+                     uboot-files)))))))))))
 
 (define-public u-boot-malta
   (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-02  5:30 ` [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
@ 2022-12-02  5:30   ` Maxim Cournoyer
  0 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-02  5:30 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/packages/bootloaders.scm (u-boot-ts-mx6): New variable.
(u-boot-ts7970-q-2g-1000mhz-c): Likewise.
---
 gnu/packages/bootloaders.scm | 58 ++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 7ec9bbb543..ed3dace87d 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1271,6 +1271,64 @@ (define-public u-boot-rpi-4-32b-efi-bin
 (define-public u-boot-rpi-arm64-efi-bin
   (make-u-boot-bin-package u-boot-rpi-arm64-efi))
 
+(define u-boot-ts-mx6
+  ;; There is no release; use the latest commit of the
+  ;; 'imx_v2015.04_3.14.52_1.1.0_ga' branch.
+  (let ((revision "0")
+        (commit "344403c64d93813fce8c6d94ed4c3ffb1fe2a181"))
+    (package
+      (inherit u-boot)
+      (name "u-boot-ts-mx6")
+      (version (git-version "2015.04_3" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/embeddedTS/u-boot-imx")
+                      (commit commit)))
+                (file-name (git-file-name "u-boot-imx-ts" version))
+                (sha256
+                 (base32
+                  "081swfz204dsy0nss4r55b8453w766yp2wgrh5y10l3gjc0fkrs1"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'patch-for-reproducibility
+                (lambda _
+                  ;; Substitute dynamically computed timestamps with static
+                  ;; ones.
+                  (substitute* "Makefile"
+                    (("U_BOOT_DATE \"%b %d %C%y\"")
+                     "U_BOOT_DATE \"Jan 01 1969\"")
+                    (("U_BOOT_TIME \"%T\"")
+                     "U_BOOT_TIME \"00:00:00\""))))
+              (add-before 'build 'adjust-for-gcc10
+                (lambda _
+                  (invoke "gcc" "--version")
+                  (copy-file "include/linux/compiler-gcc6.h"
+                             "include/linux/compiler-gcc10.h")
+                  (substitute* "arch/arm/Makefile"
+                    (("march=armv5")
+                     "march=armv5te"))))
+              (add-after 'install 'build+install-tools
+                (lambda* (#:key make-flags #:allow-other-keys)
+                  (apply invoke "make" "tools-all" make-flags)
+                  (invoke "find")
+                  (install-file "tools/env/fw_printenv"
+                                (string-append #$output "/bin"))
+                  (symlink (string-append #$output "/bin/fw_printenv")
+                           (string-append #$output "/bin/fw_setenv"))))))))
+      (native-inputs
+       (modify-inputs (package-native-inputs u-boot)
+         (delete "dtc"))))))            ;otherwise the build fails
+
+(define-public u-boot-ts7970-q-2g-1000mhz-c
+  (make-u-boot-package "ts7970-q-2g-1000mhz-c" "arm-linux-gnueabihf"
+                       #:u-boot u-boot-ts-mx6
+                       #:append-description "This U-Boot variant is for the
+Technologic System TS-7970 revision C board, which includes a quad core
+Freescale i.MX6 CPU and 2 GiB of RAM clocked at 1000MHz."))
+
 (define-public vboot-utils
   (package
     (name "vboot-utils")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument.
  2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  2022-12-02  5:30 ` [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
@ 2022-12-07 15:01 ` Maxim Cournoyer
  2022-12-07 15:02   ` [bug#59761] [PATCH v2 2/3] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
  2022-12-07 15:02   ` [bug#59761] [PATCH v2 3/3] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  2022-12-14  2:32 ` [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-07 15:01 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

And have that u-boot argument used as the complete base of the template, so
that a user can override it.

* gnu/packages/bootloaders.scm (make-u-boot-package): New U-BOOT argument.
Document it.
[native-inputs]: Move the native-inputs of U-BOOT first, so that the
cross compilation tools can be overridden via U-BOOT.
[arguments]: Rewrite using substitute-keyword-arguments, extending rather than
overriding most arguments.  Use gexps.
---
 gnu/packages/bootloaders.scm | 180 +++++++++++++++++++----------------
 1 file changed, 97 insertions(+), 83 deletions(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 8888c51736..7ec9bbb543 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -782,11 +783,13 @@ (define*-public (make-u-boot-package board triplet
                                      defconfig
                                      configs
                                      name-suffix
-                                     append-description)
+                                     append-description
+                                     (u-boot u-boot))
   "Return a U-Boot package for BOARD cross-compiled for TRIPLET with the
 optional DEFCONFIG file and optional configuration changes from CONFIGS.
 NAME-SUFFIX is appended to the package name, while APPEND-DESCRIPTION is
-appended to the package description."
+appended to the package description.  U-BOOT can be used when a fork or a
+different version of U-Boot must be used."
   (let ((same-arch? (lambda ()
                       (string=? (%current-system)
                                 (gnu-triplet->nix-system triplet)))))
@@ -801,90 +804,101 @@ (define*-public (make-u-boot-package board triplet
                                       "\n\n" append-description)
                        (package-description u-boot)))
       (native-inputs
-       `(,@(if (not (same-arch?))
+       ;; Note: leave the native u-boot inputs first, so that a user can
+       ;; override the cross-gcc and cross-binutils packages.
+       `(,@(package-native-inputs u-boot)
+         ,@(if (not (same-arch?))
                `(("cross-gcc" ,(cross-gcc triplet))
                  ("cross-binutils" ,(cross-binutils triplet)))
-               `())
-         ,@(package-native-inputs u-boot)))
+               `())))
       (arguments
-       `(#:modules ((ice-9 ftw)
-                    (srfi srfi-1)
-                    (guix build gnu-build-system)
-                    (guix build kconfig)
-                    (guix build utils))
-         #:imported-modules (,@%gnu-build-system-modules
-                             (guix build kconfig))
-         #:test-target "test"
-         #:make-flags
-         (list "HOSTCC=gcc"
-               ,@(if (not (same-arch?))
-                     `((string-append "CROSS_COMPILE=" ,triplet "-"))
-                     '()))
-         #:phases
-         (modify-phases %standard-phases
-           (replace 'configure
-             (lambda* (#:key outputs make-flags #:allow-other-keys)
-               (let* ((config-name (string-append ,board "_defconfig"))
-                      (config-file (string-append "configs/" config-name))
-                      (defconfig ,defconfig)
-                      (configs ',configs))
-                 (when defconfig
-                   ;; Replace the board-specific defconfig with the given one.
-                   (copy-file defconfig config-file))
-                 (if (file-exists? config-file)
-                     (begin
-                       (when configs
-                         (modify-defconfig config-file configs))
-                       (apply invoke "make" `(,@make-flags ,config-name))
-                       (verify-config ".config" config-file))
-                     (begin
-                       (display "invalid board name; valid board names are:"
-                                (current-error-port))
-                       (let ((suffix-len (string-length "_defconfig"))
-                             (entries (scandir "configs")))
-                         (for-each (lambda (file-name)
-                                     (when (string-suffix? "_defconfig" file-name)
-                                       (format (current-error-port)
-                                               "- ~A\n"
-                                               (string-drop-right file-name
-                                                                  suffix-len))))
-                                   (sort entries string-ci<)))
-                       (error "invalid boardname ~s" ,board))))))
-           (add-after 'configure 'disable-tools-libcrypto
-             ;; Disable libcrypto due to GPL and OpenSSL license
-             ;; incompatibilities
-             (lambda _
-               (substitute* ".config"
-                 (("CONFIG_TOOLS_LIBCRYPTO=.*$") "CONFIG_TOOLS_LIBCRYPTO=n"))))
-           (replace 'install
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (libexec (string-append out "/libexec"))
-                      (uboot-files (append
-                                    (remove
-                                     ;; Those would not be reproducible
-                                     ;; because of the randomness used
-                                     ;; to produce them.
-                                     ;; It's expected that the user will
-                                     ;; use u-boot-tools to generate them
-                                     ;; instead.
-                                     (lambda (name)
-                                       (string-suffix?
-                                        "sunxi-spl-with-ecc.bin"
-                                        name))
-                                     (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
-                                    (find-files "." "^(MLO|SPL)$"))))
-                 (mkdir-p libexec)
-                 (install-file ".config" libexec)
-                 ;; Useful for "qemu -kernel".
-                 (install-file "u-boot" libexec)
-                 (for-each
-                  (lambda (file)
-                    (let ((target-file (string-append libexec "/" file)))
-                      (mkdir-p (dirname target-file))
-                      (copy-file file target-file)))
-                  uboot-files)
-                 #t)))))))))
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:modules modules '())
+          `((ice-9 ftw)
+            (srfi srfi-1)
+            (guix build gnu-build-system)
+            (guix build kconfig)
+            (guix build utils)
+            ,@modules))
+         ((#:imported-modules imported-modules '())
+          `((guix build kconfig)
+            ,@%gnu-build-system-modules
+            ,@imported-modules))
+         ((#:test-target _ "test")
+          "test")
+         ((#:make-flags make-flags '())
+          #~(list "HOSTCC=gcc"
+                  #$@(if (not (same-arch?))
+                         (list (string-append "CROSS_COMPILE=" triplet "-"))
+                         '())
+                  #$@make-flags))
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (replace 'configure
+                (lambda* (#:key outputs make-flags #:allow-other-keys)
+                  (let* ((config-name (string-append #$board "_defconfig"))
+                         (config-file (string-append "configs/" config-name))
+                         (defconfig #$defconfig)
+                         (configs '#$configs))
+                    (when defconfig
+                      ;; Replace the board-specific defconfig with the given
+                      ;; one.
+                      (copy-file defconfig config-file))
+                    (if (file-exists? config-file)
+                        (begin
+                          (when configs
+                            (modify-defconfig config-file configs))
+                          (apply invoke "make" `(,@make-flags ,config-name))
+                          (verify-config ".config" config-file))
+                        (begin
+                          (display "invalid board name; valid board names are:"
+                                   (current-error-port))
+                          (let ((suffix-len (string-length "_defconfig"))
+                                (entries (scandir "configs")))
+                            (for-each (lambda (file-name)
+                                        (when (string-suffix? "_defconfig"
+                                                              file-name)
+                                          (format (current-error-port)
+                                                  "- ~A\n"
+                                                  (string-drop-right
+                                                   file-name suffix-len))))
+                                      (sort entries string-ci<)))
+                          (error "invalid boardname ~s" #$board))))))
+              (add-after 'configure 'disable-tools-libcrypto
+                ;; Disable libcrypto due to GPL and OpenSSL license
+                ;; incompatibilities
+                (lambda _
+                  (substitute* ".config"
+                    (("CONFIG_TOOLS_LIBCRYPTO=.*$")
+                     "CONFIG_TOOLS_LIBCRYPTO=n"))))
+              (replace 'install
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let ((libexec (string-append #$output "/libexec"))
+                        (uboot-files
+                         (append
+                          (remove
+                           ;; Those would not be reproducible
+                           ;; because of the randomness used to
+                           ;; produce them.  It's expected that the
+                           ;; user will use u-boot-tools to generate
+                           ;; them instead.
+                           (lambda (name)
+                             (string-suffix?
+                              "sunxi-spl-with-ecc.bin"
+                              name))
+                           (find-files "."
+                                       ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
+                          (find-files "." "^(MLO|SPL)$"))))
+                    (mkdir-p libexec)
+                    (install-file ".config" libexec)
+                    ;; Useful for "qemu -kernel".
+                    (install-file "u-boot" libexec)
+                    (for-each
+                     (lambda (file)
+                       (let ((target-file (string-append libexec "/" file)))
+                         (mkdir-p (dirname target-file))
+                         (copy-file file target-file)))
+                     uboot-files)))))))))))
 
 (define-public u-boot-malta
   (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))

base-commit: d4c2ea9226c229e56022ba641100ee7f5db8f53f
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v2 2/3] gnu: make-u-boot-package: Install .imx files.
  2022-12-07 15:01 ` [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
@ 2022-12-07 15:02   ` Maxim Cournoyer
  2022-12-07 15:02   ` [bug#59761] [PATCH v2 3/3] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  1 sibling, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-07 15:02 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/packages/bootloaders.scm
(make-u-boot-package) [phases] <install>: Add imx to the regexp of files
considered for installation.
---
 gnu/packages/bootloaders.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 7ec9bbb543..ab2cf06fd5 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -887,7 +887,7 @@ (define*-public (make-u-boot-package board triplet
                               "sunxi-spl-with-ecc.bin"
                               name))
                            (find-files "."
-                                       ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
+                                       ".*\\.(bin|efi|img|imx|spl|itb|dtb|rksd)$"))
                           (find-files "." "^(MLO|SPL)$"))))
                     (mkdir-p libexec)
                     (install-file ".config" libexec)
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v2 3/3] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-07 15:01 ` [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
  2022-12-07 15:02   ` [bug#59761] [PATCH v2 2/3] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
@ 2022-12-07 15:02   ` Maxim Cournoyer
  1 sibling, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-07 15:02 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/packages/bootloaders.scm (u-boot-ts-mx6): New variable.
(u-boot-ts7970-q-2g-1000mhz-c): Likewise.
---
 gnu/packages/bootloaders.scm | 59 ++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index ab2cf06fd5..28a85eeca5 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1271,6 +1271,65 @@ (define-public u-boot-rpi-4-32b-efi-bin
 (define-public u-boot-rpi-arm64-efi-bin
   (make-u-boot-bin-package u-boot-rpi-arm64-efi))
 
+(define u-boot-ts-mx6
+  ;; There is no release; use the latest commit of the
+  ;; 'imx_v2015.04_3.14.52_1.1.0_ga' branch.
+  (let ((revision "0")
+        (commit "344403c64d93813fce8c6d94ed4c3ffb1fe2a181"))
+    (package
+      (inherit u-boot)
+      (name "u-boot-ts-mx6")
+      (version (git-version "2015.04_3" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/embeddedTS/u-boot-imx")
+                      (commit commit)))
+                (file-name (git-file-name "u-boot-imx-ts" version))
+                (sha256
+                 (base32
+                  "081swfz204dsy0nss4r55b8453w766yp2wgrh5y10l3gjc0fkrs1"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'patch-for-reproducibility
+                (lambda _
+                  ;; Substitute dynamically computed timestamps with static
+                  ;; ones.
+                  (substitute* "Makefile"
+                    (("U_BOOT_DATE \"%b %d %C%y\"")
+                     "U_BOOT_DATE \"Jan 01 1969\"")
+                    (("U_BOOT_TIME \"%T\"")
+                     "U_BOOT_TIME \"00:00:00\""))))
+              (add-before 'build 'adjust-for-gcc10
+                (lambda _
+                  (invoke "gcc" "--version")
+                  (copy-file "include/linux/compiler-gcc6.h"
+                             "include/linux/compiler-gcc10.h")
+                  (substitute* "arch/arm/Makefile"
+                    (("march=armv5")
+                     "march=armv5te"))))
+              (add-after 'install 'build+install-tools
+                (lambda* (#:key make-flags #:allow-other-keys)
+                  (apply invoke "make" "tools-all" make-flags)
+                  (install-file "tools/env/fw_printenv"
+                                (string-append #$output "/bin"))
+                  (symlink (string-append #$output "/bin/fw_printenv")
+                           (string-append #$output "/bin/fw_setenv"))))))))
+      (native-inputs
+       (modify-inputs (package-native-inputs u-boot)
+         (delete "dtc"))))))            ;otherwise the build fails
+
+(define-public u-boot-ts7970-q-2g-1000mhz-c
+  (make-u-boot-package "ts7970-q-2g-1000mhz-c" "arm-linux-gnueabihf"
+                       #:u-boot u-boot-ts-mx6
+                       #:append-description
+                       "This U-Boot variant is for the Technologic Systems
+TS-7970 revision C board, which includes a quad core Freescale i.MX6 CPU and 2
+GiB of RAM clocked at 1000MHz.  The binary U-Boot image to flash is the
+@file{libexec/u-boot.imx} file."))
+
 (define-public vboot-utils
   (package
     (name "vboot-utils")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument.
  2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  2022-12-02  5:30 ` [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
  2022-12-07 15:01 ` [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
@ 2022-12-14  2:32 ` Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 2/4] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
                     ` (2 more replies)
  2022-12-20 18:22 ` [bug#59761] [PATCH v4 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-14  2:32 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

And have that u-boot argument used as the complete base of the template, so
that a user can override it.

* gnu/packages/bootloaders.scm (make-u-boot-package): New U-BOOT argument.
Document it.
[native-inputs]: Move the native-inputs of U-BOOT first, so that the
cross compilation tools can be overridden via U-BOOT.
[arguments]: Rewrite using substitute-keyword-arguments, extending rather than
overriding most arguments.  Use gexps.
---
 gnu/packages/bootloaders.scm | 180 +++++++++++++++++++----------------
 1 file changed, 97 insertions(+), 83 deletions(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 8888c51736..7ec9bbb543 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -17,6 +17,7 @@
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -782,11 +783,13 @@ (define*-public (make-u-boot-package board triplet
                                      defconfig
                                      configs
                                      name-suffix
-                                     append-description)
+                                     append-description
+                                     (u-boot u-boot))
   "Return a U-Boot package for BOARD cross-compiled for TRIPLET with the
 optional DEFCONFIG file and optional configuration changes from CONFIGS.
 NAME-SUFFIX is appended to the package name, while APPEND-DESCRIPTION is
-appended to the package description."
+appended to the package description.  U-BOOT can be used when a fork or a
+different version of U-Boot must be used."
   (let ((same-arch? (lambda ()
                       (string=? (%current-system)
                                 (gnu-triplet->nix-system triplet)))))
@@ -801,90 +804,101 @@ (define*-public (make-u-boot-package board triplet
                                       "\n\n" append-description)
                        (package-description u-boot)))
       (native-inputs
-       `(,@(if (not (same-arch?))
+       ;; Note: leave the native u-boot inputs first, so that a user can
+       ;; override the cross-gcc and cross-binutils packages.
+       `(,@(package-native-inputs u-boot)
+         ,@(if (not (same-arch?))
                `(("cross-gcc" ,(cross-gcc triplet))
                  ("cross-binutils" ,(cross-binutils triplet)))
-               `())
-         ,@(package-native-inputs u-boot)))
+               `())))
       (arguments
-       `(#:modules ((ice-9 ftw)
-                    (srfi srfi-1)
-                    (guix build gnu-build-system)
-                    (guix build kconfig)
-                    (guix build utils))
-         #:imported-modules (,@%gnu-build-system-modules
-                             (guix build kconfig))
-         #:test-target "test"
-         #:make-flags
-         (list "HOSTCC=gcc"
-               ,@(if (not (same-arch?))
-                     `((string-append "CROSS_COMPILE=" ,triplet "-"))
-                     '()))
-         #:phases
-         (modify-phases %standard-phases
-           (replace 'configure
-             (lambda* (#:key outputs make-flags #:allow-other-keys)
-               (let* ((config-name (string-append ,board "_defconfig"))
-                      (config-file (string-append "configs/" config-name))
-                      (defconfig ,defconfig)
-                      (configs ',configs))
-                 (when defconfig
-                   ;; Replace the board-specific defconfig with the given one.
-                   (copy-file defconfig config-file))
-                 (if (file-exists? config-file)
-                     (begin
-                       (when configs
-                         (modify-defconfig config-file configs))
-                       (apply invoke "make" `(,@make-flags ,config-name))
-                       (verify-config ".config" config-file))
-                     (begin
-                       (display "invalid board name; valid board names are:"
-                                (current-error-port))
-                       (let ((suffix-len (string-length "_defconfig"))
-                             (entries (scandir "configs")))
-                         (for-each (lambda (file-name)
-                                     (when (string-suffix? "_defconfig" file-name)
-                                       (format (current-error-port)
-                                               "- ~A\n"
-                                               (string-drop-right file-name
-                                                                  suffix-len))))
-                                   (sort entries string-ci<)))
-                       (error "invalid boardname ~s" ,board))))))
-           (add-after 'configure 'disable-tools-libcrypto
-             ;; Disable libcrypto due to GPL and OpenSSL license
-             ;; incompatibilities
-             (lambda _
-               (substitute* ".config"
-                 (("CONFIG_TOOLS_LIBCRYPTO=.*$") "CONFIG_TOOLS_LIBCRYPTO=n"))))
-           (replace 'install
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (libexec (string-append out "/libexec"))
-                      (uboot-files (append
-                                    (remove
-                                     ;; Those would not be reproducible
-                                     ;; because of the randomness used
-                                     ;; to produce them.
-                                     ;; It's expected that the user will
-                                     ;; use u-boot-tools to generate them
-                                     ;; instead.
-                                     (lambda (name)
-                                       (string-suffix?
-                                        "sunxi-spl-with-ecc.bin"
-                                        name))
-                                     (find-files "." ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
-                                    (find-files "." "^(MLO|SPL)$"))))
-                 (mkdir-p libexec)
-                 (install-file ".config" libexec)
-                 ;; Useful for "qemu -kernel".
-                 (install-file "u-boot" libexec)
-                 (for-each
-                  (lambda (file)
-                    (let ((target-file (string-append libexec "/" file)))
-                      (mkdir-p (dirname target-file))
-                      (copy-file file target-file)))
-                  uboot-files)
-                 #t)))))))))
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:modules modules '())
+          `((ice-9 ftw)
+            (srfi srfi-1)
+            (guix build gnu-build-system)
+            (guix build kconfig)
+            (guix build utils)
+            ,@modules))
+         ((#:imported-modules imported-modules '())
+          `((guix build kconfig)
+            ,@%gnu-build-system-modules
+            ,@imported-modules))
+         ((#:test-target _ "test")
+          "test")
+         ((#:make-flags make-flags '())
+          #~(list "HOSTCC=gcc"
+                  #$@(if (not (same-arch?))
+                         (list (string-append "CROSS_COMPILE=" triplet "-"))
+                         '())
+                  #$@make-flags))
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (replace 'configure
+                (lambda* (#:key outputs make-flags #:allow-other-keys)
+                  (let* ((config-name (string-append #$board "_defconfig"))
+                         (config-file (string-append "configs/" config-name))
+                         (defconfig #$defconfig)
+                         (configs '#$configs))
+                    (when defconfig
+                      ;; Replace the board-specific defconfig with the given
+                      ;; one.
+                      (copy-file defconfig config-file))
+                    (if (file-exists? config-file)
+                        (begin
+                          (when configs
+                            (modify-defconfig config-file configs))
+                          (apply invoke "make" `(,@make-flags ,config-name))
+                          (verify-config ".config" config-file))
+                        (begin
+                          (display "invalid board name; valid board names are:"
+                                   (current-error-port))
+                          (let ((suffix-len (string-length "_defconfig"))
+                                (entries (scandir "configs")))
+                            (for-each (lambda (file-name)
+                                        (when (string-suffix? "_defconfig"
+                                                              file-name)
+                                          (format (current-error-port)
+                                                  "- ~A\n"
+                                                  (string-drop-right
+                                                   file-name suffix-len))))
+                                      (sort entries string-ci<)))
+                          (error "invalid boardname ~s" #$board))))))
+              (add-after 'configure 'disable-tools-libcrypto
+                ;; Disable libcrypto due to GPL and OpenSSL license
+                ;; incompatibilities
+                (lambda _
+                  (substitute* ".config"
+                    (("CONFIG_TOOLS_LIBCRYPTO=.*$")
+                     "CONFIG_TOOLS_LIBCRYPTO=n"))))
+              (replace 'install
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let ((libexec (string-append #$output "/libexec"))
+                        (uboot-files
+                         (append
+                          (remove
+                           ;; Those would not be reproducible
+                           ;; because of the randomness used to
+                           ;; produce them.  It's expected that the
+                           ;; user will use u-boot-tools to generate
+                           ;; them instead.
+                           (lambda (name)
+                             (string-suffix?
+                              "sunxi-spl-with-ecc.bin"
+                              name))
+                           (find-files "."
+                                       ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
+                          (find-files "." "^(MLO|SPL)$"))))
+                    (mkdir-p libexec)
+                    (install-file ".config" libexec)
+                    ;; Useful for "qemu -kernel".
+                    (install-file "u-boot" libexec)
+                    (for-each
+                     (lambda (file)
+                       (let ((target-file (string-append libexec "/" file)))
+                         (mkdir-p (dirname target-file))
+                         (copy-file file target-file)))
+                     uboot-files)))))))))))
 
 (define-public u-boot-malta
   (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))

base-commit: 0ffa501f2b3e83ae56e9c2bd31418439090e869a
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v3 2/4] gnu: make-u-boot-package: Install .imx files.
  2022-12-14  2:32 ` [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
@ 2022-12-14  2:32   ` Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 3/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 4/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
  2 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-14  2:32 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/packages/bootloaders.scm
(make-u-boot-package) [phases] <install>: Add imx to the regexp of files
considered for installation.
---
 gnu/packages/bootloaders.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 7ec9bbb543..ab2cf06fd5 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -887,7 +887,7 @@ (define*-public (make-u-boot-package board triplet
                               "sunxi-spl-with-ecc.bin"
                               name))
                            (find-files "."
-                                       ".*\\.(bin|efi|img|spl|itb|dtb|rksd)$"))
+                                       ".*\\.(bin|efi|img|imx|spl|itb|dtb|rksd)$"))
                           (find-files "." "^(MLO|SPL)$"))))
                     (mkdir-p libexec)
                     (install-file ".config" libexec)
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v3 3/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-14  2:32 ` [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 2/4] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
@ 2022-12-14  2:32   ` Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 4/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
  2 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-14  2:32 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/packages/bootloaders.scm (u-boot-ts-mx6): New variable.
(u-boot-ts7970-q-2g-1000mhz-c): Likewise.
---
 gnu/packages/bootloaders.scm | 150 +++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index ab2cf06fd5..02c1c1a17a 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1271,6 +1271,156 @@ (define-public u-boot-rpi-4-32b-efi-bin
 (define-public u-boot-rpi-arm64-efi-bin
   (make-u-boot-bin-package u-boot-rpi-arm64-efi))
 
+(define u-boot-ts-mx6
+  ;; There is no release; use the latest commit of the
+  ;; 'imx_v2015.04_3.14.52_1.1.0_ga' branch.
+  (let ((revision "0")
+        (commit "344403c64d93813fce8c6d94ed4c3ffb1fe2a181"))
+    (package
+      (inherit u-boot)
+      (name "u-boot-ts-mx6")
+      (version (git-version "2015.04_3" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/embeddedTS/u-boot-imx")
+                      (commit commit)))
+                (file-name (git-file-name "u-boot-imx-ts" version))
+                (sha256
+                 (base32
+                  "081swfz204dsy0nss4r55b8453w766yp2wgrh5y10l3gjc0fkrs1"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'patch-u-boot
+                (lambda _
+                  (substitute* (find-files "include/configs" "^ts[0-9]{4}\\.h$")
+                    ;; Default to boot a standard zImage instead of a uImage.
+                    (("/boot/uImage")
+                     "/boot/zImage")
+                    (("uimage")
+                     "zimage")
+                    (("bootm \\$\\{loadaddr}")
+                     "bootz ${loadaddr}")
+                    ;; This reference DTB is not available in mainline.
+                    (("ts7970-revf.dtb")
+                     "ts7970.dtb")
+                    ;; Enable support for DISTRO_DEFAULTS, which enables to
+                    ;; use 'sysboot' to boot Guix System.  Also enable
+                    ;; "standard" boot commands for dealing with discovery and
+                    ;; booting of syslinux configurations (extlinux.conf).
+
+                    ;; Disable the stock CONFIG_BOOTCOMMAND to avoid a
+                    ;; redefinition error.
+                    (("CONFIG_BOOTCOMMAND")
+                     "CONFIG_BOOTCOMMAND_DISABLED")
+                    (("CONFIG_BOOTDELAY")
+                     "CONFIG_BOOTDELAY_DISABLED")
+                    ;; Inspired by include/configs/embestmx6boards.h
+                    (("#define CONFIG_EXTRA_ENV_SETTINGS.*" anchor)
+                     (string-append
+                      "#include <config_distro_defaults.h>\n\n"
+                      "#define MEM_LAYOUT_ENV_SETTINGS \\\n"
+                      "	\"bootm_size=0x10000000\\0\" \\\n"
+                      "	\"kernel_addr_r=0x10800000\\0\" \\\n"
+                      "	\"fdt_addr_r=0x18000000\\0\" \\\n"
+                      "	\"scriptaddr=0x18100000\\0\" \\\n"
+                      "	\"pxefile_addr_r=0x18200000\\0\" \\\n"
+                      "	\"ramdisk_addr_r=0x18300000\\0\"\n\n"
+                      "#define BOOT_TARGET_DEVICES(func) \\\n"
+                      "	func(MMC, mmc, 0) \\\n"
+                      "	func(MMC, mmc, 1) \\\n"
+                      "	func(SATA, sata, 0) \\\n"
+                      "	func(USB, usb, 0) \\\n"
+                      "	func(PXE, pxe, na) \\\n"
+                      "	func(DHCP, dhcp, na)\n\n"
+                      "#include <config_distro_bootcmd.h>\n\n"
+                      anchor
+                      ;; Sadly, the user config CONFIG_DEFAULT_FDT_FILE did
+                      ;; not exist in that older U-Boot, a placeholder is
+                      ;; added here, to be substituted in each TS U-Boot board
+                      ;; package.
+                      "        \"fdtfile=DEFAULT_FDT_FILE\\0\" \\\n"
+                      "        MEM_LAYOUT_ENV_SETTINGS \\\n"
+                      "        BOOTENV \\\n")))))
+              (add-after 'unpack 'patch-for-reproducibility
+                (lambda _
+                  ;; Substitute dynamically computed timestamps with static
+                  ;; ones.
+                  (substitute* "Makefile"
+                    (("U_BOOT_DATE \"%b %d %C%y\"")
+                     "U_BOOT_DATE \"Jan 01 1969\"")
+                    (("U_BOOT_TIME \"%T\"")
+                     "U_BOOT_TIME \"00:00:00\""))))
+              (add-before 'build 'adjust-for-gcc10
+                (lambda _
+                  (copy-file "include/linux/compiler-gcc6.h"
+                             "include/linux/compiler-gcc10.h")
+                  (substitute* "arch/arm/Makefile"
+                    (("march=armv5")
+                     "march=armv5te"))))
+              (add-after 'install 'build+install-tools
+                (lambda* (#:key make-flags #:allow-other-keys)
+                  ;; Apply a trivial patch not backported from mainline to fix
+                  ;; cross-compilation of tools (see:
+                  ;; https://source.denx.de/u-boot/u-boot/-/commit/
+                  ;; 3b0825296aeba69c2cbfd3e179db2e9cbe5e70d7).
+                  (substitute* '("tools/Makefile" "tools/env/Makefile")
+                    (("^HOSTCC = \\$\\(CC)" all)
+                     (string-append "override " all)))
+                  (apply invoke "make" "tools-all" make-flags)
+                  (install-file "tools/env/fw_printenv"
+                                (string-append #$output "/bin"))
+                  (symlink (string-append #$output "/bin/fw_printenv")
+                           (string-append #$output "/bin/fw_setenv"))))))))
+      (native-inputs
+       (modify-inputs (package-native-inputs u-boot)
+         (delete "dtc"))))))            ;otherwise the build fails
+
+(define-public u-boot-ts7970-q-2g-1000mhz-c
+  (let ((base
+         (make-u-boot-package "ts7970-q-2g-1000mhz-c" "arm-linux-gnueabihf"
+                              #:u-boot u-boot-ts-mx6
+                              #:append-description
+                              "This U-Boot variant is for the Technologic
+Systems TS-7970 revision C board, which includes a quad core Freescale i.MX6
+CPU and 2 GiB of RAM clocked at 1000MHz.  The binary U-Boot image to flash is
+the @file{libexec/u-boot.imx} file.  It can be used with the @file{zImage} and
+the @file{imx6q-ts7970.dtb} files provided by the
+@code{linux-libre-arm-generic} image.
+
+To flash this bootloader, write it to an SD card, then using the U-Boot serial
+console:
+@example
+mmc dev 0
+load mmc 0:1 ${loadaddr} /u-boot.imx
+sf probe
+sf erase 0 0x80000
+sf write ${loadaddr} 0x400 $filesize
+@end example
+
+The factory values of U-Boot must also be reset so that it boots using a
+zImage instead of the default uImage:
+@example
+run clearenv
+reset
+@end example
+
+For more information, refer to
+@url{https://docs.embeddedts.com/TS-7970#Update_U-Boot}.")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'patch-u-boot 'set-default-fdt-file
+                (lambda _
+                  (substitute* "include/configs/ts7970.h"
+                    (("DEFAULT_FDT_FILE")
+                     "imx6q-ts7970.dtb")))))))))))
+
 (define-public vboot-utils
   (package
     (name "vboot-utils")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v3 4/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader.
  2022-12-14  2:32 ` [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 2/4] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
  2022-12-14  2:32   ` [bug#59761] [PATCH v3 3/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
@ 2022-12-14  2:32   ` Maxim Cournoyer
  2 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-14  2:32 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/bootloader/u-boot.scm (u-boot-ts7970-q-2g-1000mhz-c-bootloader): New
variable.
---
 gnu/bootloader/u-boot.scm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 6cad33b741..65d7923465 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,6 +43,7 @@ (define-module (gnu bootloader u-boot)
             u-boot-puma-rk3399-bootloader
             u-boot-rock64-rk3328-bootloader
             u-boot-rockpro64-rk3399-bootloader
+            u-boot-ts7970-q-2g-1000mhz-c-bootloader
             u-boot-wandboard-bootloader))
 
 (define install-u-boot
@@ -127,6 +129,12 @@ (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))))
+
 \f
 
 ;;;
@@ -255,3 +263,13 @@ (define u-boot-pinebook-pro-rk3399-bootloader
    (inherit u-boot-bootloader)
    (package u-boot-pinebook-pro-rk3399)
    (disk-image-installer install-pinebook-pro-rk3399-u-boot)))
+
+(define u-boot-ts7970-q-2g-1000mhz-c-bootloader
+  ;; This bootloader doesn't really need to be installed, as it is read from
+  ;; an SPI memory chip, not the SD card.  It is copied to /boot/u-boot.imx
+  ;; for convenience and should be manually flashed at the U-Boot prompt.
+  (bootloader
+   (inherit u-boot-bootloader)
+   (package u-boot-ts7970-q-2g-1000mhz-c)
+   (installer install-u-boot-ts7970-q-2g-1000mhz-c-u-boot)
+   (disk-image-installer #f)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v4 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
                   ` (2 preceding siblings ...)
  2022-12-14  2:32 ` [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
@ 2022-12-20 18:22 ` Maxim Cournoyer
  2022-12-20 18:22   ` [bug#59761] [PATCH v4 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
  2022-12-29 19:33 ` [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Ricardo Wurmus
  2023-01-04  5:32 ` [bug#59761] [PATCH v5 1/2] gnu: " Maxim Cournoyer
  5 siblings, 1 reply; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-20 18:22 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/packages/bootloaders.scm (u-boot-ts-mx6): New variable.
(u-boot-ts7970-q-2g-1000mhz-c): Likewise.
---

(no changes since v1)

 gnu/packages/bootloaders.scm | 150 +++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 738f3975f5..545803ece1 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1251,6 +1251,156 @@ (define-public u-boot-rpi-4-32b-efi-bin
 (define-public u-boot-rpi-arm64-efi-bin
   (make-u-boot-bin-package u-boot-rpi-arm64-efi))
 
+(define u-boot-ts-mx6
+  ;; There is no release; use the latest commit of the
+  ;; 'imx_v2015.04_3.14.52_1.1.0_ga' branch.
+  (let ((revision "0")
+        (commit "344403c64d93813fce8c6d94ed4c3ffb1fe2a181"))
+    (package
+      (inherit u-boot)
+      (name "u-boot-ts-mx6")
+      (version (git-version "2015.04_3" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/embeddedTS/u-boot-imx")
+                      (commit commit)))
+                (file-name (git-file-name "u-boot-imx-ts" version))
+                (sha256
+                 (base32
+                  "081swfz204dsy0nss4r55b8453w766yp2wgrh5y10l3gjc0fkrs1"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'patch-u-boot
+                (lambda _
+                  (substitute* (find-files "include/configs" "^ts[0-9]{4}\\.h$")
+                    ;; Default to boot a standard zImage instead of a uImage.
+                    (("/boot/uImage")
+                     "/boot/zImage")
+                    (("uimage")
+                     "zimage")
+                    (("bootm \\$\\{loadaddr}")
+                     "bootz ${loadaddr}")
+                    ;; This reference DTB is not available in mainline.
+                    (("ts7970-revf.dtb")
+                     "ts7970.dtb")
+                    ;; Enable support for DISTRO_DEFAULTS, which enables to
+                    ;; use 'sysboot' to boot Guix System.  Also enable
+                    ;; "standard" boot commands for dealing with discovery and
+                    ;; booting of syslinux configurations (extlinux.conf).
+
+                    ;; Disable the stock CONFIG_BOOTCOMMAND to avoid a
+                    ;; redefinition error.
+                    (("CONFIG_BOOTCOMMAND")
+                     "CONFIG_BOOTCOMMAND_DISABLED")
+                    (("CONFIG_BOOTDELAY")
+                     "CONFIG_BOOTDELAY_DISABLED")
+                    ;; Inspired by include/configs/embestmx6boards.h
+                    (("#define CONFIG_EXTRA_ENV_SETTINGS.*" anchor)
+                     (string-append
+                      "#include <config_distro_defaults.h>\n\n"
+                      "#define MEM_LAYOUT_ENV_SETTINGS \\\n"
+                      "	\"bootm_size=0x10000000\\0\" \\\n"
+                      "	\"kernel_addr_r=0x10800000\\0\" \\\n"
+                      "	\"fdt_addr_r=0x18000000\\0\" \\\n"
+                      "	\"scriptaddr=0x18100000\\0\" \\\n"
+                      "	\"pxefile_addr_r=0x18200000\\0\" \\\n"
+                      "	\"ramdisk_addr_r=0x18300000\\0\"\n\n"
+                      "#define BOOT_TARGET_DEVICES(func) \\\n"
+                      "	func(MMC, mmc, 0) \\\n"
+                      "	func(MMC, mmc, 1) \\\n"
+                      "	func(SATA, sata, 0) \\\n"
+                      "	func(USB, usb, 0) \\\n"
+                      "	func(PXE, pxe, na) \\\n"
+                      "	func(DHCP, dhcp, na)\n\n"
+                      "#include <config_distro_bootcmd.h>\n\n"
+                      anchor
+                      ;; Sadly, the user config CONFIG_DEFAULT_FDT_FILE did
+                      ;; not exist in that older U-Boot, a placeholder is
+                      ;; added here, to be substituted in each TS U-Boot board
+                      ;; package.
+                      "        \"fdtfile=DEFAULT_FDT_FILE\\0\" \\\n"
+                      "        MEM_LAYOUT_ENV_SETTINGS \\\n"
+                      "        BOOTENV \\\n")))))
+              (add-after 'unpack 'patch-for-reproducibility
+                (lambda _
+                  ;; Substitute dynamically computed timestamps with static
+                  ;; ones.
+                  (substitute* "Makefile"
+                    (("U_BOOT_DATE \"%b %d %C%y\"")
+                     "U_BOOT_DATE \"Jan 01 1969\"")
+                    (("U_BOOT_TIME \"%T\"")
+                     "U_BOOT_TIME \"00:00:00\""))))
+              (add-before 'build 'adjust-for-gcc10
+                (lambda _
+                  (copy-file "include/linux/compiler-gcc6.h"
+                             "include/linux/compiler-gcc10.h")
+                  (substitute* "arch/arm/Makefile"
+                    (("march=armv5")
+                     "march=armv5te"))))
+              (add-after 'install 'build+install-tools
+                (lambda* (#:key make-flags #:allow-other-keys)
+                  ;; Apply a trivial patch not backported from mainline to fix
+                  ;; cross-compilation of tools (see:
+                  ;; https://source.denx.de/u-boot/u-boot/-/commit/
+                  ;; 3b0825296aeba69c2cbfd3e179db2e9cbe5e70d7).
+                  (substitute* '("tools/Makefile" "tools/env/Makefile")
+                    (("^HOSTCC = \\$\\(CC)" all)
+                     (string-append "override " all)))
+                  (apply invoke "make" "tools-all" make-flags)
+                  (install-file "tools/env/fw_printenv"
+                                (string-append #$output "/bin"))
+                  (symlink (string-append #$output "/bin/fw_printenv")
+                           (string-append #$output "/bin/fw_setenv"))))))))
+      (native-inputs
+       (modify-inputs (package-native-inputs u-boot)
+         (delete "dtc"))))))            ;otherwise the build fails
+
+(define-public u-boot-ts7970-q-2g-1000mhz-c
+  (let ((base
+         (make-u-boot-package "ts7970-q-2g-1000mhz-c" "arm-linux-gnueabihf"
+                              #:u-boot u-boot-ts-mx6
+                              #:append-description
+                              "This U-Boot variant is for the Technologic
+Systems TS-7970 revision C board, which includes a quad core Freescale i.MX6
+CPU and 2 GiB of RAM clocked at 1000MHz.  The binary U-Boot image to flash is
+the @file{libexec/u-boot.imx} file.  It can be used with the @file{zImage} and
+the @file{imx6q-ts7970.dtb} files provided by the
+@code{linux-libre-arm-generic} image.
+
+To flash this bootloader, write it to an SD card, then using the U-Boot serial
+console:
+@example
+mmc dev 0
+load mmc 0:1 ${loadaddr} /u-boot.imx
+sf probe
+sf erase 0 0x80000
+sf write ${loadaddr} 0x400 $filesize
+@end example
+
+The factory values of U-Boot must also be reset so that it boots using a
+zImage instead of the default uImage:
+@example
+run clearenv
+reset
+@end example
+
+For more information, refer to
+@url{https://docs.embeddedts.com/TS-7970#Update_U-Boot}.")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'patch-u-boot 'set-default-fdt-file
+                (lambda _
+                  (substitute* "include/configs/ts7970.h"
+                    (("DEFAULT_FDT_FILE")
+                     "imx6q-ts7970.dtb")))))))))))
+
 (define-public vboot-utils
   (package
     (name "vboot-utils")

base-commit: daaef7858ffe2d0eb0378670a6447400410d1ff9
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v4 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader.
  2022-12-20 18:22 ` [bug#59761] [PATCH v4 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
@ 2022-12-20 18:22   ` Maxim Cournoyer
  0 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2022-12-20 18:22 UTC (permalink / raw)
  To: 59761; +Cc: Maxim Cournoyer

* gnu/bootloader/u-boot.scm (u-boot-ts7970-q-2g-1000mhz-c-bootloader): New
variable.

---

Changes in v4:
- Rebase on top of #60224 and master

 gnu/bootloader/u-boot.scm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 6cad33b741..65d7923465 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,6 +43,7 @@ (define-module (gnu bootloader u-boot)
             u-boot-puma-rk3399-bootloader
             u-boot-rock64-rk3328-bootloader
             u-boot-rockpro64-rk3399-bootloader
+            u-boot-ts7970-q-2g-1000mhz-c-bootloader
             u-boot-wandboard-bootloader))
 
 (define install-u-boot
@@ -127,6 +129,12 @@ (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))))
+
 \f
 
 ;;;
@@ -255,3 +263,13 @@ (define u-boot-pinebook-pro-rk3399-bootloader
    (inherit u-boot-bootloader)
    (package u-boot-pinebook-pro-rk3399)
    (disk-image-installer install-pinebook-pro-rk3399-u-boot)))
+
+(define u-boot-ts7970-q-2g-1000mhz-c-bootloader
+  ;; This bootloader doesn't really need to be installed, as it is read from
+  ;; an SPI memory chip, not the SD card.  It is copied to /boot/u-boot.imx
+  ;; for convenience and should be manually flashed at the U-Boot prompt.
+  (bootloader
+   (inherit u-boot-bootloader)
+   (package u-boot-ts7970-q-2g-1000mhz-c)
+   (installer install-u-boot-ts7970-q-2g-1000mhz-c-u-boot)
+   (disk-image-installer #f)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
                   ` (3 preceding siblings ...)
  2022-12-20 18:22 ` [bug#59761] [PATCH v4 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
@ 2022-12-29 19:33 ` Ricardo Wurmus
  2023-01-04  4:17   ` Maxim Cournoyer
  2023-01-04  5:32 ` [bug#59761] [PATCH v5 1/2] gnu: " Maxim Cournoyer
  5 siblings, 1 reply; 20+ messages in thread
From: Ricardo Wurmus @ 2022-12-29 19:33 UTC (permalink / raw)
  To: 59761

Hi Maxim,

there seems to be some overlap between this and
https://issues.guix.gnu.org/60224.  Looking just at v4 I only have one
comment.

In your substitute* replacements it’s better not to use string-append.
You can include real line breaks in a string and escape line breaks with
\.  This is preferable to gluing strings together.  For something as
long as the replacements in this package consider using a patch file
instead.  This has the added advantage of failing the build when the
patch cannot be applied cleanly.

The rest looks good to me.

-- 
Ricardo




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-29 19:33 ` [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Ricardo Wurmus
@ 2023-01-04  4:17   ` Maxim Cournoyer
  2023-01-04  5:34     ` Maxim Cournoyer
  2023-01-04  7:35     ` Ricardo Wurmus
  0 siblings, 2 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2023-01-04  4:17 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 59761

Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

> Hi Maxim,
>
> there seems to be some overlap between this and
> https://issues.guix.gnu.org/60224.

Yes, I ended up splitting my changes focusing on u-boot in #60224, which
should be reviewed before and blocking this change here, which is based
on it.

> Looking just at v4 I only have one
> comment.
>
> In your substitute* replacements it’s better not to use string-append.

Oh?  Why is this so?  There must be hundreds of string-append occurences
used in such place, so I'm curious.

> You can include real line breaks in a string and escape line breaks with
> \.  This is preferable to gluing strings together.

OK, I guess this is your rationale for the above comment (cleaner).

> For something as
> long as the replacements in this package consider using a patch file
> instead.  This has the added advantage of failing the build when the
> patch cannot be applied cleanly.

I agree that a patch would be most suitable here, especially that if
something breaks, if would likely be silent (unlikely to be caught at
build time).  I'll extract this as a patch.

> The rest looks good to me.

OK.  I'll await your comments on #60224, which is awaiting feedback
post-rework based on your earlier feedback.

PS: I had also missed that email; please keep me in CC in all your
replies :-).

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v5 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.
  2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
                   ` (4 preceding siblings ...)
  2022-12-29 19:33 ` [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Ricardo Wurmus
@ 2023-01-04  5:32 ` Maxim Cournoyer
  2023-01-04  5:32   ` [bug#59761] [PATCH v5 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
  5 siblings, 1 reply; 20+ messages in thread
From: Maxim Cournoyer @ 2023-01-04  5:32 UTC (permalink / raw)
  To: 59761; +Cc: rekado, Maxim Cournoyer

* gnu/packages/bootloaders.scm (u-boot-ts-mx6): New variable.
(u-boot-ts7970-q-2g-1000mhz-c): Likewise.

---

Changes in v5:
- Update package revision to 08809160fbc60d6e949fa9d37d9a41aab8fef742
- Refactor patch-u-boot phase to use single string blocks
- Drop upstreamed patch in build+install-tools phase

 gnu/packages/bootloaders.scm | 148 +++++++++++++++++++++++++++++++++++
 1 file changed, 148 insertions(+)

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 7016b33f4f..22c15d13f1 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1339,6 +1339,154 @@ (define-public u-boot-rpi-4-32b-efi-bin
 (define-public u-boot-rpi-arm64-efi-bin
   (make-u-boot-bin-package u-boot-rpi-arm64-efi))
 
+(define u-boot-ts-mx6
+  ;; There is no release; use the latest commit of the
+  ;; 'imx_v2015.04_3.14.52_1.1.0_ga' branch.
+  (let ((revision "0")
+        (commit "08809160fbc60d6e949fa9d37d9a41aab8fef742"))
+    (package
+      (inherit u-boot)
+      (name "u-boot-ts-mx6")
+      (version (git-version "2015.04_3" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/embeddedTS/u-boot-imx")
+                      (commit commit)))
+                (file-name (git-file-name "u-boot-imx-ts" version))
+                (sha256
+                 (base32
+                  "01mja33351hkcs59rmfvppqlxqw4rh9gng7a7hx2cfspqwh2y6kr"))))
+      (arguments
+       (substitute-keyword-arguments (package-arguments u-boot)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'patch-u-boot
+                (lambda _
+                  (substitute* (find-files "include/configs" "^ts[0-9]{4}\\.h$")
+                    ;; Default to boot a standard zImage instead of a uImage.
+                    (("/boot/uImage")
+                     "/boot/zImage")
+                    (("uimage")
+                     "zimage")
+                    (("bootm \\$\\{loadaddr}")
+                     "bootz ${loadaddr}")
+                    ;; This reference DTB is not available in mainline.
+                    (("ts7970-revf.dtb")
+                     "ts7970.dtb")
+                    ;; Enable support for DISTRO_DEFAULTS, which enables to
+                    ;; use 'sysboot' to boot Guix System.  Also enable
+                    ;; "standard" boot commands for dealing with discovery and
+                    ;; booting of syslinux configurations (extlinux.conf).
+
+                    ;; Disable the stock CONFIG_BOOTCOMMAND to avoid a
+                    ;; redefinition error.
+                    (("CONFIG_BOOTCOMMAND")
+                     "CONFIG_BOOTCOMMAND_DISABLED")
+                    (("CONFIG_BOOTDELAY")
+                     "CONFIG_BOOTDELAY_DISABLED")
+                    ;; Inspired by include/configs/embestmx6boards.h
+                    (("#define CONFIG_EXTRA_ENV_SETTINGS.*" anchor)
+                     (string-append "\
+#include <config_distro_defaults.h>
+
+#define MEM_LAYOUT_ENV_SETTINGS    \\
+\t\"bootm_size=0x10000000\\0\"     \\
+\t\"kernel_addr_r=0x10800000\\0\"  \\
+\t\"fdt_addr_r=0x18000000\\0\"     \\
+\t\"scriptaddr=0x18100000\\0\"     \\
+\t\"pxefile_addr_r=0x18200000\\0\" \\
+\t\"ramdisk_addr_r=0x18300000\\0\"
+
+#define BOOT_TARGET_DEVICES(func)  \\
+\tfunc(MMC, mmc, 0)                \\
+\tfunc(MMC, mmc, 1)                \\
+\tfunc(SATA, sata, 0)              \\
+\tfunc(USB, usb, 0)                \\
+\tfunc(PXE, pxe, na)               \\
+\tfunc(DHCP, dhcp, na)
+
+#include <config_distro_bootcmd.h>
+
+" anchor
+
+;; Sadly, the user config CONFIG_DEFAULT_FDT_FILE did not exist in that older
+;; U-Boot.  A placeholder is added here, to be substituted in each TS U-Boot
+;; board package.
+"\
+\t\"fdtfile=DEFAULT_FDT_FILE\\0\" \\
+\tMEM_LAYOUT_ENV_SETTINGS \\
+\tBOOTENV \\\n")))))
+              (add-after 'unpack 'patch-for-reproducibility
+                (lambda _
+                  ;; Substitute dynamically computed timestamps with static
+                  ;; ones.
+                  (substitute* "Makefile"
+                    (("U_BOOT_DATE \"%b %d %C%y\"")
+                     "U_BOOT_DATE \"Jan 01 1969\"")
+                    (("U_BOOT_TIME \"%T\"")
+                     "U_BOOT_TIME \"00:00:00\""))))
+              (add-before 'build 'adjust-for-gcc10
+                (lambda _
+                  (copy-file "include/linux/compiler-gcc6.h"
+                             "include/linux/compiler-gcc10.h")
+                  (substitute* "arch/arm/Makefile"
+                    (("march=armv5")
+                     "march=armv5te"))))
+              (add-after 'install 'build+install-tools
+                (lambda* (#:key make-flags #:allow-other-keys)
+                  (apply invoke "make" "tools-all" make-flags)
+                  (install-file "tools/env/fw_printenv"
+                                (string-append #$output "/bin"))
+                  (symlink (string-append #$output "/bin/fw_printenv")
+                           (string-append #$output "/bin/fw_setenv"))))))))
+      (native-inputs
+       (modify-inputs (package-native-inputs u-boot)
+         (delete "dtc"))))))            ;otherwise the build fails
+
+(define-public u-boot-ts7970-q-2g-1000mhz-c
+  (let ((base
+         (make-u-boot-package "ts7970-q-2g-1000mhz-c" "arm-linux-gnueabihf"
+                              #:u-boot u-boot-ts-mx6
+                              #:append-description
+                              "This U-Boot variant is for the Technologic
+Systems TS-7970 revision C board, which includes a quad core Freescale i.MX6
+CPU and 2 GiB of RAM clocked at 1000MHz.  The binary U-Boot image to flash is
+the @file{libexec/u-boot.imx} file.  It can be used with the @file{zImage} and
+the @file{imx6q-ts7970.dtb} files provided by the
+@code{linux-libre-arm-generic} image.
+
+To flash this bootloader, write it to an SD card, then using the U-Boot serial
+console:
+@example
+mmc dev 0
+load mmc 0:1 ${loadaddr} /u-boot.imx
+sf probe
+sf erase 0 0x80000
+sf write ${loadaddr} 0x400 $filesize
+@end example
+
+The factory values of U-Boot must also be reset so that it boots using a
+zImage instead of the default uImage:
+@example
+run clearenv
+reset
+@end example
+
+For more information, refer to
+@url{https://docs.embeddedts.com/TS-7970#Update_U-Boot}.")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases '%standard-phases)
+          #~(modify-phases #$phases
+              (add-after 'patch-u-boot 'set-default-fdt-file
+                (lambda _
+                  (substitute* "include/configs/ts7970.h"
+                    (("DEFAULT_FDT_FILE")
+                     "imx6q-ts7970.dtb")))))))))))
+
 (define-public vboot-utils
   (package
     (name "vboot-utils")

base-commit: fef10282afdb97af43d1ec1c0c955a7fdc313e3c
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH v5 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader.
  2023-01-04  5:32 ` [bug#59761] [PATCH v5 1/2] gnu: " Maxim Cournoyer
@ 2023-01-04  5:32   ` Maxim Cournoyer
  2023-01-19  2:30     ` bug#59761: [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
  0 siblings, 1 reply; 20+ messages in thread
From: Maxim Cournoyer @ 2023-01-04  5:32 UTC (permalink / raw)
  To: 59761; +Cc: rekado, Maxim Cournoyer

* gnu/bootloader/u-boot.scm (u-boot-ts7970-q-2g-1000mhz-c-bootloader): New
variable.

---

(no changes since v4)

Changes in v4:
- Rebase on top of #60224 and master

 gnu/bootloader/u-boot.scm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 6cad33b741..65d7923465 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,6 +43,7 @@ (define-module (gnu bootloader u-boot)
             u-boot-puma-rk3399-bootloader
             u-boot-rock64-rk3328-bootloader
             u-boot-rockpro64-rk3399-bootloader
+            u-boot-ts7970-q-2g-1000mhz-c-bootloader
             u-boot-wandboard-bootloader))
 
 (define install-u-boot
@@ -127,6 +129,12 @@ (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))))
+
 \f
 
 ;;;
@@ -255,3 +263,13 @@ (define u-boot-pinebook-pro-rk3399-bootloader
    (inherit u-boot-bootloader)
    (package u-boot-pinebook-pro-rk3399)
    (disk-image-installer install-pinebook-pro-rk3399-u-boot)))
+
+(define u-boot-ts7970-q-2g-1000mhz-c-bootloader
+  ;; This bootloader doesn't really need to be installed, as it is read from
+  ;; an SPI memory chip, not the SD card.  It is copied to /boot/u-boot.imx
+  ;; for convenience and should be manually flashed at the U-Boot prompt.
+  (bootloader
+   (inherit u-boot-bootloader)
+   (package u-boot-ts7970-q-2g-1000mhz-c)
+   (installer install-u-boot-ts7970-q-2g-1000mhz-c-u-boot)
+   (disk-image-installer #f)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
  2023-01-04  4:17   ` Maxim Cournoyer
@ 2023-01-04  5:34     ` Maxim Cournoyer
  2023-01-04  7:35     ` Ricardo Wurmus
  1 sibling, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2023-01-04  5:34 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 59761

Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

>> For something as
>> long as the replacements in this package consider using a patch file
>> instead.  This has the added advantage of failing the build when the
>> patch cannot be applied cleanly.
>
> I agree that a patch would be most suitable here, especially that if
> something breaks, if would likely be silent (unlikely to be caught at
> build time).  I'll extract this as a patch.

After re-diving into the code, I opted to kept it as a substitution
given it affects multiple config files in the same way, and would make a
large, redundant patch.  I cleaned it up per your suggestions (see v5).

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
  2023-01-04  4:17   ` Maxim Cournoyer
  2023-01-04  5:34     ` Maxim Cournoyer
@ 2023-01-04  7:35     ` Ricardo Wurmus
  2023-01-04 14:46       ` Maxim Cournoyer
  1 sibling, 1 reply; 20+ messages in thread
From: Ricardo Wurmus @ 2023-01-04  7:35 UTC (permalink / raw)
  To: Maxim Cournoyer; +Cc: 59761


> PS: I had also missed that email; please keep me in CC in all your
> replies :-).

Oh, that’s odd.  I’m replying “from scratch” going just by the bug
number in issues.guix.gnu.org; it doesn’t expose your email address in a
convenient way, so I usually just grab the issue number and write an
email.

Shouldn’t debbugs Cc you when receiving comments on your patch
submission?

-- 
Ricardo




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
  2023-01-04  7:35     ` Ricardo Wurmus
@ 2023-01-04 14:46       ` Maxim Cournoyer
  0 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2023-01-04 14:46 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: 59761

Hi Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

>> PS: I had also missed that email; please keep me in CC in all your
>> replies :-).
>
> Oh, that’s odd.  I’m replying “from scratch” going just by the bug
> number in issues.guix.gnu.org; it doesn’t expose your email address in a
> convenient way, so I usually just grab the issue number and write an
> email.
>
> Shouldn’t debbugs Cc you when receiving comments on your patch
> submission?

It would be nice if it did, but I don't think it does.  Also, the
'X-Debbugs-Cc' header used in teams.scm doesn't seem to cause an actual
CC; I think it'd just cause someone not already subscribed to the
guix-patches mailing list to be sent an email.  I think it'd be better
to simply use git-send-email's '--cc', or both.

My Gnus email filter is based on the Return-Path:

--8<---------------cut here---------------start------------->8---
	   (nnimap-split-methods
	    ;; Filter guix mailing lists based on Return
	    (("list.\\1" "^Return-Path: <\\(.*\\)-bounces.*@\\(non\\)?gnu.org>")
             ("list.\\1" "^Return-Path: <\\(.*\\)-bounces.*@lists.denx.de>")
             ("list.\\1" "^Return-Path: <\\(.*\\)-owner@vger.kernel.org>")
	     ("INBOX" "")))
--8<---------------cut here---------------end--------------->8---

I think when Cc: is used in an email, it causes the Return-Path to be
that of the person sending the email rather than mailman's email, which
is what the above filter expects.

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#59761: [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c.
  2023-01-04  5:32   ` [bug#59761] [PATCH v5 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
@ 2023-01-19  2:30     ` Maxim Cournoyer
  0 siblings, 0 replies; 20+ messages in thread
From: Maxim Cournoyer @ 2023-01-19  2:30 UTC (permalink / raw)
  To: 59761-done; +Cc: rekado

Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

> * gnu/bootloader/u-boot.scm (u-boot-ts7970-q-2g-1000mhz-c-bootloader): New
> variable.
>
> ---
>
> (no changes since v4)
>
> Changes in v4:
> - Rebase on top of #60224 and master
>
>  gnu/bootloader/u-boot.scm | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Now applied!

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-01-19  2:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02  5:29 [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-02  5:30 ` [bug#59761] [PATCH 1/2] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
2022-12-02  5:30   ` [bug#59761] [PATCH 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-07 15:01 ` [bug#59761] [PATCH v2 1/3] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
2022-12-07 15:02   ` [bug#59761] [PATCH v2 2/3] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2022-12-07 15:02   ` [bug#59761] [PATCH v2 3/3] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-14  2:32 ` [bug#59761] [PATCH v3 1/4] gnu: make-u-boot-package: Add a u-boot argument Maxim Cournoyer
2022-12-14  2:32   ` [bug#59761] [PATCH v3 2/4] gnu: make-u-boot-package: Install .imx files Maxim Cournoyer
2022-12-14  2:32   ` [bug#59761] [PATCH v3 3/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-14  2:32   ` [bug#59761] [PATCH v3 4/4] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
2022-12-20 18:22 ` [bug#59761] [PATCH v4 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer
2022-12-20 18:22   ` [bug#59761] [PATCH v4 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
2022-12-29 19:33 ` [bug#59761] [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Ricardo Wurmus
2023-01-04  4:17   ` Maxim Cournoyer
2023-01-04  5:34     ` Maxim Cournoyer
2023-01-04  7:35     ` Ricardo Wurmus
2023-01-04 14:46       ` Maxim Cournoyer
2023-01-04  5:32 ` [bug#59761] [PATCH v5 1/2] gnu: " Maxim Cournoyer
2023-01-04  5:32   ` [bug#59761] [PATCH v5 2/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c-bootloader Maxim Cournoyer
2023-01-19  2:30     ` bug#59761: [PATCH 0/2] Add u-boot-ts7970-q-2g-1000mhz-c Maxim Cournoyer

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.