Search by Tags

Visual Studio Code Extension for Torizon

 

Article updated at 16 Sep 2020
Compare with Revision




Subscribe for this article updates

Select the version of Torizon from the tabs below. If you don't know the version you are using, run the command cat /etc/os-release on the board.

Torizon 5.0.0

Introduction

Toradex offers a VS Code extension to help users to develop, deploy, and debug applications on TorizonCore. The following programming languages are currently supported:

  • Python
  • .NET Core

This article demonstrates how to set up the recommended configuration comprising:

  • Visual Studio Extension for Torizon
  • .NET Code SDK (Required for .NET Core applications only)
  • Windows Subsystem for Linux - WSL2 (Only for Windows host machine )
  • ARM emulation mode (Only for Linux host machine)

This article complies to the Typographic Conventions for Torizon Documentation.

Prerequisites

  • Development Computer with

  • One of the OS below:

    • Windows 10 version 2004 (a.k.a. May 2020 update) or higher.
    • Linux (it was validated using Ubuntu 18.04)
  • Toradex Computer on Module (CoM) with TorizonCore installed.

Note: Make sure that the board and development computers are on the same network.

Install the Visual Studio Code Extension for Torizon

The latest version of the Toradex Torizon Support extension can be found on the Visual Studio Code marketplace:


  • Toradex Torizon Support - Visual Studio Code Marketplace

    Toradex Torizon Support - Visual Studio Code Marketplace

Click on the extensions button in Visual Studio Code as shown in the image below and search for Toradex Torizon Support:


  • Toradex Torizon Support Extension for Visual Studio Code

    Toradex Torizon Support Extension for Visual Studio Code

Verify that the extension has been enabled:


  • Torizon extension

    Torizon extension

Choose your development PC OS from the tabs below:

Install the .Net Core SDK on Windows

Warning: Required for .NET Core applications only

Download the latest .NET Core SDK on Microsoft Official Website and follow the setup installation. To check if everything went well, open up a command prompt, and run the following command:

$ dotnet

If the installation was successful, you should see the .NET options on the command prompt.

Expected result

Install the Windows Subsystem for Linux (WSL2)

To obtain the Linux subsystem, please refer to the Microsoft instructions. After following all the steps, reboot your machine.

Warning: WSL2 requires Windows 10, updated to version 2004 (also known as the Windows 10 May 2020 Update) or higher.

Open the Microsoft Store and install a distro. We recommend Ubuntu 18.04 LTS. When the process ends, open CMD and run the following command:

$ wsl

It will ask for your username and password, write it, and re-run the command to see the following output:


  • Wsl output

    Wsl output

After evaluating the Windows Subsystem for Linux works, install rsync and ssh from the Linux prompt:

$ sudo apt-get update && sudo apt-get install rsync ssh

Install the .Net Core SDK on Linux

Warning: Required for .NET Core applications only

Follow the .NET Microsoft Documentation to install it on Linux, and make sure you select the correct distribution on the left.

You can test if everything went well by running the following command:

$ dotnet --info
Expected result

Enable ARM Emulation Mode

The VS Code extension needs ARM emulation mode enabled through binfmt. To allow it, press F1 and type "Torizon: Enable ARM emulation for Docker containers":


  • Torizon Enable ARM Emulation

    Torizon Enable ARM Emulation

Click on continue in the following window:


  • Continue arm emulation

    Continue arm emulation

If everything goes well, you should see the ARM emulation enabled message in your Visual Studio Code.

Add Target Device Connection In Visual Studio Code

To debug and test our application, we need a device to deploy it. Open Visual Studio Code and press F1 to open the command bar, then you can run one of two commands below to add a device connected over the network or over serial.


  • Adding a Torizon device

    Adding a Torizon device

The command torizon.detectSerialDevice will add a serial connection to a Torizon device. The interface will prompt to specify the port on your development PC connected to the device over serial.

The command torizon.detectNetworkDevice will add a network connection to your Torizon device. The interface will request to specify the IP address of your Torizon device. Just make sure that your SoM is on the same network as your development PC, and your PC can reach this address.

Either way, you will then be prompted to enter a valid username and password that is on your Torizon device; this will make it briefly reboot. You should see some dialog in the Terminal output of the VS code that shows whether the connection was a success or not. Also, if you’ve already created a Torizon Project, then the device will be listed via the Torizon extension sidebar menu.

Expected Result:


  • Adding a device - expected result

    Adding a device - expected result

Visual Studio Code Extension Commands

On Visual Studio Code, executing command is easy: you need to press F1 to open the command bar then type the command you want. Here is a list with every command and its respective action and category

Command Action Category
torizon.createPythonApp Create Python Application Torizon/Python
torizon.createDotNetCoreApp Create .NET Core Application Torizon/.NET
torizon.createAspDotNetCoreApp Create ASP.NET Application Torizon/.NET
torizon.detectSerialDevice Detect device via serial port connection Torizon
torizon.detectNetworkDevice Detect device via network connection Torizon
torizon.deleteDevice Remove device from device list Torizon
torizon.selectDevice Select default deployment device Torizon
torizon.buildPythonReleaseContainer Build release container for Python application Torizon/Python
torizon.enableARMEmulation Enable ARM emulation for docker containers Torizon
torizon.deployReleaseContainer Deploy release container Torizon
torizon.runReleaseContainer Run/restart release container Torizon
torizon.updateContainers Download/update base containers Torizon
torizon.buildDotNetReleaseContainer Build release container for .NET application Torizon/.NET

Known Issues

  • The extension will start the back-end server, which takes around 30 seconds. If you try to run commands during that time, you’ll get an error.
  • Toradex provides templates for 32 and 64 bits containers. At the moment, the 32bit version is the one used for the test during development. Feel free to test on the 64bit version.
  • There is no UI to configure projects, monitor devices, etc. (will come soon). At the moment, you can edit config.yaml in the appconfig_0 folder. See Moses IDE Backend for reference.

Torizon 4.0.0

Introduction

Toradex offers a VS Code extension to help users to develop, deploy, and debug applications on TorizonCore. The following programming languages are currently supported:

  • Python
  • .NET Core

This article demonstrates how to set up the recommended configuration comprising:

  • Visual Studio Extension for Torizon
  • .NET Code SDK (Required for .NET Core applications only)
  • Windows Subsystem for Linux - WSL2 (Only for Windows host machine )
  • ARM emulation mode (Only for Linux host machine)

This article complies to the Typographic Conventions for Torizon Documentation.

Prerequisites

  • Development Computer with

  • One of the OS below:

    • Windows 10 version 2004 (a.k.a. May 2020 update) or higher.
    • Linux (it was validated using Ubuntu 18.04)
  • Toradex Computer on Module (CoM) with TorizonCore installed.

Note: Make sure that the board and development computers are on the same network.

Install the Visual Studio Code Extension for Torizon

The latest version of the Toradex Torizon Support extension can be found on the Visual Studio Code marketplace:


  • Toradex Torizon Support - Visual Studio Code Marketplace

    Toradex Torizon Support - Visual Studio Code Marketplace

Click on the extensions button in Visual Studio Code as shown in the image below and search for Toradex Torizon Support:


  • Toradex Torizon Support Extension for Visual Studio Code

    Toradex Torizon Support Extension for Visual Studio Code

Verify that the extension has been enabled:


  • Torizon extension

    Torizon extension

Choose your development PC OS from the tabs below:

Install the .Net Core SDK on Windows

Warning: Required for .NET Core applications only

Download the latest .NET Core SDK on Microsoft Official Website and follow the setup installation. To check if everything went well, open up a command prompt, and run the following command:

$ dotnet

If the installation was successful, you should see the .NET options on the command prompt.

Expected result

Install the Windows Subsystem for Linux (WSL2)

To obtain the Linux subsystem, please refer to the Microsoft instructions. After following all the steps, reboot your machine.

Warning: WSL2 requires Windows 10, updated to version 2004 (also known as the Windows 10 May 2020 Update) or higher.

Open the Microsoft Store and install a distro. We recommend Ubuntu 18.04 LTS. When the process ends, open CMD and run the following command:

$ wsl

It will ask for your username and password, write it, and re-run the command to see the following output:


  • Wsl output

    Wsl output

After evaluating the Windows Subsystem for Linux works, install rsync and ssh from the Linux prompt:

$ sudo apt-get update && sudo apt-get install rsync ssh

Install the .Net Core SDK on Linux

Warning: Required for .NET Core applications only

Follow the .NET Microsoft Documentation to install it on Linux, and make sure you select the correct distribution on the left.

You can test if everything went well by running the following command:

$ dotnet --info
Expected result

Enable ARM Emulation Mode

The VS Code extension needs ARM emulation mode enabled through binfmt. To allow it, press F1 and type "Torizon: Enable ARM emulation for Docker containers":


  • Torizon Enable ARM Emulation

    Torizon Enable ARM Emulation

Click on continue in the following window:


  • Continue arm emulation

    Continue arm emulation

If everything goes well, you should see the ARM emulation enabled message in your Visual Studio Code.

Add Target Device Connection In Visual Studio Code

To debug and test our application, we need a device to deploy it. Open Visual Studio Code and press F1 to open the command bar, then you can run one of two commands below to add a device connected over the network or over serial.


  • Adding a Torizon device

    Adding a Torizon device

The command torizon.detectSerialDevice will add a serial connection to a Torizon device. The interface will prompt to specify the port on your development PC connected to the device over serial.

The command torizon.detectNetworkDevice will add a network connection to your Torizon device. The interface will request to specify the IP address of your Torizon device. Just make sure that your SoM is on the same network as your development PC, and your PC can reach this address.

Either way, you will then be prompted to enter a valid username and password that is on your Torizon device; this will make it briefly reboot. You should see some dialog in the Terminal output of the VS code that shows whether the connection was a success or not. Also, if you’ve already created a Torizon Project, then the device will be listed via the Torizon extension sidebar menu.

Expected Result:


  • Adding a device - expected result

    Adding a device - expected result

Visual Studio Code Extension Commands

On Visual Studio Code, executing command is easy: you need to press F1 to open the command bar then type the command you want. Here is a list with every command and its respective action and category

Command Action Category
torizon.createPythonApp Create Python Application Torizon/Python
torizon.createDotNetCoreApp Create .NET Core Application Torizon/.NET
torizon.createAspDotNetCoreApp Create ASP.NET Application Torizon/.NET
torizon.detectSerialDevice Detect device via serial port connection Torizon
torizon.detectNetworkDevice Detect device via network connection Torizon
torizon.deleteDevice Remove device from device list Torizon
torizon.selectDevice Select default deployment device Torizon
torizon.buildPythonReleaseContainer Build release container for Python application Torizon/Python
torizon.enableARMEmulation Enable ARM emulation for docker containers Torizon
torizon.deployReleaseContainer Deploy release container Torizon
torizon.runReleaseContainer Run/restart release container Torizon
torizon.updateContainers Download/update base containers Torizon
torizon.buildDotNetReleaseContainer Build release container for .NET application Torizon/.NET

Known Issues

  • The extension will start the back-end server, which takes around 30 seconds. If you try to run commands during that time, you’ll get an error.
  • Toradex provides templates for 32 and 64 bits containers. At the moment, the 32bit version is the one used for the test during development. Feel free to test on the 64bit version.
  • There is no UI to configure projects, monitor devices, etc. (will come soon). At the moment, you can edit config.yaml in the appconfig_0 folder. See Moses IDE Backend for reference.