LoginSignup
2
2

More than 3 years have passed since last update.

TOPPERS/FMP3をQEMUで動作させる

Last updated at Posted at 2020-08-07

はじめに

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

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

動作確認環境

  • Ubuntu 18.04 LTS(WSL含む)

準備

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

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

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

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

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

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

$cd fmp3_3.1
$mkdir obj
$cd obj
$../configure.rb -T zybo_z7_gcc -w -S "syslog.o banner.o serial.o chip_serial.o logtask.o xuartps.o"
$make

実行

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

TOPPERS/FMP3 Kernel Release 3.1.0 for ZYBO_Z7 <Zynq-7000, Cortex-A9> (Aug  7 2020, 23:13:00)
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

Processor 1 start.
Processor 2 start.
local_inirtn exinf = 1, counter = 1
local_inirtn exinf = 2, counter = 2
Server task 2 starts.
System logging task is started on port 1.
Server task 1 starts.
Sample program starts (exinf = 1).
select tskno 0x11
select cycid 1
select almid 1
select processor 1
select class     1
task1_1 is running on prc1 (001) .   |
task1_1 is running on prc1 (002) .   |

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

デバッグ

Makefileの編集

./fmp3_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 -smp 2
gdb:$(OBJFILE)
        gdb-multiarch -ex="target remote :1234" -ex="monitor system_reset" -ex="load" $(OBJFILE)

実行

コンソールを2個開く.

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

$cd fmp3_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 -smp 2

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

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

$cd fmp3_3.1/obj
$make gdb
gdb-multiarch -ex="target remote :1234" -ex="monitor system_reset" -ex="load" fmp
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 fmp...done.
Remote debugging using :1234
0x00000000 in ?? ()
Loading section .text, size 0xcae8 lma 0x100000
Loading section .rodata, size 0x1dc0 lma 0x10cae8
Loading section .ARM.exidx, size 0x8 lma 0x10e8a8
Loading section .data, size 0x40 lma 0x10e8b0
Loading section .bss, size 0x153e0 lma 0x10e8f0
Start address 0x10003c, load size 146640
Transfer rate: 28640 KB/sec, 1955 bytes/write.
(gdb)

実行を開始する.

(gdb) c 

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

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

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

コア情報の表示

(gdb) info threads 
  Id   Target Id         Frame 
* 1    Thread 1 (CPU#0 [running]) 0x001003b4 in consume_time (ctime=343347000)
    at ../sample/sample1.c:145
  2    Thread 2 (CPU#1 [running]) dispatcher_2 ()
    at ../arch/arm_gcc/common/core_support.S:251

スレッドの切り替え

(gdb) thread 2
[Switching to thread 2 (Thread 2)]
#0  dispatcher_2 () at ../arch/arm_gcc/common/core_support.S:251
251             b               dispatcher_2                    /* 割込み待ち */

QEMUのビルド

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

2
2
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
2
2