;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Danny Milosavljevic ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages u-boot) #:use-module (guix download) #:use-module (guix packages) #:use-module ((guix licenses) #:select (gpl2)) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (gnu packages) #:use-module (gnu packages python) #:use-module (gnu packages bison) #:use-module (gnu packages flex) #:use-module (gnu packages algebra) ; bc #:use-module (srfi srfi-1) #:use-module ((srfi srfi-1) #:select (last))) (define-public device-tree-compiler (package (name "device-tree-compiler") (version "1.4.0") (source (origin (method url-fetch) ;; or (uri (string-append "https://launchpad.net/ubuntu/+archive/primary/+files/" "device-tree-compiler_" version "+dfsg.orig.tar.gz")) (sha256 (base32 "0hzsqkpbgl73fblpnaiczirgwn0hapa7z478xjy6vvkqljpa3ygm")) (patches (search-patches "u-boot-device-tree-compiler-01_build_doc.patch" "u-boot-device-tree-compiler-23-libfdt-Add-missing-functions-to-shared-library.patch" "u-boot-device-tree-compiler-24_libfdt-Add-some-missing-symbols-to-version.lds.patch")) (modules '((guix build utils))) (snippet '(substitute* "Makefile" (("/usr/bin/install") "install"))))) (home-page "https://git.kernel.org/cgit/utils/dtc/dtc.git") (synopsis "Compiles Device Tree Source Files (.dts)") (description "dtc compiles Device Tree Source Files to Device Tree Binary Files. These are hardware (board) description files (used by Linux and BSD).") (license gpl2) (build-system gnu-build-system) (native-inputs `(("bison" ,bison) ("flex" ,flex))) (arguments `(#:make-flags `("CC=gcc" ,(string-append "HOME=" (assoc-ref %outputs "out"))) ; Note: or patch out PREFIX #:phases (modify-phases %standard-phases (delete 'configure)))))) (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")))) (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 gpl2) (native-inputs `(("python-2" ,python-2) ("device-tree-compiler" ,device-tree-compiler) ("bc" ,bc))) (build-system gnu-build-system))) (define (make-u-boot-package board) (package (inherit u-boot) (name (string-append "u-boot-" (string-downcase board))) (arguments `(#:test-target "test" ,@(if (string-prefix? "x86_64" (or (%current-target-system) (%current-system))) '(#:system "i686-linux") '()) #:make-flags '("HOSTCC=gcc") #:phases (modify-phases %standard-phases (replace 'configure (lambda* (#:key outputs make-flags #:allow-other-keys) (let ((configname (string-append ,board "_defconfig"))) (if (zero? (system* "ls" (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 (string-append (assoc-ref outputs "out") "/libexec"))) (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)$")))))))))) ;(define-public u-boot-a20-olinuxino-lime2 ; (make-u-boot-package "A20-OLinuXino-Lime2")) ;(define-public u-boot-efi-x86 ; (make-u-boot-package "efi-x86")) ; Something should: ; - create extlinux.conf and put it on the first bootable partition (the one with the Active flag) ; - install the u-boot bootloader