LoginSignup
7
7

More than 5 years have passed since last update.

QEMUでRaspberry Pi 64bit + リアルタイムOS(TOPPERS/FMP)をエミュレートする

Last updated at Posted at 2018-10-28

QEMUでリアルタイムOSを動かす

以下のRaspberry Pi 3 AArch64モード + TOPPERS/FMPカーネルの環境をQEMUでエミュレートする.
https://qiita.com/toshinaga/items/672c41a1f390922d5bae
実機レスの動作,検証が可能になる.

必要な機材

  • Linux PCのみ
    ビルド,および動作に使用する.
    VirtualBox + Ubuntu 16.04上を使用した.

開発環境の構築

  • コンパイラ
    以下からフリーのARMv8 AArch64用コンパイラを入手する.
    https://www.linaro.org/downloads/
    Versionはgcc-linaro-6.3.1-2017.02-xxx_aarch64-elfを使用した.
    xxxはPC環境によって適切なものを選択する.
    ダウンロードして適当な場所に展開したら以下にpathに通す.
    <解凍したディレクトリ>/gcc-linaro-6.3.1-2017.02-xxx_aarch64-elf/bin

  • コンフィギュレータ
    以下からコンフィギュレータを入手する.
    https://www.toppers.jp/cfg-download.html

  • QEMU
    以下を実行してQEMUをインストールして,~/opt/qemu/binにpathを通す.

git clone git://git.qemu.org/qemu.git
cd qemu
# git checkout stable-2.12  # 2018/10/26時点の最新stableにはUART割込みにバグがありmasterを使用する
git submodule init
git submodule update --recursive
cd ..
mkdir qemu_build
cd qemu_build
../qemu/configure --prefix=~/opt/qemu --target-list=aarch64-softmmu
make
make install

ビルド

リポジトリを取得してfmpをビルドする.

git clone https://github.com/YujiToshinaga/RPi64Toppers.git
cd RPi64Toppers/fmp
mkdir -p cfg/cfg
mv <コンフィギュレータを解凍したディレクトリ>/cfg cfg/cfg
chmod 755 cfg/cfg/cfg
mkdir build
cd build
perl ../configure -T rpi_arm64_gcc
make fmp

起動

ビルドしたfmpを引数に指定して以下を実行する.

qemu-system-aarch64 -M raspi3 -m 256 -serial null -serial mon:stdio -kernel fmp -nographic -smp 4

QEMUを終了するには Ctrl-a, x を実行する.

GDB(デバッガ)を用いた起動

GDBからQEMUに接続することで、GDBのコマンドによるステップ実行やブレーク,QEMUのコマンドによるレジスタの中身の参照などのデバッグが可能になる.

ターミナルを開き,QEMUを起動する.

qemu-system-aarch64 -M raspi3 -m 256 -serial null -serial mon:stdio -S -gdb tcp::1234 -nographic -smp 4

さらに別のターミナルを開き,GDBを実行してFMPを実行する.

aarch64-elf-gdb fmp
(gdb) target remote localhost:1234
(gdb) load
(gdb) monitor system_reset
(gdb) continue
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7