明日にはでっかい太陽が昇るかもしれません。

「覚悟」とは!! 暗闇の荒野に!!進むべき道を切り開く事だッ!

U-Boot (aarch64) on Qemu を動作させたい (1)

なんとか、動作させるまで漕ぎ着けたいな。。

現状は以下のような状態です。

  1. qemu-system-aarch64 -M raspi2 -cpu cortex-a53 -kernel u-boot ... (u-boot with rpi_3_defconfig) は全く(?) 動作していないっぽい。
  2. 同じ aarch64 (cortex-a53) の xlinx-zcu102 (qemu-system-aarch64 -M xlnx-zcu102 -kernel u-boot.elf -nographic -m 2G -drive file=u-boot,id=d,if=none -device ide-drive,drive=d,bus=ide.0) は起動しているので、 qemu / u-boot 自体に問題があるわけではなさそう。

どうすれば raspi3 向け U-Boot を qemu-system-aarch64 で動作させるところまでたどり着けるかは検討ついていませんが、とりあえず手を動かしてみる。

qemu 上でどこまで動作しているのかを知る

qemu-system-aarch64 に gdb をつないでどこまで動作しているか見てみる。

qemu-system-aarch64 \
        -S \
        -gdb tcp::1234 \
        -M raspi2 \
        -cpu cortex-a53 \
        -kernel u-boot/u-boot \
        -nographic \
$ aarch64-linux-gnu-gdb
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
warning: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
(gdb) c
Continuing.
^C
Thread 1 received signal SIGINT, Interrupt.
0x00000004 in ?? ()
(gdb) bt
#0  0x00000004 in ?? ()

さすがにアドレス 0x4 はまったく動いている気配がしない。

仕事で基板立ち上げにほとんど関わった経験もないから、疑わしいところの検討もつかないな、これは。

qemu がどのように動作しているのか知る

rkx1209.hatenablog.com

を参考に、 qemu 側から現在の動作状態を調査してみる。 (u-boot のバイトコードがどこまで処理されているかがわかれば、見直すポイントを知る手助けになるかなーという期待から)

qemu コンソールから info qom-tree を確認すると、 CPU が cortex-a15 となっていた。

(qemu) info qom-tree /
...
  /machine (raspi2-machine)
    /peripheral (container)
    /ram[0] (qemu:memory-region)
    /soc (bcm2836)
      /cpu[0] (cortex-a15-arm-cpu)

コンソールからの -cpu cortex-a53 は無視されている??

取り急ぎ、 raspi2 / bcm2836 のコードをコピペして raspi3 / bcm2837 を作成して解析を続行する。