Build and Deploy Applications
You can deploy XRT applications to Azure Sphere from the following host development systems:
Note
Before deploying XRT to Azure Sphere hardware, you must have set up the Azure Cloud as described in Set Up Azure Cloud.
Windows
You can use Visual Studio Code to configure, build and debug AzureSphere XRT applications.
Install and Configure Visual Studio Code
To build XRT applications using Visual Studio on Windows, complete the following steps:
-
Install Visual Studio Code, if not already installed. See https://code.visualstudio.com/.
-
Install Build Tools.
-
Install Cmake. See https://cmake.org/download/.
-
Download Ninja. See https://github.com/ninja-build/ninja/releases.
-
Extract the Ninja executable into C:\Program Files\CMake\bin
-
-
Install the following extensions:
- Azure Sphere
- CMake Extensions
-
Install ncat (part of Nmap) (optional). See https://nmap.org/download.
-
Navigate to the Azure Sphere example in the VS Code explorer.
Open .vscode/settings.json
- Ensure the value of the "DEVICE" configuration is set to the required device service e.g. "bacnet" or "ethernet-ip".
- Ensure the value of the "BOARD" configuration is set to the required board type. The options are "mt3620-dk", "mt3620-g100", "mt3620-sk" or "mt3620-sr620".
-
Configure the Application Manifest.
Open the app_manifest.json in the directory matching the board type e.g. mt3620-dk/app_manifest.json
- Follow the instructions for the BACNet or EthernetIP example to configure the example application in the example Git repo. See Use the Example Code.
-
Attach your Azure Sphere development board to your PC with the USB cable.
-
Start a UDP listener (optional). This allow application logging output to be viewed as log messages are created.
-
Open a command window or PowerShell.
-
Issue the command: PC running ncat.
ncat -l 1999 --keep-open --udp --recv-only
-
-
Configure the digital twin. See Configuring XRT Using a Device Twin.
-
Build the application.
- Select the VSCode CMake view in the Activity Bar (left most column).
- Click the "Build" button in the Status Bar (bottom of window).
-
Deploy and Debug the application.
- Select the VSCode Run and Debug view in the Activity Bar (left most column).
- Press F5. The application will be downloaded to your Azure Sphere board and the application started under control of the debugger.
Linux
To build XRT applications using the Ubuntu command line, enter the following commands:
mkdir build
cd build
cmake -G "Ninja" \
-DCMAKE_TOOLCHAIN_FILE="/opt/azurespheresdk/CMakeFiles/AzureSphereToolchain.cmake" \
-DAZURE_SPHERE_TARGET_TOOLS_REVISION="21.10" \
-DAZURE_SPHERE_TARGET_API_SET="11" \
-DDEVICE="modbus" \
-DBOARD="mt3620-dk" \
-DCMAKE_BUILD_TYPE="Debug" ..
ninja
cd ..
-
Deploy the application and initiate a Telnet session, using the following commands:
azsphere device sideload delete azsphere device sideload deploy --image-package build/xrt-app.imagepackage
-
Start the application in debug mode, using the following commands, where CID is the unique identifier for the application:
To monitor the application output, complete the following steps:azsphere device app stop --component-id ${CID} azsphere device app start --debug --component-id ${CID}
-
Connect using Telnet, as follows:
telnet 192.168.35.2 2342
-
Open another command shell and enter the following command:
/opt/azurespheresdk/Sysroots/11/tools/sysroots/x86_64-pokysdklinux/usr/bin/arm-poky-linux-musleabi/arm-poky-linux-musleabi-gdb xrt-app.out
-
In gdb, enter the following commands:
set sysroot /opt/azurespheresdk/Sysroots/11 target remote 192.168.35.2:2345 continue
-
View the debug output in the command shell used for step 2 above. The simulated Modbus device input is read at the interval specified in the Modbus Device Service configuration