When it comes to Linux development, it is possible to choose several IDEs, workflows and programming languages for development. Aiming to simplify your development experience Toradex provides TorizonCore IDE integration with Visual Studio Code for Windows and Linux PCs, and Visual Studio for Windows PCs.
In this module you will:
Note: support for a more complex workflow on Visual Studio will be presented to you at the end of the quickstart guide, as well as support for other programming languages on Visual Studio Code. If you have a Linux PC for development, you can also try the quickstart guide for Torizon with Linux selected as Development PC OS.
For this Quickstart Guide:
For this lesson:
Note: Carefully read this module's cover page clicking on "Module 2: First Steps with Torizon" on the left menu bar before starting this lesson.
When installing Visual Studio make sure you select at least the following workloads for the correct operation of the Torizon Extension for Visual Studio.
If you already have Visual Studio installed, run the Visual Studio Installer and modify your current setup:
The latest versions of the Toradex Torizon Support extension can be found on the Visual Studio marketplace, in two versions:
Close all running instances of Visual Studio. Choose one of Torizon extensions from the above, download and install it.
Tip: The extension is available for Visual Studio 2019 only!
Check that the installation was successful by opening the extension list under Extensions > Manage Extensions:
Select Tools > Download/update base and sdk containers:
Note: Be patient! This process can take a while.
The extension provides some windows and toolbars but they are hidden by default. You can show the device list by selecting View > Other Windows > Torizon devices from the menu bar in Visual Studio.
Once it shows up, you can detect devices through serial port or network. In this guide we will use the network device detection.
To add your device to this list, select Detect device on the network and set your board's IP or hostname as found out on the previous lessons:
Note: Remember that the credentials are username: torizon
and password: <custom password you have set during the first login>
Attention: As soon as you click Detect, the board will reboot! All instances of Putty will close with a Connection Lost message.
After the board reboots, refresh the device on the list. The Windows Defender will ask you to allow moses.exe
.
Moses is the Torizon Extension back-end. Click on Allow Access.
See the collected data from the board:
Enable the Torizon toolbar on Visual Studio selecting Tools > Customize, scroll down the list, select "Torizon Toolbar" and hit Close:
Create a New Project and select Torizon C/C++ Application from the Visual C++ category:
Give a Project Name to your project and make sure to mark the checkbox Place solution and project in the same directory:
When you click Create in the previous step, a dialog will ask you to Select supported platforms.
Select debian arm32v7 bullseye
and verify that torizon is the username:
Note: Please notice that the list of platforms may change. New updates of the extension will make additional platforms available with new releases of debian and specialized platforms with specific libraries pre-installed.
Open Debug > Linux Console so you can see the application output.
On the Solution Explorer menu open the main.cpp file and slightly modify it to make our debug fun:
main.cpp
#include <cstdio>
int main() {
int var = 1, i;
for(i = 0; i < 5; i++){
var = 2*var;
printf("Loop %d - var=%d\n", i, var);
}
return 0;
}
Add a breakpoint by clicking on the left of the line number. For instance, insert a breakpoint relative to the printf
command (line 7).
Either choose Debug > Deploy and debug Torizon or click on Deploy and Debug Torizon Application on the Torizon Toolbar:
A dialog will ask if you want to build the application. Choose Yes:
Note: This step takes a while to finish since the app has to be built.
See the expected output in the animated illustration below:
When the build is finished, deploy the application to the computer on module by selecting Debug > Deploy and debug Torizon and selecting your board:
Warning: This step takes a while, when run for the first time, since the container has to be built and deployed to the target.
You can use the Visual Studio debugging features to step through your code and observe variable values, functions, etc.
As the Quickstart is a step-by-step guide, the current lesson is only a brief introduction to application development with Torizon. For a great development experience, you can choose to use the Visual Studio Extension For Torizon and write your application in C/C++ or use the Visual Studio Code Extension for Torizon and write your application in C/C++, C#/.NET or Python.
You can also use other programming languages, or even ready-to-use technologies such as databases, by either choosing a container image from the community as the official Node.js container image or building your own container based on a community one or our Debian Containers for Torizon.