鬱猫のつぶやき

鬱猫が日々思っていることをつづります

QEMU RISC-V Fedora の Dockerfileを更新した

RISC-V を簡単に試すことができるDockerfileを作成した。Qiitaの記事からDockerfileの更新したもの。Docker Hubから利用できる。

前回からの変更点として、ブートローダにbblが使われなくなっていることがあげられる。READMEにも以下のような記載がある。

This image introduces bootflow changes. We use now OpenSBI -> U-Boot (S-mode)
[extlinux] -> kernel. The kernel and initramfs are wrapped in U-Boot container
for now. This should change later this year once kernel header patches are
merged in kernel and U-Boot.

OpenSBI -> U-Boot -> kernel の順番で起動するようになったとのこと。

これに伴い、QEMUFedoraを起動する際のコマンドが変わった。

qemu-system-riscv64 -nographic -machine virt -smp 4 -m 2G -kernel fw_payload-uboot-qemu-virt-smode.elf -device virtio-blk-device,drive=hd0 -drive file=Fedora-Developer-Rawhide-20190703.n.0-sda.raw,format=raw,id=hd0 -device virtio-net-device,netdev=usernet -netdev user,id=usernet,hostfwd=tcp::10000-:22

-kernelにはfw_payload-uboot-qemu-virt-smode.elfファームウェアとして指定する。

OSの起動に成功すると以下のような標準出力が表示される。

OpenSBI v0.4 (Jul  3 2019 10:27:18)
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name          : QEMU Virt Machine
Platform HART Features : RV64ACDFIMSU
Platform Max HARTs     : 8
Current Hart           : 2
Firmware Base          : 0x80000000
Firmware Size          : 112 KB
Runtime SBI Version    : 0.1

PMP0: 0x0000000080000000-0x000000008001ffff (A)
PMP1: 0x0000000000000000-0xffffffffffffffff (A,R,W,X)


U-Boot 2019.07-rc4 (Jul 02 2019 - 11:46:47 +0000)

CPU:   rv64imafdcsu
Model: riscv-virtio,qemu
DRAM:  2 GiB
In:    uart@10000000
Out:   uart@10000000
Err:   uart@10000000
Net:   
Warning: virtio-net#1 using MAC address from ROM
eth0: virtio-net#1
Hit any key to stop autoboot:  0 

Device 0: QEMU VirtIO Block Device
            Type: Hard Disk
            Capacity: 8192.0 MB = 8.0 GB (16777216 x 512)
... is now current device
Scanning virtio 0:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
576 bytes read in 10 ms (55.7 KiB/s)
Ignoring unknown command: ui
Ignoring malformed menu command:  autoboot
Ignoring malformed menu command:  hidden
Ignoring unknown command: totaltimeout
Fedora-Developer-Rawhide-20190703.n.0 Boot Options.
1:  Fedora-Developer-Rawhide-20190703.n.0 (5.2.0-0.rc7.git0.1.0.riscv64.fc31.riscv64)
Enter choice: 1:    Fedora-Developer-Rawhide-20190703.n.0 (5.2.0-0.rc7.git0.1.0.riscv64.fc31.riscv64)
Retrieving file: /uInitrd-5.2.0-0.rc7.git0.1.0.riscv64.fc31.riscv64
15447501 bytes read in 89 ms (165.5 MiB/s)
Retrieving file: /uImage-5.2.0-0.rc7.git0.1.0.riscv64.fc31.riscv64
7603947 bytes read in 48 ms (151.1 MiB/s)
append: ro root=UUID=3b75927f-d59f-4b04-96ce-823ead0046bc rhgb quiet LANG=en_US.UTF-8
## Booting kernel from Legacy Image at 84000000 ...
   Image Name:   5.2.0-0.rc7.git0.1.0.riscv64.fc3
   Image Type:   RISC-V Linux Kernel Image (gzip compressed)
   Data Size:    7603883 Bytes = 7.3 MiB
   Load Address: 80200000
   Entry Point:  80200000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 88300000 ...
   Image Name:   initramfs
   Image Type:   RISC-V Linux RAMDisk Image (gzip compressed)
   Data Size:    15447437 Bytes = 14.7 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at ff76dd40
   Booting using the fdt blob at 0xff76dd40
   Uncompressing Kernel Image ... OK
   Using Device Tree in place at 00000000ff76dd40, end 00000000ff771d99

Starting kernel ...

以前と比較してOSの起動にかなり時間がかかる。気長に待つのが良い。