[PATCH 0/4] Generalize bootloader installer selection.

OpenSubmitted by Danny Milosavljevic.
Details
3 participants
  • Danny Milosavljevic
  • Jelle Licht
  • Ludovic Courtès
Owner
unassigned
Severity
normal
D
D
Danny Milosavljevic wrote on 11 May 2018 16:35
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180511143515.23435-1-dannym@scratchpost.org
Danny Milosavljevic (4):
system: Add os-with-u-boot.
bootloader: install-u-boot: Automatically select the correct
installer.
bootloader: Add make-u-boot-bootloader.
bootloader: Simplify bootloader installer selection.

doc/guix.texi | 21 ++++++++
gnu/bootloader/u-boot.scm | 88 ++++++++-----------------------
gnu/packages/bootloaders.scm | 4 +-
gnu/system/examples/beaglebone-black.tmpl | 2 +-
gnu/system/install.scm | 33 ++++++++----
5 files changed, 70 insertions(+), 78 deletions(-)
D
D
Danny Milosavljevic wrote on 11 May 2018 16:36
[PATCH 1/4] system: Add os-with-u-boot.
(address . 31416@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180511143652.26935-1-dannym@scratchpost.org
* gnu/system/install.scm (os-with-u-boot): New procedure.
* gnu/packages/bootloaders.scm (make-u-boot-package): Export.
* doc/guix.texi (Building the Installation Image for ARM boards): New
subsection.
---
doc/guix.texi | 21 +++++++++++++++++++++
gnu/packages/bootloaders.scm | 2 +-
gnu/system/install.scm | 16 +++++++++++++++-
3 files changed, 37 insertions(+), 2 deletions(-)

Toggle diff (79 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 637c9c3f4..b2b173ded 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8733,6 +8733,27 @@ Have a look at @file{gnu/system/install.scm} in the source tree,
 and see also @ref{Invoking guix system} for more information
 about the installation image.
 
+@subsection Building the Installation Image for ARM boards
+
+Many ARM boards require a board-specific bootloader in order to boot.
+
+If you build an entire disk image and the is not still available otherwise
+(on another available drive etc), it's advisable to build an image that
+includes the bootloader, specifically:
+
+@example
+guix system disk-image --system=armhf-linux -e '((@ (gnu system install) os-with-u-boot) (@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
+@end example
+
+Or if you don't cross compile:
+
+@example
+guix system disk-image -e '((@ (gnu system install) os-with-u-boot) (@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
+@end example
+
+"A20-OLinuXino-Lime2" is the name of the board.  If you specify an invalid
+board, you get a list.
+
 @node System Configuration
 @section System Configuration
 
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index c0a0101c5..526e53384 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -359,7 +359,7 @@ tree binary files.  These are board description files used by Linux and BSD.")
 also initializes the boards (RAM etc).")
     (license license:gpl2+)))
 
-(define (make-u-boot-package board triplet)
+(define-public (make-u-boot-package board triplet)
   "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
   (let ((same-arch? (if (string-prefix? (%current-system)
                                         (gnu-triplet->nix-system triplet))
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index a2917e485..b563e8b5b 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -52,7 +52,8 @@
             mx6cuboxi-installation-os
             nintendo-nes-classic-edition-installation-os
             novena-installation-os
-            wandboard-installation-os))
+            wandboard-installation-os
+            os-with-u-boot))
 
 ;;; Commentary:
 ;;;
@@ -386,6 +387,19 @@ You have been warned.  Thanks for being so brave.\x1b[0m
                      nvi                          ;:wq!
                      %base-packages))))
 
+(define* (os-with-u-boot os board #:key (bootloader-target "/dev/mmcblk0")
+                         (triplet "arm-linux-gnueabihf"))
+  "Given OS, amend it with the u-boot bootloader for BOARD,
+installed to BOOTLOADER-TARGET (a drive), compiled for TRIPLET.
+
+If you want a serial console, make sure to specify one in your
+operating-system's kernel-arguments (\"console=ttyS0\" or similar)."
+  (operating-system (inherit os)
+    (bootloader (bootloader-configuration
+                 (bootloader (bootloader (inherit u-boot-bootloader)
+                              (package (make-u-boot-package board triplet))))
+                 (target bootloader-target)))))
+
 (define* (embedded-installation-os bootloader bootloader-target tty
                                    #:key (extra-modules '()))
   "Return an installation os for embedded systems.
D
D
Danny Milosavljevic wrote on 11 May 2018 16:36
[PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer.
(address . 31416@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180511143652.26935-2-dannym@scratchpost.org
* gnu/bootloader/u-boot.scm (install-u-boot): Automatically select the correct
installer.
---
gnu/bootloader/u-boot.scm | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

Toggle diff (30 lines)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index bc8f98f32..e0941c961 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -41,7 +41,24 @@
 (define install-u-boot
   #~(lambda (bootloader device mount-point)
       (if bootloader
-        (error "Failed to install U-Boot"))))
+        (let* ((config-file-name (string-append bootloader "/libexec/.config"))
+               (soc (call-with-input-file config-file-name
+                                          (let loop ((line (read-line port)))
+                                            (if (not (eof-object? line))
+                                                (let ((match
+                                                       (string-match
+                                                        "^CONFIG_SYS_SOC=\"([^\"]*)\""
+                                                        line)))
+                                                  (if match
+                                                      (match:substring match 1)
+                                                      (loop (read-line port))))
+                                                #f)))))
+          (match soc
+           ("am33xx" (install-beaglebone-black-u-boot bootloader device mount-point))
+           ("mx6" (install-imx-u-boot bootloader device mount-point))
+           ("sunxi" (install-allwinner-u-boot bootloader device mount-point))
+           (_ (error "Failed to install U-Boot (no installation method found)"
+                     soc)))))))
 
 (define install-beaglebone-black-u-boot
   ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
D
D
Danny Milosavljevic wrote on 11 May 2018 16:36
[PATCH 3/4] bootloader: Add make-u-boot-bootloader.
(address . 31416@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180511143652.26935-3-dannym@scratchpost.org
* gnu/bootloader/u-boot.scm (make-u-boot-bootloader): New procedure.
(u-boot-allwinner-bootloader): Delete variable.
(u-boot-imx-bootloader): Delete variable.
(u-boot-beaglebone-black-bootloader): Modify.
(u-boot-nintendo-nes-classic-edition-bootloader): Modify.
(u-boot-a20-olinuxino-lime-bootloader): Modify.
(u-boot-a20-olinuxino-lime2-bootloader): Modify.
(u-boot-a20-olinuxino-micro-bootloader): Modify.
(u-boot-banana-pi-m2-ultra-bootloader): Modify.
(u-boot-mx6cuboxi-bootloader): Modify.
(u-boot-wandboard-bootloader): Modify.
(u-boot-novena-bootloader): Modify.
---
gnu/bootloader/u-boot.scm | 54 ++++++++++++++---------------------------------
1 file changed, 16 insertions(+), 38 deletions(-)

Toggle diff (87 lines)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index e0941c961..feda17f99 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -36,7 +36,8 @@
             u-boot-mx6cuboxi-bootloader
             u-boot-nintendo-nes-classic-edition-bootloader
             u-boot-novena-bootloader
-            u-boot-wandboard-bootloader))
+            u-boot-wandboard-bootloader
+            make-u-boot-bootloader))
 
 (define install-u-boot
   #~(lambda (bootloader device mount-point)
@@ -104,58 +105,35 @@
    (package #f)
    (installer install-u-boot)))
 
-(define u-boot-beaglebone-black-bootloader
-  (bootloader
-   (inherit u-boot-bootloader)
-   (package u-boot-beagle-bone-black)
-   (installer install-beaglebone-black-u-boot)))
-
-(define u-boot-allwinner-bootloader
+(define (make-u-boot-bootloader bootloader-package)
+  "Given BOOTLOADER-PACKAGE, make a bootloader that can install."
   (bootloader
-   (inherit u-boot-bootloader)
-   (installer install-allwinner-u-boot)))
+    (inherit u-boot-bootloader)
+    (package bootloader-package)))
 
-(define u-boot-imx-bootloader
-  (bootloader
-   (inherit u-boot-bootloader)
-   (installer install-imx-u-boot)))
+(define u-boot-beaglebone-black-bootloader
+  (make-u-boot-bootloader u-boot-beagle-bone-black))
 
 (define u-boot-nintendo-nes-classic-edition-bootloader
-  (bootloader
-    (inherit u-boot-allwinner-bootloader)
-    (package u-boot-nintendo-nes-classic-edition)))
+  (make-u-boot-bootloader u-boot-nintendo-nes-classic-edition))
 
 (define u-boot-a20-olinuxino-lime-bootloader
-  (bootloader
-   (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-lime)))
+  (make-u-boot-bootloader u-boot-a20-olinuxino-lime))
 
 (define u-boot-a20-olinuxino-lime2-bootloader
-  (bootloader
-   (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-lime2)))
+  (make-u-boot-bootloader u-boot-a20-olinuxino-lime2))
 
 (define u-boot-a20-olinuxino-micro-bootloader
-  (bootloader
-   (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-micro)))
+  (make-u-boot-bootloader u-boot-a20-olinuxino-micro))
 
 (define u-boot-banana-pi-m2-ultra-bootloader
-  (bootloader
-   (inherit u-boot-allwinner-bootloader)
-   (package u-boot-banana-pi-m2-ultra)))
+  (make-u-boot-bootloader u-boot-banana-pi-m2-ultra))
 
 (define u-boot-mx6cuboxi-bootloader
-  (bootloader
-   (inherit u-boot-imx-bootloader)
-   (package u-boot-mx6cuboxi)))
+  (make-u-boot-bootloader u-boot-mx6cuboxi))
 
 (define u-boot-wandboard-bootloader
-  (bootloader
-   (inherit u-boot-imx-bootloader)
-   (package u-boot-wandboard)))
+  (make-u-boot-bootloader u-boot-wandboard))
 
 (define u-boot-novena-bootloader
-  (bootloader
-   (inherit u-boot-imx-bootloader)
-   (package u-boot-novena)))
+  (make-u-boot-bootloader u-boot-novena))
D
D
Danny Milosavljevic wrote on 11 May 2018 16:36
[PATCH 4/4] bootloader: Simplify bootloader installer selection.
(address . 31416@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20180511143652.26935-4-dannym@scratchpost.org
* gnu/bootloader/u-boot.scm (u-boot-bootloader): Delete variable.
(u-boot-a20-olinuxino-lime-bootloader): Delete variable.
(u-boot-a20-olinuxino-lime2-bootloader): Delete variable.
(u-boot-a20-olinuxino-micro-bootloader): Delete variable.
(u-boot-banana-pi-m2-ultra-bootloader): Delete variable.
(u-boot-beaglebone-black-bootloader): Delete variable.
(u-boot-mx6cuboxi-bootloader): Delete variable.
(u-boot-nintendo-nes-classic-edition-bootloader): Delete variable.
(u-boot-novena-bootloader): Delete variable.
(u-boot-wandboard-bootloader): Delete variable.
* gnu/packages/bootloader.scm (u-boot-beagle-bone-black): Rename to...
(u-boot-beaglebone-black): ...this.
* gnu/system/examples/beaglebone-black.tmpl: Use make-u-boot-bootloader.
* gnu/system/install.scm (os-with-u-boot): Use make-u-boot-bootloader.
(beaglebone-black-installation-os): Use make-u-boot-bootloader.
(a20-olinuxino-lime-installation-os): Use make-u-boot-bootloader.
(a20-olinuxino-lime2-emmc-installation-os): Use make-u-boot-bootloader.
(a20-olinuxino-micro-installation-os): Use make-u-boot-bootloader.
(banana-pi-m2-ultra-installation-os): Use make-u-boot-bootloader.
(mx6cuboxi-installation-os): Use make-u-boot-bootloader.
(novena-installation-os): Use make-u-boot-bootloader.
(nintendo-nes-classic-edition-installation-os): Use make-u-boot-bootloader.
(wandboard-installation-os): Use make-u-boot-bootloader.
---
gnu/bootloader/u-boot.scm | 39 +------------------------------
gnu/packages/bootloaders.scm | 2 +-
gnu/system/examples/beaglebone-black.tmpl | 2 +-
gnu/system/install.scm | 21 ++++++++---------
4 files changed, 13 insertions(+), 51 deletions(-)

Toggle diff (153 lines)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index feda17f99..f804997a4 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -27,17 +27,7 @@
   #:use-module (guix monads)
   #:use-module (guix records)
   #:use-module (guix utils)
-  #:export (u-boot-bootloader
-            u-boot-a20-olinuxino-lime-bootloader
-            u-boot-a20-olinuxino-lime2-bootloader
-            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
-            u-boot-novena-bootloader
-            u-boot-wandboard-bootloader
-            make-u-boot-bootloader))
+  #:export (make-u-boot-bootloader))
 
 (define install-u-boot
   #~(lambda (bootloader device mount-point)
@@ -110,30 +100,3 @@
   (bootloader
     (inherit u-boot-bootloader)
     (package bootloader-package)))
-
-(define u-boot-beaglebone-black-bootloader
-  (make-u-boot-bootloader u-boot-beagle-bone-black))
-
-(define u-boot-nintendo-nes-classic-edition-bootloader
-  (make-u-boot-bootloader u-boot-nintendo-nes-classic-edition))
-
-(define u-boot-a20-olinuxino-lime-bootloader
-  (make-u-boot-bootloader u-boot-a20-olinuxino-lime))
-
-(define u-boot-a20-olinuxino-lime2-bootloader
-  (make-u-boot-bootloader u-boot-a20-olinuxino-lime2))
-
-(define u-boot-a20-olinuxino-micro-bootloader
-  (make-u-boot-bootloader u-boot-a20-olinuxino-micro))
-
-(define u-boot-banana-pi-m2-ultra-bootloader
-  (make-u-boot-bootloader u-boot-banana-pi-m2-ultra))
-
-(define u-boot-mx6cuboxi-bootloader
-  (make-u-boot-bootloader u-boot-mx6cuboxi))
-
-(define u-boot-wandboard-bootloader
-  (make-u-boot-bootloader u-boot-wandboard))
-
-(define u-boot-novena-bootloader
-  (make-u-boot-bootloader u-boot-novena))
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 526e53384..759abdc92 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -424,7 +424,7 @@ also initializes the boards (RAM etc).")
 (define-public u-boot-malta
   (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
 
-(define-public u-boot-beagle-bone-black
+(define-public u-boot-beaglebone-black
   (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
 
 (define-public u-boot-pine64-plus
diff --git a/gnu/system/examples/beaglebone-black.tmpl b/gnu/system/examples/beaglebone-black.tmpl
index 97201330c..1fd03dab9 100644
--- a/gnu/system/examples/beaglebone-black.tmpl
+++ b/gnu/system/examples/beaglebone-black.tmpl
@@ -13,7 +13,7 @@
   ;; Assuming /dev/mmcblk1 is the eMMC, and "my-root" is
   ;; the label of the target root file system.
   (bootloader (bootloader-configuration
-               (bootloader u-boot-beaglebone-black-bootloader)
+               (bootloader (make-u-boot-bootloader u-boot-beaglebone-black))
                (target "/dev/mmcblk1")))
 
   ;; This module is required to mount the SD card.
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index b563e8b5b..7508f95a8 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -396,8 +396,7 @@ If you want a serial console, make sure to specify one in your
 operating-system's kernel-arguments (\"console=ttyS0\" or similar)."
   (operating-system (inherit os)
     (bootloader (bootloader-configuration
-                 (bootloader (bootloader (inherit u-boot-bootloader)
-                              (package (make-u-boot-package board triplet))))
+                 (bootloader (make-u-boot-bootloader (make-u-boot-package board triplet)))
                  (target bootloader-target)))))
 
 (define* (embedded-installation-os bootloader bootloader-target tty
@@ -418,7 +417,7 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
     (initrd-modules (append extra-modules %base-initrd-modules))))
 
 (define beaglebone-black-installation-os
-  (embedded-installation-os u-boot-beaglebone-black-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-beaglebone-black)
                             "/dev/sda"
                             "ttyO0"
                             #:extra-modules
@@ -427,42 +426,42 @@ The bootloader BOOTLOADER is installed to BOOTLOADER-TARGET."
 
 
 (define a20-olinuxino-lime-installation-os
-  (embedded-installation-os u-boot-a20-olinuxino-lime-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-a20-olinuxino-lime)
                             "/dev/mmcblk0" ; SD card storage
                             "ttyS0"))
 
 (define a20-olinuxino-lime2-emmc-installation-os
-  (embedded-installation-os u-boot-a20-olinuxino-lime2-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-a20-olinuxino-lime2)
                             "/dev/mmcblk1" ; eMMC storage
                             "ttyS0"))
 
 (define a20-olinuxino-micro-installation-os
-  (embedded-installation-os u-boot-a20-olinuxino-micro-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-a20-olinuxino-micro)
                             "/dev/mmcblk0" ; SD card storage
                             "ttyS0"))
 
 (define banana-pi-m2-ultra-installation-os
-  (embedded-installation-os u-boot-banana-pi-m2-ultra-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-banana-pi-m2-ultra)
                             "/dev/mmcblk1" ; eMMC storage
                             "ttyS0"))
 
 (define mx6cuboxi-installation-os
-  (embedded-installation-os u-boot-mx6cuboxi-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-mx6cuboxi)
                             "/dev/mmcblk0" ; SD card storage
                             "ttymxc0"))
 
 (define novena-installation-os
-  (embedded-installation-os u-boot-novena-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-novena)
                             "/dev/mmcblk1" ; SD card storage
                             "ttymxc1"))
 
 (define nintendo-nes-classic-edition-installation-os
-  (embedded-installation-os u-boot-nintendo-nes-classic-edition-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-nintendo-nes-classic-edition)
                             "/dev/mmcblk0" ; SD card (solder it yourself)
                             "ttyS0"))
 
 (define wandboard-installation-os
-  (embedded-installation-os u-boot-wandboard-bootloader
+  (embedded-installation-os (make-u-boot-bootloader u-boot-wandboard)
                             "/dev/mmcblk0" ; SD card storage
                             "ttymxc0"))
L
L
Ludovic Courtès wrote on 13 May 2018 11:24
Re: [bug#31416] [PATCH 1/4] system: Add os-with-u-boot.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87in7rnc1d.fsf@gnu.org
Hello!

Great that you’re streamlining GuixSD on ARM!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (5 lines)
> * gnu/system/install.scm (os-with-u-boot): New procedure.
> * gnu/packages/bootloaders.scm (make-u-boot-package): Export.
> * doc/guix.texi (Building the Installation Image for ARM boards): New
> subsection.

[...]

Toggle quote (2 lines)
> +@subsection Building the Installation Image for ARM boards

“Boards”

Toggle quote (2 lines)
> +Many ARM boards require a board-specific bootloader in order to boot.

Maybe: “require a specific variant of the
@uref{http://www.denx.de/wiki/U-Boot/,U-Boot} bootloader.”

Toggle quote (8 lines)
> +If you build an entire disk image and the is not still available otherwise
> +(on another available drive etc), it's advisable to build an image that
> +includes the bootloader, specifically:
> +
> +@example
> +guix system disk-image --system=armhf-linux -e '((@ (gnu system install) os-with-u-boot) (@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
> +@end example

Note: In Texinfo you need to double all the at signs.

Toggle quote (2 lines)
> +Or if you don't cross compile:

It’s not cross-compilation. :-)

But I don’t think you need to repeat the command line.

Toggle quote (1 lines)
> +"A20-OLinuXino-Lime2" is the name of the board. If you specify an invalid
^
@code

Toggle quote (2 lines)
> +board, you get a list.

I think the patch is otherwise OK.

Ludo’.
L
L
Ludovic Courtès wrote on 13 May 2018 11:31
Re: [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87d0xznbpw.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (34 lines)
> * gnu/bootloader/u-boot.scm (install-u-boot): Automatically select the correct
> installer.
> ---
> gnu/bootloader/u-boot.scm | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
> index bc8f98f32..e0941c961 100644
> --- a/gnu/bootloader/u-boot.scm
> +++ b/gnu/bootloader/u-boot.scm
> @@ -41,7 +41,24 @@
> (define install-u-boot
> #~(lambda (bootloader device mount-point)
> (if bootloader
> - (error "Failed to install U-Boot"))))
> + (let* ((config-file-name (string-append bootloader "/libexec/.config"))
> + (soc (call-with-input-file config-file-name
> + (let loop ((line (read-line port)))
> + (if (not (eof-object? line))
> + (let ((match
> + (string-match
> + "^CONFIG_SYS_SOC=\"([^\"]*)\""
> + line)))
> + (if match
> + (match:substring match 1)
> + (loop (read-line port))))
> + #f)))))
> + (match soc
> + ("am33xx" (install-beaglebone-black-u-boot bootloader device mount-point))
> + ("mx6" (install-imx-u-boot bootloader device mount-point))
> + ("sunxi" (install-allwinner-u-boot bootloader device mount-point))
> + (_ (error "Failed to install U-Boot (no installation method found)"
> + soc)))))))

Hmm ‘install-beaglebone-black-u-boot’ & co are not in the same stage
AFAICS; are you missing #$ escapes here?

Also we’re probably missing (ice-9 rdelim) and (ice-9 regex) as in the
build stage.

Last, isn’t it a bit hacky? :-) Previously every <bootloader> would
contain its installation method, so this was unambiguous, but now we’re
back to guessing what installation method to use.

Ludo’.
L
L
Ludovic Courtès wrote on 13 May 2018 11:36
Re: [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87603rnbi5.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (8 lines)
> +(define (make-u-boot-bootloader bootloader-package)
> + "Given BOOTLOADER-PACKAGE, make a bootloader that can install."
> (bootloader
> - (inherit u-boot-bootloader)
> - (installer install-allwinner-u-boot)))
> + (inherit u-boot-bootloader)
> + (package bootloader-package)))

What about making it entirely dynamic similar to the ‘cross-gcc’
procedure?

Like:

(define (u-boot-bootloader board)
(bootloader
(installer (board-installer board))
(package (make-u-boot-package (board-name board)
(board-triplet board)))))

where:

(define-record-type <board>
(board name triplet installer)
…)

Thoughts?

Ludo’.
D
D
Danny Milosavljevic wrote on 13 May 2018 12:43
Re: [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180513124350.0053f8e2@scratchpost.org
Hi Ludo,

On Sun, 13 May 2018 11:31:23 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (4 lines)
> Last, isn’t it a bit hacky? :-) Previously every <bootloader> would
> contain its installation method, so this was unambiguous, but now we’re
> back to guessing what installation method to use.

Yeah, it's a bit hacky.

But I don't like the weird spreading-out of bootloader installers as
opposed to bootloader packages either. It would be nicest if upstream
just included installation scripts :P

How the board will boot depends *only* on the Sytem-On-a-Chip in use -
for example all the Allwinner sunxi chips boot the same way.

Usually it's just what the vendor decided to use years (decades) ago
and it stays the same over many many chip generations.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlr4FuYACgkQ5xo1VCww
uqUGUQf/bFOdIC+30tEFxJz6r4OMMHcVu1MLldiJ4IC5jrMVCzy4NG6OUpvlKVC3
X4CXpEbQZ/53oj4Slnubl6ByyPf/YsAFjp1o2UjTVuG7z3qKrkrroY7lNBRQwmoj
K2O3rRZZi0tO5SAFR3ahOtjlRKny9G77887RLZqen+ywU/zijEexKRCSGYPtYP/M
lZS5/TDeGldPcDOZ2UF7s0pIexdzk1abTCnW6Iec4zuJTlL+h+CBPeU2A9ysKTP9
kaV8apIjy3FOPHjutqW8XDR54SfQQ3u9c2ddVBrDueoaFMZCZWMBEyBOxXbbfcxi
KKLD08EfqC7k0xWWWd/eKqKmGXwfKw==
=tkCo
-----END PGP SIGNATURE-----


D
D
Danny Milosavljevic wrote on 13 May 2018 13:03
Re: [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180513125925.66a91367@scratchpost.org
Hi Ludo,

Toggle quote (6 lines)
> (define-record-type <board>
> (board name triplet installer)
> …)
>
> Thoughts?

The idea of make-u-boot-bootloader (and os-with-u-boot) was that it would free
us from having to play whack-a-mole regarding u-boot (except for the
installation methods of which there are much fewer than boards or chip models)
and also free the user from having to know anything but the board name.

With your idea it would mean that we'd have to carry a huge list of <board>s,
defining the board and architecture and installer, right? (or I guess the
user would have to create it on-the-fly)

That's exactly what I was trying to avoid :)

I know my method isn't perfect either - I should have said "WIP" - but the idea
is that the user would just use os-with-u-boot and specify his board name - and the
rest is magically being worked out (for all boards in u-boot).

I'm trying to keep to information that is available within u-boot (like .config)
so we don't have to maintain the stuff ourselves. The installer was supposed
to read out the u-boot parts and infer the correct incantations to use by itself.

To infer the triplet, we can search for "CONFIG_ARM64=y".

The SOC should be fine to infer as in this patch.

No chance inferring the actual installation commands, though. Too bad...

They've got all kinds of funny config entries like

CONFIG_SPL_FIT_GENERATOR="board/sunxi/mksunxi_fit_atf.sh"

but I don't see the installation commands / info... hrmmmm...
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlr4G48ACgkQ5xo1VCww
uqUgMwf/V4cYk1sanQH+JdOeSBWxm9wmmIfBrE+yL9Tzf7LUHFeT+XvfAfz8caGr
q/Zihs7SsYiCuaxqoJ/p8oYzBbuygi4NfXBcvhSj3ebBcZ/iKLxcW0mGjJvG6zyp
aGdAEqq163LZlo09EMh80tonKw5lRuGo0W8k7guEeOqi4wf6kaljIPMsQwF9UqIy
/HH+virEd7L4TSmAcN0rAZyehPzjfdhqiDLXCIBFgsTFyEkidUk1gE24GtHj6ZjL
12Oq5hcpZb7JIoArYgk9Ju4KRUibROhMUNg5+qtmgbqw8kkjjEQq/KGKDcRsDbLh
GTZX0HQWWnBQeHxqTbDavJkA2C2Rsg==
=nkRx
-----END PGP SIGNATURE-----


D
D
Danny Milosavljevic wrote on 13 May 2018 13:15
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180513131510.4a88c298@scratchpost.org
Toggle quote (2 lines)
> To infer the triplet, we can search for "CONFIG_ARM64=y".

Not really, it's not in the u-boot tarball before it started building it. Hmm...

But you're right, it shouldn't be cross-compiling it in the first place if "-s"
works (or if the user builds it on the target anyway), so we could just punt on
this entirely.

P.S. how do I make make-u-boot-package default triplet to the host triplet?
(%current-system) is not a gnu triplet, right?
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlr4Hj4ACgkQ5xo1VCww
uqUelwf+NSon41e+Ug7nrhsD9StoojGWyZWLg+We59M417Sp1Sge4Y35XjKCn2DN
G3EN0Ur6l6oZx6iwyxa0NYRHgIj5Y2ALdTzRHgB06zi/yj/udyjrOk1nA7Z9kj1+
Kf5GVkrXxD8FaQEwgHJp8rwuAukM7IwE+XRfVpljfH5MTnx8/A/W5mTIjq5QArxZ
eDvZNcncwaTrWo89GpOQhADr+CqD2W+YSeWdP8K1A8HAtRKsFo2GiBJCVagDym2q
04jBGs4spWQbmpjpXylhfQRTCGP2waGQWc4X6vsLCECian+H0Ex/QD+UG6dJ/EZX
0mjEuIgtvZfLATBtr3c3eVcdosTvnQ==
=6ciW
-----END PGP SIGNATURE-----


J
J
Jelle Licht wrote on 13 May 2018 14:09
Re: [bug#31416] [PATCH 1/4] system: Add os-with-u-boot.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
CAPsKtf+esBz7jveWjF8BLbRTAKikm7m6LwzUEhwBZgeeQn7jzQ@mail.gmail.com
2018-05-11 16:36 GMT+02:00 Danny Milosavljevic <dannym@scratchpost.org>:
[...]

Toggle quote (8 lines)
> +@subsection Building the Installation Image for ARM boards
> +
> +Many ARM boards require a board-specific bootloader in order to boot.
> +
> +If you build an entire disk image and the is not still available otherwise
> +(on another available drive etc), it's advisable to build an image that
> +includes the bootloader, specifically:
>
`and the' seems to miss something after it.

Toggle quote (10 lines)
> +
> +@example
> +guix system disk-image --system=armhf-linux -e '((@ (gnu system install)
> os-with-u-boot) (@ (gnu system install) installation-os)
> "A20-OLinuXino-Lime2")'
> +@end example
> +
> +Or if you don't cross compile:
>

nitpick: I do not like contractions in writing, but if we already use them
elsewhere, disregard this ;-).

Toggle quote (10 lines)
> +
> +@example
> +guix system disk-image -e '((@ (gnu system install) os-with-u-boot) (@
> (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
> +@end example
> +
> +"A20-OLinuXino-Lime2" is the name of the board. If you specify an invalid
> +board, you get a list.
>

Could you clarify what you mean when you say you get a list?

Toggle quote (3 lines)
> [...]
>
>
Thanks for working on this! I really want to see GuixSD on ARM succeed as
well.
Attachment: file
D
D
Danny Milosavljevic wrote on 13 May 2018 15:46
Re: [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180513154615.32ccd51b@scratchpost.org
The number of boards vs. the number of SOCs:

u-boot-2018.05$ tools/genboardscfg.py
u-boot-2018.05$ wc -l boards.cfg
1249 boards.cfg
u-boot-2018.05$ cat boards.cfg |tail +7 |awk '{print $4}' |sort |uniq |grep -v '^$' |wc -l # 4 is the "SOC" column
86
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlr4QacACgkQ5xo1VCww
uqUdgwgAhDRyt37yLSqNDnU8XOoWlmEFlbWJJebEdM9eAGxwTNZFUaucWOVw7kgk
HWbqnPco2jeL13Rhn75GVQJ9pT4oYn7HsYUJoZW2kvCvMRIg/D2hTu0eqsXd7KVu
6WxYRfEWKyeCsEc3LwXQrNIfQc8iPZBK0DFbSsY3TtWhHa2SO3FxoBktLo7KE+8b
JafA849Ot8y45SFUXKhCEg+weVH1qqXOXByJDAoMjX58Dp8mySTvoQuKmZTFbnAn
yNYPWokC8pKdAE1kyx3cbbXDai8NHQnTp5gzHttRI6pGD3I9mKA3WlXr/bXKdZH2
wsBu5feKe7BqOp4fAdVN2WgSrNeoyg==
=AAXz
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 14 May 2018 10:31
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87o9hibpv2.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (3 lines)
> P.S. how do I make make-u-boot-package default triplet to the host triplet?
> (%current-system) is not a gnu triplet, right?

You could do:

Toggle snippet (5 lines)
scheme@(guile-user)> ,use(guix utils)
scheme@(guile-user)> (nix-system->gnu-triplet (%current-system))
$2 = "x86_64-unknown-linux-gnu"

Ludo’.
L
L
Ludovic Courtès wrote on 14 May 2018 10:34
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87in7qbppv.fsf@gnu.org
Hello Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (17 lines)
>> (define-record-type <board>
>> (board name triplet installer)
>> …)
>>
>> Thoughts?
>
> The idea of make-u-boot-bootloader (and os-with-u-boot) was that it would free
> us from having to play whack-a-mole regarding u-boot (except for the
> installation methods of which there are much fewer than boards or chip models)
> and also free the user from having to know anything but the board name.
>
> With your idea it would mean that we'd have to carry a huge list of <board>s,
> defining the board and architecture and installer, right? (or I guess the
> user would have to create it on-the-fly)
>
> That's exactly what I was trying to avoid :)

Oh I see, especially the 1.2K boards vs. 86 SoCs!

Then perhaps “board” is not the right abstraction; maybe <soc> would
make more sense?

Either way, my point was that it would be nice to have some abstraction
to clearly specify things, and then use that as an input to construct
both the U-Boot package and its configuration.

Or do you think enumerating the SoCs would still be too painful? In
that case, some auto-guessing might be the right choice, but in general,
I think it should be a last resort. :-)

Thanks,
Ludo’.
D
D
Danny Milosavljevic wrote on 14 May 2018 18:29
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180514182953.3d4c4f3c@scratchpost.org
Ji Ludo,

Toggle quote (2 lines)
> Or do you think enumerating the SoCs would still be too painful?

No, I think that would be a good idea.

I'm not 100% sure that the SOC's ROM loads the bootloader always in the same
way - but all SOCs I have ever seen so far do that (it also makes sense -
the factory probably has chip test rigs and they don't want to
update those every time a new chip revision comes out).

(sometimes this can even be generalized to the vendor instead of the soc,
though not always)

If it does happen that there's a config resistor or something, we can cross
that bridge when we come to it.

So yeah, let's have a table of installers, using the soc as a key (for now?).

Still to do: bikeshedding the name :)

What about

(define-record <installer>
soc installation-procedure
...)

(I think <soc> as record name would be weird, no?)

Or just a hash table soc -> installation-procedure ?

How does the instantiation of the table data look? Just toplevel statements? I've caused problems with those before :)

Where do we put it? gnu/bootloader/u-boot.scm ?
L
L
Ludovic Courtès wrote on 15 Jun 2018 09:12
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87r2l8wmjk.fsf@gnu.org
Hi Danny,

Apologies for dropping the ball!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (10 lines)
> Still to do: bikeshedding the name :)
>
> What about
>
> (define-record <installer>
> soc installation-procedure
> ...)
>
> (I think <soc> as record name would be weird, no?)

I think <installer> is too vague and it sounds like it’s basically a
procedure, which it’s not. <soc> would be fine IMO, or <system-on-chip>
if we want.

Toggle quote (4 lines)
> Or just a hash table soc -> installation-procedure ?
>
> How does the instantiation of the table data look? Just toplevel statements? I've caused problems with those before :)

I think we need a table to look things up by name anyway, but we may
also need a record type: I suppose we’d want to describe things in that
record.

For the lookup table itself, see for example ‘file-system-type-modules’
in (gnu system linux-initrd).

Toggle quote (2 lines)
> Where do we put it? gnu/bootloader/u-boot.scm ?

Sounds like the right place, yes.

Thanks,
Ludo’.
D
D
Danny Milosavljevic wrote on 17 Jun 2018 02:28
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180617022855.671a3ef6@scratchpost.org
Hi Ludo,

On Fri, 15 Jun 2018 09:12:31 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (2 lines)
> Apologies for dropping the ball!

No problem, no need to hurry!

I've researched a little in the mean time and found out that other projects
DO have automated u-boot installation, for example:


So we could leave this stuff mostly to them - although it would mean
we'd only support boards they support.

It would make us lose support for these for now:

* qemu_arm_vexpress
* qemu_mips64el_malta
* banana-pi-m2-ultra
* nintendo-nes-classic-edition
* novena
* cubieboard
* puma-rk3399

So we'd have to upstream support for those[1] - and also have a fallback in the
mean time maybe.

A very minimal WIP patch for that is attached.

What it does is install a "genimage.cfg" which describes how to install u-boot for
the current board into the derivation of u-boot.

Do we want to proceed like that?

Should I move load-u-boot-config into a new guix/build/u-boot.scm ? Or how
do I get it into the build side without rebuilding the world?

[1] I added banana-pi-m2-ultra in my local buildroot checkout by creating 3 short
text files, so it's not that bad.
Toggle diff (282 lines)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 52b38dd1a..4213830cd 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -110,7 +110,7 @@
 (define u-boot-beaglebone-black-bootloader
   (bootloader
    (inherit u-boot-bootloader)
-   (package u-boot-beagle-bone-black)
+   (package u-boot-beaglebone)
    (installer install-beaglebone-black-u-boot)))
 
 (define u-boot-allwinner-bootloader
@@ -136,17 +136,17 @@
 (define u-boot-a20-olinuxino-lime-bootloader
   (bootloader
    (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-lime)))
+   (package u-boot-olimex-a20-olinuxino-lime)))
 
 (define u-boot-a20-olinuxino-lime2-bootloader
   (bootloader
    (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-lime2)))
+   (package u-boot-olimex-a20-olinuxino-lime2)))
 
 (define u-boot-a20-olinuxino-micro-bootloader
   (bootloader
    (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-micro)))
+   (package u-boot-olimex-a20-olinuxino-micro)))
 
 (define u-boot-banana-pi-m2-ultra-bootloader
   (bootloader
@@ -156,7 +156,7 @@
 (define u-boot-mx6cuboxi-bootloader
   (bootloader
    (inherit u-boot-imx-bootloader)
-   (package u-boot-mx6cuboxi)))
+   (package u-boot-mx6cubox)))
 
 (define u-boot-wandboard-bootloader
   (bootloader
@@ -171,7 +171,7 @@
 (define u-boot-pine64-plus-bootloader
   (bootloader
    (inherit u-boot-allwinner64-bootloader)
-   (package u-boot-pine64-plus)))
+   (package u-boot-pine64)))
 
 (define u-boot-puma-rk3399-bootloader
   (bootloader
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index eb1e433ba..080515e79 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -456,6 +456,26 @@ def test_ctrl_c"))
 also initializes the boards (RAM etc).  This package provides its
 board-independent tools.")))
 
+(define-public buildroot-minimal
+  (package
+    (name "buildroot-minimal")
+    (version "2018.05")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append
+                "https://github.com/buildroot/buildroot/archive/"
+                version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "002y07c1q3bx2f37ywq0qaj2f4wfn09dia09khnp7sy6ajz3k7p3"))))
+    (build-system gnu-build-system)
+    (synopsis "Generate embedded Linux system images")
+    (description "@code{buildroot} generates embedded Linux system images.")
+    (home-page "https://github.com/buildroot/buildroot")
+    (license license:gpl2+)))
+
 (define-public (make-u-boot-package board triplet)
   "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
   (let ((same-arch? (if (string-prefix? (%current-system)
@@ -472,9 +492,12 @@ board-independent tools.")))
              `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7))
                ("cross-binutils" ,(cross-binutils triplet)))
              `(("gcc-7" ,gcc-7)))
+         ("buildroot" ,(package-source buildroot-minimal))
          ,@(package-native-inputs u-boot)))
       (arguments
-       `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
+       `(#:modules
+         ((ice-9 ftw) (ice-9 rdelim) (ice-9 regex) (guix build utils)
+          (guix build gnu-build-system))
          #:test-target "test"
          #:make-flags
          (list "HOSTCC=gcc"
@@ -483,16 +506,86 @@ board-independent tools.")))
                    '()))
          #:phases
          (modify-phases %standard-phases
+           (add-after 'unpack 'unpack-buildroot
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (invoke "tar" "xf" (assoc-ref inputs "buildroot"))
+               ((@ (ice-9 match) match) (filter (lambda (name) (string-prefix? "buildroot" name)) (scandir "."))
+                ((name) (symlink name "buildroot")))
+               #t))
            (replace 'configure
-             (lambda* (#:key outputs make-flags #:allow-other-keys)
-               (let ((config-name (string-append ,board "_defconfig")))
-                 (if (file-exists? (string-append "configs/" config-name))
-                     (zero? (apply system* "make" `(,@make-flags ,config-name)))
+             (lambda* (#:key  outputs make-flags #:allow-other-keys)
+;; FIXME move out.
+(define (load-u-boot-config port)
+  "Read the u-boot configuration from PORT and return an alist with the
+entries."
+  (let loop ((line (read-line port)))
+    (if (eof-object? line)
+        '()
+        (let ((match (string-match "^([A-Za-z][^=]*)=(.*)$" line)))
+          (if match
+              (cons (cons (match:substring match 1)
+                          (match:substring match 2))
+                    (loop (read-line port)))
+              (loop (read-line port)))))))
+
+               (let* ((buildroot-config-basename
+                       (string-append ,board "_defconfig"))
+                      (buildroot-config-dirname "buildroot/")
+                      (buildroot-config-name
+                       (string-append buildroot-config-dirname "configs/"
+                                      buildroot-config-basename))
+                      (buildroot-config
+                       (if (file-exists? buildroot-config-name)
+                           (call-with-input-file buildroot-config-name load-u-boot-config)
+                           #f)))
+                 (if buildroot-config
+                     (let* ((cfg (lambda (name)
+                                   (assoc-ref buildroot-config name)))
+                            (u-boot-config-match
+                             (and=> (or (cfg "BR2_TARGET_UBOOT_BOARD_DEFCONFIG")
+                                        (cfg "BR2_TARGET_UBOOT_BOARDNAME"))
+                                    (lambda (x)
+                                      (string-match "^\"(.*)\"$" x))))
+                            (u-boot-config-name
+                             (and u-boot-config-match
+                                  (match:substring u-boot-config-match 1)))
+                            (BR2_ROOTFS_POST_IMAGE_SCRIPT
+                             (cfg "BR2_ROOTFS_POST_IMAGE_SCRIPT"))
+                            (BR2_ROOTFS_POST_SCRIPT_ARGS
+                             (cfg "BR2_ROOTFS_POST_SCRIPT_ARGS"))
+                            (genimage-config-name
+                             (cond
+                              ;; Prefer genimage.sh parameters.
+                              ((and BR2_ROOTFS_POST_IMAGE_SCRIPT
+                                    (string=? BR2_ROOTFS_POST_IMAGE_SCRIPT
+                                              "\"support/scripts/genimage.sh\"")
+                                    BR2_ROOTFS_POST_SCRIPT_ARGS)
+                               (and=> (string-match "^\"-c (.*)\"$" BR2_ROOTFS_POST_SCRIPT_ARGS)
+                                      (lambda (match) (match:substring match 1))))
+                              ;; Fall back to the script directory.
+                              (BR2_ROOTFS_POST_IMAGE_SCRIPT
+                               (and=> (string-match "^\"(.*)/[^/]*\"$" BR2_ROOTFS_POST_IMAGE_SCRIPT)
+                                       (lambda (match) (string-append (match:substring match 1)
+                                                                  "/genimage.cfg"))))
+                              ;; Fall back to no "genimage.cfg".
+                              (else
+                               #f))))
+                         (if genimage-config-name
+                           (let ((x (string-append buildroot-config-dirname
+                                                   genimage-config-name)))
+                             (if (file-exists? x)
+                                 (copy-file x "genimage.cfg"))))
+                       (if (not u-boot-config-name)
+                           (error "Cannot build U-Boot for this system."))
+                       (apply invoke "make"
+                              `(,@make-flags
+                                ,(string-append u-boot-config-name
+                                                "_defconfig"))))
                      (begin
                        (display "Invalid board name. Valid board names are:"
                                 (current-error-port))
                        (let ((suffix-len (string-length "_defconfig"))
-                             (entries (scandir "configs")))
+                             (entries (scandir (dirname buildroot-config-name))))
                          (for-each (lambda (file-name)
                                      (when (string-suffix? "_defconfig" file-name)
                                        (format (current-error-port)
@@ -500,7 +593,8 @@ board-independent tools.")))
                                                (string-drop-right file-name
                                                                   suffix-len))))
                                    (sort entries string-ci<)))
-                       #f)))))
+                       (error "Invalid board name ~s."
+                              buildroot-config-basename))))))
            (replace 'install
              (lambda* (#:key outputs #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out"))
@@ -512,6 +606,9 @@ board-independent tools.")))
                  (install-file ".config" libexec)
                  ;; Useful for "qemu -kernel".
                  (install-file "u-boot" libexec)
+                 (if (file-exists? "genimage.cfg")
+                     (install-file "genimage.cfg" libexec))
+
                  (for-each
                   (lambda (file)
                     (let ((target-file (string-append libexec "/" file)))
@@ -519,17 +616,17 @@ board-independent tools.")))
                       (copy-file file target-file)))
                   uboot-files))))))))))
 
-(define-public u-boot-vexpress
-  (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
+(define-public u-boot-qemu-arm-vexpress
+  (make-u-boot-package "qemu_arm_vexpress" "arm-linux-gnueabihf"))
 
-(define-public u-boot-malta
-  (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
+(define-public u-boot-qemu-mips64el-malta
+  (make-u-boot-package "qemu_mips64el_malta" "mips64el-linux-gnuabi64"))
 
-(define-public u-boot-beagle-bone-black
-  (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
+(define-public u-boot-beaglebone
+  (make-u-boot-package "beaglebone" "arm-linux-gnueabihf"))
 
-(define-public u-boot-pine64-plus
-  (let ((base (make-u-boot-package "pine64_plus" "aarch64-linux-gnu")))
+(define-public u-boot-pine64
+  (let ((base (make-u-boot-package "pine64" "aarch64-linux-gnu")))
     (package
       (inherit base)
       (arguments
@@ -550,33 +647,38 @@ board-independent tools.")))
        `(("firmware" ,arm-trusted-firmware-pine64-plus)
          ,@(package-native-inputs base))))))
 
+;; MISSING
 (define-public u-boot-banana-pi-m2-ultra
   (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
 
-(define-public u-boot-a20-olinuxino-lime
-  (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
+(define-public u-boot-olimex-a20-olinuxino-lime
+  (make-u-boot-package "olimex_a20_olinuxino_lime" "arm-linux-gnueabihf"))
 
-(define-public u-boot-a20-olinuxino-lime2
-  (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
+(define-public u-boot-olimex-a20-olinuxino-lime2
+  (make-u-boot-package "olimex_a20_olinuxino_lime2" "arm-linux-gnueabihf"))
 
-(define-public u-boot-a20-olinuxino-micro
-  (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
+(define-public u-boot-olimex-a20-olinuxino-micro
+  (make-u-boot-package "olimex_a20_olinuxino_micro" "arm-linux-gnueabihf"))
 
+;; MISSING
 (define-public u-boot-nintendo-nes-classic-edition
   (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
 
 (define-public u-boot-wandboard
   (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
 
-(define-public u-boot-mx6cuboxi
-  (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
+(define-public u-boot-mx6cubox
+  (make-u-boot-package "mx6cubox" "arm-linux-gnueabihf"))
 
+;; MISSING
 (define-public u-boot-novena
   (make-u-boot-package "novena" "arm-linux-gnueabihf"))
 
+;; MISSING
 (define-public u-boot-cubieboard
   (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
 
+;; MISSING
 (define-public u-boot-puma-rk3399
   (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
     (package
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlslq0cACgkQ5xo1VCww
uqVQFwgAoggaWe8fm5D42K1oCZDCEoq8z9kGaQTOMqm7Hoic3KBLwnYM4MjtndgN
vTDn1trp1ulh8CbWBT7mzj/BfU+TtCJ75q86Yr8eT5KtFION9Q8TBm4WteKQxRiy
F6VTAlDQueIWNL+CMA+DvRrqjrSBUxG27MmB2aBh3Kb0xl3ZRJElprrQisKhGqyp
NcbSKrlgSJzDBoT8GkkOE+KrhH6GQSm8pTzQtvx9NIyHyVnWY/XC4Q8eOL2MLKAM
sIpIIzLLEUDl6E0bJIWvX2XQotXOYMRagXBVOB+DLCr9oeZdqnulxVFCmU8nNLgw
cx+2LthdPxDQKHtdIqm/CUbXPAXRfQ==
=Gt5h
-----END PGP SIGNATURE-----


D
D
Danny Milosavljevic wrote on 17 Jun 2018 14:35
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180617143517.433a5ce0@scratchpost.org
v2, with u-boot-without-buildroot fallback, attached.
Toggle diff (292 lines)
diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 52b38dd1a..4213830cd 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -110,7 +110,7 @@
 (define u-boot-beaglebone-black-bootloader
   (bootloader
    (inherit u-boot-bootloader)
-   (package u-boot-beagle-bone-black)
+   (package u-boot-beaglebone)
    (installer install-beaglebone-black-u-boot)))
 
 (define u-boot-allwinner-bootloader
@@ -136,17 +136,17 @@
 (define u-boot-a20-olinuxino-lime-bootloader
   (bootloader
    (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-lime)))
+   (package u-boot-olimex-a20-olinuxino-lime)))
 
 (define u-boot-a20-olinuxino-lime2-bootloader
   (bootloader
    (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-lime2)))
+   (package u-boot-olimex-a20-olinuxino-lime2)))
 
 (define u-boot-a20-olinuxino-micro-bootloader
   (bootloader
    (inherit u-boot-allwinner-bootloader)
-   (package u-boot-a20-olinuxino-micro)))
+   (package u-boot-olimex-a20-olinuxino-micro)))
 
 (define u-boot-banana-pi-m2-ultra-bootloader
   (bootloader
@@ -156,7 +156,7 @@
 (define u-boot-mx6cuboxi-bootloader
   (bootloader
    (inherit u-boot-imx-bootloader)
-   (package u-boot-mx6cuboxi)))
+   (package u-boot-mx6cubox)))
 
 (define u-boot-wandboard-bootloader
   (bootloader
@@ -171,7 +171,7 @@
 (define u-boot-pine64-plus-bootloader
   (bootloader
    (inherit u-boot-allwinner64-bootloader)
-   (package u-boot-pine64-plus)))
+   (package u-boot-pine64)))
 
 (define u-boot-puma-rk3399-bootloader
   (bootloader
diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index eb1e433ba..7036c6bbc 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -456,6 +456,26 @@ def test_ctrl_c"))
 also initializes the boards (RAM etc).  This package provides its
 board-independent tools.")))
 
+(define-public buildroot-minimal
+  (package
+    (name "buildroot-minimal")
+    (version "2018.05")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append
+                "https://github.com/buildroot/buildroot/archive/"
+                version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "002y07c1q3bx2f37ywq0qaj2f4wfn09dia09khnp7sy6ajz3k7p3"))))
+    (build-system gnu-build-system)
+    (synopsis "Generate embedded Linux system images")
+    (description "@code{buildroot} generates embedded Linux system images.")
+    (home-page "https://github.com/buildroot/buildroot")
+    (license license:gpl2+)))
+
 (define-public (make-u-boot-package board triplet)
   "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
   (let ((same-arch? (if (string-prefix? (%current-system)
@@ -472,9 +492,12 @@ board-independent tools.")))
              `(("cross-gcc" ,(cross-gcc triplet #:xgcc gcc-7))
                ("cross-binutils" ,(cross-binutils triplet)))
              `(("gcc-7" ,gcc-7)))
+         ("buildroot" ,(package-source buildroot-minimal))
          ,@(package-native-inputs u-boot)))
       (arguments
-       `(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
+       `(#:modules
+         ((ice-9 ftw) (ice-9 rdelim) (ice-9 regex) (guix build utils)
+          (guix build gnu-build-system))
          #:test-target "test"
          #:make-flags
          (list "HOSTCC=gcc"
@@ -483,16 +506,94 @@ board-independent tools.")))
                    '()))
          #:phases
          (modify-phases %standard-phases
+           (add-after 'unpack 'unpack-buildroot
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (invoke "tar" "xf" (assoc-ref inputs "buildroot"))
+               ((@ (ice-9 match) match) (filter (lambda (name) (string-prefix? "buildroot" name)) (scandir "."))
+                ((name) (symlink name "buildroot")))
+               #t))
            (replace 'configure
-             (lambda* (#:key outputs make-flags #:allow-other-keys)
-               (let ((config-name (string-append ,board "_defconfig")))
-                 (if (file-exists? (string-append "configs/" config-name))
-                     (zero? (apply system* "make" `(,@make-flags ,config-name)))
-                     (begin
+             (lambda* (#:key  outputs make-flags #:allow-other-keys)
+;; FIXME move out.
+(define (load-u-boot-config port)
+  "Read the u-boot configuration from PORT and return an alist with the
+entries."
+  (let loop ((line (read-line port)))
+    (if (eof-object? line)
+        '()
+        (let ((match (string-match "^([A-Za-z][^=]*)=(.*)$" line)))
+          (if match
+              (cons (cons (match:substring match 1)
+                          (match:substring match 2))
+                    (loop (read-line port)))
+              (loop (read-line port)))))))
+
+               (let* ((buildroot-config-basename
+                       (string-append ,board "_defconfig"))
+                      (buildroot-config-dirname "buildroot/")
+                      (buildroot-config-name
+                       (string-append buildroot-config-dirname "configs/"
+                                      buildroot-config-basename))
+                      (buildroot-config
+                       (if (file-exists? buildroot-config-name)
+                           (call-with-input-file buildroot-config-name load-u-boot-config)
+                           #f)))
+                 (cond
+                  (buildroot-config
+                     (let* ((cfg (lambda (name)
+                                   (assoc-ref buildroot-config name)))
+                            (u-boot-config-match
+                             (and=> (or (cfg "BR2_TARGET_UBOOT_BOARD_DEFCONFIG")
+                                        (cfg "BR2_TARGET_UBOOT_BOARDNAME"))
+                                    (lambda (x)
+                                      (string-match "^\"(.*)\"$" x))))
+                            (u-boot-config-name
+                             (and u-boot-config-match
+                                  (match:substring u-boot-config-match 1)))
+                            (BR2_ROOTFS_POST_IMAGE_SCRIPT
+                             (cfg "BR2_ROOTFS_POST_IMAGE_SCRIPT"))
+                            (BR2_ROOTFS_POST_SCRIPT_ARGS
+                             (cfg "BR2_ROOTFS_POST_SCRIPT_ARGS"))
+                            (genimage-config-name
+                             (cond
+                              ;; Prefer genimage.sh parameters.
+                              ((and BR2_ROOTFS_POST_IMAGE_SCRIPT
+                                    (string=? BR2_ROOTFS_POST_IMAGE_SCRIPT
+                                              "\"support/scripts/genimage.sh\"")
+                                    BR2_ROOTFS_POST_SCRIPT_ARGS)
+                               (and=> (string-match "^\"-c (.*)\"$" BR2_ROOTFS_POST_SCRIPT_ARGS)
+                                      (lambda (match) (match:substring match 1))))
+                              ;; Fall back to the script directory.
+                              (BR2_ROOTFS_POST_IMAGE_SCRIPT
+                               (and=> (string-match "^\"(.*)/[^/]*\"$" BR2_ROOTFS_POST_IMAGE_SCRIPT)
+                                      (lambda (match) (string-append (match:substring match 1)
+                                                                 "/genimage.cfg"))))
+                              ;; Fall back to no "genimage.cfg".
+                              (else
+                               #f))))
+                         (if genimage-config-name
+                           (let ((x (string-append buildroot-config-dirname
+                                                   genimage-config-name)))
+                             (if (file-exists? x)
+                                 (copy-file x "genimage.cfg"))))
+                       (if (not u-boot-config-name)
+                           (error "Cannot build U-Boot for this system."))
+                       (apply invoke "make"
+                              `(,@make-flags
+                                ,(string-append u-boot-config-name
+                                                "_defconfig")))))
+                  ;; Fall back to U-Boot without installer.
+                  ((file-exists? (string-append "configs/" ,board "_defconfig"))
+                   (apply invoke "make"
+                          `(,@make-flags
+                            ,(string-append ,board
+                                            "_defconfig"))))
+                  (else
+                   (begin
                        (display "Invalid board name. Valid board names are:"
                                 (current-error-port))
                        (let ((suffix-len (string-length "_defconfig"))
-                             (entries (scandir "configs")))
+                             (entries (scandir (dirname buildroot-config-name))))
                          (for-each (lambda (file-name)
                                      (when (string-suffix? "_defconfig" file-name)
                                        (format (current-error-port)
@@ -500,7 +601,8 @@ board-independent tools.")))
                                                (string-drop-right file-name
                                                                   suffix-len))))
                                    (sort entries string-ci<)))
-                       #f)))))
+                       (error "Invalid board name ~s."
+                              buildroot-config-basename)))))))
            (replace 'install
              (lambda* (#:key outputs #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out"))
@@ -512,6 +614,10 @@ board-independent tools.")))
                  (install-file ".config" libexec)
                  ;; Useful for "qemu -kernel".
                  (install-file "u-boot" libexec)
+
+                 (if (file-exists? "genimage.cfg")
+                     (install-file "genimage.cfg" libexec))
+
                  (for-each
                   (lambda (file)
                     (let ((target-file (string-append libexec "/" file)))
@@ -519,17 +625,17 @@ board-independent tools.")))
                       (copy-file file target-file)))
                   uboot-files))))))))))
 
-(define-public u-boot-vexpress
-  (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
+(define-public u-boot-qemu-arm-vexpress
+  (make-u-boot-package "qemu_arm_vexpress" "arm-linux-gnueabihf"))
 
-(define-public u-boot-malta
-  (make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
+(define-public u-boot-qemu-mips64el-malta
+  (make-u-boot-package "qemu_mips64el_malta" "mips64el-linux-gnuabi64"))
 
-(define-public u-boot-beagle-bone-black
-  (make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
+(define-public u-boot-beaglebone
+  (make-u-boot-package "beaglebone" "arm-linux-gnueabihf"))
 
-(define-public u-boot-pine64-plus
-  (let ((base (make-u-boot-package "pine64_plus" "aarch64-linux-gnu")))
+(define-public u-boot-pine64
+  (let ((base (make-u-boot-package "pine64" "aarch64-linux-gnu")))
     (package
       (inherit base)
       (arguments
@@ -550,33 +656,38 @@ board-independent tools.")))
        `(("firmware" ,arm-trusted-firmware-pine64-plus)
          ,@(package-native-inputs base))))))
 
+;; MISSING genimage.cfg
 (define-public u-boot-banana-pi-m2-ultra
   (make-u-boot-package "Bananapi_M2_Ultra" "arm-linux-gnueabihf"))
 
-(define-public u-boot-a20-olinuxino-lime
-  (make-u-boot-package "A20-OLinuXino-Lime" "arm-linux-gnueabihf"))
+(define-public u-boot-olimex-a20-olinuxino-lime
+  (make-u-boot-package "olimex_a20_olinuxino_lime" "arm-linux-gnueabihf"))
 
-(define-public u-boot-a20-olinuxino-lime2
-  (make-u-boot-package "A20-OLinuXino-Lime2" "arm-linux-gnueabihf"))
+(define-public u-boot-olimex-a20-olinuxino-lime2
+  (make-u-boot-package "olimex_a20_olinuxino_lime2" "arm-linux-gnueabihf"))
 
-(define-public u-boot-a20-olinuxino-micro
-  (make-u-boot-package "A20-OLinuXino_MICRO" "arm-linux-gnueabihf"))
+(define-public u-boot-olimex-a20-olinuxino-micro
+  (make-u-boot-package "olimex_a20_olinuxino_micro" "arm-linux-gnueabihf"))
 
+;; MISSING genimage.cfg
 (define-public u-boot-nintendo-nes-classic-edition
   (make-u-boot-package "Nintendo_NES_Classic_Edition" "arm-linux-gnueabihf"))
 
 (define-public u-boot-wandboard
   (make-u-boot-package "wandboard" "arm-linux-gnueabihf"))
 
-(define-public u-boot-mx6cuboxi
-  (make-u-boot-package "mx6cuboxi" "arm-linux-gnueabihf"))
+(define-public u-boot-mx6cubox
+  (make-u-boot-package "mx6cubox" "arm-linux-gnueabihf"))
 
+;; MISSING genimage.cfg
 (define-public u-boot-novena
   (make-u-boot-package "novena" "arm-linux-gnueabihf"))
 
+;; MISSING genimage.cfg
 (define-public u-boot-cubieboard
   (make-u-boot-package "Cubieboard" "arm-linux-gnueabihf"))
 
+;; MISSING genimage.cfg
 (define-public u-boot-puma-rk3399
   (let ((base (make-u-boot-package "puma-rk3399" "aarch64-linux-gnu")))
     (package
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlsmVYUACgkQ5xo1VCww
uqVCKQf+JCFdaA+XuUnHIKhXGRD9xRCBrijMoUaZpYG84/UEg/y0BIteURCtPtqE
frhotuhn17aeuJmvJCvT7zQ5TNRZ5zx9dbTTqbatn3VD3K3bOzf5LaDlFMh6T4lm
xEi4R4Idmyxe/jPyoRciVFwoX4E/86gWM+oOc01fiSbzUwskbM6kB46JVA3fjDfv
gPEOifdOt4f4gNXr6aNxgxEb4F0Yv0RP81ECFoho1ZUzp+pz5uHjPr3TxRF6GI33
H9E/8dD6SedKU1CrjVZmiHrqc65H0yX/7F98aAjNTGS8/zJkX5YZHARH3efqnwSK
y1IuV55tD4zUt78huPVU+DED8rpf7A==
=7WiX
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 17 Jun 2018 22:33
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
87in6hkvb2.fsf@gnu.org
Hello Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (8 lines)
> I've researched a little in the mean time and found out that other projects
> DO have automated u-boot installation, for example:
>
> https://github.com/buildroot/buildroot/blob/master/board/olimex/a20_olinuxino/genimage.cfg
>
> So we could leave this stuff mostly to them - although it would mean
> we'd only support boards they support.

Instead of using these .cfg files as-is, how about “importing” them?
That <soc> structure (or whatever) we discussed could contain
essentially the relevant part of those .cfg files (the partitioning info
founds in those files seems less relevant to me, or at least it seems
like a separate issue.)

WDYT?

IOW, we could definitely take Buildroot as an inspiration (it’s probably
one of the best tools in this area), but maybe not reuse the actual
files.

Thanks,
Ludo’.
D
D
Danny Milosavljevic wrote on 17 Jun 2018 23:41
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 31416@debbugs.gnu.org)
20180617234138.725002ef@scratchpost.org
Hi,

On Sun, 17 Jun 2018 22:33:05 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (4 lines)
> Instead of using these .cfg files as-is, how about “importing” them?
> That <soc> structure (or whatever) we discussed could contain
> essentially the relevant part of those .cfg files

Yeah

Toggle quote (3 lines)
> (the partitioning info
> founds in those files seems less relevant to me

Yes. Buildroot is a huge superset of what we actually need :).

Toggle quote (4 lines)
> IOW, we could definitely take Buildroot as an inspiration (it’s probably
> one of the best tools in this area), but maybe not reuse the actual
> files.

The advantage if we reused the actual files is that we'd not have to maintain
it so much ourselves.

But if we use the <soc> solution, it's not actually that much work to maintain it.

I've extracted the list of socs using

u-boot-2018.05$ grep -C 1 -r SYS_SOC . |grep default |awk '{print $3}' |sort |uniq |grep '"' >Q

and I got this list:

"ae250"
"ae3xx"
"ag101"
"am33xx"
"apq8016"
"apq8096"
"armada100"
"aspeed"
"at91"
"ath79"
"au1x00"
"baytrail"
"bcm235xx"
"bcm281xx"
"bcm283x"
"bcm3380"
"bcmcygnus"
"bcmnsp"
"braswell"
"broadwell"
"coreboot"
"davinci"
"efi"
"ep93xx"
"exynos"
"fsl-layerscape"
"hi3798cv200"
"hi6220"
"highbank"
"ivybridge"
"keystone"
"kirkwood"
"lpc32xx"
"ls102xa"
"meson"
"mvebu"
"mx25"
"mx27"
"mx31"
"mx35"
"mx5"
"mx6"
"mx7"
"mx7ulp"
"mx8m"
"mxs"
"ns2"
"omap3"
"omap4"
"omap5"
"orion5x"
"pic32mzda"
"qemu"
"quark"
"queensbay"
"rmobile"
"rockchip"
"s5pc1xx"
"snapdragon"
"socfpga"
"socfpga_arria10"
"spear"
"stih410"
"stm32mp"
"stv0991"
"sunxi"
"tangier"
"tegra114"
"tegra124"
"tegra186"
"tegra20"
"tegra210"
"tegra30"
"uniphier-v7"
"vf610"
"zynq"
"zynqmp"

Not that bad, eh?

Next would be to find those in buildroot, extract the relevant information from their genimage.cfg and unify them.
But that's a little involved. A path would be:

(1) Extract possible SYS_SOC and SYS_VENDOR from all u-boot Kconfigs
(2) Find out which u-boot defconfigs would lead to those u-boot Kconfigs
(3) Find out which buildroot defconfigs would lead to those u-boot defconfigs
(4) Find out which buildroot board directory is used by each buildroot defconfig
(5) Extract the genimage.cfg from each such buildroot board directory
(6) Extract the u-boot installation specific parts from the genimage.cfg
(7) Unify the set of "genimage.cfg" parts for this SOC and make sure they are always the same
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlsm1ZIACgkQ5xo1VCww
uqUapQf/U2K5H8bKNPuwjVnHTtQoJs4XTwZdgDmiCksknqla9ndesZ83JUgu4DGI
TFSutoS6jIaMtHnn/U/V9NATRBOiHxW+cKYk6yggh039VO1k7cFW9GVEjmw1/950
F60k601BO2p1HPLGIQnLhvZghDSRzJpK2ZGWh56vVGBsuIHBqm2/P8q5t3cvksGW
a8AvQ04GcLRM8Et3fqV7XfDsrYQZeVSTO6K3behjbT4ZP081RgupYbr++l85HKn1
zPgM9s/ZD58EqsU0VTeSUJiMSX9woySXROWHtEl0UspW+C/CjeIi0pwN9mjCqiQu
twUq+Lpl+NcXR4xSV19/o3QwjS1mIA==
=vHbM
-----END PGP SIGNATURE-----


L
L
Ludovic Courtès wrote on 18 Jun 2018 10:25
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 31416@debbugs.gnu.org)
874li0y00z.fsf@gnu.org
Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (3 lines)
> On Sun, 17 Jun 2018 22:33:05 +0200
> ludo@gnu.org (Ludovic Courtès) wrote:

[...]

Toggle quote (7 lines)
>> IOW, we could definitely take Buildroot as an inspiration (it’s probably
>> one of the best tools in this area), but maybe not reuse the actual
>> files.
>
> The advantage if we reused the actual files is that we'd not have to maintain
> it so much ourselves.

[...]

Toggle quote (11 lines)
> Next would be to find those in buildroot, extract the relevant information from their genimage.cfg and unify them.
> But that's a little involved. A path would be:
>
> (1) Extract possible SYS_SOC and SYS_VENDOR from all u-boot Kconfigs
> (2) Find out which u-boot defconfigs would lead to those u-boot Kconfigs
> (3) Find out which buildroot defconfigs would lead to those u-boot defconfigs
> (4) Find out which buildroot board directory is used by each buildroot defconfig
> (5) Extract the genimage.cfg from each such buildroot board directory
> (6) Extract the u-boot installation specific parts from the genimage.cfg
> (7) Unify the set of "genimage.cfg" parts for this SOC and make sure they are always the same

Sounds like a plan.

Though honestly, I think it’s fine if we have fewer configs available as
long as they’re known good. It’s not a goal IMO to have as many
supported boards as Buildroot.

So I’d suggest defining the <soc> API and using it, taking inspiration
from those genimage.cfg files as needed.

Thanks,
Ludo’.
?