Subject: [bug#45584] [PATCH 0/2] system: image: Fix root fs corruption from certain u-boot.

From: Caliph Nomble <[email-masked]>
Date: Sun, 10 Jan 2021 00:48:33 +0000

Hi,

Sorry for the late response. I just got a chance to test on a pinebook-pro, and
was able to use a generated image on it. Screen wouldn't turn on but I got a
functioning shell on serial; I was still just using mainline
linux-libre-arm64-generic so I don't think that's a bootloader problem.

> Here's an attached patch that should do that, but I'm not sure it brings
> a real improvement, unless there are a lot of different offset out
> there.

I'm all for extensability, so that sounds good to me.

Over the past few days I've been playing with u-boot, and I think that the
install offset may be configurable, with the current offset just being used for
compatability with Rockchip's proprietary miniloader. I could make a patchset
to move u-boot up and test it out on the pinebook-pro and rockpro64, if that
would be a better solution?

Thanks!
From 2c0806c28ae5ca07cba136ce2e32a7de0702693d Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <[email-masked]>
Date: Sat, 2 Jan 2021 17:56:25 +0100
Subject: [PATCH] offset

---
 gnu/system/image.scm               | 12 ++++++------
 gnu/system/images/novena.scm       |  2 +-
 gnu/system/images/pine64.scm       |  2 +-
 gnu/system/images/pinebook-pro.scm |  4 +++-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 67930750d5..90b9209988 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -128,21 +128,21 @@
            (label "GUIX_IMAGE")
            (flags '(boot)))))))
 
-(define arm32-disk-image
+(define* (arm32-disk-image #:optional (offset root-offset))
   (image
    (format 'disk-image)
    (target "arm-linux-gnueabihf")
    (partitions
     (list (partition
            (inherit root-partition)
-           (offset root-offset))))
+           (offset offset))))
    ;; FIXME: Deleting and creating "/var/run" and "/tmp" on the overlayfs
    ;; fails.
    (volatile-root? #f)))
 
-(define arm64-disk-image
+(define* (arm64-disk-image #:optional (offset root-offset))
   (image
-   (inherit arm32-disk-image)
+   (inherit (arm32-disk-image offset))
    (target "aarch64-linux-gnu")))
 
 
@@ -189,12 +189,12 @@ set to the given OS."
 (define arm32-image-type
   (image-type
    (name 'arm32-raw)
-   (constructor (cut image-with-os arm32-disk-image <>))))
+   (constructor (cut image-with-os (arm32-disk-image) <>))))
 
 (define arm64-image-type
   (image-type
    (name 'arm64-raw)
-   (constructor (cut image-with-os arm64-disk-image <>))))
+   (constructor (cut image-with-os (arm64-disk-image) <>))))
 
 
 ;;
diff --git a/gnu/system/images/novena.scm b/gnu/system/images/novena.scm
index c4d25e850e..dfaf2c60ee 100644
--- a/gnu/system/images/novena.scm
+++ b/gnu/system/images/novena.scm
@@ -52,7 +52,7 @@
 (define novena-image-type
   (image-type
    (name 'novena-raw)
-   (constructor (cut image-with-os arm32-disk-image <>))))
+   (constructor (cut image-with-os (arm32-disk-image) <>))))
 
 (define novena-barebones-raw-image
   (image
diff --git a/gnu/system/images/pine64.scm b/gnu/system/images/pine64.scm
index f0b0c3f50d..63b31399a5 100644
--- a/gnu/system/images/pine64.scm
+++ b/gnu/system/images/pine64.scm
@@ -57,7 +57,7 @@
 (define pine64-image-type
   (image-type
    (name 'pine64-raw)
-   (constructor (cut image-with-os arm64-disk-image <>))))
+   (constructor (cut image-with-os (arm64-disk-image) <>))))
 
 (define pine64-barebones-raw-image
   (image
diff --git a/gnu/system/images/pinebook-pro.scm b/gnu/system/images/pinebook-pro.scm
index b038e262cb..02a0b8132d 100644
--- a/gnu/system/images/pinebook-pro.scm
+++ b/gnu/system/images/pinebook-pro.scm
@@ -57,7 +57,9 @@
 (define pinebook-pro-image-type
   (image-type
    (name 'pinebook-pro-raw)
-   (constructor (cut image-with-os arm64-disk-image <>))))
+   (constructor (cut image-with-os
+                     (arm64-disk-image (* 9 (expt 2 20))) ;9MiB
+                     <>))))
 
 (define pinebook-pro-barebones-raw-image
   (image
-- 
2.29.2