-
Notifications
You must be signed in to change notification settings - Fork 7
Create platform for QEMU's virt target #7
Comments
I've modified the U540 platform for QEMU's
The failure looks very much like the issue here: https://lists.denx.de/pipermail/u-boot/2020-July/421194.html |
The branches are https://github.com/riscv/riscv-edk2/tree/riscv-virt-540-mod and https://github.com/riscv/riscv-edk2-platforms/tree/riscv-virt-540-mod. OpenSBI ( diff --git c/lib/utils/fdt/fdt_helper.c i/lib/utils/fdt/fdt_helper.c
index aec73a0..0ceca44 100644
--- c/lib/utils/fdt/fdt_helper.c
+++ i/lib/utils/fdt/fdt_helper.c
@@ -7,11 +7,13 @@
*/
#include <libfdt.h>
+#include <libfdt_env.h>
#include <sbi/riscv_asm.h>
#include <sbi/sbi_console.h>
#include <sbi/sbi_hartmask.h>
#include <sbi/sbi_platform.h>
#include <sbi/sbi_scratch.h>
+#include <sbi/sbi_string.h>
#include <sbi_utils/fdt/fdt_helper.h>
#include <sbi_utils/irqchip/plic.h>
#include <sbi_utils/sys/clint.h>
@@ -123,7 +125,7 @@ int fdt_parse_hart_id(void *fdt, int cpu_offset, u32 *hartid)
prop = fdt_getprop(fdt, cpu_offset, "device_type", &len);
if (!prop || !len)
return SBI_EINVAL;
- if (strncmp (prop, "cpu", strlen ("cpu")))
+ if (sbi_strncmp (prop, "cpu", strlen ("cpu")))
return SBI_EINVAL;
val = fdt_getprop(fdt, cpu_offset, "reg", &len);
Building still works the same as U540, since I haven't split it out into its own platform yet:
Run it like this with your own disk image: qemu-system-riscv64 -machine virt \
-bios Build/FreedomU540HiFiveUnleashed/DEBUG_GCC5/FV/U540.fd \
-m 2048 -nographic \
-device virtio-blk-device,drive=hd0 \
-drive file=/home/zoid/Downloads/linux.iso,format=raw,id=hd0 \
-device virtio-net-device,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::10000-:22 |
Virtio disk and virtio NIC work:
|
Pre-built image based on 3a3c857 at https://danielschaefer.me/static/U540-virt-3a3c8579ec33335e3.fd |
Hm. EDK2 definitely boots... but:
Both of these things work fine under u-boot logs:
Our nightly riscv64 images are available here if you want to test: |
By the way, UEFI SCT (Self Certification Test) runs fine on the virt machine :) |
Hi @JohnAZoidberg,
|
I've noticed qemu 6.x flat out crashes when loading the latest u-boot OpenSBI bootloader. Maybe also related to the High MMIO change you mentioned? |
@kallisti5 : I have not tried u-boot. But I expect some level of testing with u-boot done for the high mmio change. EDK2 virt support is not yet merged and hence I guess no one would have tested it. |
No, haven't seen this. What version of QEMU? |
It is based on v6.0.0-rc4. |
Hi @JohnAZoidberg ,
|
Thanks! Would that work with QEMU 5.0 also? |
Was this branch working with 5.0? Without my change also, it doesn't work for me. It hangs after below message. SecCoreStartUpWithStack: Initializing OpenSBI library for booting hart 0 |
Yes, with 5.2 it was working for me. But it needs a second patch for OpenSBI that I forgot to mention here: #14 (comment) |
I created a fork of OpenSBI to put our patches and updated the submodule to point to there. Just do
|
Ok, I can confirm that your proposed change works with 5.2 and 6.0. Thanks! |
This branch doesn't work with older QEMU.
so I don't think this is due to the change contributed by @vlsunil. Only Ubuntu 21.04 has 5.2. Older version have only 5.0 or older. |
I consider this done. It's not upstreamed but it's working well on riscv-virt-gh-actions branch. Just build Linux boots fine from ESP on virtio :) |
Status
Instructions for building and runninng: https://github.com/JohnAZoidberg/riscv-edk2-docker/tree/riscv-virt
WIP branches:
Original comment
The
qemu-system-riscv64 -machine virt
target of QEMU doesn't look like a SiFive board. It only has virtio peripherals, therefore our current platforms don't work.Here we don't even need our own device tree, we can just take it from MROM because QEMU puts it there: https://github.com/qemu/qemu/blob/d0ed6a69d399ae193959225cdeaa9382746c91cc/hw/riscv/boot.c#L249
The text was updated successfully, but these errors were encountered: