LoginSignup
1

More than 3 years have passed since last update.

TOPPERS/HRP3をQEMUで動作させる

Last updated at Posted at 2020-08-07

はじめに

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

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

動作確認環境

  • Ubuntu 18.04 LTS(WSL含む)

準備

こちらの記事を参照のこと.

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

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

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

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

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

$cd hrp3_3.1
$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 hrp

TOPPERS/HRP3 Kernel Release 3.2.0 for ZYBO_Z7 <Zynq-7000, Cortex-A9> (Aug  7 2020, 23:27:36)
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).   @    |
task3 is running (001).        |  *
task1 is running (002).   @    |
task3 is running (002).        |  *

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

デバッグ

Makefileの編集

./hrp3_3.1/target/zybo_z7_gcc/Makefile を編集して以下を追加.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 hrp3_3.1/obj
$cd make runqd
qemu-system-arm  -M xilinx-zynq-a9 -m 16 -serial null -serial mon:stdio -S -gdb tcp:\:1234 -nographic

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

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

$cd hrp3_3.1/obj
$make gdb
gdb-multiarch -ex="target remote :1234" -ex="monitor system_reset" -ex="load" hrp
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 hrp...done.
Remote debugging using :1234
0x00000000 in ?? ()
Loading section .text_kernel, size 0xe6fc lma 0x100000
Loading section .rodata_kernel, size 0x15000 lma 0x10f000
Loading section .text_shared, size 0x2624 lma 0x124000
Loading section .rodata_shared, size 0xad4 lma 0x127000
Loading section .ARM.exidx, size 0x8 lma 0x127ad4
Start address 0x100000, load size 157692
Transfer rate: 51332 KB/sec, 1946 bytes/write.
(gdb)

実行を開始する.

(gdb) c 

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

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

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

QEMUのビルド

こちらの記事を参照のこと.

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
1