Skip to content

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:

  1. Install Visual Studio Code, if not already installed.

  2. Install Build Tools.

    • Install Cmake

    • Download Ninja

    • Extract the Ninja executable into C:\\Program Files\\CMake\\bin

  3. Install the following extensions:

    • Azure Sphere
    • CMake Extensions
  4. Install ncat (part of Nmap) (optional)

  5. 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, for example, 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.
  6. Configure the Application Manifest.

    Open the app_manifest.json in the directory matching the board type, for example, mt3620-dk/app_manifest.json

  7. Attach your Azure Sphere development board to your PC with the USB cable.

  8. 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
    
  9. Configure the digital twin. See Configuring XRT Using a Device Twin.

  10. Build the application.

    • Select the VSCode CMake view in the Activity Bar (leftmost column).
    • Click the "Build" button in the Status Bar (bottom of the window).
  11. Deploy and Debug the application.

    • Select the VSCode Run and Debug view in the Activity Bar (leftmost column).
    • Press F5. The application will be downloaded to your Azure Sphere board and the application started under the 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 ..
To deploy and debug the built application using the Ubuntu command line, complete the following steps:

  1. 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
    

  2. Start the application in debug mode, using the following commands, where CID is the unique identifier for the application:

    azsphere device app stop --component-id ${CID}
    azsphere device app start --debug --component-id ${CID}
    
    To monitor the application output, complete the following steps:

  3. Connect using Telnet, as follows:

    telnet 192.168.35.2 2342
    

  4. 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
    

  5. In gdb, enter the following commands:

    set sysroot /opt/azurespheresdk/Sysroots/11
    target remote 192.168.35.2:2345
    continue
    

  6. 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.

Back to top