2017-06-11 12:58:38 +02:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
|
|
;;; Copyright © 2017 David Craven <david@craven.ch>
|
2019-12-14 17:37:23 +01:00
|
|
|
|
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
|
2020-02-02 00:04:39 +01:00
|
|
|
|
;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
|
2020-04-20 18:21:07 -07:00
|
|
|
|
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2025-09-18 12:25:39 +09:00
|
|
|
|
;;; Copyright © 2022 Maxim Cournoyer <maxim@guixotic.coop>
|
2023-05-28 10:57:35 +03:00
|
|
|
|
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
|
2024-10-31 22:15:50 +01:00
|
|
|
|
;;; Copyright © 2023-2024 Herman Rimm <herman@rimm.ee>
|
2024-03-19 23:18:35 +08:00
|
|
|
|
;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
|
2017-06-11 12:58:38 +02:00
|
|
|
|
;;;
|
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
(define-module (gnu bootloader u-boot)
|
|
|
|
|
|
#:use-module (gnu bootloader extlinux)
|
|
|
|
|
|
#:use-module (gnu bootloader)
|
|
|
|
|
|
#:use-module (gnu packages bootloaders)
|
|
|
|
|
|
#:use-module (guix gexp)
|
2024-10-31 22:15:50 +01:00
|
|
|
|
#:use-module (ice-9 match)
|
2017-12-12 16:41:56 +01:00
|
|
|
|
#:export (u-boot-bootloader
|
2018-01-22 22:35:06 +01:00
|
|
|
|
u-boot-a20-olinuxino-lime-bootloader
|
2018-01-20 20:46:00 +01:00
|
|
|
|
u-boot-a20-olinuxino-lime2-bootloader
|
2018-01-20 20:55:52 +01:00
|
|
|
|
u-boot-a20-olinuxino-micro-bootloader
|
2018-09-14 21:31:24 +02:00
|
|
|
|
u-boot-bananapi-m2-ultra-bootloader
|
2018-01-20 22:05:16 +01:00
|
|
|
|
u-boot-beaglebone-black-bootloader
|
2020-02-02 00:04:39 +01:00
|
|
|
|
u-boot-cubietruck-bootloader
|
2019-10-18 15:43:09 -07:00
|
|
|
|
u-boot-firefly-rk3399-bootloader
|
2018-05-07 14:32:02 +00:00
|
|
|
|
u-boot-mx6cuboxi-bootloader
|
2018-05-07 14:34:43 +00:00
|
|
|
|
u-boot-nintendo-nes-classic-edition-bootloader
|
2018-05-09 06:59:10 +00:00
|
|
|
|
u-boot-novena-bootloader
|
2023-11-18 17:01:27 +01:00
|
|
|
|
u-boot-orangepi-r1-plus-lts-rk3328-bootloader
|
2024-12-13 22:07:35 +01:00
|
|
|
|
u-boot-orangepi-zero2w-bootloader
|
2018-05-17 15:16:09 -07:00
|
|
|
|
u-boot-pine64-plus-bootloader
|
2019-12-14 17:37:23 +01:00
|
|
|
|
u-boot-pine64-lts-bootloader
|
2018-11-20 16:32:16 -08:00
|
|
|
|
u-boot-pinebook-bootloader
|
2020-04-20 18:21:07 -07:00
|
|
|
|
u-boot-pinebook-pro-rk3399-bootloader
|
2018-05-28 21:10:15 -07:00
|
|
|
|
u-boot-puma-rk3399-bootloader
|
2019-10-18 13:14:08 -07:00
|
|
|
|
u-boot-rock64-rk3328-bootloader
|
2019-10-14 02:01:53 -04:00
|
|
|
|
u-boot-rockpro64-rk3399-bootloader
|
2023-05-28 10:57:35 +03:00
|
|
|
|
u-boot-sifive-unmatched-bootloader
|
2024-03-19 23:18:35 +08:00
|
|
|
|
u-boot-qemu-riscv64-bootloader
|
2024-05-11 13:32:57 +08:00
|
|
|
|
u-boot-starfive-visionfive2-bootloader
|
2022-12-09 00:27:09 -05:00
|
|
|
|
u-boot-ts7970-q-2g-1000mhz-c-bootloader
|
2018-05-07 14:34:43 +00:00
|
|
|
|
u-boot-wandboard-bootloader))
|
2017-06-11 12:58:38 +02:00
|
|
|
|
|
2024-10-31 22:15:50 +01:00
|
|
|
|
(define (make-u-boot-installer file)
|
|
|
|
|
|
(let ((file
|
|
|
|
|
|
(match file
|
|
|
|
|
|
((? string?)
|
|
|
|
|
|
(list #~(install-file (string-append bootloader #$file)
|
|
|
|
|
|
install-dir)))
|
|
|
|
|
|
((? file-like?) (list #~(install-file #$file install-dir)))
|
|
|
|
|
|
(#f '()))))
|
|
|
|
|
|
#~(lambda (bootloader device mount-point)
|
|
|
|
|
|
(let ((install-dir (string-append mount-point "/boot")))
|
|
|
|
|
|
#$@file))))
|
|
|
|
|
|
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(define (write-u-boot-image files block-size)
|
|
|
|
|
|
"FILES is a list of (FILE COUNT OFFSET) tuples. Each FILE is written
|
|
|
|
|
|
to the target image at BLOCK-SIZE * OFFSET. The number of bytes written
|
|
|
|
|
|
is BLOCK-SIZE * COUNT, or FILE size if COUNT is not given."
|
|
|
|
|
|
(define (write-file-to-image file)
|
|
|
|
|
|
(match file
|
|
|
|
|
|
((file count ... offset)
|
|
|
|
|
|
(let* ((file #~(string-append bootloader "/libexec/" #$file))
|
|
|
|
|
|
(size (match count
|
|
|
|
|
|
(() #~(stat:size (stat #$file)))
|
|
|
|
|
|
((count) (* count block-size)))))
|
|
|
|
|
|
#~(write-file-on-device #$file #$size image
|
|
|
|
|
|
#$(* offset block-size))))))
|
|
|
|
|
|
#~(lambda (bootloader _ image)
|
|
|
|
|
|
#$@(map write-file-to-image files)))
|
|
|
|
|
|
|
2017-06-11 12:58:38 +02:00
|
|
|
|
(define install-u-boot
|
2020-10-05 10:58:55 +02:00
|
|
|
|
#~(lambda (bootloader root-index image)
|
2017-06-11 12:58:38 +02:00
|
|
|
|
(if bootloader
|
|
|
|
|
|
(error "Failed to install U-Boot"))))
|
|
|
|
|
|
|
2017-12-12 16:41:56 +01:00
|
|
|
|
(define install-beaglebone-black-u-boot
|
|
|
|
|
|
;; http://wiki.beyondlogic.org/index.php?title=BeagleBoneBlack_Upgrading_uBoot
|
|
|
|
|
|
;; This first stage bootloader called MLO (U-Boot SPL) is expected at
|
|
|
|
|
|
;; 0x20000 by BBB ROM code. The second stage bootloader will be loaded by
|
|
|
|
|
|
;; the MLO and is expected at 0x60000. Write both first stage ("MLO") and
|
|
|
|
|
|
;; second stage ("u-boot.img") images, read in BOOTLOADER directory, to the
|
|
|
|
|
|
;; specified DEVICE.
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("MLO" 256 256) ("u-boot.img" 768 1024)) 512))
|
2017-12-12 16:41:56 +01:00
|
|
|
|
|
2018-01-19 00:25:13 +01:00
|
|
|
|
(define install-allwinner-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("u-boot-sunxi-with-spl.bin" 8)) 1024))
|
2018-01-19 00:25:13 +01:00
|
|
|
|
|
2018-05-17 15:16:09 -07:00
|
|
|
|
(define install-allwinner64-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("u-boot-sunxi-with-spl.bin" 8)
|
|
|
|
|
|
("u-boot-sunxi-with-spl.fit.itb" 40))
|
|
|
|
|
|
1024))
|
2018-05-17 15:16:09 -07:00
|
|
|
|
|
2018-05-07 14:32:02 +00:00
|
|
|
|
(define install-imx-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("SPL" 1) ("u-boot.img" 69)) 1024))
|
2018-05-07 14:32:02 +00:00
|
|
|
|
|
2018-05-28 21:10:15 -07:00
|
|
|
|
(define install-puma-rk3399-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("idbloader.img" 64) ("u-boot.itb" 512)) 512))
|
2018-05-28 21:10:15 -07:00
|
|
|
|
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(define install-rockchip-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("idbloader.img" 64) ("u-boot.itb" 16384)) 512))
|
2019-10-14 02:01:53 -04:00
|
|
|
|
|
2023-05-28 10:57:35 +03:00
|
|
|
|
(define install-sifive-unmatched-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("spl/u-boot-spl.bin" 34) ("u-boot.itb" 2082))
|
|
|
|
|
|
512))
|
2023-05-28 10:57:35 +03:00
|
|
|
|
|
2024-05-11 13:32:57 +08:00
|
|
|
|
(define install-starfive-visionfive2-u-boot
|
2024-12-12 22:07:09 +01:00
|
|
|
|
(write-u-boot-image '(("spl/u-boot-spl.bin.normal.out" 34)
|
|
|
|
|
|
("u-boot.itb" 2082))
|
|
|
|
|
|
512))
|
2024-05-11 13:32:57 +08:00
|
|
|
|
|
|
|
|
|
|
(define install-starfive-visionfive2-uEnv.txt
|
2024-10-31 22:15:50 +01:00
|
|
|
|
(make-u-boot-installer
|
|
|
|
|
|
;; If the board SPI uses the vendor's U-Boot, it will find starfive/
|
|
|
|
|
|
;; starfive_visionfive2.dtb. We cannot guarantee that users will
|
|
|
|
|
|
;; update this U-Boot, so set the FDT explicitly.
|
|
|
|
|
|
(plain-file "uEnv.txt"
|
|
|
|
|
|
"fdtfile=starfive/jh7110-starfive-visionfive-2-v1.3b.dtb~%")))
|
2024-03-19 23:18:35 +08:00
|
|
|
|
|
2017-06-11 12:58:38 +02:00
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
|
;;; Bootloader definitions.
|
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
|
|
(define u-boot-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit extlinux-bootloader)
|
|
|
|
|
|
(name 'u-boot)
|
|
|
|
|
|
(package #f)
|
2020-10-05 10:58:55 +02:00
|
|
|
|
(installer #f)
|
|
|
|
|
|
(disk-image-installer install-u-boot)))
|
2017-12-12 16:41:56 +01:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-beaglebone-black-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
2022-12-26 21:44:25 -05:00
|
|
|
|
(package u-boot-am335x-boneblack)
|
2020-10-05 10:58:55 +02:00
|
|
|
|
(disk-image-installer install-beaglebone-black-u-boot)))
|
2018-01-19 00:25:13 +01:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-allwinner-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
2020-10-05 10:58:55 +02:00
|
|
|
|
(disk-image-installer install-allwinner-u-boot)))
|
2018-01-19 00:25:13 +01:00
|
|
|
|
|
2018-05-17 15:16:09 -07:00
|
|
|
|
(define u-boot-allwinner64-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
2020-10-05 10:58:55 +02:00
|
|
|
|
(disk-image-installer install-allwinner64-u-boot)))
|
2018-05-17 15:16:09 -07:00
|
|
|
|
|
2018-05-07 14:32:02 +00:00
|
|
|
|
(define u-boot-imx-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
2020-10-05 10:58:55 +02:00
|
|
|
|
(disk-image-installer install-imx-u-boot)))
|
2018-05-07 14:32:02 +00:00
|
|
|
|
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(define u-boot-rockchip-bootloader
|
|
|
|
|
|
;; SD and eMMC use the same format
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
|
|
|
|
|
(disk-image-installer install-rockchip-u-boot)))
|
|
|
|
|
|
|
2018-01-20 22:05:16 +01:00
|
|
|
|
(define u-boot-nintendo-nes-classic-edition-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-nintendo-nes-classic-edition)))
|
|
|
|
|
|
|
2018-01-22 22:35:06 +01:00
|
|
|
|
(define u-boot-a20-olinuxino-lime-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-a20-olinuxino-lime)))
|
|
|
|
|
|
|
2018-01-20 20:46:00 +01:00
|
|
|
|
(define u-boot-a20-olinuxino-lime2-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-a20-olinuxino-lime2)))
|
|
|
|
|
|
|
2018-01-20 20:55:52 +01:00
|
|
|
|
(define u-boot-a20-olinuxino-micro-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-a20-olinuxino-micro)))
|
|
|
|
|
|
|
2018-09-14 21:31:24 +02:00
|
|
|
|
(define u-boot-bananapi-m2-ultra-bootloader
|
2018-01-19 00:25:13 +01:00
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
2018-09-14 21:31:24 +02:00
|
|
|
|
(package u-boot-bananapi-m2-ultra)))
|
2018-05-07 14:32:02 +00:00
|
|
|
|
|
2020-02-02 00:04:39 +01:00
|
|
|
|
(define u-boot-cubietruck-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-cubietruck)))
|
|
|
|
|
|
|
2019-10-18 15:43:09 -07:00
|
|
|
|
(define u-boot-firefly-rk3399-bootloader
|
|
|
|
|
|
(bootloader
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(inherit u-boot-rockchip-bootloader)
|
|
|
|
|
|
(package u-boot-firefly-rk3399)))
|
2019-10-18 15:43:09 -07:00
|
|
|
|
|
2018-05-07 14:32:02 +00:00
|
|
|
|
(define u-boot-mx6cuboxi-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-imx-bootloader)
|
|
|
|
|
|
(package u-boot-mx6cuboxi)))
|
2018-05-07 14:34:43 +00:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-wandboard-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-imx-bootloader)
|
|
|
|
|
|
(package u-boot-wandboard)))
|
2018-05-09 06:59:10 +00:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-novena-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-imx-bootloader)
|
|
|
|
|
|
(package u-boot-novena)))
|
2018-05-17 15:16:09 -07:00
|
|
|
|
|
2023-11-18 17:01:27 +01:00
|
|
|
|
(define u-boot-orangepi-r1-plus-lts-rk3328-bootloader
|
|
|
|
|
|
(bootloader
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(inherit u-boot-rockchip-bootloader)
|
|
|
|
|
|
(package u-boot-orangepi-r1-plus-lts-rk3328)))
|
2023-11-18 17:01:27 +01:00
|
|
|
|
|
2024-12-13 22:07:35 +01:00
|
|
|
|
(define u-boot-orangepi-zero2w-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-orangepi-zero2w)))
|
|
|
|
|
|
|
2018-05-17 15:16:09 -07:00
|
|
|
|
(define u-boot-pine64-plus-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner64-bootloader)
|
|
|
|
|
|
(package u-boot-pine64-plus)))
|
2018-05-28 21:10:15 -07:00
|
|
|
|
|
2019-12-14 17:37:23 +01:00
|
|
|
|
(define u-boot-pine64-lts-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner-bootloader)
|
|
|
|
|
|
(package u-boot-pine64-lts)))
|
|
|
|
|
|
|
2018-11-20 16:32:16 -08:00
|
|
|
|
(define u-boot-pinebook-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-allwinner64-bootloader)
|
|
|
|
|
|
(package u-boot-pinebook)))
|
|
|
|
|
|
|
2018-05-28 21:10:15 -07:00
|
|
|
|
(define u-boot-puma-rk3399-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
|
|
|
|
|
(package u-boot-puma-rk3399)
|
2020-10-05 10:58:55 +02:00
|
|
|
|
(disk-image-installer install-puma-rk3399-u-boot)))
|
2019-10-14 02:01:53 -04:00
|
|
|
|
|
2019-10-18 13:14:08 -07:00
|
|
|
|
(define u-boot-rock64-rk3328-bootloader
|
|
|
|
|
|
(bootloader
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(inherit u-boot-rockchip-bootloader)
|
|
|
|
|
|
(package u-boot-rock64-rk3328)))
|
2019-10-18 13:14:08 -07:00
|
|
|
|
|
2019-10-14 02:01:53 -04:00
|
|
|
|
(define u-boot-rockpro64-rk3399-bootloader
|
|
|
|
|
|
(bootloader
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(inherit u-boot-rockchip-bootloader)
|
|
|
|
|
|
(package u-boot-rockpro64-rk3399)))
|
2020-04-20 18:21:07 -07:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-pinebook-pro-rk3399-bootloader
|
|
|
|
|
|
(bootloader
|
2024-12-12 22:03:25 +01:00
|
|
|
|
(inherit u-boot-rockchip-bootloader)
|
|
|
|
|
|
(package u-boot-pinebook-pro-rk3399)))
|
2022-12-09 00:27:09 -05:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-ts7970-q-2g-1000mhz-c-bootloader
|
|
|
|
|
|
;; This bootloader doesn't really need to be installed, as it is read from
|
|
|
|
|
|
;; an SPI memory chip, not the SD card. It is copied to /boot/u-boot.imx
|
|
|
|
|
|
;; for convenience and should be manually flashed at the U-Boot prompt.
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
|
|
|
|
|
(package u-boot-ts7970-q-2g-1000mhz-c)
|
2024-10-31 22:15:50 +01:00
|
|
|
|
(installer (make-u-boot-installer "libexec/u-boot.imx"))
|
2022-12-09 00:27:09 -05:00
|
|
|
|
(disk-image-installer #f)))
|
2023-05-28 10:57:35 +03:00
|
|
|
|
|
|
|
|
|
|
(define u-boot-sifive-unmatched-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
|
|
|
|
|
(package u-boot-sifive-unmatched)
|
|
|
|
|
|
(disk-image-installer install-sifive-unmatched-u-boot)))
|
2024-03-19 23:18:35 +08:00
|
|
|
|
|
2024-05-11 13:32:57 +08:00
|
|
|
|
(define u-boot-starfive-visionfive2-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
|
|
|
|
|
(package u-boot-starfive-visionfive2)
|
|
|
|
|
|
(installer install-starfive-visionfive2-uEnv.txt)
|
|
|
|
|
|
(disk-image-installer install-starfive-visionfive2-u-boot)))
|
|
|
|
|
|
|
2024-03-19 23:18:35 +08:00
|
|
|
|
(define u-boot-qemu-riscv64-bootloader
|
|
|
|
|
|
(bootloader
|
|
|
|
|
|
(inherit u-boot-bootloader)
|
|
|
|
|
|
(package u-boot-qemu-riscv64)
|
2024-10-31 22:15:50 +01:00
|
|
|
|
(installer (make-u-boot-installer "libexec/u-boot.bin"))
|
2024-03-19 23:18:35 +08:00
|
|
|
|
(disk-image-installer #f)))
|