Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Architectures & Platforms Gentoo on Alternative Architectures
  • Search

[solved] risc-v qemu kernel not starting

Post here for other supported architectures, or if you are interested in porting Gentoo to a currently unsupported architecture.
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
nukulartechniker
n00b
n00b
Posts: 2
Joined: Tue Jul 19, 2022 5:31 am
Contact:
Contact nukulartechniker
Website

[solved] risc-v qemu kernel not starting

  • Quote

Post by nukulartechniker » Tue Jul 19, 2022 6:43 am

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 :P)

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: Select all

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: Select all

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/ma ... too/config

Boot Message when everything works (ubuntu kernel)
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.38) #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)
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.
Top
quilosaq
Veteran
Veteran
Posts: 1596
Joined: Tue Dec 22, 2009 5:07 pm

  • Quote

Post by quilosaq » Tue Jul 19, 2022 9:11 am

Try compiling Virtio block driver (CONFIG_SCSI_VIRTIO) inside kernel, not as module.

https://wiki.gentoo.org/wiki/QEMU/Linux_guest#Kernel
Top
nukulartechniker
n00b
n00b
Posts: 2
Joined: Tue Jul 19, 2022 5:31 am
Contact:
Contact nukulartechniker
Website

  • Quote

Post by nukulartechniker » Tue Jul 19, 2022 10:36 am

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.
Top
Post Reply

3 posts • Page 1 of 1

Return to “Gentoo on Alternative Architectures”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic