[edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test

Sunil V L posted 4 patches 2 years, 7 months ago
There is a newer version of this series
[edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test
Posted by Sunil V L 2 years, 7 months ago
Add a readme file which provides information regarding how
to build and test EDK2 on RISC-V qemu virt platform.

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
---
 OvmfPkg/RiscVVirt/README.md | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 OvmfPkg/RiscVVirt/README.md

diff --git a/OvmfPkg/RiscVVirt/README.md b/OvmfPkg/RiscVVirt/README.md
new file mode 100644
index 000000000000..b07d5b6d3bf9
--- /dev/null
+++ b/OvmfPkg/RiscVVirt/README.md
@@ -0,0 +1,46 @@
+# Support for RISC-V qemu virt platform
+
+## Overview
+RISC-V qemu 'virt' is a generic platform which does not correspond to any real
+hardware.
+
+EDK2 for RISC-V virt platform is a payload (S-mode) for a previous stage M-mode
+firmware like opensbi. It follows PEI less design.
+
+The minimum qemu version required is
+**[8.1](https://wiki.qemu.org/Planning/8.1)** or with commit
+[7efd65423a](https://github.com/qemu/qemu/commit/7efd65423ab22e6f5890ca08ae40c84d6660242f)
+which supports separate pflash devices for EDK2 code and variable storage.
+
+## Build
+    export WORKSPACE=`pwd`
+    export GCC5_RISCV64_PREFIX=riscv64-linux-gnu-
+    export PACKAGES_PATH=$WORKSPACE/edk2
+    export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
+    source edk2/edksetup.sh
+    make -C edk2/BaseTools
+    source edk2/edksetup.sh BaseTools
+    build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -t GCC5
+
+## Test
+1) RISC-V qemu pflash devices should be of of size 32MiB.
+
+    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_CODE.fd`
+
+    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd`
+
+2) Run qemu
+
+        qemu-system-riscv64 \
+        -accel tcg -m 4096 -smp 2 \
+        -serial mon:stdio \
+        -device virtio-gpu-pci -full-screen \
+        -device qemu-xhci \
+        -device usb-kbd \
+        -blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
+        -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
+        -M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
+        -kernel linux/arch/riscv/boot/Image \
+        -initrd buildroot/output/images/rootfs.cpio \
+        -netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
+        -append "root=/dev/ram rw console=ttyS0 earlycon=uart8250,mmio,0x10000000"
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106147): https://edk2.groups.io/g/devel/message/106147
Mute This Topic: https://groups.io/mt/99567401/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test
Posted by Heinrich Schuchardt 2 years, 7 months ago
On 6/16/23 12:16, Sunil V L wrote:
> Add a readme file which provides information regarding how
> to build and test EDK2 on RISC-V qemu virt platform.
> 
> Signed-off-by: Sunil V L <sunilvl@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Jiewen Yao <jiewen.yao@...>
> Cc: Jordan Justen <jordan.l.justen@...>
> Cc: Gerd Hoffmann <kraxel@...>
> Cc: Andrei Warkentin <andrei.warkentin@...>

Unfortunately you only sent me the cover letter. Copying from the 
mailing list may have led to some formatting being lost.

> ---
>   OvmfPkg/RiscVVirt/README.md | 46 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 46 insertions(+)
>   create mode 100644 OvmfPkg/RiscVVirt/README.md
> 
> diff --git a/OvmfPkg/RiscVVirt/README.md b/OvmfPkg/RiscVVirt/README.md
> new file mode 100644
> index 000000000000..b07d5b6d3bf9
> --- /dev/null
> +++ b/OvmfPkg/RiscVVirt/README.md
> @@ -0,0 +1,46 @@
> +# Support for RISC-V qemu virt platform
> +
> +## Overview
> +RISC-V qemu 'virt' is a generic platform which does not correspond to any real

%s/qemu/QEMU/

> +hardware.
> +
> +EDK2 for RISC-V virt platform is a payload (S-mode) for a previous stage M-mode

%s/for/for the/

> +firmware like opensbi. It follows PEI less design.

%s/opensbi/OpenSBI/

> +
> +The minimum qemu version required is

%s/qemu/QEMU/

> +**[8.1](https://wiki.qemu.org/Planning/8.1)** or with commit
> +[7efd65423a](https://github.com/qemu/qemu/commit/7efd65423ab22e6f5890ca08ae40c84d6660242f)
> +which supports separate pflash devices for EDK2 code and variable storage.
> +
> +## Build
> +    export WORKSPACE=`pwd`
> +    export GCC5_RISCV64_PREFIX=riscv64-linux-gnu-
> +    export PACKAGES_PATH=$WORKSPACE/edk2
> +    export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
> +    source edk2/edksetup.sh
> +    make -C edk2/BaseTools
> +    source edk2/edksetup.sh BaseTools
> +    build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -t GCC5
> +
> +## Test
> +1) RISC-V qemu pflash devices should be of of size 32MiB.
> +
> +    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_CODE.fd`
> +
> +    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd`
> +
> +2) Run qemu

%s/qemu/QEMU/

> +
> +        qemu-system-riscv64 \
> +        -accel tcg -m 4096 -smp 2 \
> +        -serial mon:stdio \
> +        -device virtio-gpu-pci -full-screen \
> +        -device qemu-xhci \
> +        -device usb-kbd \
> +        -blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
> +        -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
> +        -M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
> +        -kernel linux/arch/riscv/boot/Image \
> +        -initrd buildroot/output/images/rootfs.cpio \

If you use -kernel and -initrd, why would you use EDK II? It is much 
easier to use the kernel and initrd that is on the drive that you will 
need anyway.

We should provide an example that works on all operating systems no just 
Linux. Hence, I would prefer an example connecting a disk image:

-drive file=riscv64.img,format=raw,if=virtio \


> +        -netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
> +        -append "root=/dev/ram rw console=ttyS0 earlycon=uart8250,mmio,0x10000000"

You should remove this parameter too as it is Linux specific.

For testing you could use:

https://cdimage.ubuntu.com/releases/22.04.2/release/ubuntu-22.04.2-live-server-riscv64.img.gz

The unzipped image provides GRUB as EFI/boot/bootriscv64.efi on the ESP.

These are the commands I used:

dd if=/dev/zero of=riscv64.img bs=1M count=16384

qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
-m 4096 -smp 2 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-device virtio-rng-pci \
-blockdev 
node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 \
-device virtio-net-pci,netdev=net0 \
-drive file=riscv64.img,format=raw,if=virtio \
-drive file=ubuntu-22.04.2-live-server-riscv64.img,if=virtio,media=cdrom

As EDK II by default has the EFI shell as first boot option just choose 
the second disk from the boot menu or use the EFI shell to invoke GRUB.

To initialize KASLR and provide enough entropy to /dev/random the RNG 
device is useful.

Best regards

Heinrich

> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106188): https://edk2.groups.io/g/devel/message/106188
Mute This Topic: https://groups.io/mt/99567401/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test
Posted by Sunil V L 2 years, 7 months ago
Hi Heinrich,

Thank you very much for the review!

On Fri, Jun 16, 2023 at 03:06:49PM +0200, Heinrich Schuchardt wrote:
> On 6/16/23 12:16, Sunil V L wrote:
> > Add a readme file which provides information regarding how
> > to build and test EDK2 on RISC-V qemu virt platform.
> > 
> > Signed-off-by: Sunil V L <sunilvl@...>
> > Cc: Ard Biesheuvel <ardb+tianocore@...>
> > Cc: Jiewen Yao <jiewen.yao@...>
> > Cc: Jordan Justen <jordan.l.justen@...>
> > Cc: Gerd Hoffmann <kraxel@...>
> > Cc: Andrei Warkentin <andrei.warkentin@...>
> 
> Unfortunately you only sent me the cover letter. Copying from the mailing
> list may have led to some formatting being lost.
> 
Ahh, I usually copy only what Maintainer.txt asks in individual patches and
copy others in the cover letter so that they are aware of the series.
Will add you in CC for v3.

> > ---
> >   OvmfPkg/RiscVVirt/README.md | 46 +++++++++++++++++++++++++++++++++++++
> >   1 file changed, 46 insertions(+)
> >   create mode 100644 OvmfPkg/RiscVVirt/README.md
> > 
> > diff --git a/OvmfPkg/RiscVVirt/README.md b/OvmfPkg/RiscVVirt/README.md
> > new file mode 100644
> > index 000000000000..b07d5b6d3bf9
> > --- /dev/null
> > +++ b/OvmfPkg/RiscVVirt/README.md
> > @@ -0,0 +1,46 @@
> > +# Support for RISC-V qemu virt platform
> > +
> > +## Overview
> > +RISC-V qemu 'virt' is a generic platform which does not correspond to any real
> 
> %s/qemu/QEMU/
> 
OK.

> > +hardware.
> > +
> > +EDK2 for RISC-V virt platform is a payload (S-mode) for a previous stage M-mode
> 
> %s/for/for the/
>
OK.
 
> > +firmware like opensbi. It follows PEI less design.
> 
> %s/opensbi/OpenSBI/
> 
OK.

> > +
> > +The minimum qemu version required is
> 
> %s/qemu/QEMU/
>
OK.
 
> > +**[8.1](https://wiki.qemu.org/Planning/8.1)** or with commit
> > +[7efd65423a](https://github.com/qemu/qemu/commit/7efd65423ab22e6f5890ca08ae40c84d6660242f)
> > +which supports separate pflash devices for EDK2 code and variable storage.
> > +
> > +## Build
> > +    export WORKSPACE=`pwd`
> > +    export GCC5_RISCV64_PREFIX=riscv64-linux-gnu-
> > +    export PACKAGES_PATH=$WORKSPACE/edk2
> > +    export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
> > +    source edk2/edksetup.sh
> > +    make -C edk2/BaseTools
> > +    source edk2/edksetup.sh BaseTools
> > +    build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -t GCC5
> > +
> > +## Test
> > +1) RISC-V qemu pflash devices should be of of size 32MiB.
> > +
> > +    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_CODE.fd`
> > +
> > +    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd`
> > +
> > +2) Run qemu
> 
> %s/qemu/QEMU/
>
OK.
 
> > +
> > +        qemu-system-riscv64 \
> > +        -accel tcg -m 4096 -smp 2 \
> > +        -serial mon:stdio \
> > +        -device virtio-gpu-pci -full-screen \
> > +        -device qemu-xhci \
> > +        -device usb-kbd \
> > +        -blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
> > +        -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
> > +        -M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
> > +        -kernel linux/arch/riscv/boot/Image \
> > +        -initrd buildroot/output/images/rootfs.cpio \
> 
> If you use -kernel and -initrd, why would you use EDK II? It is much easier
> to use the kernel and initrd that is on the drive that you will need anyway.
>
I thought it may be easier option for users without much dependencies on
the disk image. But I agree with you that it needs to be OS agnostic
example. openSUSE Tumbleweed disk image has everything required
pre-installed. Let me add that as the example use case.

Thanks!
Sunil


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#106152): https://edk2.groups.io/g/devel/message/106152
Mute This Topic: https://groups.io/mt/99567401/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-