azure-sphere-samples/BUILD_INSTRUCTIONS.md

4.0 KiB

Build a sample application

The sample applications are designed to be built with Visual Studio on Windows, and with Visual Studio Code or the command-line interface (CLI) on both Windows and Linux, unless otherwise noted.

To build and run real-time capable apps (RTApps), see Tutorial: Build a real-time capable application in the online documentation.

Build and run a high-level sample application with Visual Studio

  1. Install Visual Studio and the Azure Sphere Extension for Visual Studio, and any additional tools as described in the online documentation.

  2. Open Visual Studio and select Open a local folder. Navigate to the folder that contains the sample you want to build. If the folder contains samples for both high-level apps and real-time capable apps (RTApps), make sure you open the correct folder.

  3. If the application targets hardware-specific features, open the CMakeLists.txt file and change the TARGET_DIRECTORY setting to specify the folder that contains definitions for the hardware you're using. By default, the TARGET_DIRECTORY specifies HardwareDefinitions/mt3620_rbd, which matches the Seeed Azure Sphere MT3620 Development Kit:

    azsphere_target_hardware_definition(${PROJECT_NAME} TARGET_DIRECTORY "../../../HardwareDefinitions/mt3620_rdb" TARGET_DEFINITION "sample_appliance.json")

    Several hardware definitions are provided with the Azure Sphere SDK. For example, if you're using a SEEED MT3620 Mini Dev Board, specify HardwareDefinitions/seeed_mt3620_mdb instead.

  4. In Visual Studio, select View > Output to display the Output window.

  5. Ensure that your device is connected to your PC by USB.

  6. In the Set startup item, select (HLCore) to build a high-level app.

  7. Press F5 to build and deploy the application.

Build and run a high-level sample application with Visual Studio Code

  1. Install Visual Studio Code, the Azure Sphere Extension for Visual Studio Code, and any additional tools as described in the online documentation:

  2. Start Visual Studio Code. Select File > Open Folder, and then select the folder that contains the sample you want to build. If the folder contains samples for both high-level apps and real-time capable apps (RTApps), make sure you open the correct folder.

  3. If the application targets hardware-specific features, open the CMakeLists.txt file and change the TARGET_DIRECTORY setting to specify the folder that contains definitions for the hardware you're using. By default, the TARGET_DIRECTORY specifies HardwareDefinitions/mt3620_rbd, which matches the Seeed Azure Sphere MT3620 Development Kit:

    azsphere_target_hardware_definition(${PROJECT_NAME} TARGET_DIRECTORY "../../../HardwareDefinitions/mt3620_rdb" TARGET_DEFINITION "sample_appliance.json")

    Several hardware definitions are provided with the Azure Sphere SDK. For example, if you're using a SEEED MT3620 Mini Dev Board, specify HardwareDefinitions/seeed_mt3620_mdb instead.

  4. Press F5 to build and debug the project. If the project has not previously been built, or if files have changed and rebuilding is required, Visual Studio Code will build the project before debugging starts.

  5. Wait several seconds for Visual Studio Code to build the application, create an image package, deploy it to the board, and start it in debug mode. You'll see status updates in the Output pane along the way.