unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 59761@debbugs.gnu.org
Cc: rekado@elephly.net, Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#59761] [PATCH v5 1/2] gnu: Add u-boot-ts7970-q-2g-1000mhz-c.
Date: Wed,  4 Jan 2023 00:32:33 -0500	[thread overview]
Message-ID: <20230104053234.4540-1-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20221202052903.10475-1-maxim.cournoyer@gmail.com>

* 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





  parent reply	other threads:[~2023-01-04  5:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Maxim Cournoyer [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230104053234.4540-1-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=59761@debbugs.gnu.org \
    --cc=rekado@elephly.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).