Skip to main content
Version: 6

Configure Build Environment for Torizon Containers

Introduction​

In this article, you will learn the basic setup of a development environment for Torizon, regardless of your choice of code editor/IDE or revision control system. As applications are integrated into TorizonCore using containers, this setup mainly involves configuring a Docker environment. Here you will find instructions for both Linux and Windows development environments.

Torizon Development Environment​

While it is possible to build and configure containers directly on the target for quick tests or prototypes, this approach is generally not suitable for projects that require long-term maintenance.

The recommended workflow for Torizon involves the cross-compilation of containers. In this case, you should define the necessary configuration steps to initialize your container in a Dockerfile and use it to build the container on your host machine:

  • Installing packages.
  • Changing configuration file.
  • Adding application-specific content.

Your development machine will likely use an x86/x64 processor, while Toradex's modules have Arm SOCs. To build containers that can run on a different processor architecture, you have to properly configure the Docker environment according to the instructions presented in this article.

This article complies with the Typographic Conventions for Toradex Documentation.

Prerequisites​

  • Host machine with:

    danger

    You have to install the Visual Studio Code from its Download page. The V2.0 extension will not work with VS Code installed via Snap or Flatpak!

    For WSL 2, the Visual Studio Code has to be installed on the Windows side.

Windows​

Follow the steps to configure your development environment on Windows.

Install WSL 2​

The Windows Subsystem for Linux (WSL) enables the use of most Linux command-line tools, utilities and applications directly on Windows. It also lets you leverage the IDE Extension 2 with Visual Studio Code installed on your Windows machine.

  1. Install Linux on Windows with WSL. Remember to change the default Linux distribution installed. Choose one of the Torizon IDE 2 officially supported Linux distributions.

  2. Check which version of WSL you are running. If WSL 1 is installed, upgrade version from WSL 1 to WSL 2.

Install Docker Engine​

Since Docker Desktop is licensed under the Docker Subscription Service Agreement, we recommend using Docker Engine.

  1. Install Docker Engine: The release of Docker provided by some distribution feeds is not up to date. To ensure the correct Docker installation, follow the instructions for your distribution in the Docker documentation.

  2. Set up Docker to run Docker without root privileges

Install the WSL VS Code extension​

To use WSL in Visual Studio Code, install the WSL extension:

The WSL extension lets you use VS Code on Windows to build Linux applications that run on the Windows Subsystem for Linux (WSL). You get all the productivity of Windows while developing with Linux-based tools, runtimes, and utilities.

Linux​

Follow the steps to configure your development environment on Linux.

Install Docker Engine​

Since Docker Desktop is licensed under the Docker Subscription Service Agreement, we recommend using Docker Engine.

  1. Install Docker Engine: The release of Docker provided by some distribution feeds is not up to date. To ensure the correct Docker installation, follow the instructions for your distribution in the Docker documentation.

  2. Set up Docker to run Docker without root privileges

Enable Arm emulation​

Arm emulation makes it possible to run Arm instructions on Intel x86-64 architectures. That is, you can run binaries compiled for the Arm instruction set on an x86 computer.

To enable this emulation to be used with Docker, run the following command:

info

Use the same command for Windows (Docker Desktop Hyper-V VM or Docker Desktop using WSL 2 as backend) and Linux distributions.

$ docker run --rm -it --privileged torizon/binfmt
caution

This operation will run a privileged container, it will run for the time required to enable Arm emulation using binfmt. It should be a safe operation.

info

Enabling Arm emulation through this method is NOT persistent. After reboots, you have to run this command again to re-enable Arm emulation.

This command will install and register the interpreters that will know how to run the arm32v7 and arm64v8 instructions on your Intel x86 development PC. This use the Kernel Linux support for miscellaneous binary formats feature.

To test whether the interpreters have been successfully installed, run the commands:

Test arm32v7​

$ docker run --rm -it arm32v7/debian arch

The return must be:

armv7l

Test arm64v8​

$ docker run --rm -it arm64v8/debian arch

The return must be:

aarch64


Send Feedback!