2019-03-04 09:52:49 -05:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2019 Timothy Sample <samplet@ngyro.com>
|
2024-08-06 20:11:17 -04:00
|
|
|
;;; Copyright © 2024 Lilah Tascheter <lilah@lunabee.space>
|
2019-03-04 09:52:49 -05: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 depthcharge)
|
|
|
|
#:use-module (gnu bootloader)
|
|
|
|
#:use-module (gnu packages bootloaders)
|
2024-08-06 20:11:17 -04:00
|
|
|
#:use-module (gnu system boot)
|
2019-03-04 09:52:49 -05:00
|
|
|
#:use-module (guix gexp)
|
2024-08-06 20:11:17 -04:00
|
|
|
#:use-module (guix deprecation)
|
|
|
|
#:use-module (guix diagnostics)
|
|
|
|
#:use-module (guix i18n)
|
|
|
|
#:use-module (guix records)
|
2019-03-04 09:52:49 -05:00
|
|
|
#:use-module (guix utils)
|
2024-08-06 20:11:17 -04:00
|
|
|
#:use-module (srfi srfi-26)
|
|
|
|
#:use-module (srfi srfi-35)
|
|
|
|
#:export (depthcharge-veyron-speedy-bootloader
|
|
|
|
depthcharge-bootloader))
|
2019-03-04 09:52:49 -05:00
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
(define* (install-depthcharge arch dtb
|
|
|
|
#:key bootloader-config current-boot-alternative
|
|
|
|
#:allow-other-keys)
|
|
|
|
(when (not (null? (bootloader-configuration-menu-entries bootloader-config)))
|
|
|
|
(raise (formatted-message
|
|
|
|
(G_ "extra menu-entries are not supported for depthcharge!"))))
|
|
|
|
(with-targets (bootloader-configuration-targets bootloader-config)
|
|
|
|
;; use 'part instead of 'disk, cause we write an image directly into a
|
|
|
|
;; partition instead of the extra-partition disk space
|
|
|
|
(('part => (disk :device))
|
|
|
|
(match-menu-entry
|
|
|
|
(boot-alternative->menu-entry current-boot-alternative)
|
|
|
|
(linux linux-arguments initrd)
|
|
|
|
#~(begin
|
|
|
|
(use-modules (ice-9 binary-ports) (rnrs bytevectors))
|
|
|
|
(set-path-environment-variable "PATH" '("bin") (list #$dtc))
|
2019-03-04 09:52:49 -05:00
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
;; TODO: These files have to be writable, so we copy them.
|
|
|
|
;; This can probably be fixed by using a ".its" file, just
|
|
|
|
;; be careful not to break initrd loading.
|
|
|
|
(copy-file #$linux "zImage")
|
|
|
|
(chmod "zImage" #o755)
|
|
|
|
(copy-file (string-append (dirname #$linux) "/lib/dtbs/" #$dtb)
|
|
|
|
"dtb")
|
|
|
|
(chmod "dtb" #o644)
|
|
|
|
(copy-file #$initrd "initrd")
|
|
|
|
(chmod "initrd" #o644)
|
2019-03-04 09:52:49 -05:00
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
(invoke #+(file-append u-boot-tools "/bin/mkimage")
|
|
|
|
"-D" "-I dts -O dtb -p 2048"
|
|
|
|
"-f" "auto" ; format
|
|
|
|
"-A" #$arch ; architecture
|
|
|
|
"-O" "linux" ; os
|
|
|
|
"-T" "kernel" ; image type
|
|
|
|
"-C" "None" ; compression
|
|
|
|
"-d" "zImage" ; image data
|
|
|
|
"-a" "0" ; load address (hex)
|
|
|
|
"-b" "dtb" ; dtb for device
|
|
|
|
"-i" "initrd" ; initrd
|
|
|
|
"image.itb")
|
|
|
|
(call-with-output-file "bootloader.bin"
|
|
|
|
(lambda (port)
|
|
|
|
(put-bytevector port (make-bytevector 512 0))))
|
|
|
|
(call-with-output-file "kernel-arguments"
|
|
|
|
(lambda (port)
|
|
|
|
(display (string-join (list #$@linux-arguments)) port)))
|
|
|
|
(invoke #+(file-append vboot-utils "/bin/vbutil_kernel")
|
|
|
|
"--version" "1"
|
|
|
|
"--vmlinuz" "image.itb"
|
|
|
|
"--arch" #$arch
|
|
|
|
"--keyblock"
|
|
|
|
#$(file-append vboot-utils
|
|
|
|
"/share/vboot-utils/devkeys/kernel.keyblock")
|
|
|
|
"--signprivate"
|
|
|
|
#$(file-append vboot-utils
|
|
|
|
"/share/vboot-utils/devkeys/kernel_data_key.vbprivk")
|
|
|
|
"--config" "kernel-arguments"
|
|
|
|
"--pack" "vmlinux.kpart")
|
|
|
|
(write-file-on-device "vmlinux.kpart"
|
|
|
|
(stat:size (stat "vmlinux.kpart"))
|
|
|
|
#$disk 0))))))
|
2019-03-04 09:52:49 -05:00
|
|
|
|
2024-08-06 20:11:17 -04:00
|
|
|
(define depthcharge-veyron-speedy-bootloader
|
2019-03-04 09:52:49 -05:00
|
|
|
(bootloader
|
|
|
|
(name 'depthcharge)
|
2024-08-06 20:11:17 -04:00
|
|
|
(installer (cute install-depthcharge "arm" "rk3288-veyron-speedy.dtb"
|
|
|
|
<...>))))
|
|
|
|
|
|
|
|
(define-deprecated/alias depthcharge-bootloader
|
|
|
|
depthcharge-veyron-speedy-bootloader)
|