guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] gnu: Add u-boot.


From: David Craven
Subject: [PATCH] gnu: Add u-boot.
Date: Mon, 29 Aug 2016 18:16:26 +0200

From: Danny Milosavljevic <address@hidden>

* gnu/packages/u-boot.scm (u-boot, make-u-boot-package,
  u-boot-vexpress_ca9x4, u-boot-malta armhf-linux-uboot,
  mips64el-linux-uboot): New variables.

Co-authored-by: David Craven <address@hidden>
---
 gnu/packages/u-boot.scm | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/u-boot.scm b/gnu/packages/u-boot.scm
index e9376a4..fd69bc1 100644
--- a/gnu/packages/u-boot.scm
+++ b/gnu/packages/u-boot.scm
@@ -22,8 +22,12 @@
   #:use-module (guix download)
   #:use-module (guix packages)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module ((gnu packages algebra) #:select (bc))
   #:use-module (gnu packages bison)
-  #:use-module (gnu packages flex))
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages python))
 
 (define-public dtc
   (package
@@ -58,3 +62,80 @@
     (description "dtc compiles Device Tree Source Files to Device Tree Binary 
Files.
 These are hardware (board) description files (used by Linux and BSD).")
     (license license:gpl2+)))
+
+(define u-boot
+  (package
+    (name "u-boot")
+    (version "2016.07")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "ftp://ftp.denx.de/pub/u-boot/";
+                    "u-boot-" version ".tar.bz2"))
+              (sha256
+               (base32
+                "0lqj4ckmfqiap8mc6z2d5albs3g2h5mzccbn60hsgxhabhibfkwp"))))
+    (native-inputs
+     `(("bc" ,bc)
+       ("dtc" ,dtc)
+       ("python-2" ,python-2)))
+    (build-system  gnu-build-system)
+    (home-page "http://www.denx.de/wiki/U-Boot/";)
+    (synopsis "ARM Universal Bootloader")
+    (description "U-Boot is an universal bootloader mostly used for ARM boards.
+It also initializes the boards (RAM etc).")
+    (license license:gpl2+)))
+
+(define (make-u-boot-package board triplet xgcc)
+  (package
+    (inherit u-boot)
+    (name (string-append "u-boot-" (string-downcase board)))
+    (native-inputs
+     `(("cross-gcc" ,xgcc)
+       ("cross-binutils" ,(cross-binutils triplet))
+       ,@(package-native-inputs u-boot)))
+    (arguments
+     `(#:test-target "test"
+       #:make-flags
+       (list "HOSTCC=gcc" (string-append "CROSS_COMPILE=" ,triplet "-"))
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key outputs make-flags #:allow-other-keys)
+             (let ((configname (string-append ,board "_defconfig")))
+               (if (file-exists? (string-append "configs/" configname))
+                   (zero? (apply system* "make" `(,@make-flags ,configname)))
+                   (begin
+                     (display "Invalid boardname. Valid boardnames would have 
been:")
+                     (newline)
+                     (system* "ls" "-1" "configs")
+                     #f)))))
+         (replace 'install
+           (lambda* (#:key outputs make-flags #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (libexec (string-append out "/libexec"))
+                    (uboot-files (find-files "." ".*\\.(bin|efi)$")))
+               (mkdir-p libexec)
+               (for-each
+                (lambda (file-path)
+                  (let ((target-file-path (string-append libexec "/" 
file-path)))
+                    (mkdir-p (dirname target-file-path))
+                    (copy-file file-path target-file-path)))
+                uboot-files)))))))))
+
+(define-public u-boot-vexpress_ca9x4
+  (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf" xgcc-armhf))
+
+(define-public u-boot-malta
+  (make-u-boot-package "malta" "mips64el-linux-gnuabi64" xgcc-mips64el))
+
+(define-public armhf-linux-uboot
+  u-boot-vexpress_ca9x4)
+
+(define-public mips64el-linux-uboot
+  u-boot-malta)
+
+;; Something should:
+;; - create extlinux.conf and put it on the first bootable partition
+;;   (the one with the Active flag)
+;; - install the u-boot bootloader
-- 
2.9.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]