gnu: Add arm-trusted-firmware-rk3328.
[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)
8d858010
DM
23 #:use-module (gnu packages bootloaders)
24 #:use-module (guix gexp)
ceb39527 25 #:export (u-boot-bootloader
c55c6985 26 u-boot-a20-olinuxino-lime-bootloader
4b9e9abb 27 u-boot-a20-olinuxino-lime2-bootloader
a7bb327e 28 u-boot-a20-olinuxino-micro-bootloader
e830c9d0 29 u-boot-bananapi-m2-ultra-bootloader
84ee3378 30 u-boot-beaglebone-black-bootloader
07ca9045 31 u-boot-mx6cuboxi-bootloader
fd5536e3 32 u-boot-nintendo-nes-classic-edition-bootloader
1b960787 33 u-boot-novena-bootloader
9f7d6665 34 u-boot-pine64-plus-bootloader
74e35e8c 35 u-boot-pinebook-bootloader
6fe16577 36 u-boot-puma-rk3399-bootloader
fd5536e3 37 u-boot-wandboard-bootloader))
8d858010
DM
38
39(define install-u-boot
40 #~(lambda (bootloader device mount-point)
41 (if bootloader
42 (error "Failed to install U-Boot"))))
43
ceb39527
MO
44(define install-beaglebone-black-u-boot
45 ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
46 ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
47 ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
48 ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
49 ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
50 ;; specified DEVICE.
51 #~(lambda (bootloader device mount-point)
52 (let ((mlo (string-append bootloader "/libexec/MLO"))
53 (u-boot (string-append bootloader "/libexec/u-boot.img")))
54 (write-file-on-device mlo (* 256 512)
55 device (* 256 512))
56 (write-file-on-device u-boot (* 1024 512)
57 device (* 768 512)))))
58
30aeb846
DM
59(define install-allwinner-u-boot
60 #~(lambda (bootloader device mount-point)
61 (let ((u-boot (string-append bootloader
62 "/libexec/u-boot-sunxi-with-spl.bin")))
63 (write-file-on-device u-boot (stat:size (stat u-boot))
64 device (* 8 1024)))))
65
9f7d6665
VC
66(define install-allwinner64-u-boot
67 #~(lambda (bootloader device mount-point)
68 (let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
69 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
70 (write-file-on-device spl (stat:size (stat spl))
71 device (* 8 1024))
72 (write-file-on-device u-boot (stat:size (stat u-boot))
73 device (* 40 1024)))))
74
07ca9045
VC
75(define install-imx-u-boot
76 #~(lambda (bootloader device mount-point)
77 (let ((spl (string-append bootloader "/libexec/SPL"))
78 (u-boot (string-append bootloader "/libexec/u-boot.img")))
79 (write-file-on-device spl (stat:size (stat spl))
80 device (* 1 1024))
81 (write-file-on-device u-boot (stat:size (stat u-boot))
82 device (* 69 1024)))))
83
6fe16577
VC
84(define install-puma-rk3399-u-boot
85 #~(lambda (bootloader device mount-point)
86 (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
87 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
88 (write-file-on-device spl (stat:size (stat spl))
89 device (* 64 512))
90 (write-file-on-device u-boot (stat:size (stat u-boot))
91 device (* 512 512)))))
92
8d858010
DM
93\f
94
95;;;
96;;; Bootloader definitions.
97;;;
98
99(define u-boot-bootloader
100 (bootloader
101 (inherit extlinux-bootloader)
102 (name 'u-boot)
103 (package #f)
104 (installer install-u-boot)))
ceb39527
MO
105
106(define u-boot-beaglebone-black-bootloader
107 (bootloader
108 (inherit u-boot-bootloader)
6b99afee 109 (package u-boot-am335x-boneblack)
ceb39527 110 (installer install-beaglebone-black-u-boot)))
30aeb846
DM
111
112(define u-boot-allwinner-bootloader
113 (bootloader
114 (inherit u-boot-bootloader)
115 (installer install-allwinner-u-boot)))
116
9f7d6665
VC
117(define u-boot-allwinner64-bootloader
118 (bootloader
119 (inherit u-boot-bootloader)
120 (installer install-allwinner64-u-boot)))
121
07ca9045
VC
122(define u-boot-imx-bootloader
123 (bootloader
124 (inherit u-boot-bootloader)
125 (installer install-imx-u-boot)))
126
84ee3378
DM
127(define u-boot-nintendo-nes-classic-edition-bootloader
128 (bootloader
129 (inherit u-boot-allwinner-bootloader)
130 (package u-boot-nintendo-nes-classic-edition)))
131
c55c6985
DM
132(define u-boot-a20-olinuxino-lime-bootloader
133 (bootloader
134 (inherit u-boot-allwinner-bootloader)
135 (package u-boot-a20-olinuxino-lime)))
136
4b9e9abb
DM
137(define u-boot-a20-olinuxino-lime2-bootloader
138 (bootloader
139 (inherit u-boot-allwinner-bootloader)
140 (package u-boot-a20-olinuxino-lime2)))
141
a7bb327e
DM
142(define u-boot-a20-olinuxino-micro-bootloader
143 (bootloader
144 (inherit u-boot-allwinner-bootloader)
145 (package u-boot-a20-olinuxino-micro)))
146
e830c9d0 147(define u-boot-bananapi-m2-ultra-bootloader
30aeb846
DM
148 (bootloader
149 (inherit u-boot-allwinner-bootloader)
e830c9d0 150 (package u-boot-bananapi-m2-ultra)))
07ca9045
VC
151
152(define u-boot-mx6cuboxi-bootloader
153 (bootloader
154 (inherit u-boot-imx-bootloader)
155 (package u-boot-mx6cuboxi)))
fd5536e3
VC
156
157(define u-boot-wandboard-bootloader
158 (bootloader
159 (inherit u-boot-imx-bootloader)
160 (package u-boot-wandboard)))
1b960787
VC
161
162(define u-boot-novena-bootloader
163 (bootloader
164 (inherit u-boot-imx-bootloader)
165 (package u-boot-novena)))
9f7d6665
VC
166
167(define u-boot-pine64-plus-bootloader
168 (bootloader
169 (inherit u-boot-allwinner64-bootloader)
170 (package u-boot-pine64-plus)))
6fe16577 171
74e35e8c
VC
172(define u-boot-pinebook-bootloader
173 (bootloader
174 (inherit u-boot-allwinner64-bootloader)
175 (package u-boot-pinebook)))
176
6fe16577
VC
177(define u-boot-puma-rk3399-bootloader
178 (bootloader
179 (inherit u-boot-bootloader)
180 (package u-boot-puma-rk3399)
181 (installer install-puma-rk3399-u-boot)))