工控網(wǎng)首頁(yè)
>

應(yīng)用設(shè)計(jì)

>

基于 TI AM62 測(cè)試 QtWayland 部署

基于 TI AM62 測(cè)試 QtWayland 部署

1). 簡(jiǎn)介

目前主流的 ARM 平臺(tái)嵌入式 Linux BSP 的顯示后端基本都已經(jīng)從 X11 升級(jí)到了 Wayland, 而常用的 Wayland Compositor - Weston 對(duì)于 Linux 下常用的 Qt 圖形界面開發(fā)框架的一些 Plugin (比如 Qt VirtualKeyboard) 的配合并不完善,因此本文就基于 TI AM62 處理器平臺(tái)測(cè)試 Qt 提供的 Wayland Compositor - QtWayland 的部署測(cè)試。

 

本文所演示的平臺(tái)來自于 Toradex Verdin AM62 嵌入式平臺(tái)。

 

 

2. 準(zhǔn)備

a). Verdin AM62 ARM核心版配合Dahlia 載板,并連接調(diào)試串口和 HDMI 顯示器以及 USB 觸摸/鼠標(biāo)用于測(cè)試。

 

 

3). Verdin AM62 Yocto Linux 編譯部署以及配置

a). 由于需要增加對(duì)Qt Eglfs/KMS, QtWayland 和 Qt VirtualKeyboard 的支持,需要通過Yocto/Openembedded 框架重新編譯 Yocto Linux BSP,具體的配置方法請(qǐng)參考這里部署如下修改后編譯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注釋掉以下內(nèi)容 ###

 ############################### 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默認(rèn)即可正常顯示,如果實(shí)際測(cè)試是連接其他接口如 LVDS 等顯示設(shè)備,可以參考這里調(diào)整 Device-Tree Overlay 設(shè)置來使能相關(guān)的顯示設(shè)備。

 

.輸入設(shè)備如 USB HID 電容式觸摸或者 USB 鼠標(biāo)通常無需額外設(shè)置,插上即可使用。

 

 

4). Qtwayland compositor 編譯部署

a). Qt Qtwayland組件可以非常方便的使用C++/QML語(yǔ)言開發(fā)定制化的Wayland compositor,詳細(xì)說明請(qǐng)見這里,也提供了很多sample project供參考

 

b). 本文測(cè)試所使用的Qtwayland compositor 來自于Qt 官方的 Pure-qml sample 示例,源代碼請(qǐng)參考這里,這是一個(gè)基于 QML 開發(fā)的并且支持 Qt VirtualKeyboard plugin 的簡(jiǎn)單 Qtwayland compositor

 

c). 參考這里說明使用上面章節(jié) 3.a編譯出的SDK文件配置 Qtcreator IDE 工具交叉編譯環(huán)境,然后下載 Pure-qml 工程源代碼后通過 Qtcreator IDE 進(jìn)行交叉編譯,生成 pure-qml 可執(zhí)行二進(jìn)制文件上傳到 Verdin AM62 Linux 系統(tǒng)中

 

d). 使用編譯好的 pure-qml Qtwayland compositor 替換系統(tǒng)默認(rèn)的Weston compositor

.創(chuàng)建pure-qml.sh執(zhí)行腳本文件

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

# 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 – 由于系統(tǒng) DRM 掛載顯示設(shè)備在啟動(dòng)過程中,其對(duì)應(yīng)的 card 號(hào)碼可能會(huì)變化, 因此腳本前面先對(duì) kms.conf” 文件里面的設(shè)置和系統(tǒng)啟動(dòng)后的設(shè)備card0 或者 card1 進(jìn)行匹配修改,后再啟動(dòng)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 &

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

 

.創(chuàng)建Qtwayland systemd service 文件,參考這里說明,Qt VirtualKeyboard 基于 Wayland Compositor 使用時(shí)候,需要在 Compositor 側(cè)配置 “QT_IM_MODULE” 環(huán)境變量,而不是應(yīng)用側(cè)。

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

$ 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). 測(cè)試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 顯示結(jié)果

基于 TI AM62 測(cè)試 QtWayland 部署6524.png 

 

 

5). Qt VirtualKeyboard Example應(yīng)用測(cè)試

a). 分別使用一個(gè)Qt Widget應(yīng)用和一個(gè)Qt Quick應(yīng)用進(jìn)行測(cè)試

.Qt Widget應(yīng)用 – Line Edits Example,詳細(xì)說明請(qǐng)參考這里,源碼從這里下載,將編譯好的可執(zhí)行binary “lineedits” 上傳到 Verdin AM62 Linux /home/root 目錄

./ Qt Quick 應(yīng)用 – Qt VirtualKeyboard Basic Example,詳細(xì)說明請(qǐng)參考這里,源碼從這里下載,如上面 4.d 章節(jié)所提到的,需要如下修改 main.cpp 將環(huán)境變量取消導(dǎo)出,然后將編譯好的可執(zhí)行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). 創(chuàng)建應(yīng)用啟動(dòng)腳本 /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). 創(chuàng)建開機(jī)自啟動(dòng)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 并測(cè)試

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

$ systemctl enable qtwayland-app-launch

$ reboot

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

 

e). 重啟后分別啟動(dòng) basic 和 lineedits 應(yīng)用效果如下,USB HID 電容觸摸和鼠標(biāo)都可以正常操作虛擬鍵盤輸入

基于 TI AM62 測(cè)試 QtWayland 部署8563.png 

基于 TI AM62 測(cè)試 QtWayland 部署8565.png 

6). 總結(jié)

本文基于 Ti AM62 處理器演示了 QtWayland compositor 的部署以及 Qt VirtualKeyboard 應(yīng)用的測(cè)試。

審核編輯(
王靜
)
投訴建議

提交

查看更多評(píng)論
其他資訊

查看更多

Verdin AM62 LVGL 移植

基于 NXP iMX8MM 測(cè)試 Secure Boot 功能

隆重推出 Aquila - 新一代 Toradex 計(jì)算機(jī)模塊

Verdin iMX8MP 調(diào)試串口更改

NXP iMX8MM Cortex-M4 核心 GPT Capture 測(cè)試