1 | # Support for RISC-V QEMU virt platform
|
---|
2 |
|
---|
3 | ## Overview
|
---|
4 | RISC-V QEMU 'virt' is a generic platform which does not correspond to any real
|
---|
5 | hardware.
|
---|
6 |
|
---|
7 | EDK2 for RISC-V virt platform is a payload (S-mode) for the previous stage M-mode
|
---|
8 | firmware like OpenSBI. It follows PEI less design.
|
---|
9 |
|
---|
10 | The minimum QEMU version required is
|
---|
11 | **[8.1](https://wiki.qemu.org/Planning/8.1)** or with commit
|
---|
12 | [7efd65423a](https://github.com/qemu/qemu/commit/7efd65423ab22e6f5890ca08ae40c84d6660242f)
|
---|
13 | which supports separate pflash devices for EDK2 code and variable storage.
|
---|
14 |
|
---|
15 | ## Get edk2 sources
|
---|
16 |
|
---|
17 | git clone --recurse-submodule [email protected]:tianocore/edk2.git
|
---|
18 |
|
---|
19 | ## Build
|
---|
20 |
|
---|
21 | ### Using GCC toolchain
|
---|
22 | **Prerequisite**: RISC-V GNU compiler toolchain should be installed.
|
---|
23 |
|
---|
24 | export WORKSPACE=`pwd`
|
---|
25 | export GCC5_RISCV64_PREFIX=riscv64-linux-gnu-
|
---|
26 | export PACKAGES_PATH=$WORKSPACE/edk2
|
---|
27 | export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
|
---|
28 | source edk2/edksetup.sh --reconfig
|
---|
29 | make -C edk2/BaseTools
|
---|
30 | source edk2/edksetup.sh BaseTools
|
---|
31 | build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -t GCC5
|
---|
32 |
|
---|
33 | ### Using CLANGDWARF toolchain (clang + lld)
|
---|
34 | **Prerequisite**: LLVM toolchain with clang and lld should be installed.
|
---|
35 |
|
---|
36 | export WORKSPACE=`pwd`
|
---|
37 | export CLANGDWARF_BIN=/usr/bin/
|
---|
38 | export PACKAGES_PATH=$WORKSPACE/edk2
|
---|
39 | export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
|
---|
40 | source edk2/edksetup.sh --reconfig
|
---|
41 | make -C edk2/BaseTools
|
---|
42 | source edk2/edksetup.sh BaseTools
|
---|
43 | build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -t CLANGDWARF
|
---|
44 |
|
---|
45 | After a successful build, two files namely **RISCV_VIRT_CODE.fd** and **RISCV_VIRT_VARS.fd** are created.
|
---|
46 |
|
---|
47 | ## Test
|
---|
48 | Below example shows how to boot openSUSE Tumbleweed E20.
|
---|
49 |
|
---|
50 | 1) RISC-V QEMU pflash devices should be of of size 32MiB.
|
---|
51 |
|
---|
52 | `truncate -s 32M RISCV_VIRT_CODE.fd`
|
---|
53 |
|
---|
54 | `truncate -s 32M RISCV_VIRT_VARS.fd`
|
---|
55 |
|
---|
56 | 2) Running QEMU
|
---|
57 |
|
---|
58 | qemu-system-riscv64 \
|
---|
59 | -M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
|
---|
60 | -m 4096 -smp 2 \
|
---|
61 | -serial mon:stdio \
|
---|
62 | -device virtio-gpu-pci -full-screen \
|
---|
63 | -device qemu-xhci \
|
---|
64 | -device usb-kbd \
|
---|
65 | -device virtio-rng-pci \
|
---|
66 | -blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
|
---|
67 | -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
|
---|
68 | -netdev user,id=net0 \
|
---|
69 | -device virtio-net-pci,netdev=net0 \
|
---|
70 | -device virtio-blk-device,drive=hd0 \
|
---|
71 | -drive file=openSUSE-Tumbleweed-RISC-V-E20-efi.riscv64.raw,format=raw,id=hd0
|
---|