QT5 cross-platform build for Nvidia Jetson TX2


Introduction.

Get started with Nvidia Jetson You can, as with a regular personal computer, by connecting a monitor and a mouse to it, but this is not always convenient. If Jetson is part of some device and access to it is limited, then changing the firmware can turn into a problem. In this case, cross-platform assembly helps. If the project is written in C++, then cross-compilation can be organized using cmake. File toolchain.cmake can be easily found on the Internet. However, if the project is written in QT, then the instructions given on the Internet turn out to be incomplete and information has to be collected from various sources, correcting errors in them along the way. Therefore, we tried to collect in one article complete and reliable instructions for cross-platform QT5 assembly for Nvidia Jetson TX2 as of February 2023.

Image for Jetson.

On the site Nvidia https://developer.nvidia.com/drive/sdk-manager download a utility called sdkmanager. At the time of writing in sdkmanager there was no support ubuntu versions above 18. However, this limitation can be bypassed. To do this, on the host, you need to change the value of the VERSION_ID field to 18.04 in the /usr/lib/os-release file:
sudo vi /usr/lib/os-release
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

After replacement:

NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

For Jetson TX2 there are many carrier boards (carrier board) and, as a rule, board manufacturers provide instructions for patching the image to work with their board, since images from sdkmanager out of the box work only with boards from Nvidia. In our case, a carrier board is used Auvidea J120. On the site https://auvidea.eu/firmware/ find a suitable image patch (Figure 1) and download the archive. You will need it later to make changes to the image.

Figure 1: Kernel patch for Auvidea j120 board.

Figure 1: Kernel patch for the board Auvidea j120.

In general, there is a more recent image patch from December 2021, however, after flashing this image, the USB ports on the board do not work, so the patch from February 2020 was chosen.

Next, run sdkmanager:
sdkmanager --archivedversions
Key archivedversions needed so that in the list of versions you can select the version we need Jet Pack 4.3. Otherwise, it will not be listed.

After launch sdkmanager A menu will appear asking you to enter your username and password from your account. Nvidia (Figure 2). If you don’t have an account, you can register on the site for free. nvidia.com.

Figure 2: sdkmanager start menu

Figure 2: Start Menu sdkmanager

After registration, you will be able to select a version jetpack and type Jetson (Figure 3). You need to choose the same as in Figure 3.

Figure 3: Selecting JetPack and Jetson versions.

Figure 3: Version selection jetpack And Jetson.

Next, go to the second step (Figure 4). At this step, the image is downloaded and the components are installed on the host.

Figure 4: Selecting components to install.

Figure 4: Selecting components to install.

We skip the next step, because you need to patch the jetson image to work with the board auvidea j120. Let’s say that the installation directory was “/tools/nvidia/”. Patch archive downloaded from the site auvidea unpack and make the necessary changes to the image in accordance with the instructions:
cp -r kernel_out/* /tools/nvidia/JetPack_4.3_Linux_JETSON_TX2/Linux_for_Tegra/
cd /tools/nvidia/JetPack_4.3_Linux_JETSON_TX2/Linux_for_Tegra/
sudo ./apply_binaries.sh

After we connect jetson to the PC and translate it into recovery modeto do this, hold down the button force recoverythen press the button reset and let go force recovery. Next, we flash Jetson:
cd /tools/nvidia/JetPack_4.3_Linux_JETSON_TX2/Linux_for_Tegra/
sudo ./flash.sh jetson-tx2 mmcblk0p1

TO Jetson connect the keyboard, mouse and monitor. It is necessary to configure the network and it is recommended to set the correct time. Further, we will assume that the address is configured as follows: 192.168.0.160, the user is nvidia and password – nvidia.

Build QT.

On the host, go to the directory “rootfs” and repair symbolic links:
cd /tools/nvidia/JetPack_4.3_Linux_JETSON_TX2/Linux_for_Tegra/rootfs

sudo ln -sf lib/aarch64-linux-gnu/libz.so.1 usr/lib/aarch64-linux-gnu/libz.so
sudo ln -sf lib/aarch64-linux-gnu/libm.so.6 usr/lib/aarch64-linux-gnu/libm.so
sudo ln -sf lib/aarch64-linux-gnu/libdl.so.2 usr/lib/aarch64-linux-gnu/libdl.so
sudo ln -sf lib/aarch64-linux-gnu/libpng12.so.0.54.0 usr/lib/aarch64-linux-gnu/libpng.so

Clone the repository and select the working branch:

git clone git://code.qt.io/qt/qtbase.git -b dev
cd qtbase
git checkout v5.12.10

Go to the folder with the repository and configure the assembly QT:

./configure -opensource --confirm-license -no-pkg-config -device linux-jetson-tx1-g++
-device-option CROSS_COMPILE=aarch64-linux-gnu-
-sysroot /tools/tx2/nvidia/JetPack_4.3_Linux_JETSON_TX2/Linux_for_Tegra/rootfs/ -prefix
/usr/local/qt5 -extprefix /tools/tx2/qt5 -hostprefix /tools/tx2/qt5-host
-nomake examples -nomake tests -no-opengl

Next, we collect QT:

make -j8
make install

The compiled versions of QT for the host and for the device will be located at the address specified during the build configuration, in this case at the address “/tools/tx2/“. On the jetson, create a folder and assign user rights to it:

mkdir /usr/local/qt5
sudo chown nvidia:nvidia qt5

Then we synchronize the folders from the host:

rsync -e ssh -avz qt5 nvidia@192.168.0.160:/usr/local

Build setup in QT Creator.

After building QT, it is recommended to configure QT Creator. For assembly in QT Creator you need to specify the compiler, QT assembly and bundle them into one set (Kit). As a compiler, we used the compiler Linarowhich can be downloaded from the website https://releases.linaro.org/components/toolchain/binaries/.

Figure 5: Adding a compiler to QT Creator.

Figure 5: Adding a compiler to QT Creator.

Figure 5 shows the added compiler Linaro version 4.9. After choosing a compiler, specify the path to qmake(figure 6).

Figure 6: Adding a QT version to QT Creator.

Figure 6: Adding the QT version to QT Creator.

Next, we combine the added tools into one set called “JetsonTx2“(Figure 7).

Figure 7: Creating a bundle in QT Creator.

Figure 7: Creating a kit in QT Creator.

Now you can collect projects under Jetson V QT Creator!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *