Subject: [bug#72987] [PATCH v3 4/5] gnu: bootloader: Add orangepi-zero2w bootloader.

From: Herman Rimm <[email-masked]>
Date: Fri, 13 Dec 2024 22:07:35 +0100

* gnu/bootloader/u-boot.scm (u-boot-orangepi-zero2w-bootloader): Add
variable.
* gnu/packages/bootloaders.scm (u-boot-orangepi-zero2w): Add variable.
* gnu/packages/firmware.scm (arm-trusted-firmware-sun50i-h616): Add
variable.

Change-Id: Idb43fdabac51b3301f3bea24fec72bfa29636489
---
 gnu/bootloader/u-boot.scm    |  6 ++++++
 gnu/packages/bootloaders.scm | 18 ++++++++++++++++++
 gnu/packages/firmware.scm    |  3 +++
 3 files changed, 27 insertions(+)

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 9c7df3b40f..52527ab0db 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -42,6 +42,7 @@ (define-module (gnu bootloader u-boot)
             u-boot-nintendo-nes-classic-edition-bootloader
             u-boot-novena-bootloader
             u-boot-orangepi-r1-plus-lts-rk3328-bootloader
+            u-boot-orangepi-zero2w-bootloader
             u-boot-pine64-plus-bootloader
             u-boot-pine64-lts-bootloader
             u-boot-pinebook-bootloader
@@ -231,6 +232,11 @@ (define u-boot-orangepi-r1-plus-lts-rk3328-bootloader
    (inherit u-boot-rockchip-bootloader)
    (package u-boot-orangepi-r1-plus-lts-rk3328)))
 
+(define u-boot-orangepi-zero2w-bootloader
+  (bootloader
+   (inherit u-boot-allwinner-bootloader)
+   (package u-boot-orangepi-zero2w)))
+
 (define u-boot-pine64-plus-bootloader
   (bootloader
    (inherit u-boot-allwinner64-bootloader)
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index d946270317..b91ff00e28 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -1204,6 +1204,24 @@ (define*-public (make-u-boot-sunxi64-package board triplet scp-firmware
        (modify-inputs (package-inputs base)
          (append arm-trusted-firmware-sun50i-a64))))))
 
+(define-public u-boot-orangepi-zero2w
+  (let ((base (make-u-boot-package
+               "orangepi_zero2w" "aarch64-linux-gnu")))
+    (package
+      (inherit base)
+      (arguments
+       (substitute-keyword-arguments (package-arguments base)
+         ((#:phases phases)
+          #~(modify-phases #$phases
+              (add-after 'unpack 'set-environment
+                (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                  (setenv "SCP" "/dev/null")
+                  (setenv "BL31" (search-input-file inputs "bl31.bin"))))))))
+      (inputs
+       (modify-inputs (package-inputs base)
+         ;; The Zero 2W uses the slightly revised Allwinner H618.
+         (append arm-trusted-firmware-sun50i-h616))))))
+
 (define-public u-boot-pine64-plus
   (make-u-boot-sunxi64-package "pine64_plus" "aarch64-linux-gnu"
                                (delay crust-pine64-plus)))
diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index 868be8488c..d89b136c86 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -1168,6 +1168,9 @@ (define-public arm-trusted-firmware-sun50i-a64
       (inherit base)
       (name "arm-trusted-firmware-sun50i-a64"))))
 
+(define-public arm-trusted-firmware-sun50i-h616
+  (make-arm-trusted-firmware "sun50i_h616"))
+
 (define-public arm-trusted-firmware-rk3328
   (make-arm-trusted-firmware "rk3328"))
 
-- 
2.45.2