4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NUCLEO-F767ZIでTOPPERS/ASP3とmrubyを動かす

Last updated at Posted at 2020-08-22

STMicroelectronicsのNUCLEO-F767ZIでTOPPERS/ASP3とmrubyを動かす方法です。
動作確認には「sample1」のmruby版を使います。

インストール

ARM用gccがインストールされていない場合はインストールしておいてください。

本記事はすべて同じディレクトリにcloneすることを想定しています。

$ls -1
application-samples
asp3-f767zi
mruby
mruby-stm-nucleo-toppers
mruby-tlsf
mruby-toppers-sample1

違う場所に置きたい場合は、パスに関する記述を修正してください。

TOPPERS/ASP3

NUCLEO-F767ZI 用ASP3が以下の場所にあります。

git clone https://github.com/yurie/asp3-f767zi.git

mruby

本記事ではmruby3ブランチを使用しています。
動作確認済バージョンは8/7の以下のハッシュ値です。動作確認済みのバージョンで試す場合は3行目のcheckoutを行ってください。
checkoutしたら元のディレクトリに戻っておくのを忘れないでね!

git clone -b mruby3 https://github.com/mruby/mruby.git
cd mruby
git checkout 9c2fcd8c4bdbe6817a99e3fcb8a12eed142baa0b
cd ..

必要なmrbgemsの取得

mrubyt-tlsf

mrubyのメモリ管理にtlsfを使用するためのmrbgemです。

git clone https://github.com/yamanekko/mruby-tlsf.git

mruby-stm-nucleo-toppers

TOPPERSのAPIをmrubyから呼べるようにするためのmrbgemです。

git clone https://github.com/yamanekko/mruby-stm-nucleo-toppers

mruby-toppers-sample1

「TOPPERSのsample1」を実現するために作ったmrbgemです。

git clone https://github.com/yamanekko/mruby-toppers-sample1

asp3-f767zi-application-samples

NUCLEO-F767ZI上のTOPPERS/ASP3用mrubyのサンプルコードです。

application-samples という名前でcloneしてください。

git clone https://github.com/yamanekko/asp3-f767zi-application-samples application-samples

build configファイルの追加

mruby/targetにapplication-samples用のbuild configファイルを追加します。
stm32-nucleo-f767zi-toppersにsample1用のmrbgemを追加したものです)
置き場所がmruby2.x.xまでと異なるので注意してください。

cp application-samples/build_config/stm32-nucleo-f767zi-toppers-sample1.rb mruby/target/

mrubyのビルド

cd mruby
rake TARGET=stm32-nucleo-f767zi-toppers-sample1

ビルドが完了すると、以下のようなメッセージが表示されます。

Build summary:

================================================
      Config Name: host
 Output Directory: build/host
         Binaries: mruby-config, mrbc
    Included Gems:
             mruby-array-ext - Array class extension
             mruby-bin-config - mruby-config command
        ----- (略) -----
             mruby-time - standard Time class
             mruby-toplevel-ext - toplevel object (main) methods extension
================================================

================================================
      Config Name: nucleo-f767zi-tp
 Output Directory: build/nucleo-f767zi-tp
    Included Gems:
             mruby-sample1 - 1.0.0 - code for TOPPERS sample1
             mruby-stm-nucleo-toppers - STM32 Nucleo Boards class for toppers
             mruby-tlsf - 1.0.0 - use TLSF in mrb_(malloc|realloc|free)
================================================

アプリケーションのビルド

通常のTOPPERSのビルドにmrubyのバイトコードの生成を追加したものになります。

cd asp3-f767zi
mkdir OBJ
cd OBJ
../configure.rb -T nucleo_f767zi_gcc -a ../../application-samples -m ../../application-samples/makefile 

実行すると以下のメッセージが表示されます。

Generating Makefile from ../../application-samples/makefile.

mrubyのバイトコードを生成してからmakeします。

../../application-samples/mrbc-exec.sh
make

ビルドに成功するとコンソールに以下のメッセージが表示され、OBJディレクトリにaspができています。

configuration check passed

aspを実行して、シリアルでsyslogを表示するとこんな感じになります。
mruby版は現状使えるコマンドが限られているので、README.mdを参照してください。

TOPPERS/ASP3 Kernel Release 3.5.0 for NUCLEO(STM32F767ZI:ARM Cortex-M7) (Aug 21 2020, 19:48:37)
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

System logging task is started.
Sample program starts (exinf = 0).
used:48224
### main task initialize: 2
### main task task1 active
C: task1 start

used:96552
### -- task1 active

task1 is running 1 : .  |
task1 is running 2 : .  |
task1 is running 3 : .  |
task1 is running 4 : .  |
task1 is running 5 : .  |
4
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?