当前位置:网站首页>基于全志H3的QT5.12.9移植教程
基于全志H3的QT5.12.9移植教程
2022-07-01 23:59:00 【冬瓜~】

一. 前言

大学玩了很久的STM32单片机,STM32的MCU大多数是基于Arm Cortex-M3/M4/M7架构的芯片,具有极强的实时处理能力,但MCU相比于MPU而言还是有局限性。相比于MCU,MPU具有更高的处理和运算能力,一般需要运行较大型的操作系统(如:Linux、Andriod)来实现复杂的任务处理,这就决定了MPU应该具备更高的主频和更强大的算力,主要代表:Arm Cortex-A架构的处理器。
为了完成在嵌入式上的进阶,在某宝买到了一块Liunx开发板,处理器为基于ARM Cortex-A7架构的全志H3。项目需要在开发板上运行QT应用,但是商家提供的最小系统中没有QT的运行环境,需要自己移植。
二. 下载链接
开发环境 :Ubuntu 18.04
开发板系统 :精简版Linux3.4
Qt源码 :qt-everywhere-src-5.12.9
Qt Creater:qt-opensource-linux-x64-5.12.9.run
交叉编译器 :gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-guneabi.tar.xz
- 开发板资料(含开发板固件与源码)https://pan.baidu.com/s/1a6F_0xYCsZj9S1xIl0FRmg(密码:amxc)
- Qt Creater与Qt 源码下载链接:https://download.qt.io/archive/qt/
- 交叉编译器官方下载链接:https://releases.linaro.org/components/toolchain/binaries/
- 交叉编译器清华大学镜像站下载链接:https://mirrors.tuna.tsinghua.edu.cn/armbian-releases/_toolchain/
- GLIBC 库官方下载链接:https://sourceware.org/glibc/wiki/Glibc%20Timeline
- Xshell绿色版下载链接 :https://423down.lanzouh.com/b0f2b54tc
其中Qt源码和交叉编译器如果不想直接在官网翻,也可以直接在CSDN下载:
三. 系统编译
更新编译器
Linux系统源码由商家提供,首先解压H3-DVK-lichee-201809.tar到Ubuntu系统中,Linux源码中的默认交叉编译器版本太低,需要替换成4.9.4版本的交叉编译器。将解压好的交叉编译器替换掉源码中lichee/brandy/gcc-linaro的文件夹。

源码编译
首次编译,需要导入默认的内核配置,进入linux3.4文件夹。执行:
cp H3_defconfig .config
退回到lichee文件夹,再执行:
./build.sh config
#依次选择 1 1 0 2
#如果提示usbwifi 选择 y
仅首次编译需要 config,以后再次编译只需使用命令
./build.sh
编译成功后,打包固件:
./build.sh pack
# 固件位置:tools/pack/sun8iw7p1_dragonboard_dolphin.img
四. QT源码编译
添加编译器路径
解压Qt源码到Ubuntu系统,修改文件内容:
路径:qt-everywhere-src-5.12.9/qtbase/linux-arm-gnueabi-g++/qmake.conf
目的:主要是为了指定编译Qt源码的编译器路径,这里选择刚刚复制到lichee源码中的编译器。
#
# qmake configuration for building with arm-linux-gnueabi-g++
# MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-gcc
QMAKE_CXX = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-g++
QMAKE_LINK = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-g++
# modifications to linux.conf
QMAKE_AR = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-objcopy
QMAKE_NM = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-nm -P
QMAKE_STRIP = /home/dell/linux_H3/lichee/brandy/gcc-linaro/bin/arm-linux-gnueabi-strip
load(qt_config)
配置、编译、安装
进入qt-everywhere-src-5.12.9目录创建config.sh配置脚本,内容为:
./configure \
-prefix /home/dell/qt_install \
-xplatform linux-arm-gnueabi-g++ \
-confirm-license \
-opensource \
-release \
-shared \
-qt-zlib \
-qt-freetype \
-sql-sqlite \
-qt-libjpeg \
-no-qml-debug \
-no-dbus \
-no-gif \
-no-iconv \
-no-opengl \
-no-cups \
-no-glib \
-no-rpath \
-no-avx \
-no-openssl \
-nomake tools \
-qt-libpng \
-no-tslib \
其中,-prefix /home/dell/qt_install为指定的Qt库安装路径,-xplatform linux-arm-gnueabi-g++为指定编译器,其余选项可以根据自己的需求来增减Qt组件,适当剪裁。
修改执行权限
chmod 777 config,sh
执行配置
./config.sh
编译源码
make -j16
安装Qt
make install
安装完成后,编译得到的Qt库就在/home/dell/qt_install中。
五. QT移植与环境变量添加
将上一步编译得到的Qt库,即/home/dell/qt_install,整个文件夹复制到lichee/buildroot/target/dragonboard/rootfs/opt/中。

修改lichee/buildroot/target/dragonboard/extra/profile ,添加全局变量:
export LD_LIBRARY_PATH=/opt/qt_install/lib
export QT_QPA_PLATFORM_PLUGIN_PATH=/opt/qt_install/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
修改完成后重新编译linux,打包系统。
./build.sh
./build.sh pack
六. 升级GLIBC
将上一步打包得到的固件烧录进开发板,使用Xshell串口连接开发板打开终端,进入opt/qt_install/example目录,随便打开一个Qt示例,执行对应文件夹下的可执行文件。
Qt执行报错,这是由于我们更换了更高版本的交叉编译器,系统源码里原本的C/C++库就不支持了。
可以在对应文件夹下执行如下命令查看对应版本号:
strings libstdc++.so.6 | grep CXXABI # 在/usr/lib中执行,查看CXXABI版本号
strings libc.so.6 | grep GLIBC # 在/lib中执行,查看GLIBC版本号

我们需要将新的编译器中对应的库文件移植进系统中。对应库文件在gcc-linaro/arm-linux-gnueabi/libc下。
这里粗暴得将该目录下的文件全部复制到lichee/buildroot/target/dragonboard/rootfs/lib/以及lichee/buildroot/target/dragonboard/rootfs/usr/lib/中,覆盖同名的库。
七. 运行QT程序
成功升级库后,再次跑Qt案例中的可执行文件,成功跑通,至此Qt.5.12.9移植成功。

八. 参考资料
边栏推荐
- ARP message header format and request flow
- Selectively inhibiting learning bias for active sampling
- Record the accidental success and failure of uploading large files
- How to solve the image pop-up problem when pycharm calls Matplotlib to draw
- algolia 搜索需求,做的快自闭了...
- 微信小程序缓存过期时间的相关设置(推荐)
- SQL optimization
- Use the htaccess file to prohibit the script execution permission in the directory
- Asp .NetCore 微信订阅号自动回复之文本篇
- ADO. Net SqlDataAdapter object
猜你喜欢

门级建模—课后习题

Correlation - intra group correlation coefficient

Is there a piece of code that makes you convinced by human wisdom

Digital transformation has a long way to go, so how to take the key first step

Download the online video m3u8 tutorial

PostgreSQL source code (57) why is the performance gap so large in hot update?

Overview of edge calculation

第六章 数据流建模

写给当前及未来博士研究生一些建议整理分享
![[Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler](/img/35/e458fd437a0bed4bace2d6d65c9ec8.png)
[Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler
随机推荐
Correlation - intra group correlation coefficient
Openvino model performance evaluation tool DL workbench
Niuke - Practice 101 - reasoning clown
启牛学院开户安全的吗?开户怎么开?
[cmake] cmake configuration in QT Creator
Jielizhi Bluetooth headset quality control and production skills [chapter]
BlocProvider为什么感觉和Provider很相似?
Leetcode 96 différents arbres de recherche binaires
Soft exam information system project manager_ Compiled abbreviations of the top ten management processes to help memory recitation - -- software test advanced information system project manager 054
Resumption of attack and defense drill
牛客-练习赛101-推理小丑
Similarities and differences between the defined identity execution function authid determiner and PostgreSQL in Oracle
【QT】对于Qt MSVC 2017无法编译的问题解决
[QT] test whether QT can connect to the database
ConcurrentSkipListMap——跳表原理
二叉搜索树的创建,查找,添加,删除操作
GCC compilation
const // It is a const object... class nullptr_ t
leetcode96不同的二叉搜索树
RPA tutorial 01: Excel automation from introduction to practice