上篇文章介绍了STM32MP157D-DK1开发板Qt镜像的构建,通过在Ubuntu中重新编译带有Qt功能的系统来实现。
本篇在上篇的基础上,继续搭建Qt的交叉编译环境,实现Qt程序在Ubuntu中编译,在STM32MP157板子中运行。
1 编译安装SDK
在上篇编译系统镜像的基础上,继续编译和安装SDK。
1.1 编译SDK
执行如下执指令编译带有Qt功能的SDK:
bitbake st-example-image-qtwayland -c populate_sdk
中途如果报do_fetch失败的错误,可参考上篇编译镜像时的do_fetch失败的解决方法。
最终编译成功的结果如下:
对应的打印如下:
xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$ bitbake st-example-image-qtwayland -c populate_sdk
NOTE: Started PRServer with DBfile: /home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, Address: 127.0.0.1:36533, PID: 2974644
Loading cache: 100% |###############################################################################################################################################################| Time: 0:00:01
Loaded 4879 entries from dependency cache.
Parsing recipes: 100% |#############################################################################################################################################################| Time: 0:00:01
Parsing of 3068 .bb files complete (3067 cached, 1 parsed). 4879 targets, 562 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependenciesBuild Configuration:
BB_VERSION = "2.4.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-ostl-linux-gnueabi"
MACHINE = "stm32mp1"
DISTRO = "openstlinux-weston"
DISTRO_VERSION = "4.2.1-snapshot-20231224"
TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard"
TARGET_FPU = "hard"
DISTRO_CODENAME = "mickledore"
ACCEPT_EULA_stm32mp1 = "1"
GCCVERSION = "12.%"
PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp"
meta-python
meta-oe
meta-gnome
meta-initramfs
meta-multimedia
meta-networking
meta-webserver
meta-filesystems
meta-perl = "HEAD:c032fd0b1a9d444711103c2703dfa8e2964a3865"
meta-st-stm32mp = "HEAD:931b3f5be2c00f55d114c8f9122082a9d229b776"
meta-qt5 = "HEAD:cf6ffcbad5275a3428f6046468a0c9d572e813d1"
meta-st-openstlinux = "HEAD:8c780facff81d3c3878c5fdcd18bdd24fc36478d"
meta = "HEAD:20cd64812d286c920bd766145ab1cd968e72667e"Initialising tasks: 100% |##########################################################################################################################################################| Time: 0:00:07
Sstate summary: Wanted 363 Local 353 Mirrors 0 Missed 10 Current 2412 (97% match, 99% complete)
Removing 4 stale sstate objects for arch stm32mp1: 100% |###########################################################################################################################| Time: 0:00:00
NOTE: Executing Tasks
WARNING: nativesdk-cmsis-svd-0.4-r0 do_install: Can not find STMicro in /home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1/tmp-glibc/work/x86_64-nativesdk-ostl_sdk-linux/nativesdk-cmsis-svd/0.4-r0/cmsis-svd/data
Setscene tasks: 2775 of 2775
NOTE: Tasks Summary: Attempted 7874 tasks of which 7856 didn't need to be rerun and all succeeded.
NOTE: Writing buildhistory
NOTE: Writing buildhistory took: 8 secondsSummary: There was 1 WARNING message.
xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$
执行成功后,会下deploy目录生成sdk目录,如下:
1.2 安装SDK
执行sdk中的脚本,来安装SDK到指定目录,我的是安装到Developer-Package/SDK目录
./tmp-glibc/deploy/sdk/st-example-image-qtwayland-openstlinux-weston-stm32mp1-x86_64-toolchain-4.2.1-snapshot.sh -y -d /home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK
对应的打印如下:
xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$ ls
bitbake-cookerdaemon.log buildhistory cache conf downloads sstate-cache tmp-glibc
xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$
xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$ ./tmp-glibc/deploy/sdk/st-example-image-qtwayland-openstlinux-weston-stm32mp1-x86_64-toolchain-4.2.1-snapshot.sh -y -d /home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK
ST OpenSTLinux - Weston - (A Yocto Project Based Distro) SDK installer version 4.2.1-snapshot
=============================================================================================
You are about to install the SDK to "/home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK". Proceed [Y/n]? Y
Extracting SDK.................................................................................................................................................................................................................................................................................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.$ . /home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$
安装完成后,可以在对应的目录中看到相关的文件:
2 交叉编译Qt
在刚才指定安装SDK的目录中,自带了许多Qt的例子,可以使用交叉编译器来编译一个Qt程序试一下,比如:
cd ~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/usr/share/examples/gui
. ~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
qmake && make
编译成功的打印如下:
最后编译出analogclock可执行文件,可以用file指令看下文件类型。
3 在板子中运行Qt
将analogclock文件拷贝到了STM32MP157D-DK1开发板中,运行程序,可以看到一个时钟的显示效果,如下图:
4 总结
本篇介绍了STM32MP157D-DK1开发板Qt程序交叉编译环境的搭建过程,并通过一个实际的Qt程序,编译后在板子中实际运行测试,验证Qt编译环境的可用性。