Subject: [bug#59761] [PATCH v2 3/3] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 7 Dec 2022 10:02:01 -0500

* 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