Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Click on the “Embedded Application Research Institute” above, and select “Pin/Star the Official Account

Valuable Resources Delivered First-Hand!

Source | CSDN – Yu Ge Tou Tou

Compiled & Formatted | Embedded Application Research Institute

QT is currently one of the mainstream UI design software, and the Linux system supports QT applications, providing many convenient interfaces. Therefore, it is necessary to document various details of implementing UI interface functions based on QT on an LCD screen.

Learning video link:

https://www.bilibili.com/video/BV1pt4y1b7Mf/?spm_id_from=333.999.0.0&vd_source=4a2954680b189d193ad37cd99526e685)

1. System Configuration

For convenience, I used the factory system provided by ZhiDian YuanZi, which has QT pre-installed and configured, allowing for direct flashing of QT programs to achieve functionality.

The factory UI interface of ZhiDian YuanZi has already been written in, so the next step is to modify it.

2. Configuring Qt Creator

For the installation of cross-compilation work, refer to the relevant documentation from ZhiDian YuanZi, which will not be elaborated here.

Startup

During startup, it is necessary to load the cross-compiler, so the corresponding command needs to be inserted into qtcreator.sh

sudo vi /opt/QT5.12.12/Tools/QtCreator/bin/qtcreator.sh # Adjust according to your QT installation path

Insert the following command on the first line

source /opt/st/stm32mp1/3.1-snapshot/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Use the following command to start (you can also write it into a .sh file for easier startup)

/opt/Qt5.12.9/Tools/QtCreator/bin/qtcreator.sh &

Compiler Configuration

Embedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded Devices

Create a new project and select the following compilation kit

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Compile

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Remote Debugging

Embedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded DevicesEmbedded Linux Learning Notes: Using QT on Linux Embedded Devices

Configure debugging in Linuxfb/eglfs mode (just modify Command line arguments to linuxfb or eglfs)

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Note: This step of Upload Files via SFTP must also be added, otherwise new code will not be automatically uploaded to the development board

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Note: linuxfb uses pure software rendering, while eglfs uses GPU rendering, the latter provides smoother display.

However, eglfs is only available when using EMMC to boot the Linux kernel and root filesystem; for remote network debugging, only linuxfb mode can be used.

After configuration, when running the program, Qt Creator will send the program to the development board and then start running.

Local Debugging on Ubuntu

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

3. Modifying the Kernel Boot LOGO

(1) Modify the logo display source code

Modify the fbcon.c file’s fbcon_prepare_logo function

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

Modify the fbmem.c file’s fb_show_logo_line function

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

(2) Prepare a .png image that fits the screen size

Embedded Linux Learning Notes: Using QT on Linux Embedded Devices

(3) Use the netpbm image conversion library to process the image

pngtopnm logo.png > logo.pnm # Convert formatpnmquant 224 logo.pnm > logo_224.pnm # Modify color channel countpnmtoplainpnm logo_224.pnm > logo_linux_clut224.ppm # Convert format

**(4) Place the file in the specified path **

sudo cp logo_linux_clut224.ppm kernel_path/drivers/video/logo

After recompiling the kernel, use the new kernel to boot the development board.

4. Configure Auto-Start UI Interface

Disable the factory UI service of ZhiDian YuanZi

systemctl disable atk-qtapp-start.service # Execute this to disable Qt desktop service, it won't take effect on the next startupsystemctl enable atk-qtapp-start.service # Execute this to enable Qt desktop service systemctl stop atk-qtapp-start.service # Temporarily stop Qt desktop service, use restart to restart the service

Command to start the UI interface

/usr/local/test -platform linuxfb # Adjust according to the path where you placed the UI program

Create an auto-start service

cd /lib/systemd/systemtouch jozen-qt-start.servicevi jozen-qt-start.service
# Add the following content[Unit]Description=Run a Custom Script at StartupAfter=default.target
[Service]ExecStart=/usr/local/test -platform linuxfb
[Install]WantedBy=default.target

After writing, enable it using the syscmd command above.

Copyright Statement: This article is an original work by CSDN blogger “Yu Ge Tou Tou”, following the CC 4.0 BY-SA copyright agreement. Please include the original source link and this statement when reprinting.

Original link:

https://blog.csdn.net/weixin_45728705/article/details/129805576

Previous Highlights

[In-depth] Understanding volatile behavior from a microscopic perspective

Book Reflection Sharing (1) – Replicable Leadership

Little Bear’s Douyin video of his son riding a motorcycle, smoothness 666666

Linux Driver Development / GPIO Subsystem / Quick Start

Step-by-step guide to implementing OLED video playback on STM32 (very simple yet very intensive!).

If you find this article helpful, please click [Looking] and share it, which is also a support for me.

Leave a Comment