海思Hi3559AV100移植Qt5.9.9(一)

目录

前言

1 基础环境搭建

1.1 概述

1.2 Ubuntu虚拟机安装

1.2.1 准备

1.2.2 安装

1.3 软件包安装

2 安装编译SDK

2.1 准备

2.2 解压缩SDK

2.3 展开SDK

2.4 安装交叉编译器

2.4.1 安装 aarch64 交叉编译器

2.4.2 安装 arm-none-eabi 交叉编译器

2.4.3 使能环境变量

3 编译SDK

3.1 内核准备

3.2 编译

4 总结


前言

海思Hi3559AV100平台性能强悍,支持H264、H265 编码,分辨率可达16K,帧率可达120fps,应用于安防、无人机、智能机器人、人工智能、教育、车载设备、会议等诸多行业。但海思官方SDK并没有提供GUI组件,用户开发图形界面应用十分不便。

Qt 是一个跨平台的C++应用程序开发框架。它提供给开发者建立图形用户界面所需的功能,广泛用于开发图形用户界面程序,也可用于开发非图形用户界面(比如命令行界面)程序。Qt是完全面向对象的,很容易扩展,并且允许真正地组件编程。如果将Qt移植到Hi3559A平台,将极大地方便用户开发图形应用程序。

本系列将以Qt5.9.9为例详细介绍移植Qt全过程,包括:

  1. 从零搭建海思交叉编译环境;
  2. 交叉编译Qt5.9.9;
  3. H3559AV100平台运行Qt程序;
  4. 如何使Qt支持QML(GPU/EGLFS);
  5. 如何支持多点触控。

本文是Hi3559AV100移植Qt系列的第一篇,主要介绍编译Qt前的环境准备。Qt的交叉编译环境也就是海思提供的SDK环境,SDK编译通过也就保证了交叉编译环境OK。

【参考】

  • 《Hi3559A╱C V100 SDK 安装及升级使用说明》


1 基础环境搭建

1.1 概述

一个典型的嵌入式开发环境通常包括 Linux 服务器、Windows 工作台和目标板,三者同处于一个网络中,如下图所示。
 

因为条件有限,无法搭建独立的Linux服务器,采用虚拟机替代。考虑后期需要基于Linux平台开发Qt界面应用,选择Ubuntu作为编译服务器。

1.2 Ubuntu虚拟机安装

1.2.1 准备

1.2.2 安装

  • 新建虚拟机

1. 在“文件”菜单下新建虚拟机。

2. 选择自定义安装

3. 硬件兼容性保持默认配置即可

4. 安装操作系统选择“稍后安装操作系统”

5. 客户机操作系统类型选择“Linux”,版本选择“Ubuntu 64位”

6. 根据需要自行配置虚拟机名称和虚拟机文件存放路径

7. 根据物理的配置合理分配虚拟机的处理器数量,保证物理机运行良好情况下,越多越好

8. 根据物理的配置合理分配虚拟机的内存,保证物理机运行良好情况下,越多越好

9. 网络类型暂且选择NAT,创建后可根据需要修改

10. IO控制器类型保持默认

11. 磁盘类型保持默认

12. 新建的虚拟机,当然选择新建虚拟磁盘

13. 磁盘容量尽量大点,省的后续扩展,本人配置了40G

14. 磁盘文件名称自定义

15. 总算配置结束了,最后check一下,选择“完成”

完成后出现的虚拟机Tab页

  • 系统安装

1. 在虚拟机Tab页中,点击“编辑虚拟机设置”

2. 在虚拟机设置的硬件配置页面,选择“CD/DVD”配置项

3. “连接”选项下,选择“使用ISO映像文件”,并选择下载的Ubuntu镜像文件

4. 点击“确定”后,启动虚拟机

5. 启动后,开始检查镜像文件

6. 语言默认英文,选择“Install Ubuntu”

7. 键盘配置默认

8. 软件就不在线更新了,节省时间

9. 空的磁盘,采用默认选项,Install Now

10. 时区东八,shanghai

11. 创建个用户后,Continue,等待安装完成吧

12. N久后,Restart完成虚拟机安装

1.3 软件包安装

操作系统安装好后,且用户已自行配置好网络环境,则可继续如下步骤完成相关软件包的安装:

1 配置默认使用 bash

sudo dpkg-reconfigure dash

 选择 no

2 更新软件源

2.1 备份原来的源,将以前的源备份一下,以防以后可以用的。

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.2 打开/etc/apt/sources.list文件,在前面添加如下条目,并保存。

sudo vi /etc/apt/sources.list(可将vi更换为自己熟悉的编辑器)

#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

2.3 更新

sudo apt-get update

3 安装软件包

sudo apt-get install vim make libc6:i386 lib32z1 lib32stdc++6 zlib1g-dev libncurses5-dev ncurses-term libncursesw5-dev g++ texinfo texlive gawk libssl-dev openssl bc

4 创建/etc/ld.so.preload 文件,并执行 echo "" > /etc/ld.so.preload,以解决 64bit linux server 上某些第三方库编译失败的问题。

virtual-machine:~/Desktop$ sudo touch /etc/ld.so.preload
virtual-machine:~/Desktop$ sudo chmod 666 /etc/ld.so.preload 
virtual-machine:~/Desktop$ sudo echo "" > /etc/ld.so.preload

2 安装编译SDK

2.1 准备

2.2 解压缩SDK

使用命令:tar -zxf Hi3559AV100_SDK_Vx.x.x.x.tgz,解压缩该文件,可以得到一个Hi3559AV100_SDK_Vx.x.x.x 目录。

virtual-machine:~$ mkdir work
virtual-machine:~$ cd /mnt/hgfs/board/
virtual-machine:/mnt/hgfs/board$ ls
Hi3559AV100_SDK_V2.0.2.0.tgz
virtual-machine:/mnt/hgfs/board$ tar -zxvf Hi3559AV100_SDK_V2.0.2.0.tgz -C ~/work/
Hi3559AV100_SDK_V2.0.2.0/
Hi3559AV100_SDK_V2.0.2.0/package/
Hi3559AV100_SDK_V2.0.2.0/package/mpp.tgz
Hi3559AV100_SDK_V2.0.2.0/package/drv.tgz
Hi3559AV100_SDK_V2.0.2.0/package/hisyslink.tgz
Hi3559AV100_SDK_V2.0.2.0/package/osdrv.tgz
Hi3559AV100_SDK_V2.0.2.0/package/osal.tgz
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_2k_24bit.yaffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_96M.ext4
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_256k.jffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/u-boot-hi3559av100.bin
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_128k.jffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_2k_4bit.yaffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_2k_128k_32M.ubifs
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_4k_256k_50M.ubifs
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/rootfs_hi3559av100_64k.jffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_big-little_arm64/uImage_hi3559av100_big-little
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_2k_24bit.yaffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_96M.ext4
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_256k.jffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/u-boot-hi3559av100.bin
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_128k.jffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_2k_4bit.yaffs2
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/uImage_hi3559av100_multi-core
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_2k_128k_32M.ubifs
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_4k_256k_50M.ubifs
Hi3559AV100_SDK_V2.0.2.0/image_glibc_multi-core_arm64/rootfs_hi3559av100_64k.jffs2
Hi3559AV100_SDK_V2.0.2.0/scripts/
Hi3559AV100_SDK_V2.0.2.0/scripts/common.sh
Hi3559AV100_SDK_V2.0.2.0/sdk.cleanup
Hi3559AV100_SDK_V2.0.2.0/sdk.unpack

2.3 展开SDK

返回 Hi3559AV100_SDK_Vx.x.x.x 目录,运行./sdk.unpack(请用 root 或 sudo 权限执行)。将会展开 SDK 包打包压缩存放的内容,请按照提示完成操作。

virtual-machine:/mnt/hgfs/board$ cd ~/work/Hi3559AV100_SDK_V2.0.2.0/
virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0$ ls
image_glibc_big-little_arm64  package  sdk.cleanup
image_glibc_multi-core_arm64  scripts  sdk.unpack
virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0$ ./sdk.unpack 
Unpacking SDK
WARN: Be sure you have installed the cross-compiler. if not, install it first!
WARN: ALL THE SOUCE FILES WILL BE OVERWRITED, FILES YOU MOTIFIED WILL BE LOST !!!

OS_TYPE  =
SDK_CHIP =hi3559av100
unpacking osal
run_command_progress_float: 'tar -xvzf package/osal.tgz'
[100%]##################################################|
unpacking hisyslink
run_command_progress_float: 'tar -xvzf package/hisyslink.tgz'
[100%]##################################################|
unpacking osdrv
run_command_progress_float: 'tar -xvzf package/osdrv.tgz'
[100%]##################################################|
unpacking mpp
mkdir: created directory 'mpp'
run_command_progress_float: 'tar -xvzf package/mpp.tgz'
[100%]##################################################|
unpacking drv
mkdir: created directory 'drv'
run_command_progress_float: 'tar -xvzf package/drv.tgz'
[100%]##################################################|

2.4 安装交叉编译器

2.4.1 安装 aarch64 交叉编译器

解压 tar –xzf aarch64-himix100-linux.tgz,运行 chmod +x aarch64-himix100-linux.install,然后运行./aarch64-himix100-linux.install 即可。

virtual-machine:~/work$ tar xzf aarch64-himix100-linux.tgz
virtual-machine:~/work$ 
virtual-machine:~/work$ cd aarch64-himix100-linux/
virtual-machine:~/work/aarch64-himix100-linux$ ls
aarch64-himix100-linux.install  readme.txt
aarch64-himix100-linux.tar.bz2  runtime_lib.tgz
virtual-machine:~/work/aarch64-himix100-linux$ sudo ./aarch64-himix100-linux.install 
[sudo] password for raigor: 
Installing HuaWei LiteOS Linux at /opt/hisi-linux/x86-arm
mkdir: created directory '/opt/hisi-linux'
mkdir: created directory '/opt/hisi-linux/x86-arm'
mkdir: created directory '/opt/hisi-linux/x86-arm/aarch64-himix100-linux'
Extract cross tools ...
export path /opt/hisi-linux/x86-arm/aarch64-himix100-linux/bin

2.4.2 安装 arm-none-eabi 交叉编译器

解压 tar –xzf gcc-arm-none-eabi-4_9-2015q3.tgz,参考其中的 readme 下载工具链包,运行 chmod +x gcc-arm-none-eabi-4_9-2015q3.install,然后运行./gcc-arm-noneeabi-4_9-2015q3.install 即可。

virtual-machine:~/work/gcc-arm-none-eabi-4_9-2015q3$ tar xvf gcc-arm-none-eabi-4_9-2015q3.tgz
virtual-machine:~/work/gcc-arm-none-eabi-4_9-2015q3$ cd gcc-arm-none-eabi-4_9-2015q3/
virtual-machine:~/work/gcc-arm-none-eabi-4_9-2015q3$ chmod +x gcc-arm-none-eabi-4_9-2015q3.install
virtual-machine:~/work/gcc-arm-none-eabi-4_9-2015q3$ sudo ./gcc-arm-none-eabi-4_9-2015q3.install 

2.4.3 使能环境变量

执行 source /etc/profile,安装交叉编译器的脚本配置的环境变量就可以生效了,或者请重新登陆也可

virtual-machine:~/work/gcc-arm-none-eabi-4_9-2015q3$ source /etc/profile

3 编译SDK

3.1 内核准备

将内核文件linux-4.9.37.tar.gz放到~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/opensource/kernel

3.2 编译

virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv$ make BOOT_MEDIA=emmc AMP_TYPE=linux all

【错误1】"mkimage" command not found - U-Boot images will not be built

解决方法:将osdrv/tools/pc/mkimage_tool/mkimage拷贝到/usr/local/bin/

virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv$ sudo cp tools/pc/mkimage_tool/mkimage /usr/local/bin/

【错误2】

/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.a(libmtd.o): in function `dev_node2num':
/home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.c:444: undefined reference to `major'
/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.c:445: undefined reference to `minor'
/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.a(libmtd.o): in function `mtd_probe_node':
/home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.c:1390: undefined reference to `major'
/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.c:1391: undefined reference to `minor'
/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.a(libmtd_legacy.o): in function `legacy_get_dev_info':
/home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd_legacy.c:254: undefined reference to `major'
/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd_legacy.c:255: undefined reference to `minor'
collect2: error: ld returned 1 exit status
make[2]: *** [common.mk:71: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/flash_erase] Error 1
解决方法:

virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv$ vi tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd.c
virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv$ vi tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/lib/libmtd_legacy.c


添加以下头文件:
#include <sys/sysmacros.h>

【错误3】

/usr/bin/ld: /home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/mkfs.jffs2.o: in function `interpret_table_entry':
/home/raigor/work/Hi3559AV100_SDK_V2.0.2.0/osdrv/tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/mkfs.jffs2.c:468: undefined reference to `makedev'

解决方法:

virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv$ vi tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/mkfs.jffs2.c


添加以下头文件:
#include <sys/sysmacros.h>

【错误4】

In file included from mkfs.ubifs/devtable.c:47:
mkfs.ubifs/devtable.c:240:10: error: called object ‘major’ is not a function or function pointer
  240 |    name, major(nh_elt->dev), minor(nh_elt->dev));

解决方法:

vi tools/pc/jffs2_tool/tmp/mtd-utils-1.5.0/mkfs.ubifs/devtable.c


添加以下头文件:
#include <sys/sysmacros.h>

【错误5】

mksquashfs.c: In function ‘create_inode’:
mksquashfs.c:987:24: error: called object ‘major’ is not a function or function pointer

./tools/pc/squashfs4.3/tmp/squashfs4.3/squashfs-tools/mksquashfs.c


添加以下头文件:
#include <sys/sysmacros.h>

【错误6】unsquashfs.c:(.text+0x1f45): undefined reference to `makedev'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:279: unsquashfs] Error 1

./tools/pc/squashfs4.3/tmp/squashfs4.3/squashfs-tools/unsquashfs.c


添加以下头文件:
#include <sys/sysmacros.h>

oh。。。终于过了

virtual-machine:~/work/Hi3559AV100_SDK_V2.0.2.0/osdrv$ ll pub/emmc_image_glibc_multi-core_arm64/
total 81576
drwxrwxr-x 2 raigor raigor     4096 4月  12 17:37 ./
drwxrwxr-x 6 raigor raigor     4096 4月  12 17:37 ../
-rw-r--r-- 1 raigor raigor  5216648 4月  12 17:37 rootfs_hi3559av100_128k.jffs2
-rw-r--r-- 1 raigor raigor  5210152 4月  12 17:37 rootfs_hi3559av100_256k.jffs2
-rw-rw-r-- 1 raigor raigor  7733248 4月  12 17:37 rootfs_hi3559av100_2k_128k_32M.ubifs
-rw-r--r-- 1 raigor raigor 12540288 4月  12 17:37 rootfs_hi3559av100_2k_24bit.yaffs2
-rw-r--r-- 1 raigor raigor 12171456 4月  12 17:37 rootfs_hi3559av100_2k_4bit.yaffs2
-rw-rw-r-- 1 raigor raigor  9699328 4月  12 17:37 rootfs_hi3559av100_4k_256k_50M.ubifs
-rw-r--r-- 1 raigor raigor  5227964 4月  12 17:37 rootfs_hi3559av100_64k.jffs2
-rw-r--r-- 1 raigor raigor 16770432 4月  12 17:37 rootfs_hi3559av100_96M.ext4
-rwxr-xr-- 1 raigor raigor   331669 4月  12 17:27 u-boot-hi3559av100.bin*
-rw-rw-r-- 1 raigor raigor  8606666 4月  12 17:32 uImage_hi3559av100_multi-core

4 总结

以上就是Qt移植的准备工作,介绍了虚拟机交叉编译环境的安装过程、并用SDK编译的方式验证交叉编译环境的正确性。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值