@@ -9,6 +9,7 @@
;;; Copyright © 2020, 2021, 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 Juliana Sims <juli@incana.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -43,6 +44,7 @@ (define-module (gnu packages firmware)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages bison)
+ #:use-module (gnu packages bootloaders)
#:use-module (gnu packages check)
#:use-module (gnu packages cmake)
#:use-module (gnu packages compression)
@@ -567,6 +569,36 @@ (define-public opensbi-qemu
(description
"This package contains OpenSBI firmware files for use with QEMU.")))
+(define-public opensbi-rvvm
+ (let ((base opensbi-generic))
+ (package
+ (inherit base)
+ (name "opensbi-rvvm")
+ (source (origin
+ (inherit (package-source base))
+ (patches (cons
+ ;; Allows opensbi to work on systems with <32M of RAM
+ ;; https://github.com/LekKit/patches-misc/blob/cc40906fbf1de9ae466304157f2bf7b8cc909cbe/opensbi/opensbi_lowram_fdt.patch
+ (search-patch "opensbi-rvvm-lowram-fdt.patch")
+ (origin-patches (package-source base))))))
+
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ((#:make-flags flags)
+ #~(cons (string-append "FW_PAYLOAD_PATH="
+ #$(file-append u-boot-rvvm
+ "/libexec/u-boot.bin"))
+ (delete "FW_PAYLOAD=n"
+ #$flags)))))
+ (inputs (cons u-boot-rvvm
+ (package-inputs base)))
+ (description (string-append (package-description base)
+ "
+
+This package contains OpenSBI firmware files for use with
+@code{rvvm}. In particular, it adds support for low-RAM systems and builds a
+@code{fw_payload.bin} file using @code{u-boot-rvvm-riscv64}.")))))
+
(define-public seabios
(package
(name "seabios")
new file mode 100644
@@ -0,0 +1,21 @@
+Authored-by: LekKit <github.com/LekKit>
+
+Allows OpenSBI to work on devices with <32M of RAM,
+by moving FDT into page alignment zone before the kernel.
+This also allows running kernels that are >32M in size.
+
+Applies cleanly onto OpenSBI 1.2
+
+diff --git a/platform/generic/objects.mk b/platform/generic/objects.mk
+index 136853e..104a063 100644
+--- a/platform/generic/objects.mk
++++ b/platform/generic/objects.mk
+@@ -32,7 +32,7 @@ else
+ # This needs to be 2MB aligned for 64-bit system
+ FW_JUMP_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x200000)))
+ endif
+-FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x2200000)))
++FW_JUMP_FDT_ADDR=$(shell printf "0x%X" $$(($(FW_TEXT_START) + 0x100000)))
+ FW_PAYLOAD=y
+ ifeq ($(PLATFORM_RISCV_XLEN), 32)
+ # This needs to be 4MB aligned for 32-bit system