专栏中心

EEPW首页 > 专栏 > 基于 TI AM62 测试 QtWayland 部署

基于 TI AM62 测试 QtWayland 部署

发布人:toradex 时间:2024-07-10 来源:工程师 发布文章

By Toradex秦海

1). 简介

目前主流的 ARM 平台嵌入式 Linux BSP 的显示后端基本都已经从 X11 升级到了 Wayland, 而常用的 Wayland Compositor - Weston 对于 Linux 下常用的 Qt 图形界面开发框架的一些 Plugin (比如 Qt VirtualKeyboard) 的配合并不完善,因此本文就基于 TI AM62 处理器平台测试 Qt 提供的 Wayland Compositor - QtWayland 的部署测试。

 

本文所演示的平台来自于 Toradex Verdin AM62 嵌入式平台

 

 

2. 准备

a). Verdin AM62 ARM核心版配合Dahlia 载板,并连接调试串口和 HDMI 显示器以及 USB 触摸/鼠标用于测试

 

 

3). Verdin AM62 Yocto Linux 编译部署以及配置

a). 由于需要增加对Qt Eglfs/KMS, QtWayland Qt VirtualKeyboard 的支持,需要通过Yocto/Openembedded 框架重新编译 Yocto Linux BSP,具体的配置方法请参考这里部署如下修改后编译Reference-Multimedia image镜像

-------------------------------

### local.conf,增加Qt eglfs/kms, Qtwayland Qt VirtualKeyboard 支持 ###

+ TOOLCHAIN_TARGET_TASK:append = " libgles3-mesa-dev"

+ IMAGE_INSTALL:append = " qtvirtualkeyboard qtwayland ttf-droid-sans ttf-droid-sans-fallback ttf-droid-sans-mono ttf-droid-serif freetype"

+ PACKAGECONFIG:append:pn-qtvirtualkeyboard = " lang-zh_CN"

+ PACKAGECONFIG:append:pn-qtbase = " gles2extra eglfs kms"

+ PACKAGECONFIG_DISTRO:pn-qtbase = "icu examples accessibility gif gbm kms libinput"

+ PACKAGECONFIG_FONTS:pn-qtbase = "fontconfig"

+ PACKAGECONFIG:remove:pn-qtwayland = "xcomposite-egl xcomposite-glx"

 

### layers/meta-toradex-ti/qt5-layer/recipes-qt/qt5/qtbase_%.bbappend注释掉以下内容 ###

 ############################### TDX added

 

 # from meta-arago/conf/layer.conf

-PACKAGECONFIG_GL:am62xx = "gles2extra linuxfb"

-PACKAGECONFIG_DISTRO:am62xx = "icu examples accessibility gif gbm kms libinput"

-PACKAGECONFIG_FONTS:am62xx = "fontconfig"

+#PACKAGECONFIG_GL:am62xx = "gles2extra linuxfb"

+#PACKAGECONFIG_DISTRO:am62xx = "icu examples accessibility gif gbm kms libinput"

+#PACKAGECONFIG_FONTS:am62xx = "fontconfig"

 

-PACKAGECONFIG:remove:am62xx = "kms"

-PACKAGECONFIG:remove:am62xx = "vulkan"

-PACKAGECONFIG:remove:am62xx = "glib xcb"

+#PACKAGECONFIG:remove:am62xx = "kms"

+#PACKAGECONFIG:remove:am62xx = "vulkan"

+#PACKAGECONFIG:remove:am62xx = "glib xcb"

 # they don't apply without changes, drop them for now

-SRC_URI:remove = " \

-    file://0002-deform-disable-opengl-button.patch \

-    \

-    file://0001-deform-Fix-how-controls-are-shown.patch \

-    file://0001-qtbase-plugins-platforms-eglfs_kms-fix-compiler-erro.patch \

-    file://0001-eglfs-Force-888-format-only-on-env-flag.patch \

-"

+#SRC_URI:remove = " \

+#    file://0002-deform-disable-opengl-button.patch \

+#    \

+#    file://0001-deform-Fix-how-controls-are-shown.patch \

+#    file://0001-qtbase-plugins-platforms-eglfs_kms-fix-compiler-erro.patch \

+#    file://0001-eglfs-Force-888-format-only-on-env-flag.patch \

+#"

 

### compile Reference-Multimedia image ###

$ MACHINE="verdin-am62" bitbake bitbake tdx-reference-multimedia-image

 

### compile SDK ###

$ MACHINE="verdin-am62" bitbake tdx-reference-multimedia-image -c populate_sdk

-------------------------------

 

b). Yocto Linux image部署

参考这里通过Toradex Easy installer将上面编译好的image更新部署到模块

 

c). 显示配置

./ HDMI默认即可正常显示,如果实际测试是连接其他接口如 LVDS 等显示设备,可以参考这里调整 Device-Tree Overlay 设置来使能相关的显示设备。

 

./ 输入设备如 USB HID 电容式触摸或者 USB 鼠标通常无需额外设置,插上即可使用。

 

 

4). Qtwayland compositor 编译部署

a). Qt Qtwayland组件可以非常方便的使用C++/QML语言开发定制化的Wayland compositor,详细说明请见这里,也提供了很多sample project供参考

 

b). 本文测试所使用的Qtwayland compositor 来自于Qt 官方的 Pure-qml sample 示例,源代码请参考这里,这是一个基于 QML 开发的并且支持 Qt VirtualKeyboard plugin 的简单 Qtwayland compositor

 

c). 参考这里说明使用上面章节 3.a编译出的SDK文件配置 Qtcreator IDE 工具交叉编译环境,然后下载 Pure-qml 工程源代码后通过 Qtcreator IDE 进行交叉编译,生成 pure-qml 可执行二进制文件上传到 Verdin AM62 Linux 系统中

 

d). 使用编译好的 pure-qml Qtwayland compositor 替换系统默认的Weston compositor

./ 创建pure-qml.sh执行脚本文件

-------------------------------

# copy pure-qml binary to /usr/bin

$ cp pure-qml /usr/bin/

 

# create pure-qml.sh script, detailed content in below

$ vi /usr/bin/pure-qml.sh

 

# add executable permission

$ chmod +x pure-qml.sh

-------------------------------

 

./ pure-qml.sh – 由于系统 DRM 挂载显示设备在启动过程中,其对应的 card 号码可能会变化, 因此脚本前面先对 kms.conf” 文件里面的设置和系统启动后的设备card0 或者 card1 进行匹配修改后再启动compositor

-------------------------------

#!/bin/sh

set -e

 

# modify kms.conf if seetings is not consistent with system drm card device name

if [ -d /sys/class/drm/card0-HDMI-A-1 ];then

sed -i '2 s/card1/card0/' /etc/qt5/eglfs_kms_cfg.json

fi

 

if [ -d /sys/class/drm/card1-HDMI-A-1 ];then

sed -i '2 s/card0/card1/' /etc/qt5/eglfs_kms_cfg.json

fi

 

# execute qtwayland compositor

/usr/bin/pure-qml &

-------------------------------

 

./ 创建Qtwayland systemd service 文件参考这里说明,Qt VirtualKeyboard 基于 Wayland Compositor 使用时候,需要在 Compositor 侧配置 “QT_IM_MODULE” 环境变量,而不是应用侧。

-------------------------------

$ vi /lib/systemd/system/qtwayland.service

------

# This is a system unit for launching QtWayland

[Unit]

Description=Qt Wayland, a Wayland compositor, as a system service

 

RequiresMountsFor=/run

# Make sure we are started after logins are permitted.

Requires=systemd-user-sessions.service

After=systemd-user-sessions.service

After=plymouth-quit-wait.service

Before=graphical.target

 

[Service]

Environment="QT_QPA_EGLFS_KMS_CONFIG=/etc/qt5/eglfs_kms_cfg.json"

Environment="QT_QPA_EGLFS_INTEGRATION=eglfs_kms"

Environment="QT_QPA_PLATFORM=eglfs"

Environment="QT_QPA_EGLFS_KMS_ATOMIC=1"

Environment="QT_IM_MODULE=qtvirtualkeyboard"

ExecStart=/usr/bin/pure-qml.sh

 

User=root

Group=root

PAMName=login

StandardOutput=journal

StandardError=journal

 

[Install]

WantedBy=graphical.target

------

-------------------------------

 

e). 测试Qtwayland compositor

-------------------------------

### disable default Weston compositor and Qt demo app ###

$ systemctl disable weston.service

$ systemctl disable weston.socket

$ systemctl disable wayland-app-launch

### enable Qt wayland compositor ###

$ systemctl enable qtwayland

$ reboot

-------------------------------

 

重启后,可以看到如下 Qt Compositor pure-qml 显示结果

基于 TI AM62 测试 QtWayland 部署6524.png 

 

 

5). Qt VirtualKeyboard Example应用测试

a). 分别使用一个Qt Widget应用和一个Qt Quick应用进行测试

./ Qt Widget应用 Line Edits Example,详细说明请参考这里,源码从这里下载,将编译好的可执行binary lineedits上传到 Verdin AM62 Linux /home/root 目录

./ Qt Quick 应用 Qt VirtualKeyboard Basic Example,详细说明请参考这里源码从这里下载,如上面 4.d 章节所提到的,需要如下修改 main.cpp 将环境变量取消导出,然后将编译好的可执行binary basic上传到 Verdin AM62 Linux /home/root 目录

-------------------------------

...

int main(int argc, char *argv[])

{

    //qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));

 

    QGuiApplication app(argc, argv);

    QQuickView view(QString("qrc:/%2").arg(MAIN_QML));

    ...

}

-------------------------------

 

b). 创建应用启动脚本 /home/root/qtwayland-app-launch.sh

-------------------------------

#!/bin/sh

# export display environment

export XDG_RUNTIME_DIR=/run/user/`id -u`

export WAYLAND_DISPLAY=/run/user/`id -u`/wayland-0

if ! test -d "$XDG_RUNTIME_DIR"; then

    mkdir --parents $XDG_RUNTIME_DIR

    chmod 0700 $XDG_RUNTIME_DIR

fi

 

# wait for qtwayland

while [ ! -e  $XDG_RUNTIME_DIR/wayland-0 ] ; do sleep 0.1; done

sleep 1

# run basic or lineedits app

/home/root/basic -platform wayland &

#/home/root/lineedits -platform wayland &

-------------------------------

 

c). 创建开机自启动systemd service文件

-------------------------------

$ vi /lib/systemd/system/qtwayland-app-launch.service

[Unit]

Description=Start a Qt wayland application

After=qtwayland.service

Requires=qtwayland.service

 

[Service]

Restart=on-failure

Type=forking

ExecStart=/home/root/qtwayland-app-launch.sh

RestartSec=1

 

[Install]

WantedBy=graphical.target

-------------------------------

 

d). enable service 并测试

-------------------------------

$ systemctl enable qtwayland-app-launch

$ reboot

-------------------------------

 

e). 重启后分别启动 basic lineedits 应用效果如下USB HID 电容触摸和鼠标都可以正常操作虚拟键盘输入

基于 TI AM62 测试 QtWayland 部署8563.png 

基于 TI AM62 测试 QtWayland 部署8565.png 


6). 总结

本文基于 Ti AM62 处理器演示了 QtWayland compositor 的部署以及 Qt VirtualKeyboard 应用的测试。


专栏文章内容及配图由作者撰写发布,仅供工程师学习之用,如有侵权或者其他违规问题,请联系本站处理。 联系我们

关键词: ARM Linux QtWayland TI AM62 Toradex Verdin Weston

相关推荐

倾情奉献:MSP430汇编指令集(中文),详解带实例!

ARM Axion 处理器加持谷歌第八代 TPU,云端全面转向智能体 AI 架构

三步搞定隔离式放大器选择|隔离、供电、量程

最新ARM技术和嵌入式技术发展动态 中

视频 2009-10-22

Arm宣布推出Performix,为开发者带来 AI 时代必备的可扩展性能

人形机器人的触觉与语音能力正飞速提升

Arm CEO:AI智能体将推动CPU核心数升至 512

网络与存储 2026-05-11

ARM开发详解

安谋科技Arm China与国民技术签署Arm Total Access授权许可协议,加速AI时代MCU灵活创新与高效落地

ARM 展示小型低功耗上网本样品

视频 2009-03-16

边缘 AI 加速的 Arm Cortex‑M0+ MCU 如何为电子产品注入更强智能

Arm财报过山车:营收创纪录,股价跌7%

AI 数据中心继续扩张,电源和光互连都在升级

最新ARM技术和嵌入式技术发展动态 下

视频 2009-10-22

arm学习资料

资源下载 2007-12-03

Arm遭遇监管危机:FTC针对其技术授权启动反垄断调查

2026-05-18

ARM嵌入式软件编程经验谈

WinCE+ARM开发及关键技术 下

视频 2009-10-22

WinCE+ARM开发及关键技术 上

视频 2009-10-22
更多 培训课堂
更多 焦点
更多 视频

技术专区