谷动谷力

标题: STM32MP157D-DK1 Qt程序交叉编译与运行测试 [打印本页]

作者: 鸣涧    时间: 2024-1-3 15:55
标题: STM32MP157D-DK1 Qt程序交叉编译与运行测试
STM32MP157D-DK1 Qt程序交叉编译与运行测试

上篇文章介绍了STM32MP157D-DK1开发板Qt镜像的构建,通过在Ubuntu中重新编译带有Qt功能的系统来实现。

本篇在上篇的基础上,继续搭建Qt的交叉编译环境,实现Qt程序在Ubuntu中编译,在STM32MP157板子中运行。

1 编译安装SDK

在上篇编译系统镜像的基础上,继续编译和安装SDK。

1.1 编译SDK

执行如下执指令编译带有Qt功能的SDK:

  1. bitbake st-example-image-qtwayland -c populate_sdk
复制代码

中途如果报do_fetch失败的错误,可参考上篇编译镜像时的do_fetch失败的解决方法。

最终编译成功的结果如下:

对应的打印如下:

  1. xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$ bitbake st-example-image-qtwayland -c populate_sdk

  2. 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
  3. Loading cache: 100% |###############################################################################################################################################################| Time: 0:00:01
  4. Loaded 4879 entries from dependency cache.
  5. Parsing recipes: 100% |#############################################################################################################################################################| Time: 0:00:01
  6. Parsing of 3068 .bb files complete (3067 cached, 1 parsed). 4879 targets, 562 skipped, 0 masked, 0 errors.
  7. NOTE: Resolving any missing task queue dependencies

  8. Build Configuration:
  9. BB_VERSION           = "2.4.0"
  10. BUILD_SYS            = "x86_64-linux"
  11. NATIVELSBSTRING      = "universal"
  12. TARGET_SYS           = "arm-ostl-linux-gnueabi"
  13. MACHINE              = "stm32mp1"
  14. DISTRO               = "openstlinux-weston"
  15. DISTRO_VERSION       = "4.2.1-snapshot-20231224"
  16. TUNE_FEATURES        = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard"
  17. TARGET_FPU           = "hard"
  18. DISTRO_CODENAME      = "mickledore"
  19. ACCEPT_EULA_stm32mp1 = "1"
  20. GCCVERSION           = "12.%"
  21. PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp"
  22. meta-python         
  23. meta-oe              
  24. meta-gnome           
  25. meta-initramfs      
  26. meta-multimedia      
  27. meta-networking      
  28. meta-webserver      
  29. meta-filesystems     
  30. meta-perl            = "HEAD:c032fd0b1a9d444711103c2703dfa8e2964a3865"
  31. meta-st-stm32mp      = "HEAD:931b3f5be2c00f55d114c8f9122082a9d229b776"
  32. meta-qt5             = "HEAD:cf6ffcbad5275a3428f6046468a0c9d572e813d1"
  33. meta-st-openstlinux  = "HEAD:8c780facff81d3c3878c5fdcd18bdd24fc36478d"
  34. meta                 = "HEAD:20cd64812d286c920bd766145ab1cd968e72667e"

  35. Initialising tasks: 100% |##########################################################################################################################################################| Time: 0:00:07
  36. Sstate summary: Wanted 363 Local 353 Mirrors 0 Missed 10 Current 2412 (97% match, 99% complete)
  37. Removing 4 stale sstate objects for arch stm32mp1: 100% |###########################################################################################################################| Time: 0:00:00
  38. NOTE: Executing Tasks
  39. 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
  40. Setscene tasks: 2775 of 2775
  41. NOTE: Tasks Summary: Attempted 7874 tasks of which 7856 didn't need to be rerun and all succeeded.
  42. NOTE: Writing buildhistory
  43. NOTE: Writing buildhistory took: 8 seconds

  44. Summary: There was 1 WARNING message.
  45. 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目录

  1. ./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
复制代码

对应的打印如下:

  1. xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$ ls

  2. bitbake-cookerdaemon.log  buildhistory        cache  conf  downloads        sstate-cache  tmp-glibc
  3. xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$
  4. 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
  5. ST OpenSTLinux - Weston - (A Yocto Project Based Distro) SDK installer version 4.2.1-snapshot
  6. =============================================================================================
  7. You are about to install the SDK to "/home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK". Proceed [Y/n]? Y
  8. Extracting SDK.................................................................................................................................................................................................................................................................................................................................................done
  9. Setting it up...done
  10. SDK has been successfully set up and is ready to be used.
  11. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
  12. $ . /home/xxpcb/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
  13. xxpcb@xxpcb-ubuntu20:~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Distribution-Package/build-openstlinuxweston-stm32mp1$
复制代码

安装完成后,可以在对应的目录中看到相关的文件:

2 交叉编译Qt

在刚才指定安装SDK的目录中,自带了许多Qt的例子,可以使用交叉编译器来编译一个Qt程序试一下,比如:

  1. cd
  2. ~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK/sysroots/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/usr/share/examples/gui

  3. . ~/myTest/STM32MP157/STM32MPU-Ecosystem-v5.0.0/Developer-Package/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
  4. qmake && make
复制代码

编译成功的打印如下:

最后编译出analogclock可执行文件,可以用file指令看下文件类型。

3 在板子中运行Qt

将analogclock文件拷贝到了STM32MP157D-DK1开发板中,运行程序,可以看到一个时钟的显示效果,如下图:

4 总结

本篇介绍了STM32MP157D-DK1开发板Qt程序交叉编译环境的搭建过程,并通过一个实际的Qt程序,编译后在板子中实际运行测试,验证Qt编译环境的可用性。








欢迎光临 谷动谷力 (http://bbs.sunsili.com/) Powered by Discuz! X3.2