Hi there! I really appreciate your time and your reply. As you could see, I am a beginner of RISC-V and Linux, so please forgive me if I am asking silly questions.
For the last few days, I managed to build a usable opensbi binary (without payload) for cemu (at least it prints and did not panic) and a Linux kernel (version 5.2.11).
I followed the instruction you mentioned and referred to some other threads, and successfully built an opensbi with linux kernel as payload. However, when I load the new opensbi with linux kernel, the cemu emulator prints nothing after the opensbi info.
Since the process of building the kernel did not use the dtc file, I think there must exists some mechanism that passes the dtb to the kernel. After some STFW, I found that the address dtb struct should be passed via r2 register, but maybe for some reason, it does not success.
To make sure if the kernel works, I tried to run the kernel with qemu-system-riscv64
. For now, although I did not provide a rootfs, I believe the kernel should at least print some logs. I tried to run the kernel with command qemu-system-riscv64 -machine virt -nographic -kernel ../linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" -m 128
, what I got are just some opensbi logs, it seems that the kernel have another opensbi built-in.
So my question is:
- How to provide the rootfs to CEMU? AFAIK, we need an additional block device to do so.
- Is it necessary to provide the dtc when compiling Linux kernel?
Here are my logs FYI:
Trying to load kernel directly with QEMU:
❯ qemu-system-riscv64 -machine virt -nographic -kernel ../linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" -m 128
OpenSBI v1.0
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count : 1
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 10000000Hz
Platform Console Device : uart8250
Platform HSM Device : ---
Platform Reboot Device : sifive_test
Platform Shutdown Device : sifive_test
Firmware Base : 0x80000000
Firmware Size : 252 KB
Runtime SBI Version : 0.3
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*
Domain0 Region00 : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01 : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x0000000087000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Boot HART ID : 0
Boot HART Domain : root
Boot HART ISA : rv64imafdcsuh
Boot HART Features : scounteren,mcounteren,time
Boot HART PMP Count : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count : 0
Boot HART MIDELEG : 0x0000000000001666
Boot HART MEDELEG : 0x0000000000f0b509
Run the opensbi binary with kernel as payload in CEMU:
OpenSBI v1.3-49-gee1f83c
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : cyy,cemu
Platform Features : medeleg
Platform HART Count : 2
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 100000000Hz
Platform Console Device : xlnx-uartlite
Platform HSM Device : ---
Platform PMU Device : ---
Platform Reboot Device : ---
Platform Shutdown Device : ---
Platform Suspend Device : ---
Platform CPPC Device : ---
Firmware Base : 0x80000000
Firmware Size : 332 KB
Firmware RW Offset : 0x40000
Firmware RW Size : 76 KB
Firmware Heap Offset : 0x4a000
Firmware Heap Size : 36 KB (total), 2 KB (reserved), 9 KB (used), 24 KB (free)
Firmware Scratch Size : 4096 B (total), 768 B (used), 3328 B (free)
Runtime SBI Version : 1.0
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*,1*
Domain0 Region00 : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
Domain0 Region01 : 0x0000000080040000-0x000000008005ffff M: (R,W) S/U: ()
Domain0 Region02 : 0x0000000080000000-0x000000008003ffff M: (R,X) S/U: ()
Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x0000000082200000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Domain0 SysSuspend : yes
Boot HART ID : 0
Boot HART Domain : root
Boot HART Priv Version : v1.10
Boot HART Base ISA : rv64imac
Boot HART ISA Extensions : none
Boot HART PMP Count : 0
Boot HART PMP Granularity : 0
Boot HART PMP Address Bits: 0
Boot HART MHPM Info : 0 (0x00000000)
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109