无法在 Ubuntu 18.04 上使用 Qemu 启动 RISC-V

无法在 Ubuntu 18.04 上使用 Qemu 启动 RISC-V

我正在尝试在 Ubuntu 机器 18.04 上使用 Qemu 运行 RISCV。为此,我遵循了以下教程:

但按照所有步骤操作后,我遇到了这个问题(请参阅下面的完整启动日志):

[ 0.400573] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.

我尝试挂载创建的 .img 文件,并且看到 /sbin/init 存在

rushi@watershed:/mnt/rootfs$ ll sbin/init
lrwxrwxrwx 1 root root 14 Dec 21 21:41 sbin/init -> ../bin/busybox*
rushi@watershed:/mnt/rootfs/sbin$ ll ../bin/busybox
-rwxr-xr-x 1 root root 989272 Dec 21 21:41 ../bin/busybox*

我对所有 RISCV 开发和系统启动过程、一般编译都是陌生的。非常感谢您的帮助。

以下是完整的启动日志:

user~/riscv64-linux$ 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 (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.000102] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[    0.003386] Console: colour dummy device 80x25
[    0.004764] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[    0.004930] pid_max: default: 32768 minimum: 301
[    0.008515] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.008564] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.034175] rcu: Hierarchical SRCU implementation.
[    0.036327] smp: Bringing up secondary CPUs ...
[    0.036403] smp: Brought up 1 node, 1 CPU
[    0.045787] devtmpfs: initialized
[    0.051744] random: get_random_u32 called from bucket_table_alloc.isra.0+0x4e/0x150 with crng_init=0
[    0.053928] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.054075] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.056622] NET: Registered protocol family 16
[    0.099525] vgaarb: loaded
[    0.100575] SCSI subsystem initialized
[    0.102143] usbcore: registered new interface driver usbfs
[    0.102453] usbcore: registered new interface driver hub
[    0.102622] usbcore: registered new device driver usb
[    0.110644] clocksource: Switched to clocksource riscv_clocksource
[    0.126588] NET: Registered protocol family 2
[    0.127458] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.130630] tcp_listen_portaddr_hash hash table entries: 512 (order: 1, 8192 bytes, linear)
[    0.130731] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.130939] TCP bind hash table entries: 8192 (order: 5, 131072 bytes, linear)
[    0.131127] TCP: Hash tables configured (established 8192 bind 8192)
[    0.132583] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.132818] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.134108] NET: Registered protocol family 1
[    0.136391] RPC: Registered named UNIX socket transport module.
[    0.136457] RPC: Registered udp transport module.
[    0.136482] RPC: Registered tcp transport module.
[    0.136498] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.136592] PCI: CLS 0 bytes, default 64
[    0.143017] workingset: timestamp_bits=62 max_order=18 bucket_order=0
[    0.154976] NFS: Registering the id_resolver key type
[    0.155730] Key type id_resolver registered
[    0.155785] Key type id_legacy registered
[    0.155901] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.156003] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.156506] 9p: Installing v9fs 9p2000 file system support
[    0.157700] NET: Registered protocol family 38
[    0.157962] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.158088] io scheduler mq-deadline registered
[    0.158171] io scheduler kyber registered
[    0.160653] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[    0.161119] pci-host-generic 30000000.pci:    IO 0x03000000..0x0300ffff -> 0x00000000
[    0.161572] pci-host-generic 30000000.pci:   MEM 0x40000000..0x7fffffff -> 0x40000000
[    0.161637] pci-host-generic 30000000.pci:   MEM 0x400000000..0x7ffffffff -> 0x400000000
[    0.163515] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[    0.164317] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[    0.164487] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.164605] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.164624] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[    0.164638] pci_bus 0000:00: root bus resource [mem 0x400000000-0x7ffffffff]
[    0.166493] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.236158] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.242182] printk: console [ttyS0] disabled
[    0.243277] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 10, base_baud = 230400) is a 16550A
[    0.267699] printk: console [ttyS0] enabled
[    0.269576] [drm] radeon kernel modesetting enabled.
[    0.282172] loop: module loaded
[    0.291691] virtio_blk virtio0: [vda] 102400 512-byte logical blocks (52.4 MB/50.0 MiB)
[    0.310649] libphy: Fixed MDIO Bus: probed
[    0.311762] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[    0.312026] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.312608] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.312982] ehci-pci: EHCI PCI platform driver
[    0.313376] ehci-platform: EHCI generic platform driver
[    0.313809] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.314134] ohci-pci: OHCI PCI platform driver
[    0.314614] ohci-platform: OHCI generic platform driver
[    0.315707] usbcore: registered new interface driver uas
[    0.316137] usbcore: registered new interface driver usb-storage
[    0.317205] mousedev: PS/2 mouse device common for all mice
[    0.318871] usbcore: registered new interface driver usbhid
[    0.319160] usbhid: USB HID core driver
[    0.320916] NET: Registered protocol family 10
[    0.326954] Segment Routing with IPv6
[    0.327577] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.330230] NET: Registered protocol family 17
[    0.331759] 9pnet: Installing 9P2000 support
[    0.332245] Key type dns_resolver registered
[    0.347909] EXT4-fs (vda): mounting ext2 file system using the ext4 subsystem
[    0.357523] EXT4-fs (vda): mounted filesystem without journal. Opts: (null)
[    0.358113] VFS: Mounted root (ext2 filesystem) readonly on device 254:0.
[    0.363449] devtmpfs: mounted
[    0.382965] Freeing unused kernel memory: 212K
[    0.383233] This architecture does not have kernel memory protection.
[    0.383571] Run /sbin/init as init process
[    0.398108] Run /etc/init as init process
[    0.398596] Run /bin/init as init process
[    0.399549] Run /bin/sh as init process
[    0.400573] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[    0.401379] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.166 #2
[    0.401701] Call Trace:
[    0.401947] [<ffffffe000037ad0>] walk_stackframe+0x0/0xa6
[    0.402232] [<ffffffe000643072>] show_stack+0x2e/0x38
[    0.402510] [<ffffffe00064b914>] dump_stack+0x66/0x80
[    0.402757] [<ffffffe0006431bc>] panic+0xd6/0x260
[    0.402978] [<ffffffe00064bb4e>] kernel_init+0xbc/0xc8
[    0.403215] [<ffffffe0000367e4>] ret_from_exception+0x0/0xc
[    0.404033] ---[ end Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
QEMU: Terminated

相关内容