在 Linux 服务器上建立交叉编译环境,Windows 工作台通过串口和网口与Hi3559AV100 单板连接,开发人员可以在 Windows 工作台中进行程序开发或者远程登录到 Linux 服务器进行程序开发。

1

搭建Linux服务器环境

使用wsl安装Ubuntu18.04

cd <tool-dir>
.\LxRunOffline.exe -h # 查看帮助

.\LxRunOffline.exe list # 查看当前已有的WSL

.\LxRunOffline.exe di -n Ubuntu # 查看子系统的位置

.\LxRunOffline.exe move -n Ubuntu -d <tar-dir> # 将子系统移动到指定文件夹
    1. 通过管理工具可以将子系统移动到非C盘,防止C盘爆炸

安装nfs,samna,ssh等网络组件

暂时略过,windows可以通过\\wsl$\Ubuntu-18.04访问wsl的文件系统

软件包安装

    1. 配置默认使用bash,执行sudo dpkg-reconfigure dash,选no
    1. 执行如下,安装软件包:
sudo apt-get install make libc6:i386 lib32z1 lib32stdc++6 zlib1g-dev libncurses5-dev ncurses-term libncursesw5-dev g++ u-boot-tools:i386 texinfo texlive gawk libssl-dev openssl bc

报如下错误:

Package libc6:i386 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
libdb1-compat tzdata

E: Package ‘libc6:i386’ has no installation candidate
E: Unable to locate package u-boot-tools:i386

跳过libc6:i386,直接安装lib32z1,会提示如下:

The following additional packages will be installed:
libc6-i386
The following NEW packages will be installed:
lib32z1 libc6-i386

这应该是名字写的有问题,同样u-boot-tools:i386也会有:

E: Unable to locate package u-boot-tools:i386`

尝试u-boot-tools-i386也不行,安装u-boot-tools倒是可以。

其他软件包安装没有问题。

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

安装交叉编译工具

    1. aarch64-himix210-linux.tgz拷贝到linux系统~文件夹下,执行如下命令:
tar -xvf aarch64-himix210-linux.tgz
cd aarch64-himix210-linux/
sudo ./aarch64-himix210-linux.install
    1. 打印如下提示信息:

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-himix210-linux’
Extract cross tools …
export path /opt/hisi-linux/x86-arm/aarch64-himix210-linux/bin

是为安装成功

测试交叉编译工具

写了一个简单的测试工程,目录结果如下:

hello
|--build
|--corss_build.sh
|--include
|--hello.h
|--src
|--hello.cc
|--CMakeLists.txt
|--main.cc

cross_build.sh内容如下:

cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=aarch64-himix210-linux-gcc \
-DCMAKE_CXX_COMPILER=aarch64-himix210-linux-g++ \
..
make -j4

执行sh文件结果如下:

– The C compiler identification is GNU 7.3.0
– The CXX compiler identification is GNU 7.3.0
– Check for working C compiler: /opt/hisi-linux/x86-arm/aarch64-himix210-linux/bin/aarch64-himix210-linux-gcc
– Check for working C compiler: /opt/hisi-linux/x86-arm/aarch64-himix210-linux/bin/aarch64-himix210-linux-gcc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /opt/hisi-linux/x86-arm/aarch64-himix210-linux/bin/aarch64-himix210-linux-g++
– Check for working CXX compiler: /opt/hisi-linux/x86-arm/aarch64-himix210-linux/bin/aarch64-himix210-linux-g++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Configuring done
– Generating done
– Build files have been written to: /home/aaron-wu/cross_compile_test/hello/build
Scanning dependencies of target hello
[ 66%] Building CXX object CMakeFiles/hello.dir/src/hello.cc.o
[ 66%] Building CXX object CMakeFiles/hello.dir/main.cc.o
[100%] Linking CXX executable hello
[100%] Built target hello
编译成功

首次安装SDK

SDK包

Hi3559AV100***/01.software/board目录下,可以看到一个Hi3559AV100_SDK_Vx.x.x.x.tgz 的文件,该文件就是 Hi3559AV100 的软件开发包

解压缩SDK包

    1. 将上述SDK包拷贝到linux服务器上
    1. 执行如下命令进行解压缩
tar -zxf Hi3559AV100_SDK_Vx.x.x.x.tgz

展开SDK包内容

cd Hi3559AV100_SDK_V2.0.4.0/
sudo sh ./sdk.cleanup
sudo sh ./sdk.unpack