LoginSignup
1
1

More than 3 years have passed since last update.

TOPPERS/HRMP3をQEMUで動作させる

Last updated at Posted at 2020-08-07

はじめに

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

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

動作確認環境

  • Ubuntu 18.04 LTS(WSL含む)

準備

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

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

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

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

$wget https://www.toppers.jp/download.cgi/hrmp3_zybo_z7_gcc-20200331.zip
$unzip hrmp3_zybo_z7_gcc-20200331.zip

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

$cd hrmp3_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 hrmp

TOPPERS/HRMP3 Kernel Release 3.1.1 for ZYBO_Z7 <Zynq-7000, Cortex-A9> (Aug  7 2020, 23:37:40)
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.
System logging task is started on port 1.
Sample program starts (exinf = 0).
TASK1_1 is running (001).   @   |   ||     |
TASK2_1 is running (001).       |   || %   |
TASK1_3 is running (001).       | * ||     |
TASK2_3 is running (001).       |   ||     | &
TASK1_1 is running (002).   @   |   ||     |
TASK2_1 is running (002).       |   || %   |
TASK2_3 is running (002).       |   ||     | &
TASK1_3 is running (002).       | * ||     |
TASK1_1 is running (003).   @   |   ||     |
TASK2_1 is running (003).       |   || %   |
TASK2_3 is running (003).       |   ||     | &
TASK1_3 is running (003).       | * ||     |

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

デバッグ

Makefileの編集

./hrmp3_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 hrmp3_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 hrmp3_3.1/obj
$make gdb
gdb-multiarch -ex="target remote :1234" -ex="monitor system_reset" -ex="load" hrmp
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 hrmp...done.
Remote debugging using :1234
0x00000000 in ?? ()
Loading section .text_kernel, size 0x124dc lma 0x100000
Loading section .rodata_kernel, size 0x15000 lma 0x113000
Loading section .text_shared, size 0x26a8 lma 0x128000
Loading section .rodata_shared, size 0xddc lma 0x12b000
Loading section .ARM.exidx, size 0x8 lma 0x12bddc
Loading section .data_shared, size 0x30 lma 0x144000
Start address 0x100000, load size 174488
Transfer rate: 42599 KB/sec, 1960 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のビルド

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

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