ZPC是ZLG全新研发的显控一体机。开源AWTK,版权无忧!多种工业通信协议,工业互联无壁垒!ZWS数据上云很轻松!更有AWFlow,应用开发很简单!本文将介绍如何在ZPC上快速移植AWTK。
ZPC系列显控一体机 是广州致远电子全新研发的集“显示”+“控制”一体化的高性能显控终端产品。外框采用铝合金材质,简洁耐用;产品集成了多路隔离RS485、多路隔离CAN总线、多路千兆以太网等丰富外设。一触即发,随心控制。产品支持多种工业通信协议,工业互联无壁垒!支持ZWS,数据上云很轻松!支持AWFlow,应用开发很简单!还支持开源AWTK GUI,版权无忧!可以快速创作您的HMI作品。
准备工作
装有Ubuntu系统或Ubuntu虚拟机的可连接外网的PC 1台;
ZPC-101Q55RTW-01显控一体机1台;
USB转RS232调试串口1个;
12V@2A的电源适配器1个;
MobaXterm串口调试上位机;
TF卡或U盘或网线等。
https://gitee.com/zlgopen/awtk
按照以下步骤,在PC虚拟机上进行操作:
host$ sudo apt install gcc-aarch64-linux-gnu git scons
//使用apt指令下载所需的工具
host$ mkdir awtk-demo && cd awtk-demo
//创建一个新的文件夹
host$ git clone https://gitee.com/zlgopen/awtk.git
//使用git克隆awtk仓库到本地,awtk为AWTK代码本仓,包含了AWTK最主要的代码
host$ git clone https://gitee.com/zlgopen/awtk-linux-fb.git
//使用git克隆awtk-linux-fb仓库到本地,awtk-linux-fb为针对嵌入式的Frame buffer机制和DRM机制的仓库
host$ ls
awtk awtk-linux-fb
host$ cd awtk-linux-fb
Ubuntu上编辑/etc/apt/sources.list 文件,将它改为如下内容:
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal universe
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-updates universe
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal multiverse
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-updates multiverse
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-security universe
deb [arch=amd64] https://mirrors.ustc.edu.cn/ubuntu/ focal-security multiverse
Ubuntu上编辑/etc/apt/sources.list.d/ubuntu-ports.list ,如果文件不存在,则创建,将它改为如下内容:
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal main restricted
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates main restricted
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal universe
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates universe
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal multiverse
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-updates multiverse
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security main restricted
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security universe
deb [arch=arm64,armhf] https://mirrors.ustc.edu.cn/ubuntu-ports/ focal-security multiverse
由于AWTK触摸功能依赖于tslib触摸库,所以Ubuntu需要下载ARM64架构的tslib。
host$ sudo dpkg --add-architecture arm64
host$ sudo apt update
host$ sudo apt install libts0:arm64 libts-dev:arm64 libdrm-dev:arm64
3. 修改代码
注:以下修改在awtk-linux-fb目录下
...
#LCD_DEVICES='fb'
LCD_DEVICES='drm'
...
修改tslib依赖库在本机的位置,Ubuntu默认位置如下:
...
TSLIB_LIB_DIR='/usr/lib/aarch64-linux-gnu/ts0'
TSLIB_INC_DIR='/usr/include'
...
修改编译工具链的指令,再次选择Ubuntu下的arm64交叉编译工具链:
...
TOOLS_PREFIX='aarch64-linux-gnu-'
...
host$ aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --without-target-system-zlib --enable-libpth-m2 --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
host$ mv config/devices.json.in config/devices.json
{
"/dev/fb0" : {
"type" : "fb"
},
"/dev/dri/card0" : {
"type" : "drm"
},
"/dev/input/event1" : {
"type" : "ts"
}
}
...
'ENABLE_CURSOR' : { 'value' : False, 'type' : bool.__name__, 'desc' : ['enable cursor mouse'], 'help_info' : 'set enable cursor mouse, value is true or false'},
...
4. 编译代码
host$ scons
host$ awtk-linux-fb ./release.sh
EXE_NAME = demoui
APP_ROOT = ../awtk
==================================================
EXE_NAME:demoui
ASSETS_DIR:../awtk/res/assets
OUTPUT_DIR:/home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/release
BIN_DIR:/home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/bin
==================================================
/home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/bin/demoui->/home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/release/bin/demoui
copy shared lib: /home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/bin/libtkc.so ==> /home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/release/bin/libtkc.so
copy shared lib: /home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/bin/libawtk.so ==> /home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/release/bin/libawtk.so
../awtk/res/assets->/home/felix/Workspace/Testcodes/awtk-demo/awtk-linux-fb/release/assets
host$ awtk-linux-fb ls -l release.tar.gz
-rw-rw-r-- 1 felix felix 8262509 7月 9 09:52 release.tar.gz
拷贝release.tar.gz文件到ZPC一体机的/root文件夹下,并按照以下指令分别执行对应解压命令解压包、设置执行权限等。
[root@zpc:~]
......
[root@zpc:~]
执行以下指令,即可运行示例demo如下图所示。
[root@zpc:~]# ./release/bin/demoui
默认系统会进入Debian系统的LXDE界面,当使用AWTK进行开发时,不需要原生桌面的情况下,可以执行以下指令关闭原生桌面,提高启动速度。
[root@zpc:~]
Synchronizing state of lightdm.service with SysV service script with /lib/systemd/systemd-....
Executing: /lib/systemd/systemd-sysv-install disable lightdm
Removed /etc/systemd/system/display-manager.service.
基于systemd创建属于awtk的运行服务,创建/usr/lib/systemd/system/awtkdemo.service文件并修改为以下内容:
[Unit]
Description=AWTK demo
After=network.target
[Service]
Type=simple
ExecStart=/root/release/bin/demoui #这里是运行路径,根据实际情况修改
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target
然后执行以下指令开启awtk的运行服务。
[root@zpc:/usr/lib/systemd/system]
Created symlink /etc/systemd/system/multi-user.target.wants/awtkdemo.service → /lib/system...
执行reboot指令后,则可看到系统启动时没有进入本来的LXDE桌面,而是直接启动AWTK示例。