From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: [PATCH v2 2/2] gnu: Add u-boot. Date: Wed, 31 Aug 2016 23:34:37 +0200 Message-ID: <20160831213437.31115-3-dannym@scratchpost.org> References: <20160831213437.31115-1-dannym@scratchpost.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.9.1" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfD9q-0001sC-3z for guix-devel@gnu.org; Wed, 31 Aug 2016 17:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bfD9j-0003GH-F6 for guix-devel@gnu.org; Wed, 31 Aug 2016 17:34:53 -0400 Received: from dd1012.kasserver.com ([85.13.128.8]:37320) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bfD9j-0003GD-4U for guix-devel@gnu.org; Wed, 31 Aug 2016 17:34:47 -0400 In-Reply-To: <20160831213437.31115-1-dannym@scratchpost.org> 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 This is a multi-part message in MIME format. --------------2.9.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: quoted-printable gnu: Add u-boot. * gnu/packages/u-boot.scm (u-boot, make-u-boot-package, armhf-linux-uboot, mips64el-linux-uboot): New variables. Co-authored-by: David Craven --- gnu/packages/u-boot.scm | 90 +++++++++++++++++++++++++++++++++++++++++++= +++--- 1 file changed, 86 insertions(+), 4 deletions(-) --------------2.9.1 Content-Type: text/x-patch; name="0002-gnu-Add-u-boot.patch" Content-Disposition: attachment; filename="0002-gnu-Add-u-boot.patch" Content-Transfer-Encoding: quoted-printable diff --git a/gnu/packages/u-boot.scm b/gnu/packages/u-boot.scm index 5f3fd49..4a10782 100644 --- a/gnu/packages/u-boot.scm +++ b/gnu/packages/u-boot.scm @@ -23,8 +23,11 @@ #: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)) =20 (define-public dtc (package @@ -38,9 +41,9 @@ (sha256 (base32 "155v52palf5fwfcnq696s41whjk0a5dqx98b7maqzdn7xbc2m6bp")) - (patches (search-patches "u-boot-dtc-01_build_doc.patch" - "u-boot-dtc-23-libfdt-Add-missing= -functions-to-shared-library.patch" - "u-boot-dtc-24_libfdt-Add-some-mi= ssing-symbols-to-version.lds.patch")))) + (patches (search-patches "dtc-01_build_doc.patch" + "dtc-23-libfdt-Add-missing-functi= ons-to-shared-library.patch" + "dtc-24_libfdt-Add-some-missing-s= ymbols-to-version.lds.patch")))) (build-system gnu-build-system) (native-inputs `(("bison" ,bison) @@ -63,3 +66,82 @@ device tree binary (.dtb) files.=20 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 Bootloader") + (description "U-Boot is a bootloader mostly used for ARM boards.=20 +It also initializes the boards (RAM etc).") + (license license:gpl2+))) + +(define (make-u-boot-package board triplet) + (let ((xgcc (cross-gcc triplet))) + (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=3Dgcc" (string-append "CROSS_COMPILE=3D" ,triplet "= -")) + #:phases + (modify-phases %standard-phases + (replace + 'configure + (lambda* (#:key outputs make-flags #:allow-other-keys) + (let ((config-name (string-append ,board "_defconfig"))) + (if (zero? (system* "ls" (string-append "configs/" config= -name))) + (zero? (apply system* "make" `(,@make-flags ,config-na= me))) + (begin + (use-modules (ice-9 match) (ice-9 format)) + (display "Invalid board name. Valid board names woul= d have been:") + (newline) + (let ((dir (opendir "configs"))) + (do ((file-name (readdir dir) (readdir dir))) + ((eof-object? file-name)) + (if (string-suffix? "_defconfig" file-name) + (format #t + "- ~A\n" + (string-drop-right file-name + (string-length "_de= fconfig"))))) + (closedir dir)) + #f))))) + (replace 'install + (lambda* (#:key outputs make-flags #:allow-other-keys) + (let ((out (string-append (assoc-ref outputs "out") "/libex= ec"))) + (mkdir-p out) + (for-each (lambda (name) + (let ((outname (string-append out "/" name))) + (mkdir-p (dirname outname)) + (copy-file name outname))) + (find-files "." ".*\\.(bin|efi|spl)$"))))))))))= ) + +(define-public armhf-linux-uboot + (make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf")) + +(define-public mips64el-linux-uboot + (make-u-boot-package "malta" "mips64el-linux-gnuabi64")) + +;;; 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.1--