From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Craven Subject: [PATCH] gnu: Add u-boot. Date: Mon, 29 Aug 2016 18:16:26 +0200 Message-ID: <20160829161626.25216-1-david@craven.ch> References: <20160829144822.3188-1-david@craven.ch> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bePEz-0006S9-5H for guix-devel@gnu.org; Mon, 29 Aug 2016 12:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bePEt-0004xD-3i for guix-devel@gnu.org; Mon, 29 Aug 2016 12:16:52 -0400 Received: from so254-10.mailgun.net ([198.61.254.10]:37570) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bePEr-0004wv-Ra for guix-devel@gnu.org; Mon, 29 Aug 2016 12:16:47 -0400 In-Reply-To: <20160829144822.3188-1-david@craven.ch> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org From: Danny Milosavljevic * 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 --- 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