0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TOPPERS/ASP3をQEMUで動かしてみた(実機なし)

0
Posted at

はじめに

TOPPERS/ASP3カーネルを、実機(ZYBO Z7)なしでMacBook上のQEMUで動かす環境構築の手順です。

Apple Silicon(M1/M2/M3)で動作確認済みです。

環境

項目 内容
OS macOS(Apple Silicon)
カーネル TOPPERS/ASP3 Release 3.7.1
ターゲット ZYBO Z7(Zynq-7000, Cortex-A9)
エミュレータ QEMU xilinx-zynq-a9

手順

1. QEMUとRubyのインストール

brew install qemu ruby

2. ARMクロスコンパイラのインストール

バージョン選択が重要です。

  • brew install arm-none-eabi-gcc → GCC 16.x が入るが NG(newlib欠如でビルドエラー)
  • brew install --cask gcc-arm-embedded → GCC 15.x が入るが NG(TECSgenとの非互換。TOPPERS/ASP3はビルド時にTECSgen=Rubyスクリプトを使うため、新しいGCCのABI変更が影響する)
  • Arm公式サイトから GCC 13.3 を入れる → ✅ OK

Arm GNU Toolchain Downloads を開き、以下を選択してダウンロード・インストールします。

  • バージョン: 13.3.Rel1
  • ホスト: macOS (Apple silicon) hosted cross toolchains
  • ターゲット: AArch32 bare-metal target (arm-none-eabi)
  • 形式: .pkg

インストール後、バージョンを確認します。

/Applications/ArmGNUToolchain/13.3.rel1/arm-none-eabi/bin/arm-none-eabi-gcc --version
# arm-none-eabi-gcc ... 13.3.1 ...

3. ASP3パッケージのダウンロードと展開

TOPPERS/ASP3カーネル簡易パッケージ から asp3_zybo_z7_gcc-20230418.zip をダウンロードします。

unzip asp3_zybo_z7_gcc-20230418.zip
cd asp3_3.7

4. ビルド

GCC 13.3をPATHに追加してからビルドします。

export PATH="/Applications/ArmGNUToolchain/13.3.rel1/arm-none-eabi/bin:$PATH"

mkdir obj && cd obj
ruby ../configure.rb -T zybo_z7_gcc
make

5. QEMUで実行

make runq

以下のように出力されれば成功です。

TOPPERS/ASP3 Kernel Release 3.7.1 for ZYBO <Zynq-7000, Cortex-A9> ...
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 を押します(同時押しではありません)。

PATHの永続化

毎回 export PATH=... を実行するのが手間な場合は .zshrc に追記します。

echo 'export PATH="/Applications/ArmGNUToolchain/13.3.rel1/arm-none-eabi/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

ディレクトリ構成(参考)

asp3_3.7/
├── sample/          ← 編集するソースコード
│   ├── sample1.c    ← タスク関数の実装
│   ├── sample1.h    ← 優先度・スタックサイズ等の定数定義
│   └── sample1.cfg  ← カーネルへのタスク登録(CRE_TSK等)
├── kernel/          ← カーネル本体(編集不要)
├── target/          ← ターゲット依存部(編集不要)
└── obj/             ← ビルド生成物(makeで自動生成)
    ├── Makefile     ← configure.rbが生成
    ├── asp          ← 実行バイナリ
    └── gen/         ← TECSgenが自動生成したCコード

おわりに

Macではツールチェーンのバージョン選択がハマりポイントです。Arm公式のGCC 13.3 を使うことで解決できました。

環境が整ったら sample/sample1.c を読みながら、タスクの追加やサービスコールの動作を試してみてください。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?