OpenSBI qemu risc-v virt machine平台

QEMU RISC-V Virt Machine Platform

QEMU RISC-V Virt Machine 是为 RISC-V 软件开发和测试而创建的虚拟平台。它也被称为 QEMU RISC-V VirtIO 机器,因为它使用 VirtIO 设备进行网络、存储和其他类型的 IO。

要构建特定于平台的库和固件映像,在顶层的make命令使用PLATFORM=generic参数.

Platform Options

QEMU RISC-V Virt Machine平台没有任何平台特定的选项。

编译环境

链接

QEMU RISC-V 64位运行

无负载情况下

build

git clone https://github.com/riscv-software-src/opensbi
cd opensbi && git checkout v1.0 && git checkout -b v1.0
export CROSS_COMPILE=riscv64-linux-gnu-
make PLATFORM=generic

run

$ qemu-system-riscv64 -M virt -m 256M -nographic -bios build/platform/generic/firmware/fw_payload.bin
OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
| |  | |_ __   ___ _ __ | (___ | |_) || |
| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
| |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|


Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 248 KB
Runtime SBI Version       : 0.3


Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
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
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109


Test payload running

U-Boot 作为payload

注意:这里的命令行示例假设U-Boot是使用qemu-riscv64_smode_defconfig配置编译的

u-boot编译

git clone https://github.com/u-boot/u-boot
cd u-boot
export CROSS_COMPILE=riscv64-linux-gnu-
make qemu-riscv64_smode_defconfig
make -j32

编译成功:生成u-boot.bin

 opensbi编译

$ export CROSS_COMPILE=riscv64-linux-gnu-
$ make PLATFORM=generic FW_PAYLOAD_PATH=../u-boot/u-boot.bin
AS        platform/generic/firmware/fw_payload.o
ELF       platform/generic/firmware/fw_payload.elf
OBJCOPY   platform/generic/firmware/fw_payload.bin

run

$ qemu-system-riscv64 -M virt -m 256M -nographic -bios build/platform/generic/firmware/fw_payload.elf


OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
| |  | |_ __   ___ _ __ | (___ | |_) || |
| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
| |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|


Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 248 KB
Runtime SBI Version       : 0.3


Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
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
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109




U-Boot 2022.04-rc4-00006-g4dc9b1771b (Mar 16 2022 - 07:13:54 +0000)


CPU:   rv64imafdcsu
Model: riscv-virtio,qemu
DRAM:  256 MiB
Core:  13 devices, 6 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:    uart@10000000
Out:   uart@10000000
Err:   uart@10000000
Net:   No ethernet found.
Hit any key to stop autoboot:  0


Device 0: unknown device
scanning bus for devices...


Device 0: unknown device
No ethernet found.
No ethernet found.
=>

$ qemu-system-riscv64 -M virt -m 256M -nographic -bios build/platform/generic/firmware/fw_jump.bin -kernel ../u-boot/u-boot.bin


OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
| |  | |_ __   ___ _ __ | (___ | |_) || |
| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
| |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|


Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 248 KB
Runtime SBI Version       : 0.3


Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
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
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109




U-Boot 2022.04-rc4-00006-g4dc9b1771b (Mar 16 2022 - 07:13:54 +0000)


CPU:   rv64imafdcsu
Model: riscv-virtio,qemu
DRAM:  256 MiB
Core:  13 devices, 6 uclasses, devicetree: board
Flash: 32 MiB
Loading Environment from nowhere... OK
In:    uart@10000000
Out:   uart@10000000
Err:   uart@10000000
Net:   No ethernet found.
Hit any key to stop autoboot:  0


Device 0: unknown device
scanning bus for devices...


Device 0: unknown device
No ethernet found.
No ethernet found.
=>

注意:将u-boot目录替换为自己的目录

linux kernel作为payload

注意:我们假设Linux内核是使用arch/riscv/configs/defconfig编译的。

busybox编译

git clone https://github.com/mirror/busybox
cd busybox && git checkout 1_35_0 && git checkout -b 1_35_0
export CROSS_COMPILE=riscv64-linux-gnu-
export ARCH=riscv
make menuconfig

进入menuconfig,配置静态编译

Settings  --->
    [*] Build static binary (no shared libs)
make -j32
make install

变成完成后在busybox下出现_install目录,拷贝此目录到linux目录下,下面有linux的下载

cp -rf _install ../linux/

进入_install目录,新建etc等目录

mkdir etc dev mnt
mkdir -p etc/init.d
touch etc/init.d/rcS

在_install /etc/init.d/目录下新创建一个 rcS 文件,并写入如下内容

$ cat etc/init.d/rcS

mkdir -p /proc
mkdir -p /tmp
mkdir -p /sys
mkdir -p /mnt
/bin/mount -a
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

需要修改etc/init.d/rcS 文件需要可执行权限,可使用 chmod 命令来修改,比如“chmod +x  etc/init.d/rcS”。

在_install/etc 目录新创建一个 fstab 文件,并写入如下内容

proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
debugfs /sys/kernel/debug debugfs defaults 0 0

在_install/etc 目录新创建一个 inittab 文件,并写入如下内容。

::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r

在_install/dev 目录下创建如下设备节点,需要 root 权限。

$ cd dev/
$ sudo mknod console c 5 1
$ sudo mknod null c 1 3

linux kernel编译

git clone git://github.com/torvalds/linux
cd linux && git checkout v5.15 && git checkout -b v5.15
export ARCH=riscv
export CROSS_COMPILE=riscv64-linux-gnu-
make defconfig
make menuconfig

配置initramfs,在initramfs source file中填入_install

General setup  --->
    (_install) Initramfs source file(s)

编译

make -j32

opensbi编译

export CROSS_COMPILE=riscv64-linux-gnu-
make PLATFORM=generic FW_PAYLOAD_PATH=../linux/arch/riscv/boot/Image

run

qemu-system-riscv64 -M virt -m 256M -nographic     \
    -bios build/platform/generic/firmware/fw_jump.bin   \
    -kernel ../linux/arch/riscv/boot/Image  \
    -append "rdinit=/linuxrc console=ttyS0"

启动日志

OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
| |  | |_ __   ___ _ __ | (___ | |_) || |
| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
| |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|


Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 248 KB
Runtime SBI Version       : 0.3


Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
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
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
[    0.000000] Linux version 5.15.0 (richard@s1-ub) (riscv64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #2 SMP Wed Mar 16 08:25:06 UTC 2022
[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Machine model: riscv-virtio,qemu
[    0.000000] efi: UEFI not found.
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x000000008fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x000000008fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000008fffffff]
[    0.000000] SBI specification v0.3 detected
[    0.000000] SBI implementation ID=0x1 Version=0x10000
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI 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 17 pages/cpu s30696 r8192 d30744 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 64135
[    0.000000] Kernel command line: rdinit=/linuxrc console=ttyS0
[    0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    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 - 0xffffffe00fe00000   ( 254 MB)
[    0.000000]       kernel : 0xffffffff80000000 - 0xffffffffffffffff   (2047 MB)
[    0.000000] Memory: 235540K/260096K available (7206K kernel code, 3794K rwdata, 4096K rodata, 3274K init, 299K bss, 24556K 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 debug extended QS entry/exit.
[    0.000000]     Tracing variant of Tasks RCU enabled.
[    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+0x4be/0x6d0 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.000151] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[    0.004740] Console: colour dummy device 80x25
[    0.009975] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[    0.010290] pid_max: default: 32768 minimum: 301
[    0.011989] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.012111] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.046399] ASID allocator using 16 bits (65536 entries)
[    0.047688] rcu: Hierarchical SRCU implementation.
[    0.050090] EFI services will not be available.
[    0.053139] smp: Bringing up secondary CPUs ...
[    0.053267] smp: Brought up 1 node, 1 CPU
[    0.061335] devtmpfs: initialized
[    0.068049] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.068327] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.073889] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.118594] vgaarb: loaded
[    0.119921] SCSI subsystem initialized
[    0.122049] usbcore: registered new interface driver usbfs
[    0.122394] usbcore: registered new interface driver hub
[    0.122623] usbcore: registered new device driver usb
[    0.132676] clocksource: Switched to clocksource riscv_clocksource
[    0.165886] NET: Registered PF_INET protocol family
[    0.167116] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.170734] tcp_listen_portaddr_hash hash table entries: 128 (order: 0, 5120 bytes, linear)
[    0.170892] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.171308] TCP bind hash table entries: 2048 (order: 4, 65536 bytes, linear)
[    0.171517] TCP: Hash tables configured (established 2048 bind 2048)
[    0.173725] UDP hash table entries: 256 (order: 2, 24576 bytes, linear)
[    0.174030] UDP-Lite hash table entries: 256 (order: 2, 24576 bytes, linear)
[    0.175325] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.180696] RPC: Registered named UNIX socket transport module.
[    0.180826] RPC: Registered udp transport module.
[    0.180941] RPC: Registered tcp transport module.
[    0.181006] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.181212] PCI: CLS 0 bytes, default 64
[    0.193502] workingset: timestamp_bits=62 max_order=16 bucket_order=0
[    0.221580] NFS: Registering the id_resolver key type
[    0.222391] Key type id_resolver registered
[    0.222472] Key type id_legacy registered
[    0.222847] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.222977] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.228860] 9p: Installing v9fs 9p2000 file system support
[    0.230120] NET: Registered PF_ALG protocol family
[    0.230643] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.230788] io scheduler mq-deadline registered
[    0.230908] io scheduler kyber registered
[    0.242305] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[    0.243018] pci-host-generic 30000000.pci:       IO 0x0003000000..0x000300ffff -> 0x0000000000
[    0.243428] pci-host-generic 30000000.pci:      MEM 0x0040000000..0x007fffffff -> 0x0040000000
[    0.244940] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[    0.245957] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[    0.246165] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.246299] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.246376] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[    0.247569] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.498997] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.506182] printk: console [ttyS0] disabled
[    0.509473] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 1, base_baud = 230400) is a 16550A
[    0.537922] printk: console [ttyS0] enabled
[    0.540687] [drm] radeon kernel modesetting enabled.
[    0.559656] loop: module loaded
[    0.562826] libphy: Fixed MDIO Bus: probed
[    0.564863] e1000e: Intel(R) PRO/1000 Network Driver
[    0.565091] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.565777] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.566143] ehci-pci: EHCI PCI platform driver
[    0.566606] ehci-platform: EHCI generic platform driver
[    0.567049] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.567420] ohci-pci: OHCI PCI platform driver
[    0.567857] ohci-platform: OHCI generic platform driver
[    0.569682] usbcore: registered new interface driver uas
[    0.570159] usbcore: registered new interface driver usb-storage
[    0.571320] mousedev: PS/2 mouse device common for all mice
[    0.573280] sdhci: Secure Digital Host Controller Interface driver
[    0.573555] sdhci: Copyright(c) Pierre Ossman
[    0.573887] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.575089] usbcore: registered new interface driver usbhid
[    0.575350] usbhid: USB HID core driver
[    0.577376] NET: Registered PF_INET6 protocol family
[    0.584857] Segment Routing with IPv6
[    0.585286] In-situ OAM (IOAM) with IPv6
[    0.585895] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.589115] NET: Registered PF_PACKET protocol family
[    0.590570] 9pnet: Installing 9P2000 support
[    0.591057] Key type dns_resolver registered
[    0.594732] debug_vm_pgtable: [debug_vm_pgtable         ]: Validating architecture page table helpers
[    0.634428] Freeing unused kernel image (initmem) memory: 3272K
[    0.635188] Run /linuxrc as init process

qemu-system-riscv64 -M virt -m 256M -nographic \
        -kernel build/platform/generic/firmware/fw_payload.elf \
        -append "rdinit=/linuxrc console=ttyS0"

启动日志:

OpenSBI v1.0
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
| |  | |_ __   ___ _ __ | (___ | |_) || |
| |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
| |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|


Platform Name             : riscv-virtio,qemu
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : aclint-mswi
Platform Timer Device     : aclint-mtimer @ 10000000Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform Reboot Device    : sifive_test
Platform Shutdown Device  : sifive_test
Firmware Base             : 0x80000000
Firmware Size             : 248 KB
Runtime SBI Version       : 0.3


Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x0000000002000000-0x000000000200ffff (I)
Domain0 Region01          : 0x0000000080000000-0x000000008003ffff ()
Domain0 Region02          : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address      : 0x0000000080200000
Domain0 Next Arg1         : 0x0000000082200000
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
Boot HART PMP Count       : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 54
Boot HART MHPM Count      : 0
Boot HART MIDELEG         : 0x0000000000000222
Boot HART MEDELEG         : 0x000000000000b109
[    0.000000] Linux version 5.15.0 (richard@s1-ub) (riscv64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #2 SMP Wed Mar 16 08:25:06 UTC 2022
[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] Machine model: riscv-virtio,qemu
[    0.000000] efi: UEFI not found.
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x000000008fffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x000000008fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000008fffffff]
[    0.000000] SBI specification v0.3 detected
[    0.000000] SBI implementation ID=0x1 Version=0x10000
[    0.000000] SBI TIME extension detected
[    0.000000] SBI IPI extension detected
[    0.000000] SBI 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 17 pages/cpu s30696 r8192 d30744 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 64135
[    0.000000] Kernel command line: rdinit=/linuxrc console=ttyS0
[    0.000000] Dentry cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    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 - 0xffffffe00fe00000   ( 254 MB)
[    0.000000]       kernel : 0xffffffff80000000 - 0xffffffffffffffff   (2047 MB)
[    0.000000] Memory: 235540K/260096K available (7206K kernel code, 3794K rwdata, 4096K rodata, 3274K init, 299K bss, 24556K 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 debug extended QS entry/exit.
[    0.000000]     Tracing variant of Tasks RCU enabled.
[    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+0x4be/0x6d0 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.000149] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[    0.004713] Console: colour dummy device 80x25
[    0.009905] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[    0.010197] pid_max: default: 32768 minimum: 301
[    0.011860] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.011979] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.055040] ASID allocator using 16 bits (65536 entries)
[    0.057212] rcu: Hierarchical SRCU implementation.
[    0.060713] EFI services will not be available.
[    0.065650] smp: Bringing up secondary CPUs ...
[    0.065832] smp: Brought up 1 node, 1 CPU
[    0.078889] devtmpfs: initialized
[    0.089237] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.089708] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.098706] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.142452] vgaarb: loaded
[    0.143555] SCSI subsystem initialized
[    0.145830] usbcore: registered new interface driver usbfs
[    0.146331] usbcore: registered new interface driver hub
[    0.146561] usbcore: registered new device driver usb
[    0.156905] clocksource: Switched to clocksource riscv_clocksource
[    0.191216] NET: Registered PF_INET protocol family
[    0.192591] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.196265] tcp_listen_portaddr_hash hash table entries: 128 (order: 0, 5120 bytes, linear)
[    0.196432] TCP established hash table entries: 2048 (order: 2, 16384 bytes, linear)
[    0.197090] TCP bind hash table entries: 2048 (order: 4, 65536 bytes, linear)
[    0.197329] TCP: Hash tables configured (established 2048 bind 2048)
[    0.200124] UDP hash table entries: 256 (order: 2, 24576 bytes, linear)
[    0.200448] UDP-Lite hash table entries: 256 (order: 2, 24576 bytes, linear)
[    0.202053] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.207033] RPC: Registered named UNIX socket transport module.
[    0.207125] RPC: Registered udp transport module.
[    0.207182] RPC: Registered tcp transport module.
[    0.207234] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.207383] PCI: CLS 0 bytes, default 64
[    0.214709] workingset: timestamp_bits=62 max_order=16 bucket_order=0
[    0.246590] NFS: Registering the id_resolver key type
[    0.247422] Key type id_resolver registered
[    0.247506] Key type id_legacy registered
[    0.247907] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.248045] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[    0.253225] 9p: Installing v9fs 9p2000 file system support
[    0.254563] NET: Registered PF_ALG protocol family
[    0.255097] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    0.255251] io scheduler mq-deadline registered
[    0.255387] io scheduler kyber registered
[    0.267059] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[    0.267832] pci-host-generic 30000000.pci:       IO 0x0003000000..0x000300ffff -> 0x0000000000
[    0.268275] pci-host-generic 30000000.pci:      MEM 0x0040000000..0x007fffffff -> 0x0040000000
[    0.269955] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[    0.271035] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[    0.271248] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.271375] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.271454] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[    0.272668] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.535350] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.543014] printk: console [ttyS0] disabled
[    0.546003] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 1, base_baud = 230400) is a 16550A
[    0.571135] printk: console [ttyS0] enabled
[    0.573915] [drm] radeon kernel modesetting enabled.
[    0.593709] loop: module loaded
[    0.596464] libphy: Fixed MDIO Bus: probed
[    0.598561] e1000e: Intel(R) PRO/1000 Network Driver
[    0.598842] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.599493] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.599846] ehci-pci: EHCI PCI platform driver
[    0.600277] ehci-platform: EHCI generic platform driver
[    0.600958] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.601333] ohci-pci: OHCI PCI platform driver
[    0.601752] ohci-platform: OHCI generic platform driver
[    0.603493] usbcore: registered new interface driver uas
[    0.603997] usbcore: registered new interface driver usb-storage
[    0.605541] mousedev: PS/2 mouse device common for all mice
[    0.607211] sdhci: Secure Digital Host Controller Interface driver
[    0.607489] sdhci: Copyright(c) Pierre Ossman
[    0.607837] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.609513] usbcore: registered new interface driver usbhid
[    0.609811] usbhid: USB HID core driver
[    0.611786] NET: Registered PF_INET6 protocol family
[    0.620397] Segment Routing with IPv6
[    0.621173] In-situ OAM (IOAM) with IPv6
[    0.621838] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.625366] NET: Registered PF_PACKET protocol family
[    0.626921] 9pnet: Installing 9P2000 support
[    0.627458] Key type dns_resolver registered
[    0.631241] debug_vm_pgtable: [debug_vm_pgtable         ]: Validating architecture page table helpers
[    0.672969] Freeing unused kernel image (initmem) memory: 3272K
[    0.678169] Run /linuxrc as init process

Debugging with GDB

qemu run opensbi

qemu-system-riscv64 -M virt -m 256M -nographic -bios \
    build/platform/generic/firmware/fw_payload.bin -s -S

开启另一个终端

gdb-multiarch --tui  \
    build/platform/generic/firmware/fw_payload.elf \
    -ex 'target remote localhost:1234'

  • 6
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

byd yes

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值