toradex的个人空间 https://blog.eetop.cn/1539194 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

基于 TI AM62 测试 QtWayland 部署

已有 352 次阅读| 2024-7-10 17:00 |系统分类:嵌入式| ARM, Linux, QtWayland, TI, AM62

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 应用的测试。




点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 3

    粉丝
  • 0

    好友
  • 1

    获赞
  • 2

    评论
  • 13923

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-27 11:49 , Processed in 0.017330 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部