gnu: Update emacs-org, emacs-org-contrib.
[jackhill/guix/guix.git] / gnu / bootloader / u-boot.scm
CommitLineData
8d858010
DM
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 David Craven <david@craven.ch>
3;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
4;;;
5;;; This file is part of GNU Guix.
6;;;
7;;; GNU Guix is free software; you can redistribute it and/or modify it
8;;; under the terms of the GNU General Public License as published by
9;;; the Free Software Foundation; either version 3 of the License, or (at
10;;; your option) any later version.
11;;;
12;;; GNU Guix is distributed in the hope that it will be useful, but
13;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;;; GNU General Public License for more details.
16;;;
17;;; You should have received a copy of the GNU General Public License
18;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20(define-module (gnu bootloader u-boot)
21 #:use-module (gnu bootloader extlinux)
22 #:use-module (gnu bootloader)
23 #:use-module (gnu system)
ceb39527 24 #:use-module (gnu build bootloader)
8d858010
DM
25 #:use-module (gnu packages bootloaders)
26 #:use-module (guix gexp)
27 #:use-module (guix monads)
28 #:use-module (guix records)
29 #:use-module (guix utils)
ceb39527 30 #:export (u-boot-bootloader
c55c6985 31 u-boot-a20-olinuxino-lime-bootloader
4b9e9abb 32 u-boot-a20-olinuxino-lime2-bootloader
a7bb327e 33 u-boot-a20-olinuxino-micro-bootloader
30aeb846 34 u-boot-banana-pi-m2-ultra-bootloader
84ee3378
DM
35 u-boot-beaglebone-black-bootloader
36 u-boot-nintendo-nes-classic-edition-bootloader))
8d858010
DM
37
38(define install-u-boot
39 #~(lambda (bootloader device mount-point)
40 (if bootloader
41 (error "Failed to install U-Boot"))))
42
ceb39527
MO
43(define install-beaglebone-black-u-boot
44 ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
45 ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
46 ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
47 ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
48 ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
49 ;; specified DEVICE.
50 #~(lambda (bootloader device mount-point)
51 (let ((mlo (string-append bootloader "/libexec/MLO"))
52 (u-boot (string-append bootloader "/libexec/u-boot.img")))
53 (write-file-on-device mlo (* 256 512)
54 device (* 256 512))
55 (write-file-on-device u-boot (* 1024 512)
56 device (* 768 512)))))
57
30aeb846
DM
58(define install-allwinner-u-boot
59 #~(lambda (bootloader device mount-point)
60 (let ((u-boot (string-append bootloader
61 "/libexec/u-boot-sunxi-with-spl.bin")))
62 (write-file-on-device u-boot (stat:size (stat u-boot))
63 device (* 8 1024)))))
64
8d858010
DM
65\f
66
67;;;
68;;; Bootloader definitions.
69;;;
70
71(define u-boot-bootloader
72 (bootloader
73 (inherit extlinux-bootloader)
74 (name 'u-boot)
75 (package #f)
76 (installer install-u-boot)))
ceb39527
MO
77
78(define u-boot-beaglebone-black-bootloader
79 (bootloader
80 (inherit u-boot-bootloader)
81 (package u-boot-beagle-bone-black)
82 (installer install-beaglebone-black-u-boot)))
30aeb846
DM
83
84(define u-boot-allwinner-bootloader
85 (bootloader
86 (inherit u-boot-bootloader)
87 (installer install-allwinner-u-boot)))
88
84ee3378
DM
89(define u-boot-nintendo-nes-classic-edition-bootloader
90 (bootloader
91 (inherit u-boot-allwinner-bootloader)
92 (package u-boot-nintendo-nes-classic-edition)))
93
c55c6985
DM
94(define u-boot-a20-olinuxino-lime-bootloader
95 (bootloader
96 (inherit u-boot-allwinner-bootloader)
97 (package u-boot-a20-olinuxino-lime)))
98
4b9e9abb
DM
99(define u-boot-a20-olinuxino-lime2-bootloader
100 (bootloader
101 (inherit u-boot-allwinner-bootloader)
102 (package u-boot-a20-olinuxino-lime2)))
103
a7bb327e
DM
104(define u-boot-a20-olinuxino-micro-bootloader
105 (bootloader
106 (inherit u-boot-allwinner-bootloader)
107 (package u-boot-a20-olinuxino-micro)))
108
30aeb846
DM
109(define u-boot-banana-pi-m2-ultra-bootloader
110 (bootloader
111 (inherit u-boot-allwinner-bootloader)
112 (package u-boot-banana-pi-m2-ultra)))