| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 |
|
| 28 | (define-module (gnu bootloader u-boot)
|
| 29 | #:use-module (gnu bootloader extlinux)
|
| 30 | #:use-module (gnu bootloader)
|
| 31 | #:use-module (gnu packages bootloaders)
|
| 32 | #:use-module (guix gexp)
|
| 33 | #:use-module (ice-9 match)
|
| 34 | #:export (u-boot-bootloader
|
| 35 | u-boot-a20-olinuxino-lime-bootloader
|
| 36 | u-boot-a20-olinuxino-lime2-bootloader
|
| 37 | u-boot-a20-olinuxino-micro-bootloader
|
| 38 | u-boot-bananapi-m2-ultra-bootloader
|
| 39 | u-boot-am335x-evm-bootloader
|
| 40 | u-boot-beaglebone-black-bootloader
|
| 41 | u-boot-cubietruck-bootloader
|
| 42 | u-boot-firefly-rk3399-bootloader
|
| 43 | u-boot-mx6cuboxi-bootloader
|
| 44 | u-boot-novena-bootloader
|
| 45 | u-boot-orangepi-r1-plus-lts-rk3328-bootloader
|
| 46 | u-boot-orangepi-zero2w-bootloader
|
| 47 | u-boot-pine64-plus-bootloader
|
| 48 | u-boot-pine64-lts-bootloader
|
| 49 | u-boot-pinebook-bootloader
|
| 50 | u-boot-pinebook-pro-rk3399-bootloader
|
| 51 | u-boot-nanopi-r4s-rk3399-bootloader
|
| 52 | u-boot-puma-rk3399-bootloader
|
| 53 | u-boot-rock-4c-plus-rk3399-bootloader
|
| 54 | u-boot-rock64-rk3328-bootloader
|
| 55 | u-boot-rockpro64-rk3399-bootloader
|
| 56 | u-boot-sifive-unmatched-bootloader
|
| 57 | u-boot-qemu-riscv64-bootloader
|
| 58 | u-boot-starfive-visionfive2-bootloader
|
| 59 | u-boot-ts7970-q-2g-1000mhz-c-bootloader
|
| 60 | u-boot-wandboard-bootloader))
|
| 61 |
|
| 62 | (define (make-u-boot-installer file)
|
| 63 | (let ((file
|
| 64 | (match file
|
| 65 | ((? string?)
|
| 66 | (list #~(install-file (string-append bootloader #$file)
|
| 67 | install-dir)))
|
| 68 | ((? file-like?)
|
| 69 | (list #~(mkdir-p install-dir)
|
| 70 | #~(copy-file #$file
|
| 71 | (string-append install-dir
|
| 72 | "/"
|
| 73 | #$(plain-file-name file)))))
|
| 74 | (#f '()))))
|
| 75 | #~(lambda (bootloader device mount-point)
|
| 76 | (let ((install-dir (string-append mount-point "/boot")))
|
| 77 | #$@file))))
|
| 78 |
|
| 79 | (define (write-u-boot-image files block-size)
|
| 80 | "FILES is a list of (FILE COUNT OFFSET) tuples. Each FILE is written
|
| 81 | to the target image at BLOCK-SIZE * OFFSET. The number of bytes written
|
| 82 | is BLOCK-SIZE * COUNT, or FILE size if COUNT is not given."
|
| 83 | (define (write-file-to-image file)
|
| 84 | (match file
|
| 85 | ((file count ... offset)
|
| 86 | (let* ((file #~(string-append bootloader "/libexec/" #$file))
|
| 87 | (size (match count
|
| 88 | (() #~(stat:size (stat #$file)))
|
| 89 | ((count) (* count block-size)))))
|
| 90 | #~(write-file-on-device #$file #$size image
|
| 91 | #$(* offset block-size))))))
|
| 92 | #~(lambda (bootloader _ image)
|
| 93 | #$@(map write-file-to-image files)))
|
| 94 |
|
| 95 | (define install-u-boot
|
| 96 | #~(lambda (bootloader root-index image)
|
| 97 | (if bootloader
|
| 98 | (error "Failed to install U-Boot"))))
|
| 99 |
|
| 100 | (define install-am335x-evm-u-boot
|
| 101 | (write-u-boot-image
|
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | '(("MLO" 256 256) |
| 139 | ("MLO" 256 512) |
| 140 | ("u-boot.img" 7424 768)) 512))
|
| 141 |
|
| 142 | (define install-beaglebone-black-u-boot
|
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | (write-u-boot-image '(("MLO" 256 256) ("u-boot.img" 768 1024)) 512))
|
| 150 |
|
| 151 | (define install-allwinner-u-boot
|
| 152 | (write-u-boot-image '(("u-boot-sunxi-with-spl.bin" 8)) 1024))
|
| 153 |
|
| 154 | (define install-allwinner64-u-boot
|
| 155 | (write-u-boot-image '(("u-boot-sunxi-with-spl.bin" 8)
|
| 156 | ("u-boot-sunxi-with-spl.fit.itb" 40))
|
| 157 | 1024))
|
| 158 |
|
| 159 | (define install-imx-u-boot
|
| 160 | (write-u-boot-image '(("SPL" 1) ("u-boot.img" 69)) 1024))
|
| 161 |
|
| 162 | (define install-puma-rk3399-u-boot
|
| 163 | (write-u-boot-image '(("idbloader.img" 64) ("u-boot.itb" 512)) 512))
|
| 164 |
|
| 165 | (define install-rockchip-u-boot
|
| 166 | (write-u-boot-image '(("idbloader.img" 64) ("u-boot.itb" 16384)) 512))
|
| 167 |
|
| 168 | (define install-sifive-unmatched-u-boot
|
| 169 | (write-u-boot-image '(("spl/u-boot-spl.bin" 34) ("u-boot.itb" 2082))
|
| 170 | 512))
|
| 171 |
|
| 172 | (define install-starfive-visionfive2-u-boot
|
| 173 | (write-u-boot-image '(("spl/u-boot-spl.bin.normal.out" 34)
|
| 174 | ("u-boot.itb" 2082))
|
| 175 | 512))
|
| 176 |
|
| 177 | (define install-starfive-visionfive2-uEnv.txt
|
| 178 | (make-u-boot-installer
|
| 179 | |
| 180 | |
| 181 | |
| 182 | (plain-file "uEnv.txt"
|
| 183 | (string-join
|
| 184 | (list
|
| 185 | "boot_targets=mmc1 nvme0 mmc0 dhcp"
|
| 186 | "bootcmd_mmc1=bootflow scan"
|
| 187 | "fdtfile=starfive/jh7110-starfive-visionfive-2-v1.3b.dtb")
|
| 188 | "\n"))))
|
| 189 |
|
| 190 |
|
| 191 | |
| 192 | |
| 193 | |
| 194 |
|
| 195 | (define u-boot-bootloader
|
| 196 | (bootloader
|
| 197 | (inherit extlinux-bootloader)
|
| 198 | (name 'u-boot)
|
| 199 | (package #f)
|
| 200 | (installer #f)
|
| 201 | (disk-image-installer install-u-boot)))
|
| 202 |
|
| 203 | (define u-boot-am335x-evm-bootloader
|
| 204 | (bootloader
|
| 205 | (inherit u-boot-bootloader)
|
| 206 | |
| 207 | |
| 208 | |
| 209 | |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | (package u-boot-am335x-evm)
|
| 225 | |
| 226 | |
| 227 | |
| 228 | (disk-image-installer install-am335x-evm-u-boot)))
|
| 229 |
|
| 230 | (define u-boot-beaglebone-black-bootloader
|
| 231 | (bootloader
|
| 232 | (inherit u-boot-bootloader)
|
| 233 | (package u-boot-am335x-boneblack)
|
| 234 | (disk-image-installer install-beaglebone-black-u-boot)))
|
| 235 |
|
| 236 | (define u-boot-allwinner-bootloader
|
| 237 | (bootloader
|
| 238 | (inherit u-boot-bootloader)
|
| 239 | (disk-image-installer install-allwinner-u-boot)))
|
| 240 |
|
| 241 | (define u-boot-allwinner64-bootloader
|
| 242 | (bootloader
|
| 243 | (inherit u-boot-bootloader)
|
| 244 | (disk-image-installer install-allwinner64-u-boot)))
|
| 245 |
|
| 246 | (define u-boot-imx-bootloader
|
| 247 | (bootloader
|
| 248 | (inherit u-boot-bootloader)
|
| 249 | (disk-image-installer install-imx-u-boot)))
|
| 250 |
|
| 251 | (define u-boot-rockchip-bootloader
|
| 252 | |
| 253 | (bootloader
|
| 254 | (inherit u-boot-bootloader)
|
| 255 | (disk-image-installer install-rockchip-u-boot)))
|
| 256 |
|
| 257 | (define u-boot-a20-olinuxino-lime-bootloader
|
| 258 | (bootloader
|
| 259 | (inherit u-boot-allwinner-bootloader)
|
| 260 | (package u-boot-a20-olinuxino-lime)))
|
| 261 |
|
| 262 | (define u-boot-a20-olinuxino-lime2-bootloader
|
| 263 | (bootloader
|
| 264 | (inherit u-boot-allwinner-bootloader)
|
| 265 | (package u-boot-a20-olinuxino-lime2)))
|
| 266 |
|
| 267 | (define u-boot-a20-olinuxino-micro-bootloader
|
| 268 | (bootloader
|
| 269 | (inherit u-boot-allwinner-bootloader)
|
| 270 | (package u-boot-a20-olinuxino-micro)))
|
| 271 |
|
| 272 | (define u-boot-bananapi-m2-ultra-bootloader
|
| 273 | (bootloader
|
| 274 | (inherit u-boot-allwinner-bootloader)
|
| 275 | (package u-boot-bananapi-m2-ultra)))
|
| 276 |
|
| 277 | (define u-boot-cubietruck-bootloader
|
| 278 | (bootloader
|
| 279 | (inherit u-boot-allwinner-bootloader)
|
| 280 | (package u-boot-cubietruck)))
|
| 281 |
|
| 282 | (define u-boot-firefly-rk3399-bootloader
|
| 283 | (bootloader
|
| 284 | (inherit u-boot-rockchip-bootloader)
|
| 285 | (package u-boot-firefly-rk3399)))
|
| 286 |
|
| 287 | (define u-boot-mx6cuboxi-bootloader
|
| 288 | (bootloader
|
| 289 | (inherit u-boot-imx-bootloader)
|
| 290 | (package u-boot-mx6cuboxi)))
|
| 291 |
|
| 292 | (define u-boot-wandboard-bootloader
|
| 293 | (bootloader
|
| 294 | (inherit u-boot-imx-bootloader)
|
| 295 | (package u-boot-wandboard)))
|
| 296 |
|
| 297 | (define u-boot-novena-bootloader
|
| 298 | (bootloader
|
| 299 | (inherit u-boot-imx-bootloader)
|
| 300 | (package u-boot-novena)))
|
| 301 |
|
| 302 | (define u-boot-orangepi-r1-plus-lts-rk3328-bootloader
|
| 303 | (bootloader
|
| 304 | (inherit u-boot-rockchip-bootloader)
|
| 305 | (package u-boot-orangepi-r1-plus-lts-rk3328)))
|
| 306 |
|
| 307 | (define u-boot-orangepi-zero2w-bootloader
|
| 308 | (bootloader
|
| 309 | (inherit u-boot-allwinner-bootloader)
|
| 310 | (package u-boot-orangepi-zero2w)))
|
| 311 |
|
| 312 | (define u-boot-pine64-plus-bootloader
|
| 313 | (bootloader
|
| 314 | (inherit u-boot-allwinner64-bootloader)
|
| 315 | (package u-boot-pine64-plus)))
|
| 316 |
|
| 317 | (define u-boot-pine64-lts-bootloader
|
| 318 | (bootloader
|
| 319 | (inherit u-boot-allwinner-bootloader)
|
| 320 | (package u-boot-pine64-lts)))
|
| 321 |
|
| 322 | (define u-boot-pinebook-bootloader
|
| 323 | (bootloader
|
| 324 | (inherit u-boot-allwinner64-bootloader)
|
| 325 | (package u-boot-pinebook)))
|
| 326 |
|
| 327 | (define u-boot-puma-rk3399-bootloader
|
| 328 | (bootloader
|
| 329 | (inherit u-boot-bootloader)
|
| 330 | (package u-boot-puma-rk3399)
|
| 331 | (disk-image-installer install-puma-rk3399-u-boot)))
|
| 332 |
|
| 333 | (define u-boot-rock-4c-plus-rk3399-bootloader
|
| 334 | (bootloader
|
| 335 | (inherit u-boot-rockchip-bootloader)
|
| 336 | (package u-boot-rock-4c-plus-rk3399)))
|
| 337 |
|
| 338 | (define u-boot-rock64-rk3328-bootloader
|
| 339 | (bootloader
|
| 340 | (inherit u-boot-rockchip-bootloader)
|
| 341 | (package u-boot-rock64-rk3328)))
|
| 342 |
|
| 343 | (define u-boot-rockpro64-rk3399-bootloader
|
| 344 | (bootloader
|
| 345 | (inherit u-boot-rockchip-bootloader)
|
| 346 | (package u-boot-rockpro64-rk3399)))
|
| 347 |
|
| 348 | (define u-boot-pinebook-pro-rk3399-bootloader
|
| 349 | (bootloader
|
| 350 | (inherit u-boot-rockchip-bootloader)
|
| 351 | (package u-boot-pinebook-pro-rk3399)))
|
| 352 |
|
| 353 | (define u-boot-nanopi-r4s-rk3399-bootloader
|
| 354 | (bootloader
|
| 355 | (inherit u-boot-rockchip-bootloader)
|
| 356 | (package u-boot-nanopi-r4s-rk3399)))
|
| 357 |
|
| 358 | (define u-boot-ts7970-q-2g-1000mhz-c-bootloader
|
| 359 | |
| 360 | |
| 361 | |
| 362 | (bootloader
|
| 363 | (inherit u-boot-bootloader)
|
| 364 | (package u-boot-ts7970-q-2g-1000mhz-c)
|
| 365 | (installer (make-u-boot-installer "libexec/u-boot.imx"))
|
| 366 | (disk-image-installer #f)))
|
| 367 |
|
| 368 | (define u-boot-sifive-unmatched-bootloader
|
| 369 | (bootloader
|
| 370 | (inherit u-boot-bootloader)
|
| 371 | (package u-boot-sifive-unmatched)
|
| 372 | (disk-image-installer install-sifive-unmatched-u-boot)))
|
| 373 |
|
| 374 | (define u-boot-starfive-visionfive2-bootloader
|
| 375 | (bootloader
|
| 376 | (inherit u-boot-bootloader)
|
| 377 | (package u-boot-starfive-visionfive2)
|
| 378 | (installer install-starfive-visionfive2-uEnv.txt)
|
| 379 | (disk-image-installer install-starfive-visionfive2-u-boot)))
|
| 380 |
|
| 381 | (define u-boot-qemu-riscv64-bootloader
|
| 382 | (bootloader
|
| 383 | (inherit u-boot-bootloader)
|
| 384 | (package u-boot-qemu-riscv64)
|
| 385 | (installer (make-u-boot-installer "libexec/u-boot.bin"))
|
| 386 | (disk-image-installer #f)))
|