Subject: [bug#29409] [PATCH] system: Add BeagleBone Black installer.

From: [email-masked]
Date: Thu, 7 Dec 2017 09:52:45 +0100

From: Mathieu Othacehe <[email-masked]>

* gnu/bootloader/u-boot.scm (u-boot-beaglebone-black-bootloader): New exported
  bootloader.
* gnu/system/boards/beaglebone-black.scm: New file returning bbb installer.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add new file.
---
 gnu/bootloader/u-boot.scm              | 18 +++++++++++++++++-
 gnu/local.mk                           |  4 +++-
 gnu/system/boards/beaglebone-black.scm | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 gnu/system/boards/beaglebone-black.scm

diff --git a/gnu/bootloader/u-boot.scm b/gnu/bootloader/u-boot.scm
index 963b0d7..2169680 100644
--- a/gnu/bootloader/u-boot.scm
+++ b/gnu/bootloader/u-boot.scm
@@ -26,13 +26,23 @@
   #:use-module (guix monads)
   #:use-module (guix records)
   #:use-module (guix utils)
-  #:export (u-boot-bootloader))
+  #:export (u-boot-bootloader
+            u-boot-beaglebone-black-bootloader))
 
 (define install-u-boot
   #~(lambda (bootloader device mount-point)
       (if bootloader
         (error "Failed to install U-Boot"))))
 
+(define install-beaglebone-black-u-boot
+  #~(lambda (bootloader device mount-point)
+      (let ((mlo (string-append bootloader "/libexec/MLO"))
+            (u-boot (string-append bootloader "/libexec/u-boot.img")))
+        (#$write-file-on-device mlo (* 256 512)
+                                device (* 256 512))
+        (#$write-file-on-device u-boot (* 1024 512)
+                                device (* 768 512)))))
+
 
 
 ;;;
@@ -45,3 +55,9 @@
    (name 'u-boot)
    (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)))
diff --git a/gnu/local.mk b/gnu/local.mk
index 434bbb0..53fc04e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -487,7 +487,9 @@ GNU_SYSTEM_MODULES =				\
   %D%/system/shadow.scm				\
   %D%/system/uuid.scm				\
   %D%/system/vm.scm				\
-						\
+                                                \
+  %D%/system/boards/beaglebone-black.scm	\
+                                                \
   %D%/build/activation.scm			\
   %D%/build/cross-toolchain.scm			\
   %D%/build/file-systems.scm			\
diff --git a/gnu/system/boards/beaglebone-black.scm b/gnu/system/boards/beaglebone-black.scm
new file mode 100644
index 0000000..19ef412
--- /dev/null
+++ b/gnu/system/boards/beaglebone-black.scm
@@ -0,0 +1,33 @@
+(define-module (gnu system boards beaglebone-black)
+  #:use-module (gnu)
+  #:use-module (gnu system install)
+  #:use-module (gnu bootloader u-boot)
+  #:use-module (gnu packages bootloaders)
+  #:use-module (gnu packages linux)
+  #:export (beaglebone-black-installation-os))
+
+(define beaglebone-black-installation-os
+  (operating-system
+    (inherit installation-os)
+    (bootloader (bootloader-configuration
+                 (bootloader u-boot-beaglebone-black-bootloader)
+                 (target "/dev/sda")))
+    (kernel linux-libre)
+    (initrd (lambda (fs . rest)
+              (apply base-initrd fs
+                     ;; This module is required to mount the sd card.
+                     #:extra-modules (list "omap_hsmmc")
+                     rest)))
+    (services (append
+               ;; mingetty does not work on serial lines.
+               ;; Use agetty with board-specific serial parameters.
+               (list (agetty-service
+                      (agetty-configuration
+                       (extra-options '("-L"))
+                       (baud-rate "115200")
+                       (term "vt100")
+                       (tty "ttyO0"))))
+               (operating-system-user-services installation-os)))))
+
+;; Return it here so 'guix system' can consume it directly.
+beaglebone-black-installation-os
-- 
2.7.4