Subject: Re: [bug#31404] Add installer support for u-boot imx6 boards.

From: Mathieu Othacehe <[email-masked]>
Date: Fri, 11 May 2018 09:53:45 +0200

Hi Vagrant,

Great to see GuixSD ported to new ARM boards, good job!

> It should be noted that the offsets for installing u-boot.img on imx6
> targets conflict with a typical GPT partition table header; works fine
> with dos partition table headers. I'm not sure what safeguards could be
> added to detect that. This also may not be unique to imx6 targets
> (e.g. pine64 u-boot/atf also has a similar issue).

We could maybe check in install procedures if the partition table is
DOS/GPT before installing and abort if the wrong type is detected?

> Also, the novena patch has a known flaw, in that it requires copying the
> u-boot.img file to the first partition rather than writing it to a raw
> offset on the mmc device.
>
> Not sure how to handle that exactly, as partitioning is typically a
> manual process in guixsd?

In the case the GuixSD installation is done directly on the target we
could try to locate the first partition, it's mount point and copy
u-boot.img at the correct location. As it sounds quite complicated, the
best option in my opinion is not to try to install u-boot on novena.

You could also add a comment explaining why the bootloader is not
installed and what does it take to make it work.

Otherwise this seems fine to me.

Thanks,

Mathieu

> Vagrant Cascadian (3):
>   system: Add mx6cuboxi installer.
>   system: Add wandboard installer.
>   gnu: Add u-boot-novena installer.
>
>  gnu/bootloader/u-boot.scm    | 34 +++++++++++++++++++++++++++++++++-
>  gnu/packages/bootloaders.scm |  3 +++
>  gnu/system/install.scm       | 20 +++++++++++++++++++-
>  3 files changed, 55 insertions(+), 2 deletions(-)
>
> -- 
> 2.17.0
>
> From 39b8f64e964c2a88d6f0bcbb5dcfa2ccb194793f Mon Sep 17 00:00:00 2001
> From: Vagrant Cascadian <[email-masked]>
> Date: Mon, 7 May 2018 14:32:02 +0000
> Subject: [PATCH 1/3] system: Add mx6cuboxi installer.
>
> * gnu/bootloader/u-boot.scm (u-boot-mx6cuboxi-bootloader):
>   New exported variable.
> * gnu/system/install.scm (mx6cuboxi-installation-os):
>   New exported variable.
> ---
>  gnu/bootloader/u-boot.scm | 20 ++++++++++++++++++++
>  gnu/system/install.scm    |  6 ++++++
>  2 files changed, 26 insertions(+)
>
> diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
> index 21d0aecce..58ee528a2 100644
> --- a/gnu/bootloader/u-boot.scm
> +++ b/gnu/bootloader/u-boot.scm
> @@ -33,6 +33,7 @@
>              u-boot-a20-olinuxino-micro-bootloader
>              u-boot-banana-pi-m2-ultra-bootloader
>              u-boot-beaglebone-black-bootloader
> +            u-boot-mx6cuboxi-bootloader
>              u-boot-nintendo-nes-classic-edition-bootloader))
>  
>  (define install-u-boot
> @@ -62,6 +63,15 @@
>          (write-file-on-device u-boot (stat:size (stat u-boot))
>                                device (* 8 1024)))))
>  
> +(define install-imx-u-boot
> +  #~(lambda (bootloader device mount-point)
> +      (let ((spl (string-append bootloader "/libexec/SPL"))
> +            (u-boot (string-append bootloader "/libexec/u-boot.img")))
> +        (write-file-on-device spl (stat:size (stat spl))
> +                              device (* 1 1024))
> +        (write-file-on-device u-boot (stat:size (stat u-boot))
> +                              device (* 69 1024)))))
> +
>  
>  
>  ;;;
> @@ -86,6 +96,11 @@
>     (inherit u-boot-bootloader)
>     (installer install-allwinner-u-boot)))
>  
> +(define u-boot-imx-bootloader
> +  (bootloader
> +   (inherit u-boot-bootloader)
> +   (installer install-imx-u-boot)))
> +
>  (define u-boot-nintendo-nes-classic-edition-bootloader
>    (bootloader
>      (inherit u-boot-allwinner-bootloader)
> @@ -110,3 +125,8 @@
>    (bootloader
>     (inherit u-boot-allwinner-bootloader)
>     (package u-boot-banana-pi-m2-ultra)))
> +
> +(define u-boot-mx6cuboxi-bootloader
> +  (bootloader
> +   (inherit u-boot-imx-bootloader)
> +   (package u-boot-mx6cuboxi)))
> diff --git a/gnu/system/install.scm b/gnu/system/install.scm
> index 920d21527..7580d981b 100644
> --- a/gnu/system/install.scm
> +++ b/gnu/system/install.scm
> @@ -49,6 +49,7 @@
>              a20-olinuxino-micro-installation-os
>              banana-pi-m2-ultra-installation-os
>              beaglebone-black-installation-os
> +            mx6cuboxi-installation-os
>              nintendo-nes-classic-edition-installation-os))
>  
>  ;;; Commentary:
> @@ -429,6 +430,11 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
>                              "/dev/mmcblk1" ; eMMC storage
>                              "ttyS0"))
>  
> +(define mx6cuboxi-installation-os
> +  (embedded-installation-os u-boot-mx6cuboxi-bootloader
> +                            "/dev/mmcblk0" ; SD card storage
> +                            "ttymxc0"))
> +
>  (define nintendo-nes-classic-edition-installation-os
>    (embedded-installation-os u-boot-nintendo-nes-classic-edition-bootloader
>                              "/dev/mmcblk0" ; SD card (solder it yourself)
> -- 
> 2.17.0
>
> From 4b552cb1c4cd1df18278a2b5b63aac4ca7337140 Mon Sep 17 00:00:00 2001
> From: Vagrant Cascadian <[email-masked]>
> Date: Mon, 7 May 2018 14:34:43 +0000
> Subject: [PATCH 2/3] system: Add wandboard installer.
>
> * gnu/bootloader/u-boot.scm (u-boot-wandboard-bootloader):
>   New exported variable.
> * gnu/system/install.scm (wandboard-installation-os):
>   New exported variable.
> ---
>  gnu/bootloader/u-boot.scm | 8 +++++++-
>  gnu/system/install.scm    | 8 +++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
> index 58ee528a2..9a62a166f 100644
> --- a/gnu/bootloader/u-boot.scm
> +++ b/gnu/bootloader/u-boot.scm
> @@ -34,7 +34,8 @@
>              u-boot-banana-pi-m2-ultra-bootloader
>              u-boot-beaglebone-black-bootloader
>              u-boot-mx6cuboxi-bootloader
> -            u-boot-nintendo-nes-classic-edition-bootloader))
> +            u-boot-nintendo-nes-classic-edition-bootloader
> +            u-boot-wandboard-bootloader))
>  
>  (define install-u-boot
>    #~(lambda (bootloader device mount-point)
> @@ -130,3 +131,8 @@
>    (bootloader
>     (inherit u-boot-imx-bootloader)
>     (package u-boot-mx6cuboxi)))
> +
> +(define u-boot-wandboard-bootloader
> +  (bootloader
> +   (inherit u-boot-imx-bootloader)
> +   (package u-boot-wandboard)))
> diff --git a/gnu/system/install.scm b/gnu/system/install.scm
> index 7580d981b..9bb1d8145 100644
> --- a/gnu/system/install.scm
> +++ b/gnu/system/install.scm
> @@ -50,7 +50,8 @@
>              banana-pi-m2-ultra-installation-os
>              beaglebone-black-installation-os
>              mx6cuboxi-installation-os
> -            nintendo-nes-classic-edition-installation-os))
> +            nintendo-nes-classic-edition-installation-os
> +            wandboard-installation-os))
>  
>  ;;; Commentary:
>  ;;;
> @@ -440,6 +441,11 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
>                              "/dev/mmcblk0" ; SD card (solder it yourself)
>                              "ttyS0"))
>  
> +(define wandboard-installation-os
> +  (embedded-installation-os u-boot-wandboard-bootloader
> +                            "/dev/mmcblk0" ; SD card storage
> +                            "ttymxc0"))
> +
>  ;; Return the default os here so 'guix system' can consume it directly.
>  installation-os
>  
> -- 
> 2.17.0
>
> From 71cb0f715cf48bf703a8607f72088783b685d418 Mon Sep 17 00:00:00 2001
> From: Vagrant Cascadian <[email-masked]>
> Date: Wed, 9 May 2018 06:59:10 +0000
> Subject: [PATCH 3/3] gnu: Add u-boot-novena installer.
>
> * gnu/packages/bootloaders.scm (u-boot-novena):
>   New variable.
> * gnu/bootloader/u-boot.scm (u-boot-novena-bootloader):
>   New exported variable.
> * gnu/system/install.scm (novena-installation-os):
>   New exported variable.
> ---
>  gnu/bootloader/u-boot.scm    | 6 ++++++
>  gnu/packages/bootloaders.scm | 3 +++
>  gnu/system/install.scm       | 6 ++++++
>  3 files changed, 15 insertions(+)
>
> diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
> index 9a62a166f..bc8f98f32 100644
> --- a/gnu/bootloader/u-boot.scm
> +++ b/gnu/bootloader/u-boot.scm
> @@ -35,6 +35,7 @@
>              u-boot-beaglebone-black-bootloader
>              u-boot-mx6cuboxi-bootloader
>              u-boot-nintendo-nes-classic-edition-bootloader
> +            u-boot-novena-bootloader
>              u-boot-wandboard-bootloader))
>  
>  (define install-u-boot
> @@ -136,3 +137,8 @@
>    (bootloader
>     (inherit u-boot-imx-bootloader)
>     (package u-boot-wandboard)))
> +
> +(define u-boot-novena-bootloader
> +  (bootloader
> +   (inherit u-boot-imx-bootloader)
> +   (package u-boot-novena)))
> diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
> index 0db6ad3f6..c0a0101c5 100644
> --- a/gnu/packages/bootloaders.scm
> +++ b/gnu/packages/bootloaders.scm
> @@ -469,6 +469,9 @@ also initializes the boards (RAM etc).")
>  (define-public u-boot-mx6cuboxi
>    (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
>  
> +(define-public u-boot-novena
> +  (make-u-boot-package "novena" "arm-linux-gnueabihf"))
> +
>  (define-public vboot-utils
>    (package
>      (name "vboot-utils")
> diff --git a/gnu/system/install.scm b/gnu/system/install.scm
> index 9bb1d8145..a2917e485 100644
> --- a/gnu/system/install.scm
> +++ b/gnu/system/install.scm
> @@ -51,6 +51,7 @@
>              beaglebone-black-installation-os
>              mx6cuboxi-installation-os
>              nintendo-nes-classic-edition-installation-os
> +            novena-installation-os
>              wandboard-installation-os))
>  
>  ;;; Commentary:
> @@ -436,6 +437,11 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
>                              "/dev/mmcblk0" ; SD card storage
>                              "ttymxc0"))
>  
> +(define novena-installation-os
> +  (embedded-installation-os u-boot-novena-bootloader
> +                            "/dev/mmcblk1" ; SD card storage
> +                            "ttymxc1"))
> +
>  (define nintendo-nes-classic-edition-installation-os
>    (embedded-installation-os u-boot-nintendo-nes-classic-edition-bootloader
>                              "/dev/mmcblk0" ; SD card (solder it yourself)