aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 David Craven <david@craven.ch>
;;; Copyright © 2017, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2023-2024 Herman Rimm <herman@rimm.ee>
;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
;;;
;;; 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)
  #:use-module (ice-9 match)
  #:export (u-boot-bootloader
            u-boot-a20-olinuxino-lime-bootloader
            u-boot-a20-olinuxino-lime2-bootloader
            u-boot-a20-olinuxino-micro-bootloader
            u-boot-bananapi-m2-ultra-bootloader
            u-boot-beaglebone-black-bootloader
            u-boot-cubietruck-bootloader
            u-boot-firefly-rk3399-bootloader
            u-boot-mx6cuboxi-bootloader
            u-boot-nintendo-nes-classic-edition-bootloader
            u-boot-novena-bootloader
            u-boot-orangepi-r1-plus-lts-rk3328-bootloader
            u-boot-pine64-plus-bootloader
            u-boot-pine64-lts-bootloader
            u-boot-pinebook-bootloader
            u-boot-pinebook-pro-rk3399-bootloader
            u-boot-puma-rk3399-bootloader
            u-boot-rock64-rk3328-bootloader
            u-boot-rockpro64-rk3399-bootloader
            u-boot-sifive-unmatched-bootloader
            u-boot-qemu-riscv64-bootloader
            u-boot-starfive-visionfive2-bootloader
            u-boot-ts7970-q-2g-1000mhz-c-bootloader
            u-boot-wandboard-bootloader))

(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))))

(define install-u-boot
  #~(lambda (bootloader root-index image)
      (if bootloader
        (error "Failed to install U-Boot"))))

(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.
  #~(lambda (bootloader root-index image)
      (let ((mlo (string-append bootloader "/libexec/MLO"))
            (u-boot (string-append bootloader "/libexec/u-boot.img")))
        (write-file-on-device mlo (* 256 512)
                              image (* 256 512))
        (write-file-on-device u-boot (* 1024 512)
                              image (* 768 512)))))

(define install-allwinner-u-boot
  #~(lambda (bootloader root-index image)
      (let ((u-boot (string-append bootloader
                                   "/libexec/u-boot-sunxi-with-spl.bin")))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 8 1024)))))

(define install-allwinner64-u-boot
  #~(lambda (bootloader root-index image)
      (let ((spl (string-append bootloader "/libexec/u-boot-sunxi-with-spl.bin"))
            (u-boot (string-append bootloader "/libexec/u-boot-sunxi-with-spl.fit.itb")))
        (write-file-on-device spl (stat:size (stat spl))
                              image (* 8 1024))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 40 1024)))))

(define install-imx-u-boot
  #~(lambda (bootloader root-index image)
      (let ((spl (string-append bootloader "/libexec/SPL"))
            (u-boot (string-append bootloader "/libexec/u-boot.img")))
        (write-file-on-device spl (stat:size (stat spl))
                              image (* 1 1024))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 69 1024)))))

(define install-orangepi-r1-plus-lts-rk3328-u-boot
  #~(lambda (bootloader root-index image)
      (let ((idb (string-append bootloader "/libexec/idbloader.img"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device idb (stat:size (stat idb))
                              image (* 64 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 16384 512)))))

(define install-puma-rk3399-u-boot
  #~(lambda (bootloader root-index image)
      (let ((spl (string-append bootloader "/libexec/idbloader.img"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device spl (stat:size (stat spl))
                              image (* 64 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 512 512)))))

(define install-firefly-rk3399-u-boot
  #~(lambda (bootloader root-index image)
      (let ((idb (string-append bootloader "/libexec/idbloader.img"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device idb (stat:size (stat idb))
                              image (* 64 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 16384 512)))))

(define install-rock64-rk3328-u-boot
  #~(lambda (bootloader root-index image)
      (let ((idb (string-append bootloader "/libexec/idbloader.img"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device idb (stat:size (stat idb))
                              image (* 64 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 16384 512)))))

(define install-rockpro64-rk3399-u-boot
  #~(lambda (bootloader root-index image)
      (let ((idb (string-append bootloader "/libexec/idbloader.img"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device idb (stat:size (stat idb))
                              image (* 64 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 16384 512)))))

(define install-pinebook-pro-rk3399-u-boot install-rockpro64-rk3399-u-boot)

(define install-sifive-unmatched-u-boot
  #~(lambda (bootloader root-index image)
      (let ((spl (string-append bootloader "/libexec/spl/u-boot-spl.bin"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device spl (stat:size (stat spl))
                              image (* 34 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 2082 512)))))

(define install-starfive-visionfive2-u-boot
  #~(lambda (bootloader root-index image)
      (let ((spl (string-append
                  bootloader "/libexec/spl/u-boot-spl.bin.normal.out"))
            (u-boot (string-append bootloader "/libexec/u-boot.itb")))
        (write-file-on-device spl (stat:size (stat spl))
                              image (* 34 512))
        (write-file-on-device u-boot (stat:size (stat u-boot))
                              image (* 2082 512)))))

(define install-starfive-visionfive2-uEnv.txt
  (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~%")))


;;;
;;; Bootloader definitions.
;;;

(define u-boot-bootloader
  (bootloader
   (inherit extlinux-bootloader)
   (name 'u-boot)
   (package #f)
   (installer #f)
   (disk-image-installer install-u-boot)))

(define u-boot-beaglebone-black-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-am335x-boneblack)
   (disk-image-installer install-beaglebone-black-u-boot)))

(define u-boot-allwinner-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (disk-image-installer install-allwinner-u-boot)))

(define u-boot-allwinner64-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (disk-image-installer install-allwinner64-u-boot)))

(define u-boot-imx-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (disk-image-installer install-imx-u-boot)))

(define u-boot-nintendo-nes-classic-edition-bootloader
  (bootloader
    (inherit u-boot-allwinner-bootloader)
    (package u-boot-nintendo-nes-classic-edition)))

(define u-boot-a20-olinuxino-lime-bootloader
  (bootloader
   (inherit u-boot-allwinner-bootloader)
   (package u-boot-a20-olinuxino-lime)))

(define u-boot-a20-olinuxino-lime2-bootloader
  (bootloader
   (inherit u-boot-allwinner-bootloader)
   (package u-boot-a20-olinuxino-lime2)))

(define u-boot-a20-olinuxino-micro-bootloader
  (bootloader
   (inherit u-boot-allwinner-bootloader)
   (package u-boot-a20-olinuxino-micro)))

(define u-boot-bananapi-m2-ultra-bootloader
  (bootloader
   (inherit u-boot-allwinner-bootloader)
   (package u-boot-bananapi-m2-ultra)))

(define u-boot-cubietruck-bootloader
  (bootloader
    (inherit u-boot-allwinner-bootloader)
    (package u-boot-cubietruck)))

(define u-boot-firefly-rk3399-bootloader
  ;; SD and eMMC use the same format
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-firefly-rk3399)
   (disk-image-installer install-firefly-rk3399-u-boot)))

(define u-boot-mx6cuboxi-bootloader
  (bootloader
   (inherit u-boot-imx-bootloader)
   (package u-boot-mx6cuboxi)))

(define u-boot-wandboard-bootloader
  (bootloader
   (inherit u-boot-imx-bootloader)
   (package u-boot-wandboard)))

(define u-boot-novena-bootloader
  (bootloader
   (inherit u-boot-imx-bootloader)
   (package u-boot-novena)))

(define u-boot-orangepi-r1-plus-lts-rk3328-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-orangepi-r1-plus-lts-rk3328)
   (disk-image-installer install-orangepi-r1-plus-lts-rk3328-u-boot)))

(define u-boot-pine64-plus-bootloader
  (bootloader
   (inherit u-boot-allwinner64-bootloader)
   (package u-boot-pine64-plus)))

(define u-boot-pine64-lts-bootloader
  (bootloader
   (inherit u-boot-allwinner-bootloader)
   (package u-boot-pine64-lts)))

(define u-boot-pinebook-bootloader
  (bootloader
   (inherit u-boot-allwinner64-bootloader)
   (package u-boot-pinebook)))

(define u-boot-puma-rk3399-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-puma-rk3399)
   (disk-image-installer install-puma-rk3399-u-boot)))

(define u-boot-rock64-rk3328-bootloader
  ;; SD and eMMC use the same format
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-rock64-rk3328)
   (disk-image-installer install-rock64-rk3328-u-boot)))

(define u-boot-rockpro64-rk3399-bootloader
  ;; SD and eMMC use the same format
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-rockpro64-rk3399)
   (disk-image-installer install-rockpro64-rk3399-u-boot)))

(define u-boot-pinebook-pro-rk3399-bootloader
  ;; SD and eMMC use the same format
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-pinebook-pro-rk3399)
   (disk-image-installer install-pinebook-pro-rk3399-u-boot)))

(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)
   (installer (make-u-boot-installer "libexec/u-boot.imx"))
   (disk-image-installer #f)))

(define u-boot-sifive-unmatched-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-sifive-unmatched)
   (disk-image-installer install-sifive-unmatched-u-boot)))

(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)))

(define u-boot-qemu-riscv64-bootloader
  (bootloader
   (inherit u-boot-bootloader)
   (package u-boot-qemu-riscv64)
   (installer (make-u-boot-installer "libexec/u-boot.bin"))
   (disk-image-installer #f)))
n class='msg-avail'>...* gnu/packages/finance.scm (monero): Update to 0.17.1.1. Guillaume Le Vaillant 2020-10-17gnu: python-duniterpy: Update to 0.60.0....* gnu/packages/finance.scm (python-duniterpy): Update to 0.60.0. Nicolas Goaziou 2020-10-14gnu: monero-gui: Update to 0.17.1.0....* gnu/packages/finance.scm (monero-gui): Update to 0.17.1.0. Guillaume Le Vaillant 2020-10-14gnu: monero: Update to 0.17.1.0....* gnu/packages/finance.scm (monero): Update to 0.17.1.0. Guillaume Le Vaillant 2020-10-05gnu: monero-gui: Update to 0.17.0.1....* gnu/packages/finance.scm (monero-gui): Update to 0.17.0.1. [native-inputs]: Add native inputs of monero. [inputs]: Add monero and its inputs. [propagated-inputs]: Remove. [arguments]: Add 'configure-flags'. Remove 'get-monero-extra-files', 'fix-makefile-vars', 'fix-paths', 'make-qt-deterministic', 'fix-version' and 'build-zxcvbn-c' phases. Add 'extract-monero-sources', 'fix-build', 'generate-zxcvbn-c-header' and 'install-monerod-link' phases. Remove custom 'configure' phase. Add custom 'install' phase. (monero)[arguments]: Remove 'BUILD_GUI_DEPS' from 'configure-flags'. Remove 'install-librandomx' and 'delete-dead-links' phases. Add 'delete-unused-files' phase. Guillaume Le Vaillant 2020-10-05gnu: monero: Update to 0.17.0.1....* gnu/packages/finance.scm (monero): Update to 0.17.0.1. Guillaume Le Vaillant 2020-09-30gnu: bitcoin-unlimited: Update to 1.9.0.1....* gnu/packages/finance.scm (bitcoin-unlimited): Update to 1.9.0.1. [arguments]: Add "--disable-static" to 'configure-flags. Remove 'fix-build' and 'make-qt-deterministic' phases. Enable "txvalidationcache" test. Guillaume Le Vaillant 2020-09-30gnu: Fix package references....* gnu/packages/algebra.scm (iml)[inputs]: Correctly refer to package inputs. * gnu/packages/astronomy.scm (xplanet), * gnu/packages/audio.scm (redkite, libaudec, lv2lint, lv2toweb), * gnu/packages/bioconductor.scm (r-cummerbund), * gnu/packages/chicken.scm (chicken), * gnu/packages/conky.scm (conky), * gnu/packages/cran.scm (r-latex2exp), * gnu/packages/crates-io.scm (rust-rgb), * gnu/packages/databases.scm (mariadb), * gnu/packages/diffoscope.scm (reprotest), * gnu/packages/file-systems.scm (glusterfs), * gnu/packages/finance.scm (electron-cash), * gnu/packages/games.scm (rinutils, ksudoku, kdiamond, kigo), * gnu/packages/geo.scm (grass), * gnu/packages/gnome.scm (libmediaart, gnome-contacts, geoclue), * gnu/packages/gnucash.scm (aqbanking), * gnu/packages/image.scm (mtpaint), * gnu/packages/kde-internet.scm (kopete, ktorrent), * gnu/packages/kde-utils.scm (kmousetool, kmouth, kronometer), * gnu/packages/linphone.scm (liblinphone), * gnu/packages/maths.scm (ppl), * gnu/packages/mercury.scm (mercury-minimal), * gnu/packages/music.scm (bjumblr, bschaffl, lsp-plugins, spectacle-analyzer, helm, tap-lv2, wolf-shaper, shiru-lv2), * gnu/packages/networking.scm (restinio), * gnu/packages/prolog.scm (swi-prolog), * gnu/packages/python-web.scm (gunicorn), * gnu/packages/python-xyz.scm (python-docusign-esign), * gnu/packages/ruby.scm (ruby-cucumber, ruby_version, ruby-addressable), * gnu/packages/sagemath.scm (python-cypari2), * gnu/packages/skarnet.scm (s6-linux-init), * gnu/packages/vpn.scm (sshuttle), * gnu/packages/web.scm (libcyaml), * gnu/packages/xdisorg.scm (kbdd), * gnu/packages/xorg.scm (xpra): Same. Efraim Flashner 2020-09-23gnu: Fix typoes in package descriptions....* gnu/packages/audio.scm (caps-plugins-lv2)[synopsis]: Fix typo. * gnu/packages/bioconductor.scm (r-karyoploter, r-anota, r-gcrma) (r-bigmemoryextras)[description]: Likewise. * gnu/packages/cran.scm (r-geometry)[synopsis]: Likewise. (r-stringdist, r-patchwork, r-depth, r-tea)[description]: Likewise. * gnu/packages/crates-io.scm (rust-assert-fs-0.11, rust-notify-4) (rust-tokio-fs-0.1)[synopsis, description]: Likewise. (rust-blas-sys-0.7)[description]: Likewise. (rust-fs-extra-1.1, rust-xattr-0.2)[synopsis]: Likewise. * gnu/packages/databases.scm (perl-mysql-config)[description]: Likewise. * gnu/packages/disk.scm (hddtemp)[description]: Likewise. * gnu/packages/django.scm (python-djangorestframework)[description]: Likewise. * gnu/packages/documentation.scm (doc++)[description]: Likewise. * gnu/packages/emacs-xyz.scm (emacs-kakoune, emacs-pyim-basedict, eless) (emacs-scpaste)[description]: Likewise. * gnu/packages/file-systems.scm (dbxfs)[description]: Likewise. * gnu/packages/finance.scm (python-stdnum)[description]: Likewise. * gnu/packages/fontutils.scm (woff2)[description]: Likewise. * gnu/packages/games.scm (openttd-opengfx)[description]: Likewise. * gnu/packages/gnome-xyz.scm (gnome-shell-extension-topicons-redux) [description]: Likewise. * gnu/packages/gnome.scm (libgrss)[description]: Likewise. * gnu/packages/golang.scm (go-github-com-mitchellh-reflectwalk) [description]: Likewise. (go-github-com-go-git-go-billy)[synopsis, description]: Likewise. * gnu/packages/haskell-check.scm (ghc-inspection-testing)[description]: Likewise. * gnu/packages/haskell-web.scm (ghc-yesod-form)[description]: Likewise. * gnu/packages/haskell-xyz.scm (ghc-hex)[description]: Likewise. * gnu/packages/hyperledger.scm (hyperledger-iroha-ed25519)[description]: Likewise. * gnu/packages/java.scm (java-mail)[synopsis]: Likewise. (java-native-access-platform)[description]: Likewise. * gnu/packages/kde-frameworks.scm (kactivities-stats)[description]: Likewise. * gnu/packages/kde-utils.scm (krusader)[description]: Likewise. * gnu/packages/language.scm (praat)[description]: Likewise. * gnu/packages/linux.scm (light)[description]: Likewise. * gnu/packages/lisp-xyz.scm (sbcl-hu.dwim.defclass-star)[description]: Likewise. * gnu/packages/mail.scm (dovecot-trees, sieve-connect)[description]: Likewise. * gnu/packages/ocaml.scm (ocaml-opam-file-format, ocaml-cppo) (ocaml4.07-ppx-variants-conv)[description]: Likewise. * gnu/packages/perl.scm (perl-convert-binhex)[description]: Likewise. * gnu/packages/python-crypto.scm (python-ecdsa)[description]: Likewise. * gnu/packages/python-web.scm (python-html5lib)[synopsis, description]: Likewise. (python-venusian)[synopsis]: Likewise. * gnu/packages/python-xyz.scm (python-readlike, python-gssapi) (python-flufl-i18n)[description]: Likewise. (python-pox, python-watchdog, python-xattr)[synopsis, description]: Likewise. * gnu/packages/ruby.scm (ruby-sorcerer)[description]: Likewise. * gnu/packages/rust-apps.scm (watchexec)[description]: Likewise. * gnu/packages/rust.scm (mrustc)[synopsis]: Likewise. * gnu/packages/shells.scm (s-shell)[description]: Likewise. * gnu/packages/ssh.scm (sshpass)[description]: Likewise. * gnu/packages/terminals.scm (beep)[description]: Likewise. * gnu/packages/web.scm (perl-lwp-useragent-cached)[description]: Likewise. * gnu/packages/wv.scm (wv)[description]: Likewise. Tobias Geerinckx-Rice 2020-09-19gnu: electron-cash: Update to 4.1.1....* gnu/packages/finance.scm (electron-cash): Update to 4.1.1. Guillaume Le Vaillant 2020-09-15gnu: homebank: Update to 5.4.3....* gnu/packages/finance.scm (homebank): Update to 5.4.3. Tobias Geerinckx-Rice 2020-09-03gnu: electron-cash: Update to 4.1.0....* gnu/packages/finance.scm (electron-cash): Update to 4.1.0. [inputs]: Use libsecp256k1-bitcoin-cash instead of libsecp256k1. Guillaume Le Vaillant 2020-08-27gnu: bitcoin-unlimited: Update to 1.9.0.0....* gnu/packages/finance.scm (bitcoin-unlimited): Update to 1.9.0.0. Guillaume Le Vaillant 2020-08-24gnu: electrum: Fix share/ location....* gnu/packages/finance.scm (electrum)[arguments]: Rename the ‘patch-home’ phase to ‘fix-prefix’. Do so. Tobias Geerinckx-Rice 2020-08-24gnu: electron-cash: Fix share/ location....* gnu/packages/finance.scm (electron-cash)[arguments]: Drop bogus ‘local/share’ subdirectory: rename ‘patch-home’ to ‘create-output-directories’ and adjust body to match. Tobias Geerinckx-Rice 2020-08-24gnu: electron-cash: Return #t from phases....* gnu/packages/finance.scm (electron-cash)[arguments]: Return truth from all phases. Tobias Geerinckx-Rice 2020-08-24gnu: electrum: Return #t from phases....* gnu/packages/finance.scm (electrum)[arguments]: Return truth from ‘patch-home’. Tobias Geerinckx-Rice 2020-08-16gnu: python-stdnum: Update to 1.14....* gnu/packages/finance.scm (python-stdnum): Update to 1.14. Tobias Geerinckx-Rice