Skip to content
| Marketplace
Sign in
Visual Studio>Tools>Toradex Torizon C/C++ Support

Toradex Torizon C/C++ Support

Toradex

|
4,649 installs
| (0) | Free
This extension will let you develop C/C++ Linux applications that will run inside a container on top of Torizon OS. You can develop and debug the application using Visual Studio 2017 on a Windows PC,

Introduction

Torizon offers a Microsoft Environment for developers familiar with Visual Studio. This article will show how to install, configure and use it to build a "hello world" application and deploy it to a target device.

Prerequisites

  • Development Computer
    • Windows 10 version 2004 (a.k.a. May 2020 update) or higher.
  • Toradex Hardware with TorizonCore installed.
    • {.note} Make sure that the board and development computer are on the same network.
  • Docker Desktop
    • {.note} Make sure Docker is running.
  • Visual Studio 2019:
    • Installed Visual Studio Workloads
      • Desktop development with C++
      • Linux development with C++

Install workload - Desktop development with C++

Install workload - Linux development with C++

Setting Up Torizon Environment

After having installed the extension, you are read to start a first configuration of the work environment for Torizon. After opening Visual Studio click on Continue without code:

Continue without code

Download Base SDK Image Containers

Visual Studio Extension For Torizon uses Docker container images that have all the toolchain and SDK for C/C++ development for Toradex Boards. It is recommended to download these container images before starting development. Select menu Tools -> Download update base and sdk containers :

Download update base and sdk containers

Downloading and updating container images may take a few minutes. Wait until you have the following message in the output:

Download update base and sdk containers completed

Torizon Devices

Visual Studio Extension For Torizon needs to be connected to a target device, which will be the context for deploying the developed applications. To connect to Toradex devices with Visual Studio Extension For Torizon use the Torizon Devices Explorer. Select the menu View -> Other Windows -> Torizon devices:

Enabling the Torizon Devices Explorer

On the Torizon Devices Explorer click on the Detect device on the network:

Detect device on the network

The window below will be shown:

Detec device IP and credentials

Enter the IP address of the Toradex board, which will be the target device, and the Torizon user credentials then click the Detect button.

{.note} These credentials are the same that were added during the first Torizon boot.

This detection process will perform an exchange of credentials between Visual Studio and the Toradex board to pair the board with the Torizon Visual Studio Extension.

After detection we should have in Torizon Devices Explorer a new entry for the target device. Click on Refresh to download information... button to list the information about the Docker Images, Containers and Proccess running on the target device:

Refresh to download information ...

Torizon Toolbar

Another feature that must be enabled before we create our first project is the Torizon Toolbar. Right click on the Visual Studio toolbar and select Torizon Toolbar:

Enabling Torizon Toolbar

After this first environment setup we are ready to create our projects.

Create New Project

To create a new Torizon C/C++ project select File -> New -> Project ...:

New Project

On the Create a new project window search for torizon templates and double click the Torizon C/C++ Application template:

Select Torizon C/C++ Application template

On the Configure your new project window:

  • Enter the Project name;
  • Select storage Location for the project files or leave the pre-defined location;
  • Be sure to check (leave checked) the "Place solution and project in the same directory."
  • Click the Create button;

On the create task Visual Studio will ask for Select supported platforms. Select the platform that matches with the architecture of the target device. For this guide we are using the Apalis iMX8QM that contains a hexa-core arm64v8 processor, so we select the option debian buster-slim:arm64v8 - 1.0:

Configure new Torizon C/C++ Application project

This will create a blank Torizon C/C++ Application template.

Deploy and Debug

After the development of your application, in the case of this guide a simple message to be written, it is time to run the application to test and debug it on the target device.

To debug your application you can enable breakpoints selecting the lines of code that you want debug:

Enabling breakpoint

After selecting any breakpoint in your source code, run the application to debug it. For this, click on the Deploy and debug torizon Application, the "play" button, from Torizon Toolbar:

Deploy and debug Torizon Application

As shown in the GIF above, when clicking on Deploy and debug torizon Application a window will be displayed warning that the application is not up to date, click on yes button to build and update the application container. This will start the build, deploy and debug process.

The first time the application containers are built takes some time:

Building application container

You will get the following messages in the output tab when the application container build has completed successfully:

Application container build with success

When the build of the application container finishes Visual Studio will start the deployment onto the target device. A window to Select device... will be shown. Select your target device to deploy from the list and click Ok button:

Select device to deploy

The deployment of the container application to the target device can take some time during the first deployment. Wait until the deployment finishes successfully. After this the application will wait until the deployment finishes successfully. After that the application will be running on the target device and the breakpoint will be reached. Click on the Continue button, or press the F5 key, to continue to the next instructions of the program:

Deploy and debug with breakpoint

After the first time, future deployments with the Deploy and debug torizon Application command will become faster, because the container will only have to be updated on the target device, a much faster process than deploying the container as a whole:

Deploy and debug after the first time (without cuts)

Deploy and Release

When the application is ready, debugged and tested, it can be deployed and released. To do this switch the Debug_debian_buster-slim_<your_arch> option to Release_debian_buster-slim_<your_arch> in the Visual Studio toolbar Solution Configurations:

Select build Release on Visual Studio toolbar Solution Configurations

Next step is to put the extension in release mode. To do this, select Project -> Properties -> Torizon C/C++ Application -> Configuration -> HelloWorld Properties and change the combo box Configuration from Common to Release:

Select Torizon Extension Release configuration

For the Release configuration you will need to add two new properties. Click on the New Property... button. In the Name: field enter targetcommands and in the Value: field enter CMD [ "/bin/HelloWorld.out" ], click OK to apply it. For the second property click on the New Property... button again. In the Name: field enter targetfiles and in the Value: field enter COPY work/bin/ /bin/, click OK to apply it:

Add the properties for Release configuration

Setting the targetcommands property is the same as adding CMD to a Dockerfile. Here we are adding the output generated by the compiler as CMD. In order to place the executable file we created in to the path referenced by CMD we must copy that file to the container image. The targetfiles property allows us to COPY to the Dockerfile. Here we are adding the output files, bin folder, to be copied to Docker image.

Click Save button to apply the changes and close the Property Pages window. Now in release mode build the application clicking on the Build Torizon Application from the Torizon Toolbar:

Build release

Wait until the build is completed. After that it is necessary to build the application container, so click on the Deploy Torizon application and container from the Torizon Toolbar:

Deploy Torizon application and container

After the deploy, refresh the list of images and containers on Torizon Devices Explorer:

Refresh Docker Images and Containers list

You can see that now there are two images and two containers. One of these containers and image is for the debug, it will no longer be needed and can be deleted to free up space. First remove the debug container and then the image. Still using Torizon Devices Explorer click on the names listed in Containers. The one that contains debug in your name, right click and select Delete:

Delete debug container

After that the same can be done for the debug image. Using Torizon Devices Explorer click on the names listed in Images. The one that contains debug in your name, right click and select Delete:

Delete debug image

Next Steps / Additional Resources

Now that you have the extension set up and deployed your first hello world application, how about continuing with something more advanced? See these other articles using that use the Visual Studio Extension For Torizon:

C/C++ Developer Workflow on Windows

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft