riscvarchive / risc-v-getting-started-guide

The official RISC-V getting started guide
https://risc-v-getting-started-guide.readthedocs.io/en/latest/
Creative Commons Attribution 4.0 International
198 stars 56 forks source link

Failed to run Ubuntu/Debian on QEMU RISC-V #29

Open takahirox opened 4 years ago

takahirox commented 4 years ago

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

$ 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

But I faced the following warnings and see no other messages.

qemu-system-riscv64: warning: No -bios option specified. Not loading a firmware.
qemu-system-riscv64: warning: This default will change in a future QEMU release. Please use the -bios option to avoid breakages when this happens.
qemu-system-riscv64: warning: See QEMU's deprecation documentation for details.

I also tried -bios default option but it seems to fail to mount root fs.

$ 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.4.0 (takahiro@takahiro-VirtualBox) (gcc version 10.1.0 (GCC)) #1 SMP Tue Sep 1 10:34:30 PDT 2020
[    0.000000] initrd not found or empty - disabling initrd
[    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] 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: 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: 51968K/129024K available (6166K kernel code, 387K rwdata, 1962K rodata, 213K init, 305K bss, 77056K 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.000125] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[    0.005020] Console: colour dummy device 80x25
[    0.010186] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[    0.010365] pid_max: default: 32768 minimum: 301
[    0.011845] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.011882] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.050872] rcu: Hierarchical SRCU implementation.
[    0.053564] smp: Bringing up secondary CPUs ...
[    0.053647] smp: Brought up 1 node, 1 CPU
[    0.066191] devtmpfs: initialized
[    0.074566] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x154 with crng_init=0
[    0.077193] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.077550] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.082457] NET: Registered protocol family 16
[    0.145915] vgaarb: loaded
[    0.147398] SCSI subsystem initialized
[    0.149305] usbcore: registered new interface driver usbfs
[    0.149656] usbcore: registered new interface driver hub
[    0.149818] usbcore: registered new device driver usb
[    0.162399] clocksource: Switched to clocksource riscv_clocksource
[    0.188781] NET: Registered protocol family 2
[    0.196592] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.196850] TCP established hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.197156] TCP bind hash table entries: 1024 (order: 2, 16384 bytes, linear)
[    0.197395] TCP: Hash tables configured (established 1024 bind 1024)
[    0.200620] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.201112] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.203875] NET: Registered protocol family 1
[    0.208520] RPC: Registered named UNIX socket transport module.
[    0.208629] RPC: Registered udp transport module.
[    0.208658] RPC: Registered tcp transport module.
[    0.208684] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.208925] PCI: CLS 0 bytes, default 64
[    0.220011] workingset: timestamp_bits=62 max_order=14 bucket_order=0
[    0.237291] NFS: Registering the id_resolver key type
[    0.238422] Key type id_resolver registered
[    0.238471] Key type id_legacy registered
[    0.238607] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.239371] 9p: Installing v9fs 9p2000 file system support
[    0.241016] NET: Registered protocol family 38
[    0.241576] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    0.241747] io scheduler mq-deadline registered
[    0.242013] io scheduler kyber registered
[    0.245290] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[    0.246223] pci-host-generic 30000000.pci:    IO 0x03000000..0x0300ffff -> 0x00000000
[    0.247150] pci-host-generic 30000000.pci:   MEM 0x40000000..0x7fffffff -> 0x40000000
[    0.250176] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[    0.251579] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[    0.251902] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.252057] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.252077] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[    0.253324] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.325890] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.335978] printk: console [ttyS0] disabled
[    0.337057] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 10, base_baud = 230400) is a 16550A
[    0.474052] printk: console [ttyS0] enabled
[    0.477304] [drm] radeon kernel modesetting enabled.
[    0.522895] loop: module loaded
[    0.553166] virtio_blk virtio0: [vda] 1869 512-byte logical blocks (957 kB/935 KiB)
[    0.628744] libphy: Fixed MDIO Bus: probed
[    0.632066] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[    0.633691] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.637151] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.641902] ehci-pci: EHCI PCI platform driver
[    0.646206] ehci-platform: EHCI generic platform driver
[    0.647905] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.649146] ohci-pci: OHCI PCI platform driver
[    0.652005] ohci-platform: OHCI generic platform driver
[    0.654601] usbcore: registered new interface driver uas
[    0.659067] usbcore: registered new interface driver usb-storage
[    0.662377] mousedev: PS/2 mouse device common for all mice
[    0.667578] usbcore: registered new interface driver usbhid
[    0.669186] usbhid: USB HID core driver
[    0.680722] NET: Registered protocol family 10
[    0.695196] Segment Routing with IPv6
[    0.697284] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.714403] NET: Registered protocol family 17
[    0.717662] 9pnet: Installing 9P2000 support
[    0.730306] Key type dns_resolver registered
[    0.791312] List of all partitions:
[    0.792612] fe00             934 vda 
[    0.792667]  driver: virtio_blk
[    0.794799] No filesystem could mount root, tried: 
[    0.794817]  ext3
[    0.804603]  ext2
[    0.805518]  ext4
[    0.806190]  vfat
[    0.806785]  msdos
[    0.807208] 
[    0.808590] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0)
[    0.814049] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.0 #1
[    0.815836] Call Trace:
[    0.816993] [<ffffffe000037ac4>] walk_stackframe+0x0/0xa6
[    0.818928] [<ffffffe000037c3a>] show_stack+0x2a/0x34
[    0.820095] [<ffffffe000621ab6>] dump_stack+0x6e/0x88
[    0.820438] [<ffffffe00003cb86>] panic+0xdc/0x246
[    0.824519] [<ffffffe000000ff4>] mount_block_root+0x1fe/0x218
[    0.825814] [<ffffffe00000111c>] mount_root+0x10e/0x124
[    0.826750] [<ffffffe000001244>] prepare_namespace+0x112/0x15c
[    0.828045] [<ffffffe000000c10>] kernel_init_freeable+0x188/0x1a4
[    0.832528] [<ffffffe000636392>] kernel_init+0x12/0xf0
[    0.833898] [<ffffffe000036818>] ret_from_exception+0x0/0xc
[    0.836435] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(254,0) ]---

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?

Emanon42 commented 3 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.

takahirox commented 3 years ago

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

apivovarov commented 3 years ago

@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.

apivovarov commented 3 years ago

I was able to run RISC-V Debian GNU/Linux bullseye/sid via QEMU.

  1. Run the latest version of Debian on regular x86_64 box (at least ver 10 Buster, better to run ver 11 Bullseye)
  2. If 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

Add testing repo (or unstable)

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

Flattened Device Tree blob at bf74b5a0

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 . [ 29.508910] systemd[1]: Queued start job for default target Graphical Interface. [ 29.516781] random: systemd: uninitialized urandom read (16 bytes read) [ 29.544966] systemd[1]: Created slice system-getty.slice. [ OK ] Created slice system-getty.slice. [ 29.549069] random: systemd: uninitialized urandom read (16 bytes read) [ 29.555421] systemd[1]: Created slice system-modprobe.slice. [ OK ] Created slice system-modprobe.slice. [ 29.557060] random: systemd: uninitialized urandom read (16 bytes read) [ 29.563236] systemd[1]: Created slice system-serial\x2dgetty.slice. [ OK ] Created slice system-serial\x2dgetty.slice. [ 29.567971] systemd[1]: Started Dispatch Password Requests to Console Directory Watch. [ OK ] Started Dispatch Password …ts to Console Directory Watch. [ 29.572611] systemd[1]: Started Forward Password Requests to Wall Directory Watch. [ OK ] Started Forward Password R…uests to Wall Directory Watch. [ 29.593488] systemd[1]: Set up automount Arbitrary Executable File Formats File System Automount Point. [ OK ] Set up automount Arbitrary…s File System Automount Point. [ 29.596377] systemd[1]: Reached target Local Encrypted Volumes. [ OK ] Reached target Local Encrypted Volumes. [ 29.598218] systemd[1]: Reached target Paths. [ OK ] Reached target Paths. [ 29.599995] systemd[1]: Reached target Remote File Systems. [ OK ] Reached target Remote File Systems. [ 29.601638] systemd[1]: Reached target Slices. [ OK ] Reached target Slices. [ 29.603370] systemd[1]: Reached target Swap. [ OK ] Reached target Swap. [ 29.609304] systemd[1]: Listening on Syslog Socket. [ OK ] Listening on Syslog Socket. [ 29.613257] systemd[1]: Listening on fsck to fsckd communication Socket. [ OK ] Listening on fsck to fsckd communication Socket. [ 29.616747] systemd[1]: Listening on initctl Compatibility Named Pipe. [ OK ] Listening on initctl Compatibility Named Pipe. [ 29.621846] systemd[1]: Listening on Journal Audit Socket. [ OK ] Listening on Journal Audit Socket. [ 29.626621] systemd[1]: Listening on Journal Socket (/dev/log). [ OK ] Listening on Journal Socket (/dev/log). [ 29.631816] systemd[1]: Listening on Journal Socket. [ OK ] Listening on Journal Socket. [ 29.637568] systemd[1]: Listening on udev Control Socket. [ OK ] Listening on udev Control Socket. [ 29.641637] systemd[1]: Listening on udev Kernel Socket. [ OK ] Listening on udev Kernel Socket. [ 29.643617] systemd[1]: Reached target Sockets. [ OK ] Reached target Sockets. [ 29.663539] systemd[1]: Mounting Huge Pages File System... Mounting Huge Pages File System... [ 29.680372] systemd[1]: Mounting POSIX Message Queue File System... Mounting POSIX Message Queue File System... [ 29.700438] systemd[1]: Mounting Kernel Debug File System... Mounting Kernel Debug File System... [ 29.719684] systemd[1]: Mounting Kernel Trace File System... Mounting Kernel Trace File System... [ 29.743616] systemd[1]: Starting Create list of static device nodes for the current kernel... Starting Create list of st…odes for the current kernel... [ 29.773743] systemd[1]: Starting Load Kernel Module configfs... Starting Load Kernel Module configfs... [ 29.793675] systemd[1]: Starting Load Kernel Module fuse... Starting Load Kernel Module fuse... [ 29.801435] systemd[1]: Condition check resulted in Set Up Additional Binary Formats being skipped. [ 29.803912] systemd[1]: Condition check resulted in File System Check on Root Device being skipped. [ 29.846686] systemd[1]: Starting Journal Service... Starting Journal Service... [ 29.880868] systemd[1]: Starting Load Kernel Modules... Starting Load Kernel Modules... [ 29.904492] systemd[1]: Starting Remount Root and Kernel File Systems... Starting Remount Root and Kernel File Systems... [ 29.932613] systemd[1]: Starting Coldplug All udev Devices... Starting Coldplug All udev Devices... [ 30.004347] systemd[1]: Mounted Huge Pages File System. [ OK ] Mounted Huge Pages File System. [ 30.011195] systemd[1]: Mounted POSIX Message Queue File System. [ OK ] Mounted POSIX Message Queue File System. [ 30.018874] systemd[1]: Mounted Kernel Debug File System. [ OK ] Mounted Kernel Debug File System. [ 30.026510] systemd[1]: Mounted Kernel Trace File System. [ OK ] Mounted Kernel Trace File System. [ 30.049864] systemd[1]: Finished Create list of static device nodes for the current kernel. [ OK ] Finished Create list of st… nodes for the current kernel. [ 30.062598] fuse: init (API version 7.32) [ 30.084177] systemd[1]: modprobe@configfs.service: Succeeded. [ 30.099811] systemd[1]: Finished Load Kernel Module configfs. [ OK ] Finished Load Kernel Module configfs. [ 30.120124] systemd[1]: modprobe@fuse.service: Succeeded. [ 30.127083] EXT4-fs (vda1): re-mounted. Opts: user_xattr,errors=remount-ro [ 30.130515] systemd[1]: Finished Load Kernel Module fuse. [ OK ] Finished Load Kernel Module fuse. [ 30.154161] systemd[1]: Finished Load Kernel Modules. [ OK ] Finished Load Kernel Modules. [ 30.167932] systemd[1]: Finished Remount Root and Kernel File Systems. [ OK ] Finished Remount Root and Kernel File Systems. [ 30.192962] systemd[1]: Mounting FUSE Control File System... Mounting FUSE Control File System... [ 30.217296] systemd[1]: Mounting Kernel Configuration File System... Mounting Kernel Configuration File System... [ 30.224815] systemd[1]: Condition check resulted in Rebuild Hardware Database being skipped. [ 30.227406] systemd[1]: Condition check resulted in Platform Persistent Storage Archival being skipped. [ 30.245619] systemd[1]: Starting Load/Save Random Seed... Starting Load/Save Random Seed... [ 30.281214] systemd[1]: Starting Apply Kernel Variables... Starting Apply Kernel Variables... [ 30.308693] systemd[1]: Starting Create System Users... Starting Create System Users... [ 30.361144] systemd[1]: Started Journal Service. [ OK ] Started Journal Service. [ OK ] Mounted FUSE Control File System. [ OK ] Mounted Kernel Configuration File System. Starting Flush Journal to Persistent Storage... [ OK ] Finished Apply Kernel Variables. [ OK ] Finished Create System Users. Starting Create Static Device Nodes in /dev... [ OK ] Finished Flush Journal to Persistent Storage. [ OK ] Finished Create Static Device Nodes in /dev. [ OK ] Reached target Local File Systems (Pre). [ OK ] Reached target Local File Systems. Starting Create Volatile Files and Directories... Starting Rule-based Manage…for Device Events and Files... [ OK ] Finished Coldplug All udev Devices. Starting Helper to synchronize boot up for ifupdown... [ OK ] Started Rule-based Manager for Device Events and Files. [ OK ] Finished Create Volatile Files and Directories. Starting Network Time Synchronization... Starting Update UTMP about System Boot/Shutdown... [ 31.623722] random: crng init done [ 31.624395] random: 7 urandom warning(s) missed due to ratelimiting [ OK ] Found device /dev/ttyS0. [ OK ] Finished Load/Save Random Seed. [ OK ] Finished Update UTMP about System Boot/Shutdown. [ OK ] Finished Helper to synchronize boot up for ifupdown. Starting Raise network interfaces... [ OK ] Started Network Time Synchronization. [ OK ] Reached target System Initialization. [ OK ] Started Daily Cleanup of Temporary Directories. [ OK ] Reached target Basic System. [ OK ] Reached target System Time Set. [ OK ] Reached target System Time Synchronized. [ OK ] Started Daily apt download activities. [ OK ] Started Daily apt upgrade and clean activities. [ OK ] Started Periodic ext4 Onli…ata Check for All Filesystems. [ OK ] Started Discard unused blocks once a week. [ OK ] Started Daily rotation of log files. [ OK ] Reached target Timers. [ OK ] Started Regular background program processing daemon. Starting Remove Stale Onli…t4 Metadata Check Snapshots... Starting getty on tty2-tty…nd logind are not available... Starting System Logging Service... [ OK ] Started System Logging Service. [ OK ] Finished getty on tty2-tty… and logind are not available. [ OK ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots. [ OK ] Finished Raise network interfaces. [ OK ] Reached target Network. Starting OpenBSD Secure Shell server... Starting Permit User Sessions... [ OK ] Finished Permit User Sessions. [ OK ] Started Getty on tty1. [ OK ] Started Getty on tty2. [ OK ] Started Getty on tty3. [ OK ] Started Getty on tty4. [ OK ] Started Getty on tty5. [ OK ] Started Getty on tty6. [ OK ] Started Serial Getty on ttyS0. [ OK ] Reached target Login Prompts. [ OK ] Started OpenBSD Secure Shell server. [ OK ] Reached target Multi-User System. [ OK ] Reached target Graphical Interface. Starting Update UTMP about System Runlevel Changes... [ OK ] Finished Update UTMP about System Runlevel Changes.

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

rushi47 commented 2 years ago

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. ]---
lizhirui commented 2 years ago

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)"

alitariq4589 commented 1 year ago

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.