Search by Tags

Build and Run your First Application - Visual Studio Code


Your progress



In this module, you will:

  • Create your Python script to run with Torizon.
  • Deploy it to the target module.
Typographic Conventions


For this Getting Started Guide:

  • Successfully completed the previous lesson from this guide.
  • Linux Machine (We tested this guide on Ubuntu 18.04 LTS. However, it can work on other distributions.).

For this lesson:

You need to have the following applications installed on your development machine. Please, visit the developers' website to get instructions about how to obtain it.

You will also need Toradex hardware and computer on the same network.

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.

Step 1

Download the Torizon support package for Visual Studio Code and Python project's Github repository.

  • Project's Github repository

    Project's Github repository

After the download, the file will be on Downloads folder, go to that directory and extract the archives to your home folder.

Open your terminal, and type the following commands:

$ cd Downloads
$ unzip -d /home/$USER
$ cd ~/python-container-master/

  • Extracting python container

    Extracting python container

Step 2

Create a new folder by copying the template directory:

$ cp -r template hello-world

Step 3

Open Visual Studio Code. Click on File-> Open Folder menu.

  • Open Folder

    Visual Studio Open Folder

Select the hello-world folder.

Step 4

On the project explorer window, open the .vscode folder and click on the file settings.json.

  • Folder structure

    Folder structure

Edit the toradexpython.targetDevice field with your board's IP or hostname.

Step 5

Press ctrl+p and type task deploydebugcontainer to start building.

  • Visual Studio command palette

    Visual Studio command palette

The Build process of the release container image will start. It should complete successfully.

  • Visual Studio command output

    Visual Studio command output

Warning: Please, be sure you have Arm emulation enabled on your PC. To enable it, please refer to the previous lessons.

Note: It is also recommended to configure your SSH Key to avoid the necessity of password every time, check more about it on the Passwordless SSH Configuration.

Step 6

Create a new file on VS Code:

  • Create file

    Create file
val = 1
print("Hello world")
val = val + 1

Step 7

Put some breakpoints on the :

  • VS Code Breakpoints

    VS Code Breakpoints

Step 8

Press F5 to debug the script on the board. This will deploy the script from your developer computer to the board and it will stop the execution on the breakpoints set on the previous step:

  • VS Code Debugging from Container

    VS Code Debugging from Container

You can view variable values and use the debug tools of VS Code normally. You can see too the output generated by the script on the DEBUG CONSOLE tab:

  • "VS Code Output from Container"

    VS Code Output from Container