diff mbox series

[bug#64907,1/2] gnu: Add u-boot-rvvm.

Message ID 62cefdc5d6a4b0e3d6e611a6b6541f00acc19d9f.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/bootloaders.scm (%u-boot-rvvm-support-patch, u-boot-rvvm): New
symbol.
* gnu/packages/patches/u-boot-rvvm-support.patch: New patch.
---
 gnu/packages/bootloaders.scm                  | 23 +++++++
 .../patches/u-boot-rvvm-support.patch         | 67 +++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 gnu/packages/patches/u-boot-rvvm-support.patch

Comments

Vagrant Cascadian Sept. 3, 2023, 2:17 a.m. UTC | #1
On 2023-07-27, Juliana Sims wrote:
> * gnu/packages/bootloaders.scm (%u-boot-rvvm-support-patch, u-boot-rvvm): New
> symbol.
> * gnu/packages/patches/u-boot-rvvm-support.patch: New patch.
...
> diff --git a/gnu/packages/patches/u-boot-rvvm-support.patch b/gnu/packages/patches/u-boot-rvvm-support.patch
> new file mode 100644
> index 0000000000..1e62a2d61d
> --- /dev/null
> +++ b/gnu/packages/patches/u-boot-rvvm-support.patch
> @@ -0,0 +1,67 @@
> +Patch to support NVMe and RVVM board properly in U-Boot
> + - Enables NVMe PCI support & booting from it
> + - Enables framebuffer driver, passes it as EFI FB
> + - Enables Realtek RTL8169 driver
> + - Get rid of DHCP boot, it is confusing and not helpful
> +
> +Applies cleanly over U-Boot 2023.4
> +Reuses QEMU virt board config, build like this:
> + make qemu-riscv64_smode_defconfig
> + CROSS_COMPILE=riscv64-linux-gnu- make
> +
> +Resulting firmware works fine on both RVVM and QEMU
> +
> +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> +index 48ca4ff4..faa17f33 100644
> +--- a/arch/riscv/Kconfig
> ++++ b/arch/riscv/Kconfig
> +@@ -15,7 +15,7 @@ config TARGET_MICROCHIP_ICICLE
> + 	bool "Support Microchip PolarFire-SoC Icicle Board"
> + 
> + config TARGET_QEMU_VIRT
> +-	bool "Support QEMU Virt Board"
> ++	bool "Support QEMU/RVVM Virt Boards"
> + 
> + config TARGET_SIFIVE_UNLEASHED
> + 	bool "Support SiFive Unleashed Board"

This seems unecessary, unless this is pulling from a patch submitted to
upstream u-boot that is likely to be merged.


> +diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
> +index 6114e1b8..7c25825a 100644
> +--- a/board/emulation/qemu-riscv/Kconfig
> ++++ b/board/emulation/qemu-riscv/Kconfig
> +@@ -29,6 +29,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
> + 	def_bool y
> + 	select GENERIC_RISCV
> + 	select SUPPORT_SPL
> ++	imply OPTIMIZE_INLINING
> + 	imply AHCI
> + 	imply SMP
> + 	imply BOARD_LATE_INIT
> +@@ -50,7 +51,12 @@ config BOARD_SPECIFIC_OPTIONS # dummy
> + 	imply SCSI_AHCI
> + 	imply AHCI_PCI
> + 	imply E1000
> ++	imply RTL8169
> + 	imply NVME
> ++	imply NVME_PCI
> ++	imply VIDEO
> ++	imply VIDEO_SIMPLE
> ++	imply NO_FB_CLEAR
> + 	imply PCI
> + 	imply PCIE_ECAM_GENERIC
> + 	imply SCSI

I *think* all of these options could be done by passing #:configs ...

For example, how the u-boot-qemu-arm changes an option:

(define-public u-boot-qemu-arm
  (make-u-boot-package "qemu_arm" "arm-linux-gnueabihf"
                       #:configs '("# CONFIG_FIT_SIGNATURE is not set")))


> +diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h
> +index 20135f56..821251a3 100644
> +--- a/include/configs/qemu-riscv.h
> ++++ b/include/configs/qemu-riscv.h
> +@@ -19,9 +19,9 @@
> + 
> + #define BOOT_TARGET_DEVICES(func) \
> + 	func(QEMU, qemu, na) \
> ++	func(NVME, nvme, 0) \
> + 	func(VIRTIO, virtio, 0) \
> +-	func(SCSI, scsi, 0) \
> +-	func(DHCP, dhcp, na)
> ++	func(SCSI, scsi, 0)
> + 
> + #include <config_distro_bootcmd.h>
> + 
> -- 
> 2.41.0

I would just leave the DHCP in; it surely cannot hurt *that* much... or?

... at which point, if all my other suggestions are accepted, the NVME
part might be the only patch to upstream sources, and you could fix it
with a snippet or phase or a one-line patch. :)

live well,
  vagrant
diff mbox series

Patch

diff --git a/gnu/packages/bootloaders.scm b/gnu/packages/bootloaders.scm
index 38eb1d104f..5f12d324e8 100644
--- a/gnu/packages/bootloaders.scm
+++ b/gnu/packages/bootloaders.scm
@@ -18,6 +18,7 @@ 
 ;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
 ;;; Copyright © 2021 Stefan <stefan-guix@vodafonemail.de>
 ;;; Copyright © 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2023 Juliana Sims <juli@incana.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -645,6 +646,15 @@  (define %u-boot-rk3399-enable-emmc-phy-patch
   ;; https://lists.denx.de/pipermail/u-boot/2021-November/466329.html
   (search-patch "u-boot-rk3399-enable-emmc-phy.patch"))
 
+(define %u-boot-rvvm-support-patch
+  ;; Patch to support NVMe and RVVM board properly in U-Boot
+  ;; - Enables NVMe PCI support & booting from it
+  ;; - Enables framebuffer driver, passes it as EFI FB
+  ;; - Enables Realtek RTL8169 driver
+  ;; - Get rid of DHCP boot, it is confusing and not helpful
+  ;; https://github.com/LekKit/patches-misc/blob/ef2bb2bc6e37f87f3af4f9d9c8b69f76408620a7/uboot/uboot_rvvm_support.patch
+  (search-patch "u-boot-rvvm-support.patch"))
+
 (define u-boot
   (package
     (name "u-boot")
@@ -1173,6 +1183,19 @@  (define-public u-boot-qemu-riscv64
 (define-public u-boot-qemu-riscv64-smode
   (make-u-boot-package "qemu-riscv64_smode" "riscv64-linux-gnu"))
 
+(define-public u-boot-rvvm
+  (let ((base (make-u-boot-package "qemu-riscv64_smode" "riscv64-linux-gnu"
+               #:append-description
+               "This U-Boot is built for @code{rvvm}.  It is also compatible
+with @code{qemu}, but adds patches from the @code{rvvm} authors.")))
+    (package
+      (inherit base)
+      (name "u-boot-rvvm")
+      (source (origin
+                (inherit (package-source base))
+                (patches (cons %u-boot-rvvm-support-patch
+                               (origin-patches (package-source base)))))))))
+
 (define-public u-boot-sandbox
   (let ((base (make-u-boot-package
                "sandbox" #f             ;build for the native system
diff --git a/gnu/packages/patches/u-boot-rvvm-support.patch b/gnu/packages/patches/u-boot-rvvm-support.patch
new file mode 100644
index 0000000000..1e62a2d61d
--- /dev/null
+++ b/gnu/packages/patches/u-boot-rvvm-support.patch
@@ -0,0 +1,67 @@ 
+Patch to support NVMe and RVVM board properly in U-Boot
+ - Enables NVMe PCI support & booting from it
+ - Enables framebuffer driver, passes it as EFI FB
+ - Enables Realtek RTL8169 driver
+ - Get rid of DHCP boot, it is confusing and not helpful
+
+Applies cleanly over U-Boot 2023.4
+Reuses QEMU virt board config, build like this:
+ make qemu-riscv64_smode_defconfig
+ CROSS_COMPILE=riscv64-linux-gnu- make
+
+Resulting firmware works fine on both RVVM and QEMU
+
+diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
+index 48ca4ff4..faa17f33 100644
+--- a/arch/riscv/Kconfig
++++ b/arch/riscv/Kconfig
+@@ -15,7 +15,7 @@ config TARGET_MICROCHIP_ICICLE
+ 	bool "Support Microchip PolarFire-SoC Icicle Board"
+ 
+ config TARGET_QEMU_VIRT
+-	bool "Support QEMU Virt Board"
++	bool "Support QEMU/RVVM Virt Boards"
+ 
+ config TARGET_SIFIVE_UNLEASHED
+ 	bool "Support SiFive Unleashed Board"
+diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
+index 6114e1b8..7c25825a 100644
+--- a/board/emulation/qemu-riscv/Kconfig
++++ b/board/emulation/qemu-riscv/Kconfig
+@@ -29,6 +29,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
+ 	def_bool y
+ 	select GENERIC_RISCV
+ 	select SUPPORT_SPL
++	imply OPTIMIZE_INLINING
+ 	imply AHCI
+ 	imply SMP
+ 	imply BOARD_LATE_INIT
+@@ -50,7 +51,12 @@ config BOARD_SPECIFIC_OPTIONS # dummy
+ 	imply SCSI_AHCI
+ 	imply AHCI_PCI
+ 	imply E1000
++	imply RTL8169
+ 	imply NVME
++	imply NVME_PCI
++	imply VIDEO
++	imply VIDEO_SIMPLE
++	imply NO_FB_CLEAR
+ 	imply PCI
+ 	imply PCIE_ECAM_GENERIC
+ 	imply SCSI
+diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h
+index 20135f56..821251a3 100644
+--- a/include/configs/qemu-riscv.h
++++ b/include/configs/qemu-riscv.h
+@@ -19,9 +19,9 @@
+ 
+ #define BOOT_TARGET_DEVICES(func) \
+ 	func(QEMU, qemu, na) \
++	func(NVME, nvme, 0) \
+ 	func(VIRTIO, virtio, 0) \
+-	func(SCSI, scsi, 0) \
+-	func(DHCP, dhcp, na)
++	func(SCSI, scsi, 0)
+ 
+ #include <config_distro_bootcmd.h>
+