LoginSignup
6
5

More than 3 years have passed since last update.

QEMUでTOPPERS/ASPカーネルを動かす - 準備編

Posted at

ここまでの記事では、STM32開発ボードでRTOSを動かしてまいりましたが、そもそも私が記事を書いている目的は

より多くの人にRTOSに触れて欲しい

であります。
それに対し、今までの記事は(ほぼ)マイコンボードが手元のある人向けでした。

このボード依存を脱却すべく、、、タイトル通り、エミュレータQEMUでTOPPERS/ASPカーネルを動かしてみようと思います!

本記事はその準備編、F/Wバイナリのビルドまでを実施します。

本編

1. 準備

1-1. 環境

  • Ubuntu 16.04 LTS
  • エミュレート対象ボード: Stellaris LM3S6965 Evaluation Board

    Cortex-M3マイコンボードです(実物は見たことない)。
    QEMUでサポートされており、かつTOPPERSで動作確認済みのためにチョイス。

  • ASPカーネル - ターゲット非依存部は1.9.3 / 依存部は1.7.0

  • StellarisWare Driver Library 10636

    残念ながら、ビルドに必要。

1-2. ASPカーネルの準備

1-2-1. ダウンロード

以下の3つをダウンロードします。

TOPPERS/ASPカーネル ターゲット非依存部パッケージ
https://www.toppers.jp/download.cgi/asp-1.9.3.tar.gz

ARM Cortex-M3アーキテクチャ・GCC依存部パッケージ
https://www.toppers.jp/download.cgi/asp_arch_arm_m_gcc-1.7.0.tar.gz
(lm3sxxxx_gccが含まれる最新版。1.9.0ではありません!)

TOPPERS新世代カーネル用コンフィギュレータ
https://www.toppers.jp/download.cgi/cfg-linux-static-1_9_6.gz

これらを、以下のディレクトリに配置するものとします。

user@user-VirtualBox:~/toppers/stellaris$ ls
asp-1.9.3.tar.gz  asp_arch_arm_m_gcc-1.7.0.tar.gz  cfg-linux-static-1_9_6.gz

加えて、以下をダウンロードしておきます。

  • 会員登録が必要
  • exeインストーラ

という残念さはありますが、、、ここは我慢です。笑

SW-DRL StellarisWare® Driver Library Standalone Package | TI.com
http://www.ti.com/tool/SW-DRL

1-2-2. 展開

基本はこちらの手順と同じ(ファイル名が一部異なるだけ)です。

今回は更に、StellarisWare Driver Libraryのコピーをします。

  1. ダウンロード済みのインストーラをWindowsで実行
  2. 「StellarisWare」フォルダを「asp/target/lm3sxxxx_gcc」ディレクトリにコピー
user@user-VirtualBox:~/toppers/stellaris/asp/target/lm3sxxxx_gcc$ tree -d -L 1 StellarisWare/
StellarisWare/
├── docs
├── driverlib
├── examples
└── inc

4 directories

1-2-3. 文字コード・改行コード変更

こちらの手順と同じ。

1-2-4. StellarisWareの事前ビルド

StellarisWareディレクトリに移動し、何も考えずにmake投入。

user@user-VirtualBox:~/toppers/stellaris/asp/target/lm3sxxxx_gcc/StellarisWare$ make
make[1]: ディレクトリ '/home/user/toppers/stellaris/asp/target/lm3sxxxx_gcc/StellarisWare/driverlib' に入ります
make[2]: ディレクトリ '/home/user/toppers/stellaris/asp/target/lm3sxxxx_gcc/StellarisWare/driverlib' に入ります
  CC    adc.c
(略)
  AR    gcc-cm3/libdriver-cm3.a
make[2]: ディレクトリ '/home/user/toppers/stellaris/asp/target/lm3sxxxx_gcc/StellarisWare/driverlib' から出ます
make[1]: ディレクトリ '/home/user/toppers/stellaris/asp/target/lm3sxxxx_gcc/StellarisWare/driverlib' から出ます

2. ビルド

2-1. configure

ビルド用ディレクトリを作成し、configureを実行します(こちらの手順と類似)。

user@user-VirtualBox:~/toppers/stellaris$ mkdir -p asp/OBJ
user@user-VirtualBox:~/toppers/stellaris$ cd asp/OBJ/
user@user-VirtualBox:~/toppers/stellaris/asp/OBJ$ ../configure --help
configure: -T option is mandatory
Installed targets are:
        dve68k_gcc
        lm3sxxxx_gcc
user@user-VirtualBox:~/toppers/stellaris/asp/OBJ$ ../configure -T lm3sxxxx_gcc -dROM
configure: Generating Makefile from ../sample/Makefile.
configure: Generating sample1.c from ../sample/sample1.c.
configure: Generating sample1.h from ../sample/sample1.h.
configure: Generating sample1.cfg from ../sample/sample1.cfg.
user@user-VirtualBox:~/toppers/stellaris/asp/OBJ$ ls
Makefile  sample1.c  sample1.cfg  sample1.h

2-2. いったんmake

make dependしてみますが、全然通りません。笑

user@user-VirtualBox:~/toppers/stellaris/asp/OBJ$ make depend
if ! [ -f Makefile.depend ]; then \
        rm -f kernel_cfg.timestamp kernel_cfg.h kernel_cfg.c ; \
        rm -f cfg1_out.c cfg1_out.o cfg1_out cfg1_out.syms cfg1_out.srec; \
        rm -f makeoffset.s offset.h; \
fi
rm -f Makefile.depend
../cfg/cfg/cfg --pass 1 --kernel asp -I. -I../include -I../arch -I..  -I../target/lm3sxxxx_gcc -I../target/lm3sxxxx_gcc/StellarisWare -I../arch/arm_m_gcc/common --api-table ../kernel/kernel_api.csv --cfg1-def-table ../kernel/kernel_def.csv  --cfg1-def-table ../arch/arm_m_gcc/common/core_def.csv sample1.cfg
arm-none-eabi-gcc -c  -mlittle-endian -mcpu=cortex-m3 -mthumb  -g  -Wall -O2  -DTOPPERS_LABEL_ASM  -DTOPPERS_ROM -I. -I../include -I../arch -I..  -I../target/lm3sxxxx_gcc -I../target/lm3sxxxx_gcc/StellarisWare -I../arch/arm_m_gcc/common   -DALLFUNC  -I../kernel cfg1_out.c
In file included from cfg1_out.c:7:0:
../target/lm3sxxxx_gcc/target_syssvc.h:74:29: error: unknown type name 'char_t'
 extern void target_fput_log(char_t c);
                             ^
Makefile:393: ターゲット 'cfg1_out.o' のレシピで失敗しました
make: *** [cfg1_out.o] エラー 1

2-3. ビルドを通す

以下の対策をしていきます。

2-3-1. char_t型をやめる

手法は割愛(雑)しますが、char_t型をchar型に置換してください。

2-3-2. Makefile.dependの修正

こちらも雑ですが、以下のdiffを参考にしてください。

user@user-VirtualBox:~/toppers/stellaris/asp/target/lm3sxxxx_gcc$ diff Makefile.target.old Makefile.target
24c24
< #USE_QEMU = true
---
> USE_QEMU = true
35c35
< COPTS := $(COPTS) -mlittle-endian -mcpu=cortex-m3
---
> COPTS := $(COPTS) -mlittle-endian -mcpu=cortex-m3 -nostartfiles
37c37
< LIBS := $(LIBS) $(DRIVER_DIR)/driverlib/gcc/libdriver.a
---
> LIBS := $(LIBS) $(DRIVER_DIR)/driverlib/gcc-cm3/libdriver-cm3.a

2-4. 再度make

今回はビルドが通るはずです!

(OBJフォルダに移動し)
user@user-VirtualBox:~/toppers/stellaris/asp/OBJ$ make depend
(略)
user@user-VirtualBox:~/toppers/stellaris/asp/OBJ$ make
(略)

おわりに

思ったより苦労しましたが、ASPカーネルが簡易パッケージでない(個別パッケージ)ので、こんなものかもしれません・・・。

次回投稿は後半部、いよいよQEMUでF/Wを動作させます!

参考

(特になし)

6
5
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
6
5