Merge branch 'master' into staging
[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>
94de8d0a 3;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
079901d7 4;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
5327b399 5;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
8d858010
DM
6;;;
7;;; This file is part of GNU Guix.
8;;;
9;;; GNU Guix is free software; you can redistribute it and/or modify it
10;;; under the terms of the GNU General Public License as published by
11;;; the Free Software Foundation; either version 3 of the License, or (at
12;;; your option) any later version.
13;;;
14;;; GNU Guix is distributed in the hope that it will be useful, but
15;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;;; GNU General Public License for more details.
18;;;
19;;; You should have received a copy of the GNU General Public License
20;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22(define-module (gnu bootloader u-boot)
23 #:use-module (gnu bootloader extlinux)
24 #:use-module (gnu bootloader)
8d858010
DM
25 #:use-module (gnu packages bootloaders)
26 #:use-module (guix gexp)
ceb39527 27 #:export (u-boot-bootloader
c55c6985 28 u-boot-a20-olinuxino-lime-bootloader
4b9e9abb 29 u-boot-a20-olinuxino-lime2-bootloader
a7bb327e 30 u-boot-a20-olinuxino-micro-bootloader
e830c9d0 31 u-boot-bananapi-m2-ultra-bootloader
84ee3378 32 u-boot-beaglebone-black-bootloader
079901d7 33 u-boot-cubietruck-bootloader
545ff7b7 34 u-boot-firefly-rk3399-bootloader
07ca9045 35 u-boot-mx6cuboxi-bootloader
fd5536e3 36 u-boot-nintendo-nes-classic-edition-bootloader
1b960787 37 u-boot-novena-bootloader
9f7d6665 38 u-boot-pine64-plus-bootloader
94de8d0a 39 u-boot-pine64-lts-bootloader
74e35e8c 40 u-boot-pinebook-bootloader
5327b399 41 u-boot-pinebook-pro-rk3399-bootloader
6fe16577 42 u-boot-puma-rk3399-bootloader
2fce14af 43 u-boot-rock64-rk3328-bootloader
fa747018 44 u-boot-rockpro64-rk3399-bootloader
fd5536e3 45 u-boot-wandboard-bootloader))
8d858010
DM
46
47(define install-u-boot
b97b423e 48 #~(lambda (bootloader root-index image)
8d858010
DM
49 (if bootloader
50 (error "Failed to install U-Boot"))))
51
ceb39527
MO
52(define install-beaglebone-black-u-boot
53 ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
54 ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
55 ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
56 ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
57 ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
58 ;; specified DEVICE.
b97b423e 59 #~(lambda (bootloader root-index image)
ceb39527
MO
60 (let ((mlo (string-append bootloader "/libexec/MLO"))
61 (u-boot (string-append bootloader "/libexec/u-boot.img")))
62 (write-file-on-device mlo (* 256 512)
b97b423e 63 image (* 256 512))
ceb39527 64 (write-file-on-device u-boot (* 1024 512)
b97b423e 65 image (* 768 512)))))
ceb39527 66
30aeb846 67(define install-allwinner-u-boot
b97b423e 68 #~(lambda (bootloader root-index image)
30aeb846
DM
69 (let ((u-boot (string-append bootloader
70 "/libexec/u-boot-sunxi-with-spl.bin")))
71 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 72 image (* 8 1024)))))
30aeb846 73
9f7d6665 74(define install-allwinner64-u-boot
b97b423e 75 #~(lambda (bootloader root-index image)
9f7d6665
VC
76 (let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
77 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
78 (write-file-on-device spl (stat:size (stat spl))
b97b423e 79 image (* 8 1024))
9f7d6665 80 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 81 image (* 40 1024)))))
9f7d6665 82
07ca9045 83(define install-imx-u-boot
b97b423e 84 #~(lambda (bootloader root-index image)
07ca9045
VC
85 (let ((spl (string-append bootloader "/libexec/SPL"))
86 (u-boot (string-append bootloader "/libexec/u-boot.img")))
87 (write-file-on-device spl (stat:size (stat spl))
b97b423e 88 image (* 1 1024))
07ca9045 89 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 90 image (* 69 1024)))))
07ca9045 91
6fe16577 92(define install-puma-rk3399-u-boot
b97b423e 93 #~(lambda (bootloader root-index image)
6fe16577
VC
94 (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
95 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
96 (write-file-on-device spl (stat:size (stat spl))
b97b423e 97 image (* 64 512))
6fe16577 98 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 99 image (* 512 512)))))
6fe16577 100
545ff7b7 101(define install-firefly-rk3399-u-boot
b97b423e 102 #~(lambda (bootloader root-index image)
545ff7b7
VC
103 (let ((idb (string-append bootloader "/libexec/idbloader.img"))
104 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
105 (write-file-on-device idb (stat:size (stat idb))
b97b423e 106 image (* 64 512))
545ff7b7 107 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 108 image (* 16384 512)))))
545ff7b7 109
2fce14af 110(define install-rock64-rk3328-u-boot
b97b423e 111 #~(lambda (bootloader root-index image)
2fce14af
VC
112 (let ((idb (string-append bootloader "/libexec/idbloader.img"))
113 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
114 (write-file-on-device idb (stat:size (stat idb))
b97b423e 115 image (* 64 512))
2fce14af 116 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 117 image (* 16384 512)))))
2fce14af 118
fa747018 119(define install-rockpro64-rk3399-u-boot
b97b423e 120 #~(lambda (bootloader root-index image)
fa747018
CN
121 (let ((idb (string-append bootloader "/libexec/idbloader.img"))
122 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
123 (write-file-on-device idb (stat:size (stat idb))
b97b423e 124 image (* 64 512))
fa747018 125 (write-file-on-device u-boot (stat:size (stat u-boot))
b97b423e 126 image (* 16384 512)))))
fa747018 127
5327b399
VC
128(define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
129
8d858010
DM
130\f
131
132;;;
133;;; Bootloader definitions.
134;;;
135
136(define u-boot-bootloader
137 (bootloader
138 (inherit extlinux-bootloader)
139 (name 'u-boot)
140 (package #f)
b97b423e
MO
141 (installer #f)
142 (disk-image-installer install-u-boot)))
ceb39527
MO
143
144(define u-boot-beaglebone-black-bootloader
145 (bootloader
146 (inherit u-boot-bootloader)
6b99afee 147 (package u-boot-am335x-boneblack)
b97b423e 148 (disk-image-installer install-beaglebone-black-u-boot)))
30aeb846
DM
149
150(define u-boot-allwinner-bootloader
151 (bootloader
152 (inherit u-boot-bootloader)
b97b423e 153 (disk-image-installer install-allwinner-u-boot)))
30aeb846 154
9f7d6665
VC
155(define u-boot-allwinner64-bootloader
156 (bootloader
157 (inherit u-boot-bootloader)
b97b423e 158 (disk-image-installer install-allwinner64-u-boot)))
9f7d6665 159
07ca9045
VC
160(define u-boot-imx-bootloader
161 (bootloader
162 (inherit u-boot-bootloader)
b97b423e 163 (disk-image-installer install-imx-u-boot)))
07ca9045 164
84ee3378
DM
165(define u-boot-nintendo-nes-classic-edition-bootloader
166 (bootloader
167 (inherit u-boot-allwinner-bootloader)
168 (package u-boot-nintendo-nes-classic-edition)))
169
c55c6985
DM
170(define u-boot-a20-olinuxino-lime-bootloader
171 (bootloader
172 (inherit u-boot-allwinner-bootloader)
173 (package u-boot-a20-olinuxino-lime)))
174
4b9e9abb
DM
175(define u-boot-a20-olinuxino-lime2-bootloader
176 (bootloader
177 (inherit u-boot-allwinner-bootloader)
178 (package u-boot-a20-olinuxino-lime2)))
179
a7bb327e
DM
180(define u-boot-a20-olinuxino-micro-bootloader
181 (bootloader
182 (inherit u-boot-allwinner-bootloader)
183 (package u-boot-a20-olinuxino-micro)))
184
e830c9d0 185(define u-boot-bananapi-m2-ultra-bootloader
30aeb846
DM
186 (bootloader
187 (inherit u-boot-allwinner-bootloader)
e830c9d0 188 (package u-boot-bananapi-m2-ultra)))
07ca9045 189
079901d7
JL
190(define u-boot-cubietruck-bootloader
191 (bootloader
192 (inherit u-boot-allwinner-bootloader)
193 (package u-boot-cubietruck)))
194
545ff7b7
VC
195(define u-boot-firefly-rk3399-bootloader
196 ;; SD and eMMC use the same format
197 (bootloader
198 (inherit u-boot-bootloader)
199 (package u-boot-firefly-rk3399)
b97b423e 200 (disk-image-installer install-firefly-rk3399-u-boot)))
545ff7b7 201
07ca9045
VC
202(define u-boot-mx6cuboxi-bootloader
203 (bootloader
204 (inherit u-boot-imx-bootloader)
205 (package u-boot-mx6cuboxi)))
fd5536e3
VC
206
207(define u-boot-wandboard-bootloader
208 (bootloader
209 (inherit u-boot-imx-bootloader)
210 (package u-boot-wandboard)))
1b960787
VC
211
212(define u-boot-novena-bootloader
213 (bootloader
214 (inherit u-boot-imx-bootloader)
215 (package u-boot-novena)))
9f7d6665
VC
216
217(define u-boot-pine64-plus-bootloader
218 (bootloader
219 (inherit u-boot-allwinner64-bootloader)
220 (package u-boot-pine64-plus)))
6fe16577 221
94de8d0a
MO
222(define u-boot-pine64-lts-bootloader
223 (bootloader
224 (inherit u-boot-allwinner-bootloader)
225 (package u-boot-pine64-lts)))
226
74e35e8c
VC
227(define u-boot-pinebook-bootloader
228 (bootloader
229 (inherit u-boot-allwinner64-bootloader)
230 (package u-boot-pinebook)))
231
6fe16577
VC
232(define u-boot-puma-rk3399-bootloader
233 (bootloader
234 (inherit u-boot-bootloader)
235 (package u-boot-puma-rk3399)
b97b423e 236 (disk-image-installer install-puma-rk3399-u-boot)))
fa747018 237
2fce14af
VC
238(define u-boot-rock64-rk3328-bootloader
239 ;; SD and eMMC use the same format
240 (bootloader
241 (inherit u-boot-bootloader)
242 (package u-boot-rock64-rk3328)
b97b423e 243 (disk-image-installer install-rock64-rk3328-u-boot)))
2fce14af 244
fa747018
CN
245(define u-boot-rockpro64-rk3399-bootloader
246 ;; SD and eMMC use the same format
247 (bootloader
248 (inherit u-boot-bootloader)
249 (package u-boot-rockpro64-rk3399)
b97b423e 250 (disk-image-installer install-rockpro64-rk3399-u-boot)))
5327b399
VC
251
252(define u-boot-pinebook-pro-rk3399-bootloader
253 ;; SD and eMMC use the same format
254 (bootloader
255 (inherit u-boot-bootloader)
256 (package u-boot-pinebook-pro-rk3399)
b97b423e 257 (disk-image-installer install-pinebook-pro-rk3399-u-boot)))