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

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

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

HLApp (HLCore)をデバッグ実行

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

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

C:\>azsphere device image list-installed
Installed images:
 --> gdbserver
   --> Image type:   Application
   --> Component ID: 8548b129-b16f-4f84-8dbe-d2c847862e78
   --> Image ID:     2eac78bb-c68c-4aa3-9849-9c82d65d9406

C:\>

(厳密には、Linux Kernelやドライバなど、システムのイメージが入っていますが、ここでは除外。知りたいときは、azsphere device image list-installed -fullで。)

サンプルのSamples/HelloWorld/HelloWorld_HighLevelAppをVisual Studioデバッグ実行すると、imagepackageがビルドされて、デバイスに転送、アプリケーションが起動します。
azsphereコマンドで確認すると、HelloWorld_Highが追加されて、デバッギング状態になっているのが確認できます。

C:\>azsphere device image list-installed
Installed images:
 --> gdbserver
   --> Image type:   Application
   --> Component ID: 8548b129-b16f-4f84-8dbe-d2c847862e78
   --> Image ID:     2eac78bb-c68c-4aa3-9849-9c82d65d9406
 --> HelloWorld_High
   --> Image type:   Application
   --> Component ID: 1689d8b2-c835-2e27-27ad-e894d6d15fa9
   --> Image ID:     0d47ac84-0ae1-4bda-91f9-b3b495baab9f

C:\>
C:\>azsphere device app show-status
1689d8b2-c835-2e27-27ad-e894d6d15fa9: App state   : debugging
GDB port    : 2345
Output port : 2342


C:\>

Visual Studioデバッグを停止すると、実行状態が停止に変わりますが、イメージはデバイス内に残ったままです。

C:\>azsphere device image list-installed
Installed images:
 --> gdbserver
   --> Image type:   Application
   --> Component ID: 8548b129-b16f-4f84-8dbe-d2c847862e78
   --> Image ID:     2eac78bb-c68c-4aa3-9849-9c82d65d9406
 --> HelloWorld_High
   --> Image type:   Application
   --> Component ID: 1689d8b2-c835-2e27-27ad-e894d6d15fa9
   --> Image ID:     0d47ac84-0ae1-4bda-91f9-b3b495baab9f

C:\>
C:\>azsphere device app show-status
1689d8b2-c835-2e27-27ad-e894d6d15fa9: App state: stopped


C:\>

ここで、デバイスのUSBを抜き差しすると(!)、デバイスに残っていたイメージが自動的に起動されます。

C:\>azsphere device image list-installed
Installed images:
 --> gdbserver
   --> Image type:   Application
   --> Component ID: 8548b129-b16f-4f84-8dbe-d2c847862e78
   --> Image ID:     2eac78bb-c68c-4aa3-9849-9c82d65d9406
 --> HelloWorld_High
   --> Image type:   Application
   --> Component ID: 1689d8b2-c835-2e27-27ad-e894d6d15fa9
   --> Image ID:     0d47ac84-0ae1-4bda-91f9-b3b495baab9f

C:\>
C:\>azsphere device app show-status
1689d8b2-c835-2e27-27ad-e894d6d15fa9: App state: running


C:\>

結果

要約すると、

  • Visual Studioデバッグ実行すると実行イメージが転送され、デバッギング状態に
  • デバッグを停止すると停止状態に
  • USB抜き差しすると実行状態に

USB接続したときに自動実行するのは、ちょっと怖いですね、、、。ハードウェアを修正するときは特に。

バイス内の実行イメージを削除

ハードウェアを修正するときは、デバイス内の実行イメージを削除するように心がけましょう。
azsphere device sideload deleteを実行すると、(gdbserverを除いた)全ての実行イメージが削除されます。

C:\>azsphere device sideload delete
Component '1689d8b2-c835-2e27-27ad-e894d6d15fa9' deleted or was not present beforehand.

C:\>
C:\>azsphere device image list-installed
Installed images:
 --> gdbserver
   --> Image type:   Application
   --> Component ID: 8548b129-b16f-4f84-8dbe-d2c847862e78
   --> Image ID:     2eac78bb-c68c-4aa3-9849-9c82d65d9406

C:\>

これで安心ですね♪

ちなみに、、、
あらたに別の実行イメージ(厳密には、別のComponent IDのイメージ)をVisual Studioから実行すると、デバイスの全ての実行イメージを削除してから、実行イメージを転送します。(一部、例外あり)
ので、あれこれと複数のアプリケーションを実行しても、デバイスのフラッシュがパンクする、といったことは発生しません。

一部、例外については後日に。