diff mbox

wip v2 u-boot support

Message ID CAL1_imn=tB-gDsZ5iOm_uyopHS8YCYyaF5R=h7BjLLDnAjVeww@mail.gmail.com
State New
Headers show

Commit Message

David Craven Sept. 8, 2016, 10:09 p.m. UTC
Hi Danny,

I'm testing your new u-boot code. I fixed a few bugs, but there is
still some work to do... ;-)

guix system vm u-boot-test.scm --no-grub

This should work without giving any errors and boot (it doesn't matter
that u-boot is built for arm). And after booting there should be the
extlinux.conf file.

Below is a test operating-system and the stuff I've already fixed.

(use-modules (gnu))
(use-package-modules linux u-boot)
(use-service-modules base networking ssh)

(operating-system
  (host-name "beagle-bone-black")
  (timezone "Europe/Zurich")
  (locale "en_US.UTF-8")

  (bootloader (u-boot-configuration
               (u-boot u-boot-beagle-bone-black)))
  (kernel linux-libre) ; linux-libre-beagle-bone-black

  (file-systems
   (cons
    (file-system
      (mount-point "/")
      (type "ext4")
      (title 'label)
      (device "root"))
    %base-file-systems))

  (users
   (cons*
    (user-account
     (name "test")
     (group "users")
     (supplementary-groups '("wheel" "video"))
     (home-directory "/home/test")
     (password "sa5JEXtYx/rm6")) ; Password is pass.
    %base-user-accounts))

  (services
   (cons*
    (dropbear-service)
    (dhcp-client-service)
    %base-services)))

                    (default '()))
   (default-entry   u-boot-configuration-default-entry  ; integer
@@ -96,7 +93,7 @@ corresponding to old generations of the system."
   FDTDIR .
   APPEND ~a
 ~%"
-                #$label
+                #$label #$label
                 #$linux #$linux-image-name
                 #$initrd
                 (string-join (list #$@arguments))))))

Comments

Danny Milosavljevic Sept. 8, 2016, 11:57 p.m. UTC | #1
Hi David,
Hi Ludo,

On Fri, 9 Sep 2016 00:09:57 +0200
David Craven <david@craven.ch> wrote:

> I'm testing your new u-boot code. I fixed a few bugs, but there is
> still some work to do... ;-)
> 
> guix system vm u-boot-test.scm --no-grub
> 
> This should work without giving any errors and boot (it doesn't matter
> that u-boot is built for arm). And after booting there should be the
> extlinux.conf file.
> 
> Below is a test operating-system and the stuff I've already fixed.

Nice!

> --- a/gnu/system/grub.scm
> +++ b/gnu/system/grub.scm
> +            <menu-entry>

Ludo was against that because it makes other packages aware how the data structure <menu-entry> is implemented. Can it be avoided?

The only place where it's used externally:

gnu/system/u-boot.scm (copied from gnu/system/grub.scm where it was also used):

(define (u-boot-configuration-file ...)
 (define entry->gexp
  (match-lambda
    (($ <menu-entry> label linux ...
        ^^^^^^

Probably something like

 (? menu-entry? ...)
...   (menu-entry-label ...)
   ... (menu-entry-linux ...)

, right?

> -                #$label
> +                #$label #$label

Indeed.

I fixed the guix system vm problem by modifying 

  gnu/system/vm.scm

to say

  (package->derivation (operating-system-grub os))

instead of

  (operating-system-grub os)

in two places.

Now it failed because someone in gnu/system.scm used grub-configuration-file on a <u-boot-configuration> :P

So replace the call of grub-configuration-file by bootloader-configuration-file, add it as follows:

(define* (bootloader-configuration-file config store-fs entries
                                        #:key
                                        (system (%current-system))
                                        (old-entries '()))
  ((match config
    ((? grub-configuration? config) grub-configuration-file)
    ((? u-boot-configuration? config) u-boot-configuration-file))
    config store-fs entries #:system system #:old-entries old-entries))

Then it complained about the built-in "format" not knowing "~d" which is used by gnu/system/u-boot.scm at the bottom. So change that to "~a".

Then it complained about gnu/system/u-boot.scm entry->gexp. Replace "~a/~a ~a" by "~a/~a".

It then successfully built a VM for me with your config.

@Ludo: Not sure where the step from package to derivation is supposed to be done (it works at that place - but is it the right place?). In the end, the build side needs to know the name of the bootloader installation directory in order to be able to read the image to install in the boot sector etc, right? And that is a way.
diff mbox

Patch

diff --git a/gnu/system.scm b/gnu/system.scm
index 24e4e15..153f7b0 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -733,9 +733,16 @@  listed in OS.  The C library expects to find it under
                                                     "/boot")
                                    (operating-system-kernel-arguments os)))
                            (initrd #~(string-append #$system "/initrd"))))))
-    (grub-configuration-file (operating-system-bootloader os)
-                             store-fs entries
-                             #:old-entries old-entries)))
+
+    (match (operating-system-bootloader os)
+      ((? grub-configuration? config)
+       (grub-configuration-file (operating-system-bootloader os)
+                                store-fs entries
+                                #:old-entries old-entries))
+      ((? u-boot-configuration? config)
+       (u-boot-configuration-file (operating-system-bootloader os)
+                                  store-fs entries
+                                  #:old-entries old-entries)))))

 (define (operating-system-parameters-file os)
   "Return a file that describes the boot parameters of OS.  The primary use of
diff --git a/gnu/system/grub.scm b/gnu/system/grub.scm
index 4c9da8c..c3d2efb 100644
--- a/gnu/system/grub.scm
+++ b/gnu/system/grub.scm
@@ -52,6 +52,7 @@ 
             grub-configuration-package
             grub-configuration-device

+            <menu-entry>
             menu-entry
             menu-entry?

diff --git a/gnu/system/u-boot.scm b/gnu/system/u-boot.scm
index 00a0165..d56f75e 100644
--- a/gnu/system/u-boot.scm
+++ b/gnu/system/u-boot.scm
@@ -48,10 +48,7 @@ 
 (define-record-type* <u-boot-configuration>
   u-boot-configuration make-u-boot-configuration
   u-boot-configuration?
-  (board           u-boot-configuration-board)           ; string ;
not optional!
-  (u-boot          u-boot-configuration-u-boot           ; package
-                   (default #f)) ; will actually default to
(make-u-boot-package board)
-  (device          u-boot-configuration-device)        ; string
+  (u-boot          u-boot-configuration-u-boot)        ; package
   (menu-entries    u-boot-configuration-menu-entries   ; list