Subject: [bug#49552] [PATCH] gnu: u-boot: Update to 2021.07.

From: Pierre Langlois <[email-masked]>
Date: Mon, 26 Jul 2021 11:54:29 +0100

Hi!

Vagrant Cascadian writes:

> On 2021-07-25, Mathieu Othacehe wrote:
>>> * gnu/packages/bootloaders.scm (u-boot): Update to 2021.07.
>>> [native-inputs]: Add python-pycryptodomex.
>>> (u-boot-2021.07): Delete variable.
>>> (u-boot-tools)[arguments]: Adapt 'patch phase, disable failing test_spl test.
>>> (u-boot-sifive-unmatched): Use default u-boot package.
>>> (u-boot-pinebook-pro-rk3328): Use default u-boot package.
>>
>> This seems fine to me, Vagrant any objections here?
>
> Heh. Just uploaded 2021.07 to Debian last night! Been meaning to look at
> updating in guix, but apparently someone beat me to it :)
>
> Overall, sounds fine to me, with one relatively minor change...
>
> u-boot-sifive-unmatched will need a pretty trivial patch in order to
> update to 2021.07:
>
>   https://bugs.launchpad.net/ubuntu/+source/u-boot/+bug/1937246
>   https://salsa.debian.org/debian/u-boot/-/blob/debian/latest/debian/patches/riscv64/unmatched-prevent-relocating-initrd-and-fdt.patch
>
> At least, it did when building on Debian (and apparently Ubuntu)...

Sure, I've added the patch! I don't have any HW to test sifive unmatched
support though, I did test the update on a pinebookpro and rockpro64
when originally posting this, the new patch shouldn't affect them.

That being said, while it works on pinebookpro, I still need an extra
patch on the rockpro64 in order to boot, both on master with u-boot
2021.07 :-/ (see #49550).

Were you able to confirm the issue? I see it looks like we have the same
configuration in debian and guix, CONFIG_USE_PREBOOT=y and the
"inno-usb" patch applied, mmmm

Thanks,
Pierre

>From 8a7b8f0b85a69fff085bd07da6777c1ebca31f74 Mon Sep 17 00:00:00 2001
From: Pierre Langlois <[email-masked]>
Date: Sat, 10 Jul 2021 14:12:02 +0100
Subject: [PATCH] gnu: u-boot: Update to 2021.07.

* gnu/packages/patches/u-boot-sifive-prevent-relocating-initrd-fdt.patch: New patch.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/bootloaders.scm (u-boot): Update to 2021.07.
[native-inputs]: Add python-pycryptodomex.
(u-boot-2021.07): Delete variable.
(u-boot-tools)[arguments]: Adapt 'patch phase, disable failing test_spl test.
(u-boot-sifive-unmatched): Use default u-boot package.
(u-boot-pinebook-pro-rk3328): Use default u-boot package.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/bootloaders.scm                  | 48 ++++++++-----------
 ...sifive-prevent-relocating-initrd-fdt.patch | 16 +++++++
 3 files changed, 36 insertions(+), 29 deletions(-)
 create mode 100644 gnu/packages/patches/u-boot-sifive-prevent-relocating-initrd-fdt.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b944c671af..495a94a988 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1772,6 +1772,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/tuxpaint-stamps-path.patch		\
   %D%/packages/patches/twinkle-bcg729.patch			\
   %D%/packages/patches/u-boot-rockchip-inno-usb.patch		\
+  %D%/packages/patches/u-boot-sifive-prevent-relocating-initrd-fdt.patch	\
   %D%/packages/patches/u-boot-riscv64-fix-extlinux.patch	\
   %D%/packages/patches/ucx-tcp-iface-ioctl.patch		\
   %D%/packages/patches/udiskie-no-appindicator.patch		\
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 742992a119..09125b1582 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -12,7 +12,7 @@
 ;;; Copyright © 2019 Mathieu Othacehe <[email-masked]>
 ;;; Copyright © 2020 Björn Höfling <[email-masked]>
 ;;; Copyright © 2018, 2019, 2020 Vagrant Cascadian <[email-masked]>
-;;; Copyright © 2020 Pierre Langlois <[email-masked]>
+;;; Copyright © 2020, 2021 Pierre Langlois <[email-masked]>
 ;;; Copyright © 2021 Vincent Legoll <[email-masked]>
 ;;; Copyright © 2021 Brice Waegeneire <[email-masked]>
 ;;;
@@ -56,6 +56,7 @@
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-crypto)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages sdl)
@@ -493,20 +494,26 @@ tree binary files.  These are board description files used by Linux and BSD.")
   ;; and https://patchwork.ozlabs.org/project/uboot/patch/[email-masked]
   (search-patch "u-boot-rockchip-inno-usb.patch"))
 
+(define %u-boot-sifive-prevent-relocating-initrd-fdt
+  ;; Fix boot in 2021.07 on Hifive unmatched, see
+  ;; https://bugs.launchpad.net/ubuntu/+source/u-boot/+bug/1937246
+  (search-patch "u-boot-sifive-prevent-relocating-initrd-fdt.patch"))
+
 (define u-boot
   (package
     (name "u-boot")
-    (version "2021.04")
+    (version "2021.07")
     (source (origin
 	      (patches
-               (list %u-boot-rockchip-inno-usb-patch))
+               (list %u-boot-rockchip-inno-usb-patch
+                     %u-boot-sifive-prevent-relocating-initrd-fdt))
               (method url-fetch)
               (uri (string-append
                     "https://ftp.denx.de/pub/u-boot/"
                     "u-boot-" version ".tar.bz2"))
               (sha256
                (base32
-                "06p1vymf0dl6jc2xy5w7p42mpgppa46lmpm2ishmgsycnldqnhqd"))))
+                "0zm7igkdnz0w4ir8rfl2dislfrl0ip104grs5hvd30a5wkm7wari"))))
     (native-inputs
      `(("bc" ,bc)
        ("bison" ,bison)
@@ -516,6 +523,7 @@ tree binary files.  These are board description files used by Linux and BSD.")
        ("perl" ,perl)
        ("python" ,python)
        ("python-coverage" ,python-coverage)
+       ("python-pycryptodomex" ,python-pycryptodomex)
        ("python-pytest" ,python-pytest)
        ("swig" ,swig)))
     (build-system  gnu-build-system)
@@ -525,21 +533,6 @@ tree binary files.  These are board description files used by Linux and BSD.")
 also initializes the boards (RAM etc).")
     (license license:gpl2+)))
 
-(define-public u-boot-2021.07
-  (package
-   (inherit u-boot)
-   (version "2021.07-rc4")
-   (source (origin
-             (patches
-               (list %u-boot-rockchip-inno-usb-patch))
-            (method url-fetch)
-            (uri (string-append
-                  "https://ftp.denx.de/pub/u-boot/"
-                  "u-boot-" version ".tar.bz2"))
-            (sha256
-             (base32
-              "0bnsywgy2b0jxim5h9dc807lqk5kq8hvgf4lcsmffnc0hf4isv8p"))))))
-
 (define-public u-boot-tools
   (package
     (inherit u-boot)
@@ -568,9 +561,12 @@ also initializes the boards (RAM etc).")
               ;; This test would require git.
               (("\\./tools/patman/patman") (which "true"))
               ;; FIXME: test fails, needs further investiation
-              (("run_test \"binman\"") ": run_test \"binman\"")
+              (("run_test \"binman\"") "# run_test \"binman\"")
+              ;; FIXME: test_spl fails, needs further investiation
+              (("test_ofplatdata or test_handoff or test_spl")
+                "test_ofplatdata or test_handoff")
               ;; FIXME: code coverage not working
-              (("run_test \"binman code coverage\"") ": run_test \"binman code coverage\"")
+              (("run_test \"binman code coverage\"") "# run_test \"binman code coverage\"")
               ;; This test would require internet access.
               (("\\./tools/buildman/buildman") (which "true")))
              (substitute* "test/py/tests/test_sandbox_exit.py"
@@ -879,11 +875,7 @@ to Novena upstream, does not load u-boot.img from the first partition.")
   (make-u-boot-package "sifive_fu540" "riscv64-linux-gnu"))
 
 (define-public u-boot-sifive-unmatched
-  (let ((base (make-u-boot-package "sifive_unmatched" "riscv64-linux-gnu")))
-    (package
-      (inherit base)
-      (version (package-version u-boot-2021.07))
-      (source (package-source u-boot-2021.07)))))
+  (make-u-boot-package "sifive_unmatched" "riscv64-linux-gnu"))
 
 (define-public u-boot-rock64-rk3328
   (let ((base (make-u-boot-package "rock64-rk3328" "aarch64-linux-gnu")))
@@ -946,9 +938,7 @@ to Novena upstream, does not load u-boot.img from the first partition.")
 (define-public u-boot-pinebook-pro-rk3399
   (let ((base (make-u-boot-package "pinebook-pro-rk3399" "aarch64-linux-gnu")))
     (package
-     (inherit base)
-      (version (package-version u-boot-2021.07))
-      (source (package-source u-boot-2021.07))
+      (inherit base)
       (arguments
         (substitute-keyword-arguments (package-arguments base)
           ((#:phases phases)
diff --git a/gnu/packages/patches/u-boot-sifive-prevent-relocating-initrd-fdt.patch b/gnu/packages/patches/u-boot-sifive-prevent-relocating-initrd-fdt.patch
new file mode 100644
index 0000000000..a5b92e3e8f
--- /dev/null
+++ b/gnu/packages/patches/u-boot-sifive-prevent-relocating-initrd-fdt.patch
@@ -0,0 +1,16 @@
+Description: prevent relocating initrd & fdt, that results in failure to boot
+Author: Heinrich Schuchardt (xypron)
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/u-boot/+bug/1937246
+Index: u-boot-2021.07~rc4+dfsg/include/configs/sifive-unmatched.h
+===================================================================
+--- u-boot-2021.07~rc4+dfsg.orig/include/configs/sifive-unmatched.h
++++ u-boot-2021.07~rc4+dfsg/include/configs/sifive-unmatched.h
+@@ -62,6 +62,8 @@
+ 	"name=system,size=-,bootable,type=${type_guid_gpt_system};"
+ 
+ #define CONFIG_EXTRA_ENV_SETTINGS \
++	"fdt_high=0xffffffffffffffff\0" \
++	"initrd_high=0xffffffffffffffff\0" \
+ 	"kernel_addr_r=0x84000000\0" \
+ 	"fdt_addr_r=0x88000000\0" \
+ 	"scriptaddr=0x88100000\0" \
-- 
2.32.0