Subject: [bug#45584] [PATCH 1/2] system: image: Add support for rockchip bootloader offsets.

From: Caliph Nomble <[email-masked]>
Date: Fri, 01 Jan 2021 01:11:49 +0000

* gnu/system/image.scm (root-largeboot-offset, arm32-largeboot-disk-image,
arm32-largeboot-image-type): New variables, used primarily to define...
(arm64-largeboot-disk-image,
arm64-largeboot-image-type): ...these new variables.
---
 gnu/system/image.scm | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 67930750d5..58d92cf4b6 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -59,6 +59,7 @@
   #:use-module (ice-9 format)
   #:use-module (ice-9 match)
   #:export (root-offset
+            root-largeboot-offset
             root-label
 
             esp-partition
@@ -67,7 +68,9 @@
             efi-disk-image
             iso9660-image
             arm32-disk-image
+            arm32-largeboot-disk-image
             arm64-disk-image
+            arm64-largeboot-disk-image
 
             image-with-os
             raw-image-type
@@ -75,7 +78,9 @@
             iso-image-type
             uncompressed-iso-image-type
             arm32-image-type
+            arm32-largeboot-image-type
             arm64-image-type
+            arm64-largeboot-image-type
 
             image-with-label
             system-image
@@ -92,6 +97,10 @@
 ;; this post-MBR gap.
 (define root-offset (* 512 2048))
 
+;; Same as above, except 9MB big. Necessary for eg. rk3399 and rk3328
+;; systems, which install the bootloader at an 8MB offset.
+(define root-largeboot-offset (+ root-offset (* 8 (expt 2 20))))
+
 ;; Generic root partition label.
 (define root-label "Guix_image")
 
@@ -140,11 +149,24 @@
    ;; fails.
    (volatile-root? #f)))
 
+(define arm32-largeboot-disk-image
+  (image
+   (inherit arm32-disk-image)
+   (partitions
+    (list (partition
+           (inherit root-partition)
+           (offset root-largeboot-offset))))))
+
 (define arm64-disk-image
   (image
    (inherit arm32-disk-image)
    (target "aarch64-linux-gnu")))
 
+(define arm64-largeboot-disk-image
+  (image
+   (inherit arm32-largeboot-disk-image)
+   (target "aarch64-linux-gnu")))
+
 
 ;;;
 ;;; Images types.
@@ -191,11 +213,21 @@ set to the given OS."
    (name 'arm32-raw)
    (constructor (cut image-with-os arm32-disk-image <>))))
 
+(define arm32-largeboot-image-type
+  (image-type
+   (name 'arm32-largeboot-raw)
+   (constructor (cut image-with-os arm32-largeboot-disk-image <>))))
+
 (define arm64-image-type
   (image-type
    (name 'arm64-raw)
    (constructor (cut image-with-os arm64-disk-image <>))))
 
+(define arm64-largeboot-image-type
+  (image-type
+   (name 'arm64-largeboot-raw)
+   (constructor (cut image-with-os arm64-largeboot-disk-image <>))))
+
 
 ;;
 ;; Helpers.
-- 
2.26.2