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>
7 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
47 (define install-u-boot
48 #~(lambda (bootloader device mount-point)
50 (error "Failed to install U-Boot"))))
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
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)
64 (write-file-on-device u-boot (* 1024 512)
65 device (* 768 512)))))
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))
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))
80 (write-file-on-device u-boot (stat:size (stat u-boot))
81 device (* 40 1024)))))
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))
89 (write-file-on-device u-boot (stat:size (stat u-boot))
90 device (* 69 1024)))))
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))
98 (write-file-on-device u-boot (stat:size (stat u-boot))
99 device (* 512 512)))))
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))
107 (write-file-on-device u-boot (stat:size (stat u-boot))
108 device (* 16384 512)))))
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))
116 (write-file-on-device u-boot (stat:size (stat u-boot))
117 device (* 16384 512)))))
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))
125 (write-file-on-device u-boot (stat:size (stat u-boot))
126 device (* 16384 512)))))
128 (define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)
133 ;;; Bootloader definitions.
136 (define u-boot-bootloader
138 (inherit extlinux-bootloader)
141 (installer install-u-boot)))
143 (define u-boot-beaglebone-black-bootloader
145 (inherit u-boot-bootloader)
146 (package u-boot-am335x-boneblack)
147 (installer install-beaglebone-black-u-boot)))
149 (define u-boot-allwinner-bootloader
151 (inherit u-boot-bootloader)
152 (installer install-allwinner-u-boot)))
154 (define u-boot-allwinner64-bootloader
156 (inherit u-boot-bootloader)
157 (installer install-allwinner64-u-boot)))
159 (define u-boot-imx-bootloader
161 (inherit u-boot-bootloader)
162 (installer install-imx-u-boot)))
164 (define u-boot-nintendo-nes-classic-edition-bootloader
166 (inherit u-boot-allwinner-bootloader)
167 (package u-boot-nintendo-nes-classic-edition)))
169 (define u-boot-a20-olinuxino-lime-bootloader
171 (inherit u-boot-allwinner-bootloader)
172 (package u-boot-a20-olinuxino-lime)))
174 (define u-boot-a20-olinuxino-lime2-bootloader
176 (inherit u-boot-allwinner-bootloader)
177 (package u-boot-a20-olinuxino-lime2)))
179 (define u-boot-a20-olinuxino-micro-bootloader
181 (inherit u-boot-allwinner-bootloader)
182 (package u-boot-a20-olinuxino-micro)))
184 (define u-boot-bananapi-m2-ultra-bootloader
186 (inherit u-boot-allwinner-bootloader)
187 (package u-boot-bananapi-m2-ultra)))
189 (define u-boot-cubietruck-bootloader
191 (inherit u-boot-allwinner-bootloader)
192 (package u-boot-cubietruck)))
194 (define u-boot-firefly-rk3399-bootloader
195 ;; SD and eMMC use the same format
197 (inherit u-boot-bootloader)
198 (package u-boot-firefly-rk3399)
199 (installer install-firefly-rk3399-u-boot)))
201 (define u-boot-mx6cuboxi-bootloader
203 (inherit u-boot-imx-bootloader)
204 (package u-boot-mx6cuboxi)))
206 (define u-boot-wandboard-bootloader
208 (inherit u-boot-imx-bootloader)
209 (package u-boot-wandboard)))
211 (define u-boot-novena-bootloader
213 (inherit u-boot-imx-bootloader)
214 (package u-boot-novena)))
216 (define u-boot-pine64-plus-bootloader
218 (inherit u-boot-allwinner64-bootloader)
219 (package u-boot-pine64-plus)))
221 (define u-boot-pine64-lts-bootloader
223 (inherit u-boot-allwinner-bootloader)
224 (package u-boot-pine64-lts)))
226 (define u-boot-pinebook-bootloader
228 (inherit u-boot-allwinner64-bootloader)
229 (package u-boot-pinebook)))
231 (define u-boot-puma-rk3399-bootloader
233 (inherit u-boot-bootloader)
234 (package u-boot-puma-rk3399)
235 (installer install-puma-rk3399-u-boot)))
237 (define u-boot-rock64-rk3328-bootloader
238 ;; SD and eMMC use the same format
240 (inherit u-boot-bootloader)
241 (package u-boot-rock64-rk3328)
242 (installer install-rock64-rk3328-u-boot)))
244 (define u-boot-rockpro64-rk3399-bootloader
245 ;; SD and eMMC use the same format
247 (inherit u-boot-bootloader)
248 (package u-boot-rockpro64-rk3399)
249 (installer install-rockpro64-rk3399-u-boot)))
251 (define u-boot-pinebook-pro-rk3399-bootloader
252 ;; SD and eMMC use the same format
254 (inherit u-boot-bootloader)
255 (package u-boot-pinebook-pro-rk3399)
256 (installer install-pinebook-pro-rk3399-u-boot)))