For some high-end use cases, like car self-driving, medical devices, telemetry equipments and so forth, the specification are usually peculiar for the goal of the devices. In some case, Nvidia® Jetson series fill the requirements: the embedded systems integrated with the CUDA function : a special system, with the special peripherals and sensors, with the special computation ability for the peculiar purpose.
However, the Nvidia® Jetson documents for building the Qt Libraries are limited. So, I write this post to show how to cross-compile shared libraries, and set the environment and set the QtCreator for Jetson TX2 Qt applications. The same procedures also works for TX1.
Due to the application on an embedded system is only for a specific purpose, the GUI system is not necessary to be window form : the whole system is for an application only. Therefore, maybe it is necessary to build the Qt libraries supporting with the full-screen form.
零. Download Jetpack and use it to flash the TX2.
The Jetpacks is here, you need to register a Nvidia account for the downloading. I use v. 3.3.
There are some detail tutorials and videos for the Jetpack setting, like this or this or this. I denote 2 precautions here:
甲. Your host Linux must be installed with xterm, or the Jetpack will be hanging while it should start downloading (after Network layout page).
乙. You could not run the Jetpack on LXDE environment, or the Jetpack program would be hanging in the component manager page.
After the flashing has been done, make sure your host is able to connect to the TX2. You could use ssh command in your host, to check is the connection workable or not.
the password is also nvidia in default.
※ How to set TX2 UART could be found here.
一. Prepare the necessary libraries and headers on TX2.
※The works are all in the TX2.
甲. install some packets to support the Qt build.
乙. Extract the GLES and EGL headers, and put them under /usr/include.
The commands are :
丙. Create a symbolic link libGLESv2.so :
丁. To leave the Nvidia-built Qt librares intact, we prepare a new directory to content the new build :
To here, the work on TX2 comes a stop.
二. Prepare the cross-compilation environment in the host.
※ The works are in the host machine.
甲. Create a directory as the TX2's rootfs , and change your current directory to that, then copy the necessary folders from the TX2:
乙. Fix the necessary symbolic links :
丙. Install the prerequisite packages.
※ Some packets may be not necessary.
丁. Prepare the toolchain:
Linaro GCC 5.5 is here, please download the gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu.tar.xz file, and move it to an appropriate location, then extract it.
I strongly recommend you should NOT use the aarch64-linux-gnu-g++ from apt-get, it will make the toolchain path setting complicated.
戊. Download Qt everywhere.
Qt everywhere is here. download a qt-everywhere tar ball, (I download qt-everywhere-src-5.13.0.tar.xz.) and extract it.
三. Compilation Qt for TX2.
甲. There is no mkspecs file for TX2, we use the TX1's. But the TX1's mkspecs needs to be modified, to avoid the compilation error.
※ The modification is necessary even your build is for TX1, as it is a bug of include path duplicate.
Comment out the line 29, in file where_the_qt_everywhere_extracted/qtbase/mkspecs/devices/linux-jetson-tx1-g++/qmake.conf.
乙 Configuration for build.
Move your directory to the root of where_the_qt_everywhere_extracted, and configurate Qt as below :
Below explain the arguments about the path.
-prefix: indicates where the built libraries will be placed in the TX2, my argument is /usr/local/qt5.
-extprefix : It specifies where the built libraries will be placed in the host, I require the path is qt_everywhere_folder/JetsonTX2/qt5.
-hostprefix : the compilation tools path. The compilation tools would be imported into the QtCreator in the host. My argument is qt_everywhere_folder/JetsonTX2/qt5-host.
Denote : All the paths had better to be the absolute paths.
丙. build Qt libraries:
The build process costs a long time.
After "make install", the Qt libraries for TX2 (qt_everywhere folder/JetsonTX2/qt5) and the host tools(qt_everywhere folder/JetsonTX2/qt5-host) will be generated. Now we copy the libraries to the TX2 :
四. Set Qt running environment on TX2.
※The works are all in the TX2.
The window mode, on XCB :
Create a file /etc/profile.d/qt_xcb.sh in your TX2, the file contents :
And bring the values into the current shell :
Test if the Qt application works or not :
The fullscreen mode, on EGLFS:
Create a file /etc/profile.d/qt_eglfs.sh in your TX2, the file contents :
※We specify the Qt applications running on EGLFS, therefore, we need to set the EGLFS environment variables. The description of all EGLFS variables is here.
Create a file under the directory /etc/udev/rules.d to enable the access permission of /dev/input/eventX. The file name could be as your wish, mine is 00-event.rules. Its content is:
Then , reboot your TX2.
/usr/local/qt5/bin/qtbusviewer would appear like below figure, that is fullscreen application.
Attention :: The application is full screen, so there is no max, min or close button.
五. Integrate the toolchain and host tools into QtCreator.
※ I assume your TX2 is online and be with your host at the same network segment.
Open QtCreator, go to Menu -> Tools -> Options, then the row Build and Run.
甲. Page Qt Versions, to add the qmake file, which located in the host_tool_path/bin (qt_everywhere_folder/JetsonTX2/qt5-host, the argument of -hostprefix).
乙. Page compilers, to add the linaro C++ compilers, aarch64-linux-gnu-g++. Besides, You might also need to add the C compiler.
丙. Page debugger, add the linaro debugger, aarch64-linux-gnu-gdb:
丁. In row devices, add a device for TX2, and set its ip, user id and password (default: nvidia/nvidia).
戊. Back row Build & Run, in page Kits, add a kit for TX2, and set the device, rootfs, compiler, Qt versions and so forth for TX2.
己. Create a Qt application in the QtCreator, select the kit for TX2. While the project has been generated automatically, add the 2 lines in the .pro file :
The lines could be placed anywhere of .pro.
庚. Press Run or Start Debugging button, the application will run in the TX2, and the debugger should work perfectly.