View previous topic :: View next topic |
Author |
Message |
nukulartechniker n00b
Joined: 19 Jul 2022 Posts: 2
|
Posted: Tue Jul 19, 2022 6:43 am Post subject: [solved] risc-v qemu kernel not starting |
|
|
solved by compiling Virtio block driver (CONFIG_SCSI_VIRTIO) inside kernel, not as module.
https://wiki.gentoo.org/wiki/QEMU/Linux_guest#Kernel
Installing gentoo on a qemu risc-v machine, kernel will not load
just for fun I started to install gentoo on a qemu risc-v machine. so far everything is working really well. basically I used an ubuntu 22.04 Image to startup the machine and then did a stage 3 install following partly the amd64 handbook.
the only package giving me headaches was grub, but with a little tinkering it finally build (and works )
right now I have a problem to boot using a gentoo kernel.
the vm starts up quite fine using the ubuntu kernel that came with the preinstalled image, i just copied kernel, initramfs and modules to get things startet.
the boot process seems to be the following open spi -> uboot -> grub -> linux kernel. this works fine for the ubuntu kernel. Am I missing something obvious?
I am using qemu 7, the command to start the vm is the following:
Code: |
qemu-system-riscv64 \
-machine virt \
-m 16G \
-smp 8 \
-kernel ./u-boot-qemu/uboot.elf \
-nographic \
-object rng-random,filename=/dev/urandom,id=rng \
-device virtio-rng-device,rng=rng \
-device virtio-net-device,netdev=eth0 \
-netdev bridge,br=virbr0,id=eth0 \
-drive file=gentoo.qcow2,if=virtio,id=gentoo,index=0
|
then openspi loads, uboot loads and finally grub
Code: |
OpenSBI v1.0
... ascii art removed
Platform Name : riscv-virtio,qemu
Platform Features : medeleg
Platform HART Count : 8
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 : 308 KB
Runtime SBI Version : 0.3
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*,1*,2*,3*,4*,5*,6*,7*
Domain0 Region00 : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01 : 0x0000000080000000-0x000000008007ffff ()
Domain0 Region02 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x00000000bf000000
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
U-Boot 2022.07-rc4+dfsg-1 (Jun 08 2022 - 19:06:20 +0000)
CPU: rv64imafdcsuh
Model: riscv-virtio,qemu
DRAM: 16 GiB
Core: 33 devices, 14 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In: uart@10000000
Out: uart@10000000
Err: uart@10000000
Net: eth0: virtio-net#1
Hit any key to stop autoboot: 0
Device 0: 1af4 VirtIO Block Device
Type: Hard Disk
Capacity: 131072.0 MB = 128.0 GB (268435456 x 512)
... is now current device
Scanning virtio 0:1...
** Unable to read file / **
Failed to load '/'
** Unable to read file ubootefi.var **
Failed to load EFI variables
BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootriscv64.efi
151552 bytes read in 1 ms (144.5 MiB/s)
Booting /efi\boot\bootriscv64.efi
Welcome to GRUB!
|
my gentoo kernel config
https://github.com/ccharon/docs/blob/master/riscv-gentoo/config
Boot Message when everything works (ubuntu kernel)
Quote: |
Linux 5.15.0-1014-generic wird geladen …
Initiale Ramdisk wird geladen …
EFI stub: Booting Linux Kernel...
EFI stub: Using DTB from configuration table
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Exiting boot services...
[ 0.000000] Linux version 5.15.0-1014-generic (buildd@riscv64-qemu-lgw01-088) (gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, GNU ld (GNU Binutils for Ubuntu) 2.3 #16-Ubuntu SMP Thu Jun 2 13:45:22 UTC 2022 (Ubuntu 5.15.0-1014.16-generic 5.15.35)
|
Boot Message with gentoo kernel (note: i omitted an initramfs on purpose, gpt, ext4 and so on are compiled in so this should not be needed)
Quote: |
Linux 5.18.12-gentoo wird geladen …
EFI stub: Booting Linux Kernel...
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services...
|
when trying to load the gentoo kernel the part with "EFI stub: Using DTB from configuration table" is faster ... maybe the gentoo kernel does not recognize the devicetree and therefor can not boot?
Last edited by nukulartechniker on Tue Jul 19, 2022 10:37 am; edited 1 time in total |
|
Back to top |
|
|
quilosaq Veteran
Joined: 22 Dec 2009 Posts: 1543
|
|
Back to top |
|
|
nukulartechniker n00b
Joined: 19 Jul 2022 Posts: 2
|
Posted: Tue Jul 19, 2022 10:36 am Post subject: |
|
|
that did the trick, now the kernel is booting with 2 things to investigate..
1. it only works when i use an initramfs. i have to look which additional drivers need to be compiled in.
2. the kernel does not write message to the serial console. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|