2016-08-29 16:45:34 +02:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2016 Danny Milosavljevic <dannym@scratchpost.org>
|
|
|
|
;;; Copyright © 2016 David Craven <david@craven.ch>
|
|
|
|
;;;
|
|
|
|
;;; 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (gnu packages u-boot)
|
|
|
|
#:use-module (guix build-system gnu)
|
|
|
|
#:use-module (guix download)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module ((guix licenses) #:prefix license:)
|
2016-08-29 18:11:04 +02:00
|
|
|
#:use-module (gnu packages)
|
|
|
|
#:use-module ((gnu packages algebra) #:select (bc))
|
2016-08-29 16:45:34 +02:00
|
|
|
#:use-module (gnu packages bison)
|
2016-08-29 18:11:04 +02:00
|
|
|
#:use-module (gnu packages cross-base)
|
|
|
|
#:use-module (gnu packages flex)
|
|
|
|
#:use-module (gnu packages python))
|
2016-08-29 16:45:34 +02:00
|
|
|
|
|
|
|
(define-public dtc
|
|
|
|
(package
|
|
|
|
(name "dtc")
|
2016-09-04 12:50:09 +02:00
|
|
|
(version "1.4.2")
|
2016-08-29 16:45:34 +02:00
|
|
|
(source (origin
|
|
|
|
(method url-fetch)
|
|
|
|
(uri (string-append
|
|
|
|
"https://www.kernel.org/pub/software/utils/dtc/"
|
|
|
|
"dtc-" version ".tar.xz"))
|
|
|
|
(sha256
|
|
|
|
(base32
|
2016-09-04 12:50:09 +02:00
|
|
|
"1b7si8niyca4wxbfah3qw4p4wli81mc1qwfhaswvrfqahklnwi8k"))))
|
2016-08-29 16:45:34 +02:00
|
|
|
(build-system gnu-build-system)
|
|
|
|
(native-inputs
|
|
|
|
`(("bison" ,bison)
|
|
|
|
("flex" ,flex)))
|
|
|
|
(arguments
|
|
|
|
`(#:make-flags
|
2016-09-08 17:10:42 +02:00
|
|
|
(list "CC=gcc"
|
|
|
|
(string-append "PREFIX=" (assoc-ref %outputs "out"))
|
|
|
|
"INSTALL=install")
|
2016-08-29 16:45:34 +02:00
|
|
|
#:phases
|
|
|
|
(modify-phases %standard-phases
|
|
|
|
(delete 'configure))))
|
|
|
|
(home-page "https://www.devicetree.org")
|
|
|
|
(synopsis "Compiles device tree source files")
|
2017-01-31 09:06:33 +01:00
|
|
|
(description "@command{dtc} compiles
|
|
|
|
@uref{http://elinux.org/Device_Tree_Usage, device tree source files} to device
|
|
|
|
tree binary files. These are board description files used by Linux and BSD.")
|
2016-08-29 16:45:34 +02:00
|
|
|
(license license:gpl2+)))
|
2016-08-29 18:11:04 +02:00
|
|
|
|
|
|
|
(define u-boot
|
|
|
|
(package
|
|
|
|
(name "u-boot")
|
2017-02-06 10:00:24 +01:00
|
|
|
(version "2017.01")
|
2016-08-29 18:11:04 +02:00
|
|
|
(source (origin
|
|
|
|
(method url-fetch)
|
|
|
|
(uri (string-append
|
|
|
|
"ftp://ftp.denx.de/pub/u-boot/"
|
|
|
|
"u-boot-" version ".tar.bz2"))
|
|
|
|
(sha256
|
|
|
|
(base32
|
2017-02-06 10:00:24 +01:00
|
|
|
"1wpc51jm3zyibgcr78jng2yksqvrya76bxgsr4pcyjrsz5sm2hkc"))))
|
2016-08-29 18:11:04 +02:00
|
|
|
(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 used mostly for ARM boards. It
|
|
|
|
also initializes the boards (RAM etc).")
|
|
|
|
(license license:gpl2+)))
|
|
|
|
|
|
|
|
(define (make-u-boot-package board triplet)
|
|
|
|
"Returns a u-boot package for BOARD cross-compiled for TRIPLET."
|
|
|
|
(package
|
|
|
|
(inherit u-boot)
|
|
|
|
(name (string-append "u-boot-" (string-downcase board)))
|
|
|
|
(native-inputs
|
|
|
|
`(("cross-gcc" ,(cross-gcc triplet))
|
|
|
|
("cross-binutils" ,(cross-binutils triplet))
|
|
|
|
,@(package-native-inputs u-boot)))
|
|
|
|
(arguments
|
2017-02-01 16:16:52 +01:00
|
|
|
`(#:modules ((ice-9 ftw) (guix build utils) (guix build gnu-build-system))
|
|
|
|
#:test-target "test"
|
2016-08-29 18:11:04 +02:00
|
|
|
#: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 ((config-name (string-append ,board "_defconfig")))
|
|
|
|
(if (file-exists? (string-append "configs/" config-name))
|
|
|
|
(zero? (apply system* "make" `(,@make-flags ,config-name)))
|
|
|
|
(begin
|
|
|
|
(display "Invalid board name. Valid board names are:")
|
2017-02-01 16:16:52 +01:00
|
|
|
(let ((suffix-len (string-length "_defconfig")))
|
|
|
|
(scandir "configs"
|
|
|
|
(lambda (file-name)
|
|
|
|
(when (string-suffix? "_defconfig" file-name)
|
|
|
|
(format #t
|
|
|
|
"- ~A\n"
|
|
|
|
(string-drop-right file-name
|
|
|
|
suffix-len))))))
|
2016-08-29 18:11:04 +02:00
|
|
|
#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|spl)$")))
|
|
|
|
(mkdir-p libexec)
|
|
|
|
(for-each
|
|
|
|
(lambda (file)
|
|
|
|
(let ((target-file (string-append libexec "/" file)))
|
|
|
|
(mkdir-p (dirname target-file))
|
|
|
|
(copy-file file target-file)))
|
|
|
|
uboot-files)))))))))
|
|
|
|
|
2016-09-13 19:03:01 +02:00
|
|
|
(define-public u-boot-vexpress
|
2016-08-29 18:11:04 +02:00
|
|
|
(make-u-boot-package "vexpress_ca9x4" "arm-linux-gnueabihf"))
|
|
|
|
|
|
|
|
(define-public u-boot-malta
|
|
|
|
(make-u-boot-package "malta" "mips64el-linux-gnuabi64"))
|
2016-09-08 17:17:04 +02:00
|
|
|
|
|
|
|
(define-public u-boot-beagle-bone-black
|
|
|
|
(make-u-boot-package "am335x_boneblack" "arm-linux-gnueabihf"))
|