LoginSignup
9
1

More than 3 years have passed since last update.

TOPPERS SafeG-MでASP3カーネルとMicropythonを同時に実行する

Last updated at Posted at 2020-12-20

概要

TOPPERS SafeG-Mを利用してASP3カーネルを保護しながらMicropythonを実行する方法を説明します。
SafeG-MについてはTOPPERS公式のページをご覧ください。
https://www.toppers.jp/safeg-m.html

対応ハードウェア

STM32L552
評価ボード:NUCLEO-L552ZE-Q (https://www.st.com/en/evaluation-tools/nucleo-l552ze-q.html)
このほか、PCとボードのシリアルポートを接続する手段が必要です(USB-シリアル変換器等)。

必要なソフトウェア

ビルドの手順

  1. リポジトリをクローンし、submoduleを更新します。

    $ git clone https://github.com/mtkrtk/micropython
    $ cd micropython
    $ git submodule init
    $ git submodule update lib/stm32lib/
    
  2. ネイティブホストのツールチェインがある場合は、mpy-crossをビルドします。

    $ make -C mpy-cross
    
  3. STM32CubeIDEを起動し、safeg-m/target/stm32l552/をワークスペースとして設定します。

  4. メニューから"File" → "Import..." → "General" → "Existing Projects into Workspace"と選択し、"Select root directory:"にワークスペースのディレクトリを指定して全てのプロジェクトをインポートします。

  5. sample/sample_Secure/configure.launchを右クリックして"Run As" → "configure"を実行し、Makefileを作成します。

  6. Secureプロジェクト、NonSecureプロジェクトの順でビルドします。

ハードウェアの設定

  1. STM32CubeProgrammerを利用し、オプションバイトを以下のように設定します。

    • DBANK = 1
    • TZEN = 1
    • SECWM1_PSTRT = 0x00
    • SECWM1_PEND = 0x51
    • SECWM2_PSTRT = 0x7F
    • SECWM2_PEND = 0x00
  2. PD_8とPD_9にUSB-シリアル変換器を接続します。

実行

ST-LinkをPCに接続し、STM32CubeIDEからsample/sample_Secure/sample.launchを右クリック、"Debug As" → "sample"を選択することで実行が開始されます。
ST-Linkのシリアルモニタを開くことで、ASP3のサンプルプログラムの出力を確認したり、コマンドを入力できます。
またASP3の全てのタスクが実行状態でなくなるとMicropythonが起動します。
MicropythonとはPD_8とPD_9のシリアルで通信できます。

Micropythonのタスクに対して、ASP3のタスクと同様にST-Linkのシリアルからコマンドを入力できます。
例えば4番のタスクに"t"コマンドを送信することでMicropythonを終了させられます。
"e"や"d"等のコマンドは、以下のPythonスクリプトを実行することで受信できます。

import safegm
safegm.call_asp3()
9
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
9
1