Merge remote-tracking branch 'master' into core-updates.
[jackhill/guix/guix.git] / gnu / bootloader / u-boot.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 David Craven <david@craven.ch>
3 ;;; Copyright © 2017, 2019 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 packages bootloaders)
24 #:use-module (guix gexp)
25 #:export (u-boot-bootloader
26 u-boot-a20-olinuxino-lime-bootloader
27 u-boot-a20-olinuxino-lime2-bootloader
28 u-boot-a20-olinuxino-micro-bootloader
29 u-boot-bananapi-m2-ultra-bootloader
30 u-boot-beaglebone-black-bootloader
31 u-boot-firefly-rk3399-bootloader
32 u-boot-mx6cuboxi-bootloader
33 u-boot-nintendo-nes-classic-edition-bootloader
34 u-boot-novena-bootloader
35 u-boot-pine64-plus-bootloader
36 u-boot-pine64-lts-bootloader
37 u-boot-pinebook-bootloader
38 u-boot-puma-rk3399-bootloader
39 u-boot-rock64-rk3328-bootloader
40 u-boot-rockpro64-rk3399-bootloader
41 u-boot-wandboard-bootloader))
42
43 (define install-u-boot
44 #~(lambda (bootloader device mount-point)
45 (if bootloader
46 (error "Failed to install U-Boot"))))
47
48 (define install-beaglebone-black-u-boot
49 ;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
50 ;; This first stage bootloader called MLO (U-Boot SPL) is expected at
51 ;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
52 ;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
53 ;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
54 ;; specified DEVICE.
55 #~(lambda (bootloader device mount-point)
56 (let ((mlo (string-append bootloader "/libexec/MLO"))
57 (u-boot (string-append bootloader "/libexec/u-boot.img")))
58 (write-file-on-device mlo (* 256 512)
59 device (* 256 512))
60 (write-file-on-device u-boot (* 1024 512)
61 device (* 768 512)))))
62
63 (define install-allwinner-u-boot
64 #~(lambda (bootloader device mount-point)
65 (let ((u-boot (string-append bootloader
66 "/libexec/u-boot-sunxi-with-spl.bin")))
67 (write-file-on-device u-boot (stat:size (stat u-boot))
68 device (* 8 1024)))))
69
70 (define install-allwinner64-u-boot
71 #~(lambda (bootloader device mount-point)
72 (let ((spl (string-append bootloader "/libexec/spl/sunxi-spl.bin"))
73 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
74 (write-file-on-device spl (stat:size (stat spl))
75 device (* 8 1024))
76 (write-file-on-device u-boot (stat:size (stat u-boot))
77 device (* 40 1024)))))
78
79 (define install-imx-u-boot
80 #~(lambda (bootloader device mount-point)
81 (let ((spl (string-append bootloader "/libexec/SPL"))
82 (u-boot (string-append bootloader "/libexec/u-boot.img")))
83 (write-file-on-device spl (stat:size (stat spl))
84 device (* 1 1024))
85 (write-file-on-device u-boot (stat:size (stat u-boot))
86 device (* 69 1024)))))
87
88 (define install-puma-rk3399-u-boot
89 #~(lambda (bootloader device mount-point)
90 (let ((spl (string-append bootloader "/libexec/u-boot-spl.rksd"))
91 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
92 (write-file-on-device spl (stat:size (stat spl))
93 device (* 64 512))
94 (write-file-on-device u-boot (stat:size (stat u-boot))
95 device (* 512 512)))))
96
97 (define install-firefly-rk3399-u-boot
98 #~(lambda (bootloader device mount-point)
99 (let ((idb (string-append bootloader "/libexec/idbloader.img"))
100 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
101 (write-file-on-device idb (stat:size (stat idb))
102 device (* 64 512))
103 (write-file-on-device u-boot (stat:size (stat u-boot))
104 device (* 16384 512)))))
105
106 (define install-rock64-rk3328-u-boot
107 #~(lambda (bootloader device mount-point)
108 (let ((idb (string-append bootloader "/libexec/idbloader.img"))
109 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
110 (write-file-on-device idb (stat:size (stat idb))
111 device (* 64 512))
112 (write-file-on-device u-boot (stat:size (stat u-boot))
113 device (* 16384 512)))))
114
115 (define install-rockpro64-rk3399-u-boot
116 #~(lambda (bootloader device mount-point)
117 (let ((idb (string-append bootloader "/libexec/idbloader.img"))
118 (u-boot (string-append bootloader "/libexec/u-boot.itb")))
119 (write-file-on-device idb (stat:size (stat idb))
120 device (* 64 512))
121 (write-file-on-device u-boot (stat:size (stat u-boot))
122 device (* 16384 512)))))
123
124 \f
125
126 ;;;
127 ;;; Bootloader definitions.
128 ;;;
129
130 (define u-boot-bootloader
131 (bootloader
132 (inherit extlinux-bootloader)
133 (name 'u-boot)
134 (package #f)
135 (installer install-u-boot)))
136
137 (define u-boot-beaglebone-black-bootloader
138 (bootloader
139 (inherit u-boot-bootloader)
140 (package u-boot-am335x-boneblack)
141 (installer install-beaglebone-black-u-boot)))
142
143 (define u-boot-allwinner-bootloader
144 (bootloader
145 (inherit u-boot-bootloader)
146 (installer install-allwinner-u-boot)))
147
148 (define u-boot-allwinner64-bootloader
149 (bootloader
150 (inherit u-boot-bootloader)
151 (installer install-allwinner64-u-boot)))
152
153 (define u-boot-imx-bootloader
154 (bootloader
155 (inherit u-boot-bootloader)
156 (installer install-imx-u-boot)))
157
158 (define u-boot-nintendo-nes-classic-edition-bootloader
159 (bootloader
160 (inherit u-boot-allwinner-bootloader)
161 (package u-boot-nintendo-nes-classic-edition)))
162
163 (define u-boot-a20-olinuxino-lime-bootloader
164 (bootloader
165 (inherit u-boot-allwinner-bootloader)
166 (package u-boot-a20-olinuxino-lime)))
167
168 (define u-boot-a20-olinuxino-lime2-bootloader
169 (bootloader
170 (inherit u-boot-allwinner-bootloader)
171 (package u-boot-a20-olinuxino-lime2)))
172
173 (define u-boot-a20-olinuxino-micro-bootloader
174 (bootloader
175 (inherit u-boot-allwinner-bootloader)
176 (package u-boot-a20-olinuxino-micro)))
177
178 (define u-boot-bananapi-m2-ultra-bootloader
179 (bootloader
180 (inherit u-boot-allwinner-bootloader)
181 (package u-boot-bananapi-m2-ultra)))
182
183 (define u-boot-firefly-rk3399-bootloader
184 ;; SD and eMMC use the same format
185 (bootloader
186 (inherit u-boot-bootloader)
187 (package u-boot-firefly-rk3399)
188 (installer install-firefly-rk3399-u-boot)))
189
190 (define u-boot-mx6cuboxi-bootloader
191 (bootloader
192 (inherit u-boot-imx-bootloader)
193 (package u-boot-mx6cuboxi)))
194
195 (define u-boot-wandboard-bootloader
196 (bootloader
197 (inherit u-boot-imx-bootloader)
198 (package u-boot-wandboard)))
199
200 (define u-boot-novena-bootloader
201 (bootloader
202 (inherit u-boot-imx-bootloader)
203 (package u-boot-novena)))
204
205 (define u-boot-pine64-plus-bootloader
206 (bootloader
207 (inherit u-boot-allwinner64-bootloader)
208 (package u-boot-pine64-plus)))
209
210 (define u-boot-pine64-lts-bootloader
211 (bootloader
212 (inherit u-boot-allwinner-bootloader)
213 (package u-boot-pine64-lts)))
214
215 (define u-boot-pinebook-bootloader
216 (bootloader
217 (inherit u-boot-allwinner64-bootloader)
218 (package u-boot-pinebook)))
219
220 (define u-boot-puma-rk3399-bootloader
221 (bootloader
222 (inherit u-boot-bootloader)
223 (package u-boot-puma-rk3399)
224 (installer install-puma-rk3399-u-boot)))
225
226 (define u-boot-rock64-rk3328-bootloader
227 ;; SD and eMMC use the same format
228 (bootloader
229 (inherit u-boot-bootloader)
230 (package u-boot-rock64-rk3328)
231 (installer install-rock64-rk3328-u-boot)))
232
233 (define u-boot-rockpro64-rk3399-bootloader
234 ;; SD and eMMC use the same format
235 (bootloader
236 (inherit u-boot-bootloader)
237 (package u-boot-rockpro64-rk3399)
238 (installer install-rockpro64-rk3399-u-boot)))