【米尔 NXP i.MX93 开发板评测】嵌入式QT开发
# 嵌入式QT测试iMX93支持`drm`。之前在IMX93上测试了一下`LVGL`,发现`LVGL`对`Linux`的优化不太好,有些场景有卡顿,LVGL还是比较适合单片机的应用场景。对比研究下来感觉还是QT更加适合嵌入式Linux UI应用。毕竟QT功能更加强大,如果QT用熟悉了,QT不仅仅可以开发UI程序,还能写一些复杂的服务。
## Linux显示子DRM
Linux DRM是Linux下比较新的显示子系统,相比之前的framebuffer功能更加强大。
配置`buildroot`,添加 test programs
查看当前`drm`驱动信息
```bash
modetest
```
测试,显示器会有彩色条纹抖动。
```bash
modetest -M imx-drm -s 35@33:720x1280 -v
```
## 事件测试
触摸屏触摸测试,从后面的说明可以看出`/dev/input/event1`为触摸屏,输入1,触摸屏幕看到有新事件。
```bash
# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: 44440000.bbnsm:pwrkey
/dev/input/event1: Goodix Capacitive TouchScreen
/dev/input/event2: gpio_keys@0
/dev/input/event3: Logitech Inc. Logi USB Headset H340 Consumer Control
/dev/input/event4: Logitech Inc. Logi USB Headset H340
Select the device event number : 1
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x416 product 0x38f version 0x1060
Input device name: "Goodix Capacitive TouchScreen"
```
## QT开发
从github同步最新的buildroot编译QT6.7,配置常用的库。
这是我当前的buildroot配置信息
```bash
BR2_aarch64=y
BR2_cortex_a55=y
BR2_ARM_FPU_VFPV4D16=y
BR2_KERNEL_HEADERS_6_1=y
BR2_PACKAGE_GLIBC_UTILS=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_PACKAGE_HOST_GDB=y
BR2_ENABLE_DEBUG=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_MDEV=y
BR2_ROOTFS_MERGED_USR=y
BR2_SYSTEM_DHCP="eth0"
BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin"
BR2_ENABLE_LOCALE_WHITELIST="en_US.UTF-8"
BR2_GENERATE_LOCALE="en_US.UTF-8"
BR2_SYSTEM_ENABLE_NLS=y
BR2_TARGET_TZ_INFO=y
BR2_PACKAGE_ALSA_UTILS=y
BR2_PACKAGE_ALSA_UTILS_ALSACONF=y
BR2_PACKAGE_ALSA_UTILS_ACONNECT=y
BR2_PACKAGE_ALSA_UTILS_ALSALOOP=y
BR2_PACKAGE_ALSA_UTILS_ALSAUCM=y
BR2_PACKAGE_ALSA_UTILS_ALSATPLG=y
BR2_PACKAGE_ALSA_UTILS_AMIDI=y
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
BR2_PACKAGE_ALSA_UTILS_APLAY=y
BR2_PACKAGE_ALSA_UTILS_APLAYMIDI=y
BR2_PACKAGE_ALSA_UTILS_ARECORDMIDI=y
BR2_PACKAGE_ALSA_UTILS_ASEQDUMP=y
BR2_PACKAGE_ALSA_UTILS_ASEQNET=y
BR2_PACKAGE_ALSA_UTILS_BAT=y
BR2_PACKAGE_ALSA_UTILS_IECSET=y
BR2_PACKAGE_ALSA_UTILS_SPEAKER_TEST=y
BR2_PACKAGE_FFMPEG_GPL=y
BR2_PACKAGE_FFMPEG_NONFREE=y
BR2_PACKAGE_FFMPEG_FFPLAY=y
BR2_PACKAGE_FFMPEG_FFPROBE=y
BR2_PACKAGE_FFMPEG_POSTPROC=y
BR2_PACKAGE_FLAC=y
BR2_PACKAGE_GSTREAMER1=y
BR2_PACKAGE_GSTREAMER1_CHECK=y
BR2_PACKAGE_GST1_PLUGINS_BASE_PLUGIN_APP=y
BR2_PACKAGE_GST1_PLUGINS_BAYER2RGB_NEON=y
BR2_PACKAGE_GST1_PLUGINS_GOOD=y
BR2_PACKAGE_GST1_PLUGINS_BAD=y
BR2_PACKAGE_GST1_LIBAV=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_GDB_SERVER=y
BR2_PACKAGE_GDB_DEBUGGER=y
BR2_PACKAGE_GDB_TUI=y
BR2_PACKAGE_BINUTILS=y
BR2_PACKAGE_BIN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ESWITCH=y
BR2_PACKAGE_FREESWITCH_MOD_BCG729=y
BR2_PACKAGE_OPENSSH=y
BR2_PACKAGE_TCPDUMP=y
BR2_PACKAGE_VSFTPD=y
BR2_PACKAGE_ZSH=y
BR2_PACKAGE_KMOD=y
BR2_PACKAGE_UTIL_LINUX_LIBFDISK=y
BR2_PACKAGE_UTIL_LINUX_AGETTY=y
BR2_PACKAGE_UTIL_LINUX_FSCK=y
BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y
BR2_PACKAGE_UTIL_LINUX_KILL=y
BR2_PACKAGE_UTIL_LINUX_LSFD=y
BR2_PACKAGE_UTIL_LINUX_MORE=y
BR2_PACKAGE_UTIL_LINUX_MOUNT=y
BR2_PACKAGE_UTIL_LINUX_SULOGIN=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_SIZE="512M"
BR2_TARGET_ROOTFS_TAR_GZIP=y
BR2_PACKAGE_HOST_ENVIRONMENT_SETUP=y
```
经过测试,低版本QT Creator交叉编译的QT APP应用程序可以运行在高版本库上面;但是高版本QT Creator 编译的app应用程序不能跑在低版本的QT库上面。
## 运行QT前的配置
通过上面的测试可知,触摸屏的input设备是 `/dev/input/event1`。注意我的buildroot里面配置了字体,如果不配置字体,QT应用会用方框代替字符。将下面的环境变量导入到当前终端中。
```bash
# 通过上面的evtest测试可知event1为触摸屏
export TSLIB_TSDEVICE=/dev/input/event1
export QT_QPA_FB_TSLIB=1
export QT_QPA_PLATFORM=linuxfb
export QT_QPA_FONTDIR=/usr/share/fonts
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
# QT适配高分屏
export QT_SCREEN_SCALE_FACTORS=2
```
打开程序测试,观察现象
下载QT开发工具:https://download.qt.io/archive/online_installers/
后面会写一篇上位机QT交叉编译器搭建,马上回来~
<p>谢谢分享,期待后续</p>
页:
[1]