LoginSignup
9
3

More than 3 years have passed since last update.

TOPPERS/ASP3をQEMUで動作させ

Last updated at Posted at 2020-08-07

はじめに

Ubuntu(WSLも含む)上でQEMUを使ってTOPPERS新世代カーネルのASP3,を実行する方法について説明します.

実機で実行する方法はマニュアルに記載しています.

動作確認環境

  • Ubuntu 18.04 LTS(WSL含む)

準備

以下のコマンドで必要なツールをインストール.

sudo apt install wget ruby build-essential gcc-arm-none-eabi gdb-multiarch libpixman-1-0 libjpeg-dev 

QEMU本体のバイナリをダウンロードして展開

wget https://github.com/toppers/qemu_zynq/releases/download/v2.12.0-toppers/qemu-system-arm.zip
unzip qemu-system-arm.zip 
chmod +x qemu-system-arm

作成したQEMUはパスの通るディレクトリ(~/bin等)にコピーします.

ASP3カーネルのビルドと実行

ソースコードのダウンロード.

新しいバージョンがあれば読み替えます.

wget https://www.toppers.jp/download.cgi/asp3_zybo_z7_gcc-20191009.zip
unzip asp3_zybo_z7_gcc-20191009.zip

プロジェクトの作成とビルド.

cd asp3_3.5
mkdir obj
cd obj
../configure.rb -T zybo_z7_gcc
make

実行

make runq
qemu-system-arm -M xilinx-zynq-a9 -semihosting -m 512M \
        -serial null -serial mon:stdio -nographic -smp 1 -kernel asp

TOPPERS/ASP3 Kernel Release 3.5.0 for ZYBO <Zynq-7000, Cortex-A9> (Aug  7 2020, 22:23:45)
Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
                            Toyohashi Univ. of Technology, JAPAN
Copyright (C) 2004-2019 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN

System logging task is started.
Sample program starts (exinf = 0).
task1 is running (001).   |
task1 is running (002).   |
task1 is running (003).   |

終了するには,Ctrl-Aの後にxを押します.

デバッグ

Makefile.targetの編集

./asp3_3.5/target/zybo_z7_gcc/Makefile.target を編集して以下を追加.Makefileなのでルールの箇所はタブにします.

runqd:$(OBJFILE)
        $(QEMU)  -M xilinx-zynq-a9 -m 16 -serial null -serial mon:stdio -S -gdb tcp::1234 -nographic
gdb:$(OBJFILE)
        gdb-multiarch -ex="target remote :1234" -ex="monitor system_reset" -ex="load" $(OBJFILE)

実行

コンソールを2個開く.

コンソール1 : QEMUを実行.必ずこちらから実行すること.

cd asp3_3.5/obj
make runqd

コンソール2 : デバッガを実行.

ターゲットへの接続,リセット,プログラムのロードが行われる.

cd asp3_3.5/obj
make gdb
gdb-multiarch -ex="target remote :1234" -ex="monitor system_reset" -ex="load" asp
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from asp...done.
Remote debugging using :1234
0x0efa7000 in ?? ()
Loading section .text, size 0x81a4 lma 0x100000
Loading section .rodata, size 0x754 lma 0x1081a4
Loading section .rodata.str1.4, size 0xd28 lma 0x1088f8
Loading section .ARM.exidx, size 0x8 lma 0x109620
Start address 0x10003c, load size 38440
Transfer rate: 37539 KB/sec, 1830 bytes/write.

実行を開始する.

(gdb) c 

実行を中断するにはCtrl-Cを押す.再度最初から実行したい場合はexitでgdbを終了して再び make gdb で実行.

gdbの簡単なコマンドは次の通り.

  • c : 実行再開
  • b : ブレークポイントを置く
  • list : ファイル表示
  • stpi : 命令ステップ

QEMUのビルド

Mac等でソースコードからビルドしたい方は,以下のコマンドでビルド可能なはずです(未確認).

git clone -b stable-2.12_toppers https://github.com/toppers/qemu_zynq.git
cd qemu_zynq
./configure --target-list=arm-softmmu
make

変更履歴

2020/08/18
・インストールするパッケージに抜けが抜けがあったので追加.

9
3
2

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
9
3