Open takahirox opened 4 years ago
Hey! Have you figure it out? I have the exact same problem as well. That is my console log:
$ sudo qemu-system-riscv64 -nographic -machine virt \
-kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" \
-drive file=busybox/busybox,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 -bios default
OpenSBI v0.6
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs : 8
Current Hart : 0
Firmware Base : 0x80000000
Firmware Size : 120 KB
Runtime SBI Version : 0.2
MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b109
PMP0 : 0x0000000080000000-0x000000008001ffff (A)
PMP1 : 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[ 0.000000] Linux version 5.9.0-rc6-00020-geff48ddeab78 (emanon@DESKTOP-630J802) (riscv64-unknown-linux-gnu-gcc (GCC) 10.1.0, GNU ld (GNU Binutils) 2.35) #1 SMP Tue Sep 22 21:51:22 BST 2020
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000080200000-0x0000000087ffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000080200000-0x0000000087ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x0000000087ffffff]
[ 0.000000] software IO TLB: mapped [mem 0x83e3a000-0x87e3a000] (64MB)
[ 0.000000] SBI specification v0.2 detected
[ 0.000000] SBI implementation ID=0x1 Version=0x6
[ 0.000000] SBI v0.2 TIME extension detected
[ 0.000000] SBI v0.2 IPI extension detected
[ 0.000000] SBI v0.2 RFENCE extension detected
[ 0.000000] riscv: ISA extensions acdfimsu
[ 0.000000] riscv: ELF capabilities acdfim
[ 0.000000] percpu: Embedded 17 pages/cpu s32040 r8192 d29400 u69632
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 31815
[ 0.000000] Kernel command line: root=/dev/vda ro console=ttyS0
[ 0.000000] Dentry cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.000000] Sorting __ex_table...
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 43860K/129024K available (8803K kernel code, 3791K rwdata, 4096K rodata, 243K init, 318K bss, 85164K reserved, 0K cma-reserved)
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] fixmap : 0xffffffcefee00000 - 0xffffffceff000000 (2048 kB)
[ 0.000000] pci io : 0xffffffceff000000 - 0xffffffcf00000000 ( 16 MB)
[ 0.000000] vmemmap : 0xffffffcf00000000 - 0xffffffcfffffffff (4095 MB)
[ 0.000000] vmalloc : 0xffffffd000000000 - 0xffffffdfffffffff (65535 MB)
[ 0.000000] lowmem : 0xffffffe000000000 - 0xffffffe007e00000 ( 126 MB)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[ 0.000000] rcu: RCU debug extended QS entry/exit.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] riscv-intc: 64 local interrupts mapped
[ 0.000000] plic: interrupt-controller@c000000: mapped 53 interrupts with 1 handlers for 2 contexts.
[ 0.000000] random: get_random_bytes called from start_kernel+0x312/0x48a with crng_init=0
[ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000138] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[ 0.003253] Console: colour dummy device 80x25
[ 0.007763] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[ 0.007904] pid_max: default: 32768 minimum: 301
[ 0.009717] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.009775] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[ 0.031942] rcu: Hierarchical SRCU implementation.
[ 0.035080] smp: Bringing up secondary CPUs ...
[ 0.035157] smp: Brought up 1 node, 1 CPU
[ 0.043612] devtmpfs: initialized
[ 0.049699] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.050066] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[ 0.054293] NET: Registered protocol family 16
[ 0.104199] vgaarb: loaded
[ 0.105900] SCSI subsystem initialized
[ 0.107441] usbcore: registered new interface driver usbfs
[ 0.107755] usbcore: registered new interface driver hub
[ 0.107905] usbcore: registered new device driver usb
[ 0.117562] clocksource: Switched to clocksource riscv_clocksource
[ 0.131098] NET: Registered protocol family 2
[ 0.134825] tcp_listen_portaddr_hash hash table entries: 128 (order: 0, 5120 bytes, linear)
[ 0.134910] TCP established hash table entries: 1024 (order: 1, 8192 bytes, linear)
[ 0.135087] TCP bind hash table entries: 1024 (order: 3, 32768 bytes, linear)
[ 0.135214] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.136135] UDP hash table entries: 256 (order: 2, 24576 bytes, linear)
[ 0.137114] UDP-Lite hash table entries: 256 (order: 2, 24576 bytes, linear)
[ 0.139239] NET: Registered protocol family 1
[ 0.141285] RPC: Registered named UNIX socket transport module.
[ 0.141331] RPC: Registered udp transport module.
[ 0.141343] RPC: Registered tcp transport module.
[ 0.141457] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.141564] PCI: CLS 0 bytes, default 64
[ 0.146034] workingset: timestamp_bits=62 max_order=14 bucket_order=0
[ 0.157044] NFS: Registering the id_resolver key type
[ 0.157879] Key type id_resolver registered
[ 0.157916] Key type id_legacy registered
[ 0.158192] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 0.158938] 9p: Installing v9fs 9p2000 file system support
[ 0.160027] NET: Registered protocol family 38
[ 0.160239] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[ 0.160342] io scheduler mq-deadline registered
[ 0.160402] io scheduler kyber registered
[ 0.167814] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[ 0.168555] pci-host-generic 30000000.pci: IO 0x0003000000..0x000300ffff -> 0x0000000000
[ 0.169024] pci-host-generic 30000000.pci: MEM 0x0040000000..0x007fffffff -> 0x0040000000
[ 0.170939] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[ 0.171639] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[ 0.172533] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 0.172640] pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
[ 0.172654] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[ 0.173809] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[ 0.232999] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[ 0.238807] printk: console [ttyS0] disabled
[ 0.239562] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 2, base_baud = 230400) is a 16550A
[ 0.300593] printk: console [ttyS0] enabled
[ 0.303218] [drm] radeon kernel modesetting enabled.
[ 0.318634] loop: module loaded
[ 0.327872] virtio_blk virtio0: [vda] 1869 512-byte logical blocks (957 kB/935 KiB)
[ 0.328388] vda: detected capacity change from 0 to 956928
[ 0.350672] libphy: Fixed MDIO Bus: probed
[ 0.351975] e1000e: Intel(R) PRO/1000 Network Driver
[ 0.352321] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 0.352873] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.353664] ehci-pci: EHCI PCI platform driver
[ 0.354074] ehci-platform: EHCI generic platform driver
[ 0.354477] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.354977] ohci-pci: OHCI PCI platform driver
[ 0.355392] ohci-platform: OHCI generic platform driver
[ 0.356502] usbcore: registered new interface driver uas
[ 0.356876] usbcore: registered new interface driver usb-storage
[ 0.358275] mousedev: PS/2 mouse device common for all mice
[ 0.360731] goldfish_rtc 101000.rtc: registered as rtc0
[ 0.361740] goldfish_rtc 101000.rtc: setting system clock to 2020-09-22T22:06:46 UTC (1600812406)
[ 0.364551] syscon-poweroff poweroff: pm_power_off already claimed (____ptrval____) sbi_shutdown
[ 0.365031] syscon-poweroff: probe of poweroff failed with error -16
[ 0.366633] usbcore: registered new interface driver usbhid
[ 0.366980] usbhid: USB HID core driver
[ 0.368724] NET: Registered protocol family 10
[ 0.374197] Segment Routing with IPv6
[ 0.375164] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 0.378267] NET: Registered protocol family 17
[ 0.379851] 9pnet: Installing 9P2000 support
[ 0.380720] Key type dns_resolver registered
[ 0.382581] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers
[ 0.400134] List of all partitions:
[ 0.400624] fe00 934 vda
[ 0.400651] driver: virtio_blk
[ 0.401629] No filesystem could mount root, tried:
[ 0.401643] ext3
[ 0.401936] ext2
[ 0.401991] ext4
[ 0.402105] vfat
[ 0.402222] msdos
[ 0.402411]
[ 0.402774] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0)
[ 0.403545] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.9.0-rc6-00020-geff48ddeab78 #1
[ 0.404537] Call Trace:
[ 0.405073] [<ffffffe000202806>] walk_stackframe+0x0/0xaa
[ 0.405984] [<ffffffe000202ad0>] show_stack+0x2e/0x3a
[ 0.406579] [<ffffffe00049ee22>] dump_stack+0x74/0x8e
[ 0.406911] [<ffffffe000208fac>] panic+0xfc/0x282
[ 0.407292] [<ffffffe000002250>] mount_block_root+0x238/0x252
[ 0.407616] [<ffffffe00000236a>] mount_root+0x100/0x12a
[ 0.408040] [<ffffffe0000024ca>] prepare_namespace+0x136/0x16c
[ 0.408698] [<ffffffe000001dbc>] kernel_init_freeable+0x19a/0x1b6
[ 0.409220] [<ffffffe0008b6960>] kernel_init+0x12/0x120
[ 0.409575] [<ffffffe0002013ee>] ret_from_exception+0x0/0xc
[ 0.410717] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0) ]---
So I think the problem might be the busybox
file system. I find another approach to build the busybox
here: https://github.com/michaeljclark/busybear-linux. It might work, I am going to try it tomorrow.
I'm not sure if this is a right approach, but I succeeded in booting it up by creating root filesystem image from busybox
.
$ cd riscv64-linux
# Build busybox
$ git clone https://github.com/mirror/busybox.git
$ cd busybox
$ git checkout 1_32_0
$ make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- defconfig
$ make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- menuconfig
# Check Settings - Build static binary (no shared libs)
$ make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- install
$ cd ..
# Create root filesystem image
$ mkdir rootfs
$ cd rootfs
$ dd if=/dev/zero of=rootfs.img bs=1M count=50
$ mkfs.ext2 -L riscv-rootfs rootfs.img
$ sudo mkdir /mnt/rootfs
$ sudo mount rootfs.img /mnt/rootfs
$ sudo cp -ar ../busybox/_install/* /mnt/rootfs
$ sudo mkdir /mnt/rootfs/{dev,home,mnt,proc,sys,tmp,var}
$ sudo chown -R -h root:root /mnt/rootfs
# Check
$ df /mnt/rootfs
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop5 49584 1704 45320 4% /mnt/rootfs
$ mount | grep rootfs
riscv64-linux/rootfs/rootfs.img on /mnt/rootfs type ext2 (rw,relatime)
# Clean up
$ sudo umount /mnt/rootfs
$ sudo rmdir /mnt/rootfs
$ cd ..
# Run QEMU
$ qemu-system-riscv64 -nographic -machine virt \
-kernel linux/arch/riscv/boot/Image \
-append "root=/dev/vda rw console=ttyS0" \
-drive file=rootfs/rootfs.img,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-bios default
https://github.com/takahirox/riscv-rust/tree/master/resources/linux/opensbi
@takahirox Thank you for you approach. It works!
The only problem I had was with busybox 1_32_0. I got the following error when I used 1_32_0 or 1_32_stable or 1_31_0.
riscv64-linux/busybox# make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- install
SPLIT include/autoconf.h -> include/config/*
scripts/basic/split-include: feature/syslog/info.h: Success
make: *** [Makefile:857: include/config/MARKER] Error 1
OS Ubuntu 20.10.
The workaround is to checkout busybox version 1_30_stable.
I was able to run RISC-V Debian GNU/Linux bullseye/sid via QEMU.
opensbi
and u-boot-qemu
packages are not found add testing
apt repository (aka bullseye). Or even unstable
(aka sid)
sudo vi /etc/apt/sources.list
deb http://cdn-aws.deb.debian.org/debian testing main deb-src http://cdn-aws.deb.debian.org/debian testing main
sudo apt update
3. Install riscv related packages
sudo apt install qemu-system-misc opensbi u-boot-qemu
4. Download Debian riscv64-virt disk image from [Debian Quick Image Baker](https://people.debian.org/~gio/dqib/). Thank you Giovanni Mascellani (gio)!
5. Extract the archive and cd into extracted folder. The folder has disk image `image.qcow2`.
6. `readme.txt` file inside the extracted folder has the command to run the VM, e.g. the command below uses 1G RAM and 8 cores. ssh port to connect to VM is 2222. Users are: debian/debian and root/root.
qemu-system-riscv64 -machine virt -m 1G -smp 8 -cpu rv64 \ -device virtio-blk-device,drive=hd \ -drive file=image.qcow2,if=none,id=hd \ -device virtio-net-device,netdev=net \ -netdev user,id=net,hostfwd=tcp::2222-:22 \ -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \ -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \ -object rng-random,filename=/dev/urandom,id=rng \ -device virtio-rng-device,rng=rng \ -nographic -append "root=LABEL=rootfs console=ttyS0"
QEMU VM loading output:
OpenSBI v0.8
/ \ / __ | _ | _ __ | (___ | _) | ' \ / \ '_ \ ___ \ | _ < | __ | _) | __/ | ____) | _) | _ ____/ | ./ _ | _ | _ | _____/ | __/___ | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
_ |
Platform Name : riscv-virtio,qemu Platform Features : timer,mfdeleg Platform HART Count : 8 Boot HART ID : 2 Boot HART ISA : rv64imafdcsu BOOT HART Features : pmp,scounteren,mcounteren,time BOOT HART PMP Count : 16 Firmware Base : 0x80000000 Firmware Size : 148 KB Runtime SBI Version : 0.2
MIDELEG : 0x0000000000000222 MEDELEG : 0x000000000000b109 PMP0 : 0x0000000080000000-0x000000008003ffff (A) PMP1 : 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
U-Boot 2020.10+dfsg-1 (Oct 05 2020 - 19:13:28 +0000)
CPU: rv64imafdcsu Model: riscv-virtio,qemu DRAM: 1 GiB In: uart@10000000 Out: uart@10000000 Err: uart@10000000 Net: eth0: virtio-net#1 Hit any key to stop autoboot: 0
Device 0: QEMU VirtIO Block Device Type: Hard Disk Capacity: 10240.0 MB = 10.0 GB (20971520 x 512) ... is now current device Scanning virtio 0:1... Found /boot/extlinux/extlinux.conf Retrieving file: /boot/extlinux/extlinux.conf 669 bytes read in 2 ms (326.2 KiB/s) U-Boot menu 1: Debian GNU/Linux bullseye/sid 5.10.0-1-riscv64 2: Debian GNU/Linux bullseye/sid 5.10.0-1-riscv64 (rescue target) Enter choice: 1 1: Debian GNU/Linux bullseye/sid 5.10.0-1-riscv64 Retrieving file: /boot/initrd.img-5.10.0-1-riscv64 57113602 bytes read in 19 ms (2.8 GiB/s) Retrieving file: /boot/vmlinux-5.10.0-1-riscv64 18104832 bytes read in 5 ms (3.4 GiB/s) append: root=LABEL=rootfs rw noquiet root=LABEL=rootfs Moving Image from 0x84000000 to 0x80200000, end=813bd000
Booting using the fdt blob at 0xbf74b5a0 Using Device Tree in place at 00000000bf74b5a0, end 00000000bf74fe1d
Starting kernel ...
[ 0.000000] Linux version 5.10.0-1-riscv64 (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.1-1) 10.2.1 20201207, GNU ld (GNU Binutils for Debian) 2.35.1) #1 SMP Debian 5.10.4-1 (2020-12-31) [ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000 [ 0.000000] efi: UEFI not found. [ 0.000000] Initial ramdisk at: 0x(ptrval) (57114624 bytes) [ 0.000000] Zone ranges: [ 0.000000] DMA32 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] software IO TLB: mapped [mem 0x00000000ba74b000-0x00000000be74b000] (64MB) [ 0.000000] SBI specification v0.2 detected [ 0.000000] SBI implementation ID=0x1 Version=0x8 [ 0.000000] SBI v0.2 TIME extension detected [ 0.000000] SBI v0.2 IPI extension detected [ 0.000000] SBI v0.2 RFENCE extension detected [ 0.000000] SBI v0.2 HSM extension detected [ 0.000000] riscv: ISA extensions acdfimsu [ 0.000000] riscv: ELF capabilities acdfim [ 0.000000] percpu: Embedded 26 pages/cpu s69016 r8192 d29288 u106496 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 257544 [ 0.000000] Kernel command line: root=LABEL=rootfs rw noquiet root=LABEL=rootfs [ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear) [ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.000000] Sorting ex_table... [ 0.000000] mem auto-init: stack:off, heap alloc:on, heap free:off [ 0.000000] Memory: 887864K/1046528K available (6849K kernel code, 4414K rwdata, 4096K rodata, 299K init, 477K bss, 158664K reserved, 0K cma-reserved) [ 0.000000] random: get_random_u64 called from __kmem_cache_create+0x40/0x440 with crng_init=0 [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=8, Nodes=1 [ 0.000000] ftrace: allocating 25513 entries in 100 pages [ 0.000000] ftrace: allocated 100 pages with 3 groups [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] Rude variant of Tasks RCU enabled. [ 0.000000] Tracing variant of Tasks RCU enabled. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies. [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0 [ 0.000000] riscv-intc: 64 local interrupts mapped [ 0.000000] plic: plic@c000000: mapped 53 interrupts with 8 handlers for 16 contexts. [ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [2] [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns [ 0.000131] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns [ 0.004323] Console: colour dummy device 80x25 [ 0.008042] printk: console [tty0] enabled [ 0.009768] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000) [ 0.010025] pid_max: default: 32768 minimum: 301 [ 0.010954] LSM: Security Framework initializing [ 0.011894] Yama: disabled by default; enable with sysctl kernel.yama.* [ 0.014092] AppArmor: AppArmor initialized [ 0.014208] TOMOYO Linux initialized [ 0.015184] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.015331] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.045611] rcu: Hierarchical SRCU implementation. [ 0.048841] EFI services will not be available. [ 0.052131] smp: Bringing up secondary CPUs ... [ 0.068123] smp: Brought up 1 node, 8 CPUs [ 0.079625] devtmpfs: initialized [ 0.088934] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.089523] futex hash table entries: 2048 (order: 5, 131072 bytes, linear) [ 0.099405] NET: Registered protocol family 16 [ 0.101884] audit: initializing netlink subsys (disabled) [ 0.103768] audit: type=2000 audit(0.096:1): state=initialized audit_enabled=0 res=1 [ 0.106390] thermal_sys: Registered thermal governor 'fair_share' [ 0.106475] thermal_sys: Registered thermal governor 'step_wise' [ 0.132474] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages [ 0.518722] iommu: Default domain type: Translated [ 0.521972] vgaarb: loaded [ 0.532679] NetLabel: Initializing [ 0.532741] NetLabel: domain hash size = 128 [ 0.532774] NetLabel: protocols = UNLABELED CIPSOv4 CALIPSO [ 0.533716] NetLabel: unlabeled traffic allowed by default [ 0.535155] clocksource: Switched to clocksource riscv_clocksource [ 0.609638] VFS: Disk quotas dquot_6.6.0 [ 0.609888] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes) [ 0.615110] AppArmor: AppArmor Filesystem Enabled [ 0.643883] NET: Registered protocol family 2 [ 0.650770] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear) [ 0.651081] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear) [ 0.651352] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear) [ 0.651568] TCP: Hash tables configured (established 8192 bind 8192) [ 0.652645] UDP hash table entries: 512 (order: 2, 16384 bytes, linear) [ 0.652898] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear) [ 0.654806] NET: Registered protocol family 1 [ 0.655478] NET: Registered protocol family 44 [ 0.655765] PCI: CLS 0 bytes, default 64 [ 0.659760] Trying to unpack rootfs image as initramfs... [ 3.913853] Freeing initrd memory: 55772K [ 3.917213] Initialise system trusted keyrings [ 3.918964] Key type blacklist registered [ 3.919865] workingset: timestamp_bits=46 max_order=18 bucket_order=0 [ 3.929255] zbud: loaded [ 3.933663] integrity: Platform Keyring initialized [ 3.933781] Key type asymmetric registered [ 3.933862] Asymmetric key parser 'x509' registered [ 3.934089] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251) [ 3.935376] io scheduler mq-deadline registered [ 3.941975] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 3.954213] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 2, base_baud = 230400) is a 16550A [ 3.981822] printk: console [ttyS0] enabled [ 3.987736] mousedev: PS/2 mouse device common for all mice [ 3.992047] goldfish_rtc 101000.rtc: registered as rtc0 [ 3.993327] goldfish_rtc 101000.rtc: setting system clock to 2021-01-07T02:23:37 UTC (1609986217) [ 3.996212] syscon-poweroff soc:poweroff: pm_power_off already claimed (__ptrval____) sbi_shutdown [ 3.996871] syscon-poweroff: probe of soc:poweroff failed with error -16 [ 3.998567] ledtrig-cpu: registered to indicate activity on CPUs [ 4.000875] NET: Registered protocol family 10 [ 4.285556] Segment Routing with IPv6 [ 4.286408] mip6: Mobile IPv6 [ 4.287112] NET: Registered protocol family 17 [ 4.288156] mpls_gso: MPLS GSO support [ 4.288947] registered taskstats version 1 [ 4.289390] Loading compiled-in X.509 certificates [ 4.380236] Loaded X.509 cert 'Debian Secure Boot CA: 6ccece7e4c6c0d1f6149f3dd27dfcc5cbb419ea1' [ 4.381237] Loaded X.509 cert 'Debian Secure Boot Signer 2020: 00b55eb3b9' [ 4.382927] zswap: loaded using pool lzo/zbud [ 4.385970] Key type ._fscrypt registered [ 4.386330] Key type .fscrypt registered [ 4.386653] Key type fscrypt-provisioning registered [ 4.388282] AppArmor: AppArmor sha1 policy hashing enabled [ 5.130577] Freeing unused kernel memory: 296K [ 5.132762] Run /init as init process Loading, please wait... Starting version 247.2-4 [ 6.091787] virtio: module verification failed: signature and/or required key missing - tainting kernel [ 6.392259] virtio_blk virtio0: [vda] 20971520 512-byte logical blocks (10.7 GB/10.0 GiB) [ 6.392819] vda: detected capacity change from 0 to 10737418240 [ 6.454687] vda: vda1 Begin: Loading essential drivers ... done. Begin: Running /scripts/init-premount ... done. Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done. Begin: Running /scripts/local-premount ... done. Warning: fsck not present, so skipping root file system [ 26.893437] EXT4-fs (vda1): mounted filesystem with ordered data mode. Opts: (null) done. Begin: Running /scripts/local-bottom ... done. Begin: Running /scripts/init-bottom ... done. [ 27.596181] Not activating Mandatory Access Control as /sbin/tomoyo-init does not exist. [ 27.717205] random: fast init done [ 28.090671] systemd[1]: Inserted module 'autofs4' [ 28.236650] systemd[1]: systemd 247.2-4 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified) [ 28.240121] systemd[1]: Detected architecture riscv64.
Welcome to Debian GNU/Linux bullseye/sid!
[ 28.251976] systemd[1]: Set hostname to
Debian GNU/Linux bullseye/sid debian ttyS0
debian login: debian Password: Linux debian 5.10.0-1-riscv64 #1 SMP Debian 5.10.4-1 (2020-12-31) riscv64
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. debian@debian:~$ cat /etc/issue Debian GNU/Linux bullseye/sid \n \l
debian@debian:~$ uname -a Linux debian 5.10.0-1-riscv64 #1 SMP Debian 5.10.4-1 (2020-12-31) riscv64 GNU/Linux
Hey @takahirox thanks for the setups, it solved my issue for rootfs but am popped with issue of initfs, any idea how to solve this (ik thread is old :( but hoping for the input). @apivovarov it will be great if you can also take a look:
Below are all the logs :
sudo qemu-system-riscv64 -m 1024 -nographic -machine virt -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" -drive file=rootfs/rootfs.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -bios default
OpenSBI v0.9
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : riscv-virtio,qemu
Platform Features : timer,mfdeleg
Platform HART Count : 1
Firmware Base : 0x80000000
Firmware Size : 100 KB
Runtime SBI Version : 0.2
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*
Domain0 Region00 : 0x0000000080000000-0x000000008001ffff ()
Domain0 Region01 : 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 : rv64imafdcsu
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 MHPM Count : 0
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109
[ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[ 0.000000] Linux version 5.4.166 (rushi@watershed) (gcc version 11.1.0 (GCC)) #2 SMP Mon Dec 20 04:17:38 EST 2021
[ 0.000000] initrd not found or empty - disabling initrd
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000080200000-0x00000000bfffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000080200000-0x00000000bfffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000bfffffff]
[ 0.000000] software IO TLB: mapped [mem 0xbb000000-0xbf000000] (64MB)
[ 0.000000] elf_hwcap is 0x112d
[ 0.000000] percpu: Embedded 17 pages/cpu s30680 r8192 d30760 u69632
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 258055
[ 0.000000] Kernel command line: root=/dev/vda ro console=ttyS0
[ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[ 0.000000] Sorting __ex_table...
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 955488K/1046528K available (6252K kernel code, 397K rwdata, 1958K rodata, 213K init, 305K bss, 91040K reserved, 0K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[ 0.000000] plic: mapped 53 interrupts with 1 handlers for 2 contexts.
[ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[ 0.000108] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[ 0.003543] Console: colour dummy device 80x25
[ 0.004976] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[ 0.008291] pid_max: default: 32768 minimum: 301
[ 0.009575] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.009621] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.038126] rcu: Hierarchical SRCU implementation.
[ 0.040390] smp: Bringing up secondary CPUs ...
[ 0.040470] smp: Brought up 1 node, 1 CPU
[ 0.050746] devtmpfs: initialized
[ 0.057330] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x150 with crng_init=0
[ 0.059625] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.059790] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[ 0.062825] NET: Registered protocol family 16
[ 0.109793] vgaarb: loaded
[ 0.110925] SCSI subsystem initialized
[ 0.112798] usbcore: registered new interface driver usbfs
[ 0.113134] usbcore: registered new interface driver hub
[ 0.113312] usbcore: registered new device driver usb
[ 0.121927] clocksource: Switched to clocksource riscv_clocksource
[ 0.139101] NET: Registered protocol family 2
[ 0.140354] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
[ 0.143831] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear)
[ 0.143936] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.144161] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear)
[ 0.144370] TCP: Hash tables configured (established 8192 bind 8192)
[ 0.146051] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[ 0.146304] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[ 0.147719] NET: Registered protocol family 1
[ 0.150220] RPC: Registered named UNIX socket transport module.
[ 0.150289] RPC: Registered udp transport module.
[ 0.150306] RPC: Registered tcp transport module.
[ 0.150320] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.150430] PCI: CLS 0 bytes, default 64
[ 0.157136] workingset: timestamp_bits=62 max_order=18 bucket_order=0
[ 0.169987] NFS: Registering the id_resolver key type
[ 0.170827] Key type id_resolver registered
[ 0.170876] Key type id_legacy registered
[ 0.171005] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 0.171114] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[ 0.171664] 9p: Installing v9fs 9p2000 file system support
[ 0.172949] NET: Registered protocol family 38
[ 0.173219] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[ 0.173362] io scheduler mq-deadline registered
[ 0.173443] io scheduler kyber registered
[ 0.176165] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[ 0.176668] pci-host-generic 30000000.pci: IO 0x03000000..0x0300ffff -> 0x00000000
[ 0.177163] pci-host-generic 30000000.pci: MEM 0x40000000..0x7fffffff -> 0x40000000
[ 0.177229] pci-host-generic 30000000.pci: MEM 0x400000000..0x7ffffffff -> 0x400000000
[ 0.179248] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[ 0.180132] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[ 0.180321] pci_bus 0000:00: root bus resource [bus 00-ff]
[ 0.180446] pci_bus 0000:00: root bus resource [io 0x0000-0xffff]
[ 0.180466] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[ 0.180480] pci_bus 0000:00: root bus resource [mem 0x400000000-0x7ffffffff]
[ 0.182467] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[ 0.257417] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[ 0.264131] printk: console [ttyS0] disabled
[ 0.265228] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 10, base_baud = 230400) is a 16550A
[ 0.290926] printk: console [ttyS0] enabled
[ 0.292886] [drm] radeon kernel modesetting enabled.
[ 0.306370] loop: module loaded
[ 0.316180] virtio_blk virtio0: [vda] 102400 512-byte logical blocks (52.4 MB/50.0 MiB)
[ 0.336838] libphy: Fixed MDIO Bus: probed
[ 0.338132] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[ 0.338434] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 0.339020] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.339415] ehci-pci: EHCI PCI platform driver
[ 0.339829] ehci-platform: EHCI generic platform driver
[ 0.340256] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.340563] ohci-pci: OHCI PCI platform driver
[ 0.340962] ohci-platform: OHCI generic platform driver
[ 0.342144] usbcore: registered new interface driver uas
[ 0.342605] usbcore: registered new interface driver usb-storage
[ 0.343757] mousedev: PS/2 mouse device common for all mice
[ 0.345416] usbcore: registered new interface driver usbhid
[ 0.345814] usbhid: USB HID core driver
[ 0.347731] NET: Registered protocol family 10
[ 0.354451] Segment Routing with IPv6
[ 0.355077] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 0.358069] NET: Registered protocol family 17
[ 0.359645] 9pnet: Installing 9P2000 support
[ 0.360158] Key type dns_resolver registered
[ 0.378062] EXT4-fs (vda): mounting ext2 file system using the ext4 subsystem
[ 0.388924] EXT4-fs (vda): mounted filesystem without journal. Opts: (null)
[ 0.389524] VFS: Mounted root (ext2 filesystem) readonly on device 254:0.
[ 0.395237] devtmpfs: mounted
[ 0.414941] Freeing unused kernel memory: 212K
[ 0.415212] This architecture does not have kernel memory protection.
[ 0.415573] Run /sbin/init as init process
[ 0.430409] Run /etc/init as init process
[ 0.430715] Run /bin/init as init process
[ 0.431727] Run /bin/sh as init process
[ 0.432782] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[ 0.433574] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.166 #2
[ 0.433976] Call Trace:
[ 0.434239] [<ffffffe000037ad0>] walk_stackframe+0x0/0xa6
[ 0.434545] [<ffffffe000643072>] show_stack+0x2e/0x38
[ 0.434790] [<ffffffe00064b914>] dump_stack+0x66/0x80
[ 0.435029] [<ffffffe0006431bc>] panic+0xd6/0x260
[ 0.435241] [<ffffffe00064bb4e>] kernel_init+0xbc/0xc8
[ 0.435487] [<ffffffe0000367e4>] ret_from_exception+0x0/0xc
[ 0.436363] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
Hey @takahirox thanks for the setups, it solved my issue for rootfs but am popped with issue of initfs, any idea how to solve this (ik thread is old :( but hoping for the input). @apivovarov it will be great if you can also take a look:
Below are all the logs :
sudo qemu-system-riscv64 -m 1024 -nographic -machine virt -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" -drive file=rootfs/rootfs.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -bios default OpenSBI v0.9 ____ _____ ____ _____ / __ \ / ____| _ \_ _| | | | |_ __ ___ _ __ | (___ | |_) || | | | | | '_ \ / _ \ '_ \ \___ \| _ < | | | |__| | |_) | __/ | | |____) | |_) || |_ \____/| .__/ \___|_| |_|_____/|____/_____| | | |_| Platform Name : riscv-virtio,qemu Platform Features : timer,mfdeleg Platform HART Count : 1 Firmware Base : 0x80000000 Firmware Size : 100 KB Runtime SBI Version : 0.2 Domain0 Name : root Domain0 Boot HART : 0 Domain0 HARTs : 0* Domain0 Region00 : 0x0000000080000000-0x000000008001ffff () Domain0 Region01 : 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 : rv64imafdcsu 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 MHPM Count : 0 Boot HART MIDELEG : 0x0000000000000222 Boot HART MEDELEG : 0x000000000000b109 [ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000 [ 0.000000] Linux version 5.4.166 (rushi@watershed) (gcc version 11.1.0 (GCC)) #2 SMP Mon Dec 20 04:17:38 EST 2021 [ 0.000000] initrd not found or empty - disabling initrd [ 0.000000] Zone ranges: [ 0.000000] DMA32 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] software IO TLB: mapped [mem 0xbb000000-0xbf000000] (64MB) [ 0.000000] elf_hwcap is 0x112d [ 0.000000] percpu: Embedded 17 pages/cpu s30680 r8192 d30760 u69632 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 258055 [ 0.000000] Kernel command line: root=/dev/vda ro console=ttyS0 [ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear) [ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.000000] Sorting __ex_table... [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 955488K/1046528K available (6252K kernel code, 397K rwdata, 1958K rodata, 213K init, 305K bss, 91040K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies. [ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1 [ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0 [ 0.000000] plic: mapped 53 interrupts with 1 handlers for 2 contexts. [ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0] [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns [ 0.000108] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns [ 0.003543] Console: colour dummy device 80x25 [ 0.004976] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000) [ 0.008291] pid_max: default: 32768 minimum: 301 [ 0.009575] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.009621] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.038126] rcu: Hierarchical SRCU implementation. [ 0.040390] smp: Bringing up secondary CPUs ... [ 0.040470] smp: Brought up 1 node, 1 CPU [ 0.050746] devtmpfs: initialized [ 0.057330] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x150 with crng_init=0 [ 0.059625] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.059790] futex hash table entries: 256 (order: 2, 16384 bytes, linear) [ 0.062825] NET: Registered protocol family 16 [ 0.109793] vgaarb: loaded [ 0.110925] SCSI subsystem initialized [ 0.112798] usbcore: registered new interface driver usbfs [ 0.113134] usbcore: registered new interface driver hub [ 0.113312] usbcore: registered new device driver usb [ 0.121927] clocksource: Switched to clocksource riscv_clocksource [ 0.139101] NET: Registered protocol family 2 [ 0.140354] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear) [ 0.143831] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear) [ 0.143936] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear) [ 0.144161] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear) [ 0.144370] TCP: Hash tables configured (established 8192 bind 8192) [ 0.146051] UDP hash table entries: 512 (order: 2, 16384 bytes, linear) [ 0.146304] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear) [ 0.147719] NET: Registered protocol family 1 [ 0.150220] RPC: Registered named UNIX socket transport module. [ 0.150289] RPC: Registered udp transport module. [ 0.150306] RPC: Registered tcp transport module. [ 0.150320] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.150430] PCI: CLS 0 bytes, default 64 [ 0.157136] workingset: timestamp_bits=62 max_order=18 bucket_order=0 [ 0.169987] NFS: Registering the id_resolver key type [ 0.170827] Key type id_resolver registered [ 0.170876] Key type id_legacy registered [ 0.171005] nfs4filelayout_init: NFSv4 File Layout Driver Registering... [ 0.171114] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering... [ 0.171664] 9p: Installing v9fs 9p2000 file system support [ 0.172949] NET: Registered protocol family 38 [ 0.173219] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 0.173362] io scheduler mq-deadline registered [ 0.173443] io scheduler kyber registered [ 0.176165] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges: [ 0.176668] pci-host-generic 30000000.pci: IO 0x03000000..0x0300ffff -> 0x00000000 [ 0.177163] pci-host-generic 30000000.pci: MEM 0x40000000..0x7fffffff -> 0x40000000 [ 0.177229] pci-host-generic 30000000.pci: MEM 0x400000000..0x7ffffffff -> 0x400000000 [ 0.179248] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff] [ 0.180132] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00 [ 0.180321] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.180446] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] [ 0.180466] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff] [ 0.180480] pci_bus 0000:00: root bus resource [mem 0x400000000-0x7ffffffff] [ 0.182467] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000 [ 0.257417] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.264131] printk: console [ttyS0] disabled [ 0.265228] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 10, base_baud = 230400) is a 16550A [ 0.290926] printk: console [ttyS0] enabled [ 0.292886] [drm] radeon kernel modesetting enabled. [ 0.306370] loop: module loaded [ 0.316180] virtio_blk virtio0: [vda] 102400 512-byte logical blocks (52.4 MB/50.0 MiB) [ 0.336838] libphy: Fixed MDIO Bus: probed [ 0.338132] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k [ 0.338434] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 0.339020] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 0.339415] ehci-pci: EHCI PCI platform driver [ 0.339829] ehci-platform: EHCI generic platform driver [ 0.340256] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 0.340563] ohci-pci: OHCI PCI platform driver [ 0.340962] ohci-platform: OHCI generic platform driver [ 0.342144] usbcore: registered new interface driver uas [ 0.342605] usbcore: registered new interface driver usb-storage [ 0.343757] mousedev: PS/2 mouse device common for all mice [ 0.345416] usbcore: registered new interface driver usbhid [ 0.345814] usbhid: USB HID core driver [ 0.347731] NET: Registered protocol family 10 [ 0.354451] Segment Routing with IPv6 [ 0.355077] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 0.358069] NET: Registered protocol family 17 [ 0.359645] 9pnet: Installing 9P2000 support [ 0.360158] Key type dns_resolver registered [ 0.378062] EXT4-fs (vda): mounting ext2 file system using the ext4 subsystem [ 0.388924] EXT4-fs (vda): mounted filesystem without journal. Opts: (null) [ 0.389524] VFS: Mounted root (ext2 filesystem) readonly on device 254:0. [ 0.395237] devtmpfs: mounted [ 0.414941] Freeing unused kernel memory: 212K [ 0.415212] This architecture does not have kernel memory protection. [ 0.415573] Run /sbin/init as init process [ 0.430409] Run /etc/init as init process [ 0.430715] Run /bin/init as init process [ 0.431727] Run /bin/sh as init process [ 0.432782] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. [ 0.433574] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.166 #2 [ 0.433976] Call Trace: [ 0.434239] [<ffffffe000037ad0>] walk_stackframe+0x0/0xa6 [ 0.434545] [<ffffffe000643072>] show_stack+0x2e/0x38 [ 0.434790] [<ffffffe00064b914>] dump_stack+0x66/0x80 [ 0.435029] [<ffffffe0006431bc>] panic+0xd6/0x260 [ 0.435241] [<ffffffe00064bb4e>] kernel_init+0xbc/0xc8 [ 0.435487] [<ffffffe0000367e4>] ret_from_exception+0x0/0xc [ 0.436363] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
You need to compile busybox staticlly. try "make menuconfig" and set "Settings/Build static binary(no shared libs)"
Hey @takahirox thanks for the setups, it solved my issue for rootfs but am popped with issue of initfs, any idea how to solve this (ik thread is old :( but hoping for the input). @apivovarov it will be great if you can also take a look:
Below are all the logs :
sudo qemu-system-riscv64 -m 1024 -nographic -machine virt -kernel linux/arch/riscv/boot/Image -append "root=/dev/vda ro console=ttyS0" -drive file=rootfs/rootfs.img,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -bios default OpenSBI v0.9 ____ _____ ____ _____ / __ \ / ____| _ \_ _| | | | |_ __ ___ _ __ | (___ | |_) || | | | | | '_ \ / _ \ '_ \ \___ \| _ < | | | |__| | |_) | __/ | | |____) | |_) || |_ \____/| .__/ \___|_| |_|_____/|____/_____| | | |_| Platform Name : riscv-virtio,qemu Platform Features : timer,mfdeleg Platform HART Count : 1 Firmware Base : 0x80000000 Firmware Size : 100 KB Runtime SBI Version : 0.2 Domain0 Name : root Domain0 Boot HART : 0 Domain0 HARTs : 0* Domain0 Region00 : 0x0000000080000000-0x000000008001ffff () Domain0 Region01 : 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 : rv64imafdcsu 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 MHPM Count : 0 Boot HART MIDELEG : 0x0000000000000222 Boot HART MEDELEG : 0x000000000000b109 [ 0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000 [ 0.000000] Linux version 5.4.166 (rushi@watershed) (gcc version 11.1.0 (GCC)) #2 SMP Mon Dec 20 04:17:38 EST 2021 [ 0.000000] initrd not found or empty - disabling initrd [ 0.000000] Zone ranges: [ 0.000000] DMA32 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Normal empty [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x00000000bfffffff] [ 0.000000] software IO TLB: mapped [mem 0xbb000000-0xbf000000] (64MB) [ 0.000000] elf_hwcap is 0x112d [ 0.000000] percpu: Embedded 17 pages/cpu s30680 r8192 d30760 u69632 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 258055 [ 0.000000] Kernel command line: root=/dev/vda ro console=ttyS0 [ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear) [ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear) [ 0.000000] Sorting __ex_table... [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 955488K/1046528K available (6252K kernel code, 397K rwdata, 1958K rodata, 213K init, 305K bss, 91040K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] rcu: Hierarchical RCU implementation. [ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies. [ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1 [ 0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0 [ 0.000000] plic: mapped 53 interrupts with 1 handlers for 2 contexts. [ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0] [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns [ 0.000108] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns [ 0.003543] Console: colour dummy device 80x25 [ 0.004976] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000) [ 0.008291] pid_max: default: 32768 minimum: 301 [ 0.009575] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.009621] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.038126] rcu: Hierarchical SRCU implementation. [ 0.040390] smp: Bringing up secondary CPUs ... [ 0.040470] smp: Brought up 1 node, 1 CPU [ 0.050746] devtmpfs: initialized [ 0.057330] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x150 with crng_init=0 [ 0.059625] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns [ 0.059790] futex hash table entries: 256 (order: 2, 16384 bytes, linear) [ 0.062825] NET: Registered protocol family 16 [ 0.109793] vgaarb: loaded [ 0.110925] SCSI subsystem initialized [ 0.112798] usbcore: registered new interface driver usbfs [ 0.113134] usbcore: registered new interface driver hub [ 0.113312] usbcore: registered new device driver usb [ 0.121927] clocksource: Switched to clocksource riscv_clocksource [ 0.139101] NET: Registered protocol family 2 [ 0.140354] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear) [ 0.143831] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear) [ 0.143936] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear) [ 0.144161] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear) [ 0.144370] TCP: Hash tables configured (established 8192 bind 8192) [ 0.146051] UDP hash table entries: 512 (order: 2, 16384 bytes, linear) [ 0.146304] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear) [ 0.147719] NET: Registered protocol family 1 [ 0.150220] RPC: Registered named UNIX socket transport module. [ 0.150289] RPC: Registered udp transport module. [ 0.150306] RPC: Registered tcp transport module. [ 0.150320] RPC: Registered tcp NFSv4.1 backchannel transport module. [ 0.150430] PCI: CLS 0 bytes, default 64 [ 0.157136] workingset: timestamp_bits=62 max_order=18 bucket_order=0 [ 0.169987] NFS: Registering the id_resolver key type [ 0.170827] Key type id_resolver registered [ 0.170876] Key type id_legacy registered [ 0.171005] nfs4filelayout_init: NFSv4 File Layout Driver Registering... [ 0.171114] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering... [ 0.171664] 9p: Installing v9fs 9p2000 file system support [ 0.172949] NET: Registered protocol family 38 [ 0.173219] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 0.173362] io scheduler mq-deadline registered [ 0.173443] io scheduler kyber registered [ 0.176165] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges: [ 0.176668] pci-host-generic 30000000.pci: IO 0x03000000..0x0300ffff -> 0x00000000 [ 0.177163] pci-host-generic 30000000.pci: MEM 0x40000000..0x7fffffff -> 0x40000000 [ 0.177229] pci-host-generic 30000000.pci: MEM 0x400000000..0x7ffffffff -> 0x400000000 [ 0.179248] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff] [ 0.180132] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00 [ 0.180321] pci_bus 0000:00: root bus resource [bus 00-ff] [ 0.180446] pci_bus 0000:00: root bus resource [io 0x0000-0xffff] [ 0.180466] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff] [ 0.180480] pci_bus 0000:00: root bus resource [mem 0x400000000-0x7ffffffff] [ 0.182467] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000 [ 0.257417] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled [ 0.264131] printk: console [ttyS0] disabled [ 0.265228] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 10, base_baud = 230400) is a 16550A [ 0.290926] printk: console [ttyS0] enabled [ 0.292886] [drm] radeon kernel modesetting enabled. [ 0.306370] loop: module loaded [ 0.316180] virtio_blk virtio0: [vda] 102400 512-byte logical blocks (52.4 MB/50.0 MiB) [ 0.336838] libphy: Fixed MDIO Bus: probed [ 0.338132] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k [ 0.338434] e1000e: Copyright(c) 1999 - 2015 Intel Corporation. [ 0.339020] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 0.339415] ehci-pci: EHCI PCI platform driver [ 0.339829] ehci-platform: EHCI generic platform driver [ 0.340256] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 0.340563] ohci-pci: OHCI PCI platform driver [ 0.340962] ohci-platform: OHCI generic platform driver [ 0.342144] usbcore: registered new interface driver uas [ 0.342605] usbcore: registered new interface driver usb-storage [ 0.343757] mousedev: PS/2 mouse device common for all mice [ 0.345416] usbcore: registered new interface driver usbhid [ 0.345814] usbhid: USB HID core driver [ 0.347731] NET: Registered protocol family 10 [ 0.354451] Segment Routing with IPv6 [ 0.355077] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver [ 0.358069] NET: Registered protocol family 17 [ 0.359645] 9pnet: Installing 9P2000 support [ 0.360158] Key type dns_resolver registered [ 0.378062] EXT4-fs (vda): mounting ext2 file system using the ext4 subsystem [ 0.388924] EXT4-fs (vda): mounted filesystem without journal. Opts: (null) [ 0.389524] VFS: Mounted root (ext2 filesystem) readonly on device 254:0. [ 0.395237] devtmpfs: mounted [ 0.414941] Freeing unused kernel memory: 212K [ 0.415212] This architecture does not have kernel memory protection. [ 0.415573] Run /sbin/init as init process [ 0.430409] Run /etc/init as init process [ 0.430715] Run /bin/init as init process [ 0.431727] Run /bin/sh as init process [ 0.432782] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. [ 0.433574] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.166 #2 [ 0.433976] Call Trace: [ 0.434239] [<ffffffe000037ad0>] walk_stackframe+0x0/0xa6 [ 0.434545] [<ffffffe000643072>] show_stack+0x2e/0x38 [ 0.434790] [<ffffffe00064b914>] dump_stack+0x66/0x80 [ 0.435029] [<ffffffe0006431bc>] panic+0xd6/0x260 [ 0.435241] [<ffffffe00064bb4e>] kernel_init+0xbc/0xc8 [ 0.435487] [<ffffffe0000367e4>] ret_from_exception+0x0/0xc [ 0.436363] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
Hi @rushi47 , It might be a little late to reply. When you boot into linux, your kernel searches for an init file to mount necessary devices. Typically it is in /sbin/init
. But as you can see busybox
did not provide a working init file. A work around can be to create your own init file. This can be achieved by creating your minimal init
file and making it executable (and remember to put it in root folder). Following can be used as an init file:
#!/bin/sh
echo "### INIT SCRIPT ###"
mkdir /proc /sys /tmp
mount -t proc none /proc #For processes
mount -t sysfs none /sys #For all the devices on the machine
mount -t tmpfs none /tmp #For virtual memory
echo -e "\nThis boot took $(cut -d' ' -f1 /proc/uptime) seconds\n"
exec /bin/sh
Also it will be a better approach to compress the generated busybox file system in .cpio.gz
format and then give path in kernel configuration before starting the compilation.
I have created a complete documentation for building linux kernel from source and booting on qemu-system-riscv64 with busybox here. If you think something is missing, feel free to point that out.
I followed the instructions in RISC-V getting started guide with #26 and #28 to run Ubuntu/Debian on QEMU RISC-V. But failed to do that.
After building QEMU, Linux, Busybox, I ran the following command to boot QEMU RISC-V with Ubuntu.
https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#running
But I faced the following warnings and see no other messages.
I also tried
-bios default
option but it seems to fail to mount root fs.Do I need to pass a certain bios file to QEMU? Or am I missing something? Does anyone succeeded in booting Ubuntu/Debian on QEMU RISC-V with the guideline?