gnu: Add python-zope-copy.
[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 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
5 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
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)
25 #:use-module (gnu packages bootloaders)
26 #:use-module (guix gexp)
27 #:export (u-boot-bootloader
28 u-boot-a20-olinuxino-lime-bootloader
29 u-boot-a20-olinuxino-lime2-bootloader
30 u-boot-a20-olinuxino-micro-bootloader
31 u-boot-bananapi-m2-ultra-bootloader
32 u-boot-beaglebone-black-bootloader
33 u-boot-cubietruck-bootloader
34 u-boot-firefly-rk3399-bootloader
35 u-boot-mx6cuboxi-bootloader
36 u-boot-nintendo-nes-classic-edition-bootloader
37 u-boot-novena-bootloader
38 u-boot-pine64-plus-bootloader
39 u-boot-pine64-lts-bootloader
40 u-boot-pinebook-bootloader
41 u-boot-pinebook-pro-rk3399-bootloader
42 u-boot-puma-rk3399-bootloader
43 u-boot-rock64-rk3328-bootloader
44 u-boot-rockpro64-rk3399-bootloader
45 u-boot-wandboard-bootloader))
46
47 (define install-u-boot
48 #~(lambda (bootloader device mount-point)
49 (if bootloader
50 (error "Failed to install U-Boot"))))
51
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.
59 #~(lambda (bootloader device mount-point)
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)
63 device (* 256 512))
64 (write-file-on-device u-boot (* 1024 512)
65 device (* 768 512)))))
66
67 (define install-allwinner-u-boot
68 #~(lambda (bootloader device mount-point)
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))
72 device (* 8 1024)))))
73
74 (define install-allwinner64-u-boot
75 #~(lambda (bootloader device mount-point)
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))
79 device (* 8 1024))
80 (write-file-on-device u-boot (stat:size (stat u-boot))
81 device (* 40 1024)))))
82
83 (define install-imx-u-boot
84 #~(lambda (bootloader device mount-point)
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))
88 device (* 1 1024))
89 (write-file-on-device u-boot (stat:size (stat u-boot))
90 device (* 69 1024)))))
91
92 (define install-puma-rk3399-u-boot
93 #~(lambda (bootloader device mount-point)
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))
97 device (* 64 512))
98 (write-file-on-device u-boot (stat:size (stat u-boot))
99 device (* 512 512)))))
100
101 (define install-firefly-rk3399-u-boot
102 #~(lambda (bootloader device mount-point)
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))
106 device (* 64 512))
107 (write-file-on-device u-boot (stat:size (stat u-boot))
108 device (* 16384 512)))))
109
110 (define install-rock64-rk3328-u-boot
111 #~(lambda (bootloader device mount-point)
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))
115 device (* 64 512))
116 (write-file-on-device u-boot (stat:size (stat u-boot))
117 device (* 16384 512)))))
118
119 (define install-rockpro64-rk3399-u-boot
120 #~(lambda (bootloader device mount-point)
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))
124 device (* 64 512))
125 (write-file-on-device u-boot (stat:size (stat u-boot))
126 device (* 16384 512)))))
127
128 (define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
129
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)
141 (installer install-u-boot)))
142
143 (define u-boot-beaglebone-black-bootloader
144 (bootloader
145 (inherit u-boot-bootloader)
146 (package u-boot-am335x-boneblack)
147 (installer install-beaglebone-black-u-boot)))
148
149 (define u-boot-allwinner-bootloader
150 (bootloader
151 (inherit u-boot-bootloader)
152 (installer install-allwinner-u-boot)))
153
154 (define u-boot-allwinner64-bootloader
155 (bootloader
156 (inherit u-boot-bootloader)
157 (installer install-allwinner64-u-boot)))
158
159 (define u-boot-imx-bootloader
160 (bootloader
161 (inherit u-boot-bootloader)
162 (installer install-imx-u-boot)))
163
164 (define u-boot-nintendo-nes-classic-edition-bootloader
165 (bootloader
166 (inherit u-boot-allwinner-bootloader)
167 (package u-boot-nintendo-nes-classic-edition)))
168
169 (define u-boot-a20-olinuxino-lime-bootloader
170 (bootloader
171 (inherit u-boot-allwinner-bootloader)
172 (package u-boot-a20-olinuxino-lime)))
173
174 (define u-boot-a20-olinuxino-lime2-bootloader
175 (bootloader
176 (inherit u-boot-allwinner-bootloader)
177 (package u-boot-a20-olinuxino-lime2)))
178
179 (define u-boot-a20-olinuxino-micro-bootloader
180 (bootloader
181 (inherit u-boot-allwinner-bootloader)
182 (package u-boot-a20-olinuxino-micro)))
183
184 (define u-boot-bananapi-m2-ultra-bootloader
185 (bootloader
186 (inherit u-boot-allwinner-bootloader)
187 (package u-boot-bananapi-m2-ultra)))
188
189 (define u-boot-cubietruck-bootloader
190 (bootloader
191 (inherit u-boot-allwinner-bootloader)
192 (package u-boot-cubietruck)))
193
194 (define u-boot-firefly-rk3399-bootloader
195 ;; SD and eMMC use the same format
196 (bootloader
197 (inherit u-boot-bootloader)
198 (package u-boot-firefly-rk3399)
199 (installer install-firefly-rk3399-u-boot)))
200
201 (define u-boot-mx6cuboxi-bootloader
202 (bootloader
203 (inherit u-boot-imx-bootloader)
204 (package u-boot-mx6cuboxi)))
205
206 (define u-boot-wandboard-bootloader
207 (bootloader
208 (inherit u-boot-imx-bootloader)
209 (package u-boot-wandboard)))
210
211 (define u-boot-novena-bootloader
212 (bootloader
213 (inherit u-boot-imx-bootloader)
214 (package u-boot-novena)))
215
216 (define u-boot-pine64-plus-bootloader
217 (bootloader
218 (inherit u-boot-allwinner64-bootloader)
219 (package u-boot-pine64-plus)))
220
221 (define u-boot-pine64-lts-bootloader
222 (bootloader
223 (inherit u-boot-allwinner-bootloader)
224 (package u-boot-pine64-lts)))
225
226 (define u-boot-pinebook-bootloader
227 (bootloader
228 (inherit u-boot-allwinner64-bootloader)
229 (package u-boot-pinebook)))
230
231 (define u-boot-puma-rk3399-bootloader
232 (bootloader
233 (inherit u-boot-bootloader)
234 (package u-boot-puma-rk3399)
235 (installer install-puma-rk3399-u-boot)))
236
237 (define u-boot-rock64-rk3328-bootloader
238 ;; SD and eMMC use the same format
239 (bootloader
240 (inherit u-boot-bootloader)
241 (package u-boot-rock64-rk3328)
242 (installer install-rock64-rk3328-u-boot)))
243
244 (define u-boot-rockpro64-rk3399-bootloader
245 ;; SD and eMMC use the same format
246 (bootloader
247 (inherit u-boot-bootloader)
248 (package u-boot-rockpro64-rk3399)
249 (installer install-rockpro64-rk3399-u-boot)))
250
251 (define u-boot-pinebook-pro-rk3399-bootloader
252 ;; SD and eMMC use the same format
253 (bootloader
254 (inherit u-boot-bootloader)
255 (package u-boot-pinebook-pro-rk3399)
256 (installer install-pinebook-pro-rk3399-u-boot)))