diff mbox series

[bug#64907,2/2] gnu: Add opensbi-rvvm.

Message ID 2502f76902b6983a62cb81e36959982ae7cdfe47.1690488628.git.juli@incana.org
State New
Headers show
Series gnu: Add rvvm support packages. | expand

Commit Message

Juliana Sims July 27, 2023, 9:18 p.m. UTC
* gnu/packages/firmware.scm (opensbi-rvvm): New symbol.
* gnu/packages/patches/opensbi-rvvm-lowram-fdt.patch: New patch.
---
 gnu/packages/firmware.scm                     | 32 +++++++++++++++++++
 .../patches/opensbi-rvvm-lowram-fdt.patch     | 21 ++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 gnu/packages/patches/opensbi-rvvm-lowram-fdt.patch

Comments

Vagrant Cascadian Sept. 3, 2023, 2:24 a.m. UTC | #1
On 2023-07-27, Juliana Sims wrote:
> * gnu/packages/firmware.scm (opensbi-rvvm): New symbol.
> * gnu/packages/patches/opensbi-rvvm-lowram-fdt.patch: New patch.
...
> diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
> index ff5afbcbe1..728050b43a 100644
> --- a/gnu/packages/firmware.scm
> +++ b/gnu/packages/firmware.scm
...
> @@ -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))))))

As discussed elsewhere, maybe try the unpatched opensbi-generic.


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

So my main question is if you can use rvvm with an unmodified
opensbi-generic, passing opensbi-generic and the u-boot-rvvm as
commandline arguments? I know this can be done with qemu...

If it really isn't possible, then just drop the low-ram patch if that
still works.

Thanks!


live well,
  vagrant
diff mbox series

Patch

diff --git a/gnu/packages/firmware.scm b/gnu/packages/firmware.scm
index ff5afbcbe1..728050b43a 100644
--- a/gnu/packages/firmware.scm
+++ b/gnu/packages/firmware.scm
@@ -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")
diff --git a/gnu/packages/patches/opensbi-rvvm-lowram-fdt.patch b/gnu/packages/patches/opensbi-rvvm-lowram-fdt.patch
new file mode 100644
index 0000000000..c9e27020f0
--- /dev/null
+++ b/gnu/packages/patches/opensbi-rvvm-lowram-fdt.patch
@@ -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