RTAppを2つ動かしてみる

前記事。

matsujirushi.hatenablog.jp

あぁ、この記事のシリーズ、写真も無いし画像も少ないし、ちょっとマニアックな内容で、、、誰か読む人いるんだろうか?と思いながら、備忘的に書いています。

今回はRTAppを2つ同時に動かしてみましょう。

RTApp 2つ = RTCore 2つ

RTApp、というかRTCoreは、アプリケーションの実行を管理する「OS」というものが存在しません。
ので、RTAppを2つ動かすということは、必然的にRTCoreを2つ使うことになります。1つ目のRTAppがRTCore #0で動いているとすると、2つ目のRTAppはRTCore #1で動かすこと。

実行するRTApp

前記事と同様、サンプルのSamples/HelloWorld/HelloWorld_RTApp_MT3620_BareMetalを使います。

1つ目のRTAppは、サンプルを未修正で使います。ビルドして出来たHelloWorld_RTApp_MT3620_BareMetal.imagepackageを、別ファイル名にコピーしておきます。

copy HelloWorld_RTApp_MT3620_BareMetal.imagepackage c:\azuresphere\HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage
        1 個のファイルをコピーしました。

2つ目のRTAppは、app_manifest.jsonのComponentIdを良い感じに変更して(w)、ついでにmain.cのシリアル送信メッセージも変更して、ビルド、コピーします。

1つ目 ... d3b80666-feaf-433a-b294-6a5846853b4a、"Tick"/"Tock"
2つ目 ... d3b80666-feaf-433a-b294-6a5846853b4b、"One"/"Two"

実行!

念のためdeleteしてから、2つのRTAppを手動でデプロイします。

C:\AzureSphere>azsphere device sideload delete

C:\AzureSphere>azsphere device sideload deploy --imagepackage HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage
Deploying 'HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage' to the attached device.
warn: This app targets Beta APIs that may change or be removed in future.
Image package 'HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage' has been deployed to the attached device.

C:\AzureSphere>azsphere device sideload deploy --imagepackage HelloWorld_RTApp_MT3620_BareMetal-one.imagepackage
Deploying 'HelloWorld_RTApp_MT3620_BareMetal-one.imagepackage' to the attached device.
warn: This app targets Beta APIs that may change or be removed in future.
Image package 'HelloWorld_RTApp_MT3620_BareMetal-one.imagepackage' has been deployed to the attached device.

C:\AzureSphere>

どれどれ、、、

C:\AzureSphere>azsphere device app show-status
d3b80666-feaf-433a-b294-6a5846853b4a: App state: running

d3b80666-feaf-433a-b294-6a5846853b4b: App state: running


C:\AzureSphere>

動いているっぽい。

ロジアナで測定すると、

f:id:matsujirushix:20191224200056p:plain

f:id:matsujirushix:20191224200218p:plain

f:id:matsujirushix:20191224200148p:plain

オォー!動いてる♪

IO0_TXDがサンプル無修正品で、IO1_TXDがサンプル修正品。

実行しているRTCoreを入れ替え

それでは、RTAppの起動順を変えてみて、実行するRTCoreが入れ替わるか見てみましょう。

C:\AzureSphere>azsphere device app stop -i d3b80666-feaf-433a-b294-6a5846853b4a
d3b80666-feaf-433a-b294-6a5846853b4a: App state: stopped


C:\AzureSphere>azsphere device app stop -i d3b80666-feaf-433a-b294-6a5846853b4b
d3b80666-feaf-433a-b294-6a5846853b4b: App state: stopped


C:\AzureSphere>azsphere device app start -i d3b80666-feaf-433a-b294-6a5846853b4b
d3b80666-feaf-433a-b294-6a5846853b4b
App state: running
Core     : 1


C:\AzureSphere>azsphere device app start -i d3b80666-feaf-433a-b294-6a5846853b4a
d3b80666-feaf-433a-b294-6a5846853b4a
App state: running
Core     : 0


C:\AzureSphere>

あれ!?

f:id:matsujirushix:20191224200639p:plain

入れ替わらねー

デプロイ順かな?試してみます。

C:\AzureSphere>azsphere device sideload delete
Component 'd3b80666-feaf-433a-b294-6a5846853b4a' deleted or was not present beforehand.
Component 'd3b80666-feaf-433a-b294-6a5846853b4b' deleted or was not present beforehand.

C:\AzureSphere>azsphere device sideload deploy --imagepackage HelloWorld_RTApp_MT3620_BareMetal-one.imagepackage
Deploying 'HelloWorld_RTApp_MT3620_BareMetal-one.imagepackage' to the attached device.
warn: This app targets Beta APIs that may change or be removed in future.
Image package 'HelloWorld_RTApp_MT3620_BareMetal-one.imagepackage' has been deployed to the attached device.

C:\AzureSphere>azsphere device sideload deploy --imagepackage HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage
Deploying 'HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage' to the attached device.
warn: This app targets Beta APIs that may change or be removed in future.
Image package 'HelloWorld_RTApp_MT3620_BareMetal-tick.imagepackage' has been deployed to the attached device.

C:\AzureSphere>

f:id:matsujirushix:20191224200831p:plain

入れ替わった!!

ということは、デプロイ時に実行するRTCoreの割り当てがされているんですね。

おまけ

RTAppを3つデプロイするとエラー。(ふむふむ)

f:id:matsujirushix:20191224201152p:plain

SeeeduinoでRTOS

Seeed UG Advent Calendar 2019 17日目の、@dedenさんの投稿。

qiita.com

手を抜いたシンプルな投稿にもかかわらず「SeeeduinoでもRTOSやりたい!!」というワードに、なにか惹きつけられるものがあります。
これは自分でも確認しておかねば!と思い、やってみることにしました。

続きを読む

Seeeduino->IoT PnP Bridge (RasPi4)->Azure IoT Central、構築手順

先月末から、IoT PnP Bridgeをゴニョゴニョとやっていたわけですが、やっとIoT PnP BridgeのUARTを動かす方法が確立できたので書いておきます。

やること

Seeeduino(Arduino Uno互換機)からUART出力する(疑似温度データ)を、IoT PnP Bridgeを動かしたRaspberry Pi 4を経由して、Azure IoT Centralへ送り、グラフ表示します。

続きを読む

Visual StudioでHLApp(HLCore)をデバッグ実行したときの振る舞い

ちょっとタイトルが上手く書けませんでした(汗

Azure SphereバイスをUSB接続してVisual Studioからデバッグ実行したときの、デバイス内の実行イメージが保持されているか否かを確認しました。

HLApp (HLCore)をデバッグ実行

Cortex-Aで動かすアプリケーション(HLApp)を見てみましょう。

azsphere device enable-developmentしたばかりのデバイス内は、gdbserverだけが入っています。

続きを読む

サイドロードを有効にできない

azsphere device enable-developmentコマンドでサイドロードを有効にしようとしたところ、
error: Device group 'Development' for product 'POTestSKU' cannot be found.
というエラーが発生しました。

C:\>azsphere device enable-development
Getting device group 'Development' for product 'POTestSKU'.
error: Device group 'Development' for product 'POTestSKU' cannot be found.
Ensure that you have the right permissions to execute this command in the selected Azure Sphere tenant.
Please see https://aka.ms/AzureSphereSDKHelp/Cloud for troubleshooting or suggestions.
error: Trace ID: 42fcf6a8-4d49-4625-bc8e-a6baed0bd71d
error: Can't retrieve the target device group.
error: Product 'POTestSKU' does not have a 'Development' device group. Run 'azsphere product device-group create-defaults --productname "POTestSKU"' and then retry.

C:\>

新しい認証モデルへ移行する前に、特定SKUに割り当てているとエラーが出るのかな?

続きを読む

Azure Sphereのサンプルプログラム github編 (19.11)

github公開のAzure Sphereサンプルプログラム、

github.com

を、ざーっと確認して、5つに分類しました。

  • ハードウェア制御
  • ネットワーク
  • Wi-Fiセットアップ
  • OTAアップデート
  • その他
続きを読む