unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#31416] [PATCH 0/4] Generalize bootloader installer selection.
@ 2018-05-11 14:35 Danny Milosavljevic
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
  2023-07-21 16:53 ` [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Maxim Cournoyer
  0 siblings, 2 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-11 14:35 UTC (permalink / raw)
  To: 31416

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(-)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 1/4] system: Add os-with-u-boot.
  2018-05-11 14:35 [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Danny Milosavljevic
@ 2018-05-11 14:36 ` Danny Milosavljevic
  2018-05-11 14:36   ` [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer Danny Milosavljevic
                     ` (4 more replies)
  2023-07-21 16:53 ` [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Maxim Cournoyer
  1 sibling, 5 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-11 14:36 UTC (permalink / raw)
  To: 31416

* 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(-)

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.

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer.
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
@ 2018-05-11 14:36   ` Danny Milosavljevic
  2018-05-13  9:31     ` Ludovic Courtès
  2018-05-11 14:36   ` [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader Danny Milosavljevic
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-11 14:36 UTC (permalink / raw)
  To: 31416

* 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)))))))
 
 (define install-beaglebone-black-u-boot
   ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
  2018-05-11 14:36   ` [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer Danny Milosavljevic
@ 2018-05-11 14:36   ` Danny Milosavljevic
  2018-05-13  9:36     ` Ludovic Courtès
  2018-05-11 14:36   ` [bug#31416] [PATCH 4/4] bootloader: Simplify bootloader installer selection Danny Milosavljevic
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-11 14:36 UTC (permalink / raw)
  To: 31416

* 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(-)

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))

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 4/4] bootloader: Simplify bootloader installer selection.
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
  2018-05-11 14:36   ` [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer Danny Milosavljevic
  2018-05-11 14:36   ` [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader Danny Milosavljevic
@ 2018-05-11 14:36   ` Danny Milosavljevic
  2018-05-13  9:24   ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Ludovic Courtès
  2018-05-13 12:09   ` Jelle Licht
  4 siblings, 0 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-11 14:36 UTC (permalink / raw)
  To: 31416

* 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(-)

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"))
 

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 1/4] system: Add os-with-u-boot.
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
                     ` (2 preceding siblings ...)
  2018-05-11 14:36   ` [bug#31416] [PATCH 4/4] bootloader: Simplify bootloader installer selection Danny Milosavljevic
@ 2018-05-13  9:24   ` Ludovic Courtès
  2018-05-13 12:09   ` Jelle Licht
  4 siblings, 0 replies; 24+ messages in thread
From: Ludovic Courtès @ 2018-05-13  9:24 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Hello!

Great that you’re streamlining GuixSD on ARM!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * 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.

[...]

> +@subsection Building the Installation Image for ARM boards

“Boards”

> +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.”

> +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.

> +Or if you don't cross compile:

It’s not cross-compilation.  :-)

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

> +"A20-OLinuXino-Lime2" is the name of the board.  If you specify an invalid
   ^
@code

> +board, you get a list.

I think the patch is otherwise OK.

Ludo’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer.
  2018-05-11 14:36   ` [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer Danny Milosavljevic
@ 2018-05-13  9:31     ` Ludovic Courtès
  2018-05-13 10:43       ` Danny Milosavljevic
  0 siblings, 1 reply; 24+ messages in thread
From: Ludovic Courtès @ 2018-05-13  9:31 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> * 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’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-11 14:36   ` [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader Danny Milosavljevic
@ 2018-05-13  9:36     ` Ludovic Courtès
  2018-05-13 11:03       ` Danny Milosavljevic
  0 siblings, 1 reply; 24+ messages in thread
From: Ludovic Courtès @ 2018-05-13  9:36 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> +(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’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer.
  2018-05-13  9:31     ` Ludovic Courtès
@ 2018-05-13 10:43       ` Danny Milosavljevic
  0 siblings, 0 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-13 10:43 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

Hi Ludo,

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

> 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.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-13  9:36     ` Ludovic Courtès
@ 2018-05-13 11:03       ` Danny Milosavljevic
  2018-05-13 11:15         ` Danny Milosavljevic
                           ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-13 11:03 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416

[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]

Hi Ludo,

>   (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...

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-13 11:03       ` Danny Milosavljevic
@ 2018-05-13 11:15         ` Danny Milosavljevic
  2018-05-14  8:31           ` Ludovic Courtès
  2018-05-13 13:46         ` Danny Milosavljevic
  2018-05-14  8:34         ` Ludovic Courtès
  2 siblings, 1 reply; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-13 11:15 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

> 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?

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 1/4] system: Add os-with-u-boot.
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
                     ` (3 preceding siblings ...)
  2018-05-13  9:24   ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Ludovic Courtès
@ 2018-05-13 12:09   ` Jelle Licht
  4 siblings, 0 replies; 24+ messages in thread
From: Jelle Licht @ 2018-05-13 12:09 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]

2018-05-11 16:36 GMT+02:00 Danny Milosavljevic <dannym@scratchpost.org>:
[...]

> +@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.

> +
> +@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 ;-).

> +
> +@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?

> [...]
>
>
Thanks for working on this! I really want to see GuixSD on ARM succeed as
well.

[-- Attachment #2: Type: text/html, Size: 2143 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-13 11:03       ` Danny Milosavljevic
  2018-05-13 11:15         ` Danny Milosavljevic
@ 2018-05-13 13:46         ` Danny Milosavljevic
  2018-05-14  8:34         ` Ludovic Courtès
  2 siblings, 0 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-13 13:46 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-13 11:15         ` Danny Milosavljevic
@ 2018-05-14  8:31           ` Ludovic Courtès
  0 siblings, 0 replies; 24+ messages in thread
From: Ludovic Courtès @ 2018-05-14  8:31 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> 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:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,use(guix utils)
scheme@(guile-user)> (nix-system->gnu-triplet (%current-system))
$2 = "x86_64-unknown-linux-gnu"
--8<---------------cut here---------------end--------------->8---

Ludo’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-13 11:03       ` Danny Milosavljevic
  2018-05-13 11:15         ` Danny Milosavljevic
  2018-05-13 13:46         ` Danny Milosavljevic
@ 2018-05-14  8:34         ` Ludovic Courtès
  2018-05-14 16:29           ` Danny Milosavljevic
  2 siblings, 1 reply; 24+ messages in thread
From: Ludovic Courtès @ 2018-05-14  8:34 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Hello Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

>>   (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’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-14  8:34         ` Ludovic Courtès
@ 2018-05-14 16:29           ` Danny Milosavljevic
  2018-06-15  7:12             ` Ludovic Courtès
  0 siblings, 1 reply; 24+ messages in thread
From: Danny Milosavljevic @ 2018-05-14 16:29 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416

Ji Ludo,

> 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 ?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-05-14 16:29           ` Danny Milosavljevic
@ 2018-06-15  7:12             ` Ludovic Courtès
  2018-06-17  0:28               ` Danny Milosavljevic
  0 siblings, 1 reply; 24+ messages in thread
From: Ludovic Courtès @ 2018-06-15  7:12 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Hi Danny,

Apologies for dropping the ball!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> 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.

> 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).

> Where do we put it? gnu/bootloader/u-boot.scm ?

Sounds like the right place, yes.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-06-15  7:12             ` Ludovic Courtès
@ 2018-06-17  0:28               ` Danny Milosavljevic
  2018-06-17 12:35                 ` Danny Milosavljevic
  2018-06-17 20:33                 ` Ludovic Courtès
  0 siblings, 2 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-06-17  0:28 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416


[-- Attachment #1.1: Type: text/plain, Size: 1272 bytes --]

Hi Ludo,

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

> 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:

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.

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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: QQ.patch --]
[-- Type: text/x-patch, Size: 12953 bytes --]

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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-06-17  0:28               ` Danny Milosavljevic
@ 2018-06-17 12:35                 ` Danny Milosavljevic
  2018-06-17 20:33                 ` Ludovic Courtès
  1 sibling, 0 replies; 24+ messages in thread
From: Danny Milosavljevic @ 2018-06-17 12:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416


[-- Attachment #1.1: Type: text/plain, Size: 55 bytes --]

v2, with u-boot-without-buildroot fallback, attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: QQ2.patch --]
[-- Type: text/x-patch, Size: 13445 bytes --]

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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-06-17  0:28               ` Danny Milosavljevic
  2018-06-17 12:35                 ` Danny Milosavljevic
@ 2018-06-17 20:33                 ` Ludovic Courtès
  2018-06-17 21:41                   ` Danny Milosavljevic
  1 sibling, 1 reply; 24+ messages in thread
From: Ludovic Courtès @ 2018-06-17 20:33 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Hello Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> 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’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-06-17 20:33                 ` Ludovic Courtès
@ 2018-06-17 21:41                   ` Danny Milosavljevic
  2018-06-18  8:25                     ` Ludovic Courtès
  0 siblings, 1 reply; 24+ messages in thread
From: Danny Milosavljevic @ 2018-06-17 21:41 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31416

[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]

Hi,

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

> 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

> (the partitioning info
> founds in those files seems less relevant to me

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

> 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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader.
  2018-06-17 21:41                   ` Danny Milosavljevic
@ 2018-06-18  8:25                     ` Ludovic Courtès
  0 siblings, 0 replies; 24+ messages in thread
From: Ludovic Courtès @ 2018-06-18  8:25 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

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

[...]

>> 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.

[...]

> 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’.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [bug#31416] [PATCH 0/4] Generalize bootloader installer selection.
  2018-05-11 14:35 [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Danny Milosavljevic
  2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
@ 2023-07-21 16:53 ` Maxim Cournoyer
  2023-09-01 18:47   ` bug#31416: " Maxim Cournoyer
  1 sibling, 1 reply; 24+ messages in thread
From: Maxim Cournoyer @ 2023-07-21 16:53 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> writes:

> 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.

Is there something to salvage here, 5 years later, or should we close
this?

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 24+ messages in thread

* bug#31416: [PATCH 0/4] Generalize bootloader installer selection.
  2023-07-21 16:53 ` [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Maxim Cournoyer
@ 2023-09-01 18:47   ` Maxim Cournoyer
  0 siblings, 0 replies; 24+ messages in thread
From: Maxim Cournoyer @ 2023-09-01 18:47 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: 31416-done

Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

> Hi Danny,
>
> Danny Milosavljevic <dannym@scratchpost.org> writes:
>
>> 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.
>
> Is there something to salvage here, 5 years later, or should we close
> this?

Closing.

-- 
Thanks,
Maxim




^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-09-01 18:47 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-11 14:35 [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Danny Milosavljevic
2018-05-11 14:36 ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Danny Milosavljevic
2018-05-11 14:36   ` [bug#31416] [PATCH 2/4] bootloader: install-u-boot: Automatically select the correct installer Danny Milosavljevic
2018-05-13  9:31     ` Ludovic Courtès
2018-05-13 10:43       ` Danny Milosavljevic
2018-05-11 14:36   ` [bug#31416] [PATCH 3/4] bootloader: Add make-u-boot-bootloader Danny Milosavljevic
2018-05-13  9:36     ` Ludovic Courtès
2018-05-13 11:03       ` Danny Milosavljevic
2018-05-13 11:15         ` Danny Milosavljevic
2018-05-14  8:31           ` Ludovic Courtès
2018-05-13 13:46         ` Danny Milosavljevic
2018-05-14  8:34         ` Ludovic Courtès
2018-05-14 16:29           ` Danny Milosavljevic
2018-06-15  7:12             ` Ludovic Courtès
2018-06-17  0:28               ` Danny Milosavljevic
2018-06-17 12:35                 ` Danny Milosavljevic
2018-06-17 20:33                 ` Ludovic Courtès
2018-06-17 21:41                   ` Danny Milosavljevic
2018-06-18  8:25                     ` Ludovic Courtès
2018-05-11 14:36   ` [bug#31416] [PATCH 4/4] bootloader: Simplify bootloader installer selection Danny Milosavljevic
2018-05-13  9:24   ` [bug#31416] [PATCH 1/4] system: Add os-with-u-boot Ludovic Courtès
2018-05-13 12:09   ` Jelle Licht
2023-07-21 16:53 ` [bug#31416] [PATCH 0/4] Generalize bootloader installer selection Maxim Cournoyer
2023-09-01 18:47   ` bug#31416: " Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).