TinyEMUはQEMUを開発したFabrice Bellard氏が開発したRISC-Vシミュレータだ。
さらに彼はRISC-VのLinuxを起動するためのbuildrootも用意したらしい。RISC-VのMLにアナウンスがあった。
とりあえず超高速のシミュレータでRISC-V Linuxを起動することができるみたいなので、試行してみた。
Buildroot / ツールチェインのダウンロード
まずはBellard氏が作ったツールチェインとイメージをすべてダウンロードする。
curl -L https://bellard.org/tinyemu/buildroot-riscv-2018-09-22.tar.gz | tar xz curl -L https://bellard.org/tinyemu/diskimage-linux-riscv-2018-09-22.tar.gz | tar xz curl -L https://bellard.org/tinyemu/tinyemu-2018-09-15.tar.gz | tar xz
次に、buildrootを構成する。今回は64-bit版で構成した。
cd buildroot-riscv-2018-09-22/ cp configs/riscv64_defconfig .config make menuconfig make
正常に終了すると、bulidrootのイメージが作成される。
TinyEMUのビルド
次に、RISC-VシミュレータであるTinyEMUをビルドする。
cd temu-2018-09-15 make
Linuxの実行
最後にLinuxを実行する。先ほど展開したdiskimage-linux-riscv-2018-09-22
のディレクトリに移り、設定ファイルを変更する。
buildroot-riscv64.cfg
内のファイルパスに問題があれば変更する。今回は変更せずに実行できる。
buildroot-riscv64.cfg
/* VM configuration file */ { version: 1, machine: "riscv64", memory_size: 256, bios: "bbl64.bin", cmdline: "console=hvc0 root=/dev/vda rw", drive0: { file: "../buildroot-riscv-2018-09-22/output/images/rootfs.ext2" }, eth0: { driver: "user" }, }
これでシミュレータを実行した。簡単に実行できる。さすがだなあ。
../temu-2018-09-15/temu buildroot-riscv64.cfg ... Jan 1 00:00:00 localhost user.info kernel: [ 0.199194] devtmpfs: mounted Jan 1 00:00:00 localhost user.info kernel: [ 0.199851] Freeing unused kernel memory: 80K Jan 1 00:00:00 localhost user.warn kernel: [ 0.199943] This architecture does not have kernel memory protection. Jan 1 00:00:00 localhost user.info kernel: [ 0.233068] EXT4-fs (vda): re-mounted. Opts: block_validity,barrier,user_xattr,errors=remount-ro Starting network... ifup: can't open '/var/run/ifstate': No such file or directory Starting dropbear sshd: OK Jan 1 00:00:00 localhost daemon.info init: starting pid 74, tty '/dev/console': '/sbin/getty -L console 0 vt100 ' Jan 1 00:00:00 localhost authpriv.info dropbear[73]: Running in background Welcome to Buildroot localhost login: