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>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
43 (define install-u-boot
44 #~(lambda (bootloader device mount-point)
46 (error "Failed to install U-Boot"))))
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
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)
60 (write-file-on-device u-boot (* 1024 512)
61 device (* 768 512)))))
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))
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))
76 (write-file-on-device u-boot (stat:size (stat u-boot))
77 device (* 40 1024)))))
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))
85 (write-file-on-device u-boot (stat:size (stat u-boot))
86 device (* 69 1024)))))
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))
94 (write-file-on-device u-boot (stat:size (stat u-boot))
95 device (* 512 512)))))
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))
103 (write-file-on-device u-boot (stat:size (stat u-boot))
104 device (* 16384 512)))))
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))
112 (write-file-on-device u-boot (stat:size (stat u-boot))
113 device (* 16384 512)))))
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))
121 (write-file-on-device u-boot (stat:size (stat u-boot))
122 device (* 16384 512)))))
127 ;;; Bootloader definitions.
130 (define u-boot-bootloader
132 (inherit extlinux-bootloader)
135 (installer install-u-boot)))
137 (define u-boot-beaglebone-black-bootloader
139 (inherit u-boot-bootloader)
140 (package u-boot-am335x-boneblack)
141 (installer install-beaglebone-black-u-boot)))
143 (define u-boot-allwinner-bootloader
145 (inherit u-boot-bootloader)
146 (installer install-allwinner-u-boot)))
148 (define u-boot-allwinner64-bootloader
150 (inherit u-boot-bootloader)
151 (installer install-allwinner64-u-boot)))
153 (define u-boot-imx-bootloader
155 (inherit u-boot-bootloader)
156 (installer install-imx-u-boot)))
158 (define u-boot-nintendo-nes-classic-edition-bootloader
160 (inherit u-boot-allwinner-bootloader)
161 (package u-boot-nintendo-nes-classic-edition)))
163 (define u-boot-a20-olinuxino-lime-bootloader
165 (inherit u-boot-allwinner-bootloader)
166 (package u-boot-a20-olinuxino-lime)))
168 (define u-boot-a20-olinuxino-lime2-bootloader
170 (inherit u-boot-allwinner-bootloader)
171 (package u-boot-a20-olinuxino-lime2)))
173 (define u-boot-a20-olinuxino-micro-bootloader
175 (inherit u-boot-allwinner-bootloader)
176 (package u-boot-a20-olinuxino-micro)))
178 (define u-boot-bananapi-m2-ultra-bootloader
180 (inherit u-boot-allwinner-bootloader)
181 (package u-boot-bananapi-m2-ultra)))
183 (define u-boot-firefly-rk3399-bootloader
184 ;; SD and eMMC use the same format
186 (inherit u-boot-bootloader)
187 (package u-boot-firefly-rk3399)
188 (installer install-firefly-rk3399-u-boot)))
190 (define u-boot-mx6cuboxi-bootloader
192 (inherit u-boot-imx-bootloader)
193 (package u-boot-mx6cuboxi)))
195 (define u-boot-wandboard-bootloader
197 (inherit u-boot-imx-bootloader)
198 (package u-boot-wandboard)))
200 (define u-boot-novena-bootloader
202 (inherit u-boot-imx-bootloader)
203 (package u-boot-novena)))
205 (define u-boot-pine64-plus-bootloader
207 (inherit u-boot-allwinner64-bootloader)
208 (package u-boot-pine64-plus)))
210 (define u-boot-pine64-lts-bootloader
212 (inherit u-boot-allwinner-bootloader)
213 (package u-boot-pine64-lts)))
215 (define u-boot-pinebook-bootloader
217 (inherit u-boot-allwinner64-bootloader)
218 (package u-boot-pinebook)))
220 (define u-boot-puma-rk3399-bootloader
222 (inherit u-boot-bootloader)
223 (package u-boot-puma-rk3399)
224 (installer install-puma-rk3399-u-boot)))
226 (define u-boot-rock64-rk3328-bootloader
227 ;; SD and eMMC use the same format
229 (inherit u-boot-bootloader)
230 (package u-boot-rock64-rk3328)
231 (installer install-rock64-rk3328-u-boot)))
233 (define u-boot-rockpro64-rk3399-bootloader
234 ;; SD and eMMC use the same format
236 (inherit u-boot-bootloader)
237 (package u-boot-rockpro64-rk3399)
238 (installer install-rockpro64-rk3399-u-boot)))