1
0

More than 3 years have passed since last update.

M5StickV で TOPPERS を動かしてみる

Last updated at Posted at 2020-11-23

はじめに

約1年前にK210用のTOPPERSが公開されて、MaixduinoでTOPPERSを動かしてみる で、Maixduino / Maix-Go での動作確認をしてみましたが、最近は同じK210のMPUを搭載したM5StickVを使ったりしているので、M5StickVでもTOPPERSを動かしてみました。

前提条件

前回はWindows PCを使用しましたが、今回はMacを使ってみます。

  • M5StickV
  • Visual Studio Code + Platform IO で Sipeed社Maix-Goボードを導入済み(以下がPlatform IO + Maix-Go環境で導入されます)

開発環境に関しては色々なページで解説されていますので省略します。PATHにツールチェーンを追加しておきます。

TOPPERS/ASPのソースとコンフィギュレータのダウンロード

ダウンロードページ https://www.toppers.jp/asp-d-download.html

から、TOPPERS/ASPカーネル ターゲット非依存部パッケージと、RISC-V HI-FIVE1/K210アーキテクチャ・GCC依存部パッケージ、の2ファイルをダウンロードします。

また、

から、コンフィギュレータ コンフィギュレータ Release 1.9.5(64bit MacOSX用バイナリ) もダウンロードします。

ソースコードの展開

作業用のディレクトリを作成して、ダウンロードしたファイルを格納します。
Finderでファイルを展開するか、以下のようにコンソールでファイルを展開します。

tar xvzf asp-1.9.3.tar.gz
tar xvzf asp_arch_riscv_gcc-1.9.4.tar.gz

aspフォルダー下にソースが展開されます。

コンフィギュレータも解凍します。

mkdir -p asp/cfg/cfg
tar xvzf cfg-osx-static-1_9_5.tar.gz
mv cfg asp/cfg/cfg

ツールチェーンの指定

展開された asp/target/k210_gcc/Makefile.target の39行目にツールチェーンが指定されていますが、Kendryte GNU Toolchainを指定してあげます。ソースコードはEUC-JPのようなので文字化けしますが、vimで該当の行だけ編集する分には問題ありません。

Makefile.target
#39行目
#GCC_TARGET = riscv-none-embed
GCC_TARGET = riscv64-unknown-elf

ビルド

ターゲットとコンフィギュレータを指定して、コンフィギュレーションします。初回の実行時はmacOSが警告を出してコンフィギュレータが実行できません。システム環境設定のセキュリティとプライバシーで、コンフィギュレータの実行許可を与えてください。その後再度コンフィギュレータを実行します。

mkdir OBJ
cd OBJ
perl ../configure -T k210_gcc -g ../cfg/cfg/cfg

ツールチェーンにパスを通して、ビルドを実行します。

PATH=$PATH:~/.platformio/packages/toolchain-kendryte210/bin

make depend
make

サンプルの実行

できあがったaspはELF形式なので、binに変換します。

riscv64-unknown-elf-objcopy -O binary asp asp.bin

フラッシュメモリに書き込みます。

~/.platformio/packages/tool-kflash-kendryte210/kflash.py asp.bin

VSCodeのターミナル等でシリアル接続すると、次のようなログが出力されました。

TOPPERS/ASP Kernel Release 1.9.3 for K210 (Nov 23 2020, 19:08:37)
Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
                            Toyohashi Univ. of Technology, JAPAN
Copyright (C) 2004-2014 by Embedded and Real-Time Systems Laboratory
            Graduate School of Information Science, Nagoya Univ., JAPAN
Copyright (C) 2017-2019 by Education Working Group TOPPERS PROJECT

mSystem logging task is started on port 1.
Sample program starts (exinf = 0).
task1 is running (001).   |
task1 is running (002).   |
task1 is running (003).   |
task1 is running (004).   |
task1 is running (005).   |
task1 is running (006).   |
task1 is running (007).   |
task1 is running (008).   |
task1 is running (009).   |
task1 is running (010).   |
...

Macのscreenも使えるかもしれません。まず、シリアルポートを確認して、

ls -l /dev/tty.*                                                
crw-rw-rw-  1 root  wheel   18,   0 11 13 22:47 /dev/tty.Bluetooth-Incoming-Port
crw-rw-rw-  1 root  wheel   18,   2 11 23 19:10 /dev/tty.usbserial-nnnnnnnnnn

接続します。

screen /dev/tty.usbserial-nnnnnnnnnn

終了は、control + a の後、controlを押したまま'¥'(バックスラッシュ) を押します。

おわり

Maixduino / Maix-Go 同様に、M5StickV でも動作確認できました。

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