Linux / 嵌入式 · 2021-12-01

海思官方SDK Hi3516EV200_SDK_V1.0.1.0的编译教程

前言:

关于海思HI3516EV200的SDK,官方有2个版本,一个是linux,一个是liteos,这里根据之前群友提供的sdk整理总结下,以防大家下载到错误的版本

linux sdk 版本为 Hi3516EV200R001C01SPC010:
链接: https://pan.baidu.com/s/1bJRVcm9DLD4RIL4zCzWMXA 
提取码:702k
liteos sdk 版本为Hi3516EV200R002C05SPC010:
链接: https://pan.baidu.com/s/1LnN-E6ekdS1iryi3x89hNw  
提取码:prkb

环境

  1. ubuntu18.04 amd64

    dopi@ubuntu:~$ cat /proc/version
    Linux version 5.3.0-62-generic (buildd@lcy01-amd64-004) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #56~18.04.1-Ubuntu SMP Wed Jun 24 16:17:03 UTC 2020
  2. 海思官方Linux SDK


解决问题的思路

  1. 遇到错误不要着急搜索引擎搜索,往往在出错文件的位置,会有一个readme.txt。 会告诉依赖项,以及解决方法。

  2. 遇到tar解压报错,估计你图快,windows下载后,拷贝到ubuntu中,文件会出错,google也救不了,这时候静下心来,wget重新慢慢下载,再编译试试。

  3. 提示系统命令缺失,可直接搜索。


参考文件

1.Hi3516EV200_SDK_V1.0.1.0\package\osdrv\readme.cn

1.osdrv 顶层 Makefile 使用说明
本目录下的编译脚本支持 arm-himix100-linux工具链对应uclibc库。具体命令如下(以hi3516ev200举例)

注意:
    由于开源工具整改,部分开源工具不再提供源码包,客户编译OSDRV时需要自行下载:
    a:linux-4.9.37.tar.gz (https://www.kernel.org/pub/)
        将下载的 linux-4.9.37.tar.gz 存放到 osdrv的opensource/kernel目录中

    b:yaffs2utils-0.2.9.tar.gz (https://github.com/dorigom/yaffs2utils/releases)
        将下载的 yaffs2utils-0.2.9.tar.gz 存放到osdrv的tools/pc/mkyaffs2image/目录中

    c:gdb-7.9.1.tar.gz  (http://ftp.gnu.org/gnu/gdb/)
        将下载的 gdb-7.9.1.tar.gz 存放到 osdrv的tools/board/gdb/目录中

    d:ncurses-6.0.tar.gz  ( http://ftp.gnu.org/gnu/ncurses/)
        将下载的 ncurses-6.0.tar.gz 存放到 osdrv的tools/board/gdb/目录中

    e:util-linux-2.31.tar.gz (https://www.kernel.org/pub/linux/utils/util-linux/v2.31)

        将下载的 util-linux-2.31.tar.gz 存放到 osdrv的tools/pc/cramfs_tool/目录中

(1)编译整个osdrv目录:
    注意:默认不发布内核源码包,只发布补丁文件。内核源码包需自行从开源社区上下载。
          从linux开源社区下载v4.9.37版本的内核:
         1)进入网站:www.kernel.org
         2)选择HTTP协议资源的https://www.kernel.org/pub/选项,进入子页面
         3)选择linux/菜单项,进入子页面
         4)选择kernel/菜单项,进入子页面
         5)选择v4.x/菜单项,进入子页面
         6)下载linux-4.9.37.tar.gz (或者linux-4.9.37.tar.xz)到osdrv/opensource/kernel目录下     


    make all

注意:由于Makefile中文件系统编译依赖组件较多,不能保证单独编译的文件系统可用,建议采用make all编译;
        但可单独编译uboot,kernel;

    可以传如下参数:
    a, BOOT_MEDIA:spi(default) or emmc
    b, CHIP:hi3516ev200(default) or hi3516ev300 or hi3518ev300 or hi3516dv200
    c, 如果客户想要更换可以使用TARGET_XLSM=*.xlsm来指定所需要的u-boot表格文件



(2)清除整个osdrv目录的编译文件:

    make OSDRV_CROSS=arm-himix100-linux clean
(3)彻底清除整个osdrv目录的编译文件,除清除编译文件外,还删除已编译好的镜像:

    make OSDRV_CROSS=arm-himix100-linux distclean

(4)单独编译kernel:
    注意:单独编译内核之前请先阅读osdrv/opensource/kernel下的readme_cn.txt说明。

    待进入内核源代码目录后,执行以下操作

    cp arch/arm/configs/hi3516ev200_full_defconfig  .config
    (emmc启动时执行如下操作:cp arch/arm/configs/hi3516ev200_emmc_defconfig  .config)
    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- menuconfig
    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- uImage

(5)单独编译模块:
    待进入内核源代码目录后,执行以下操作

    cp arch/arm/configs/hi3516ev200_full_defconfig  .config
    (emmc启动时执行如下操作:cp arch/arm/configs/hi3516ev200_emmc_defconfig  .config)
    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- menuconfig
    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- modules

(6)单独编译uboot:
    注意:发布包默认按照DMEB板的配置发布,如果客户单板和DEMB板不一致,需要根据客户自己的单板环境修改uboot表格才能使用,否则可能导致uboot无法启动或者其他问题。

    待进入boot源代码目录后,执行以下操作
    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- hi3516ev200_defconfig
    (emmc启动时执行如下操作:make ARCH=arm CROSS_COMPILE=arm-himix100-linux- hi3516ev200_emmc_defconfig)

    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- -j 20

    make -C ../../../tools/pc/hi_gzip

    cp ../../../tools/pc/hi_gzip/bin/gzip arch/arm/cpu/armv7/hi3516ev200/hw_compressed/ -rf 

    Windowns下进入到osdrv/tools/pc/uboot_tools/目录下打开对应单板的Excel文件,在main标签中点击"Generate reg bin file"按钮,生成reg_info.bin即为对应平台的表格文件。
    从osdrv/tools/pc/uboot_tools目录拷贝reg_info.bin到boot源代码目录,重命名为.reg
    cp ../../../tools/pc/uboot_tools/reg_info.bin .reg

    make ARCH=arm CROSS_COMPILE=arm-himix100-linux- u-boot-z.bin

    opensource/uboot/u-boot-2016.11下生成的u-boot-hi3516ev200.bin即为可用的u-boot镜像

(7)制作文件系统镜像:
在osdrv/pub/中有已经编译好的文件系统,因此无需再重复编译文件系统,只需要根据单板上flash的规格型号制作文件系统镜像即可。

    SPI NOR Flash使用jffs2格式的镜像,制作jffs2镜像时,需要用到SPI NOR Flash的块大小。这些信息会在uboot启动时
    会打印出来。建议使用时先直接运行mkfs.jffs2工具,根据打印信息填写相关参数。
    下面以块大小为64KB为例:
    osdrv/pub/bin/pc/mkfs.jffs2 -d osdrv/pub/rootfs_uclibc -l -e 0x10000 -o osdrv/pub/rootfs_uclibc_64k.jffs2

        Nand Flash使用yaffs2格式的镜像,制作yaffs2镜像时,需要用到nand flash的pagesize和ecc。这些信息会在uboot启动时会打
    印出来。建议使用时先直接运行mkyaffs2image工具,根据打印信息填写相关参数。
    下面以SPI NAND的2KB pagesize、4bit ecc为例:
        osdrv/pub/bin/pc/mkyaffs2image100 osdrv/pub/rootfs_uclibc osdrv/pub/rootfs_uclibc_2k_4bit.yaffs2 1 2

        Nand Flash使用UBI文件系统,在osdrv/tools/pc/ubi_sh下提供mkubiimg.sh工具用于制作UBI文件系统,需要用到Nand
    Flash的pagesize、blocksize和UBIFS分区的大小。
    以2KB pagesize, 128KB blocksize和UBI文件系统分区大小32MB为例:

    mkubiimg.sh hi3516ev200 2k 128k osdrv/pub/rootfs 32M osdrv/pub/bin/pc

    osdrv/pub/rootfs是根文件系统文件夹目录
    osdrv/pub/bin/pc是制作UBI文件系统镜像的工具目录
        生成的rootfs_hi3516ev200_2k_128k_32M.ubifs,就是最终用于烧写的UBI文件系统镜像。

2. 镜像存放目录说明
编译完的image,rootfs等存放在osdrv/pub目录下
pub
├─ bin

│   ├─ board_uclibc -------------------------------------------- himix100编译出的单板用工具
│   │   ├── ethtool
│   │   ├── flashcp
│   │   ├── flash_erase
│   │   ├── flash_otp_dump
│   │   ├── flash_otp_info
│   │   ├── gdb-arm-himix100-linux
│   │   ├── mtd_debug
│   │   ├── mtdinfo
│   │   ├── nanddump
│   │   ├── nandtest
│   │   ├── nandwrite
│   │   ├── sumtool
│   │   ├── ubiattach
│   │   ├── ubicrc32
│   │   ├── ubidetach
│   │   ├── ubiformat
│   │   ├── ubimkvol
│   │   ├── ubinfo
│   │   ├── ubinize
│   │   ├── ubirename
│   │   ├── ubirmvol
│   │   ├── ubirsvol
│   │   └── ubiupdatevol
│   └─ pc
│       ├── lzma
│       ├── mkfs.cramfs
│       ├── mkfs.jffs2
│       ├── mkfs.ubifs
│       ├── mkimage
│       ├── mksquashfs
│       └── ubinize
├─image_uclibc ------------------------------------------------- himix100编译出的镜像文件
│   ├── uImage_hi3516ev200 ----------------------------------------- kernel镜像
│   ├── u-boot-hi3516ev200.bin ------------------------------------- u-boot镜像
│   ├── rootfs_hi3516ev200_64k.jffs2 ------------------------------- 64K jffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_128k.jffs2 ------------------------------ 128K jffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_256k.jffs2 ------------------------------ 256K jffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_2k_4bit.yaffs2 -------------------------- yaffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_2k_24bit.yaffs2 ------------------------- yaffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_4k_4bit.yaffs2 -------------------------- yaffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_4k_24bit.yaffs2 ------------------------- yaffs2 文件系统镜像
│   ├── rootfs_hi3516ev200_2k_128k_32M.ubifs------------------------ 2k 128k UBI 文件系统镜像
│   └── rootfs_hi3516ev200_4k_256k_50M.ubifs------------------------ 4k 256k UBI 文件系统镜像
│
├─ rootfs.ubiimg ----------------------------------------------- UBIFS根文件系统
├─ rootfs_uclibc.tgz  ------------------------------------------- himix100编译出的rootfs文件系统


3.osdrv目录结构说明:
osdrv
├─Makefile ------------------------------ osdrv目录编译脚本
├─tools --------------------------------- 存放各种工具的目录
│  ├─board ------------------------------ 各种单板上使用工具
│  │  ├─ethtools ----------------------- ethtools工具
│  │  ├─reg-tools-1.0.0 ----------------- 寄存器读写工具
│  │  ├─eudev-3.2.7 ------------------------ udev工具集
│  │  ├─mtd-utils ----------------------- flash裸读写工具集
│  │  ├─gdb ----------------------------- gdb工具
│  │  └─e2fsprogs ----------------------- mkfs工具集
│  └─pc ---------------------------------- 各种pc上使用工具
│      ├─jffs2_tool----------------------- jffs2文件系统制作工具
│      ├─cramfs_tool --------------------- cramfs文件系统制作工具
│      ├─squashfs4.3 --------------------- squashfs文件系统制作工具
│      ├─nand_production ----------------- nand量产工具
│      ├─lzma_tool ----------------------- lzma压缩工具
│      ├─zlib ---------------------------- zlib工具
│      ├─mkyaffs2image -- ---------------- yaffs2文件系统制作工具
│      └─uboot_tools ----------------------uboot镜像制作工具、xls文件及ddr初始化脚本、reg_info.bin制作工具
├─pub ----------------------------------- 存放各种镜像的目录
│  ├─image_uclibc ------------------------ 基于himix100工具链编译,可供FLASH烧写的映像文件,包括uboot、内核、文件系统
│  ├─bin -------------------------------- 各种未放入根文件系统的工具
│  │  ├─pc ------------------------------ 在pc上执行的工具
│  │  ├─board_uclibc --------------------- 基于himix100工具链编译,在单板上执行的工具
│  └─rootfs_uclibc.tgz ------------------- 基于himix100工具链编译的根文件系统
├─opensource----------------------------- 存放各种开源源码目录
│  ├─busybox ---------------------------- 存放busybox源代码的目录
│  ├─uboot ------------------------------ 存放uboot及安全boot源代码的目录
│  └─kernel ----------------------------- 存放kernel源代码的目录
└─rootfs_scripts ------------------------- 存放根文件系统制作脚本的目录

4.注意事项
(1)在windows下复制源码包时,linux下的可执行文件可能变为非可执行文件,导致无法编译使用;u-boot或内核下编译后,会有很多符号链接文件,在windows下复制这些源码包, 会使源码包变的巨大,因为linux下的符号链接文件变为windows下实实在在的文件,因此源码包膨胀。因此使用时请注意不要在windows下复制源代码包。
(2)使用某一工具链编译后,如果需要更换工具链,请先将原工具链编译文件清除,然后再更换工具链编译。
(3)编译板端软件
    a.此芯片具有浮点运算单元和neon。文件系统中的库是采用软浮点和neon编译而成,因此请用户注意,所有此芯片板端代码编译时需要在Makefile里面添加选项-mcpu=cortex-a7、-mfloat-abi=softfp和-mfpu=neon-vfpv4。
如:
对于A7:
    CFLAGS += -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -fno-aggressive-loop-optimizations
    CXXFlAGS +=-mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4 -fno-aggressive-loop-optimizations
其中CXXFlAGS中的XX根据用户Makefile中所使用宏的具体名称来确定,e.g:CPPFLAGS。
  1. 提前搭建好交叉编译环境:arm-himix100-linux-gcc

    kernel 下载

    进入 osdrv/opensource/kernel/目下载linuxlinux-4.9.37.tar.gz

    cd osdrv/opensource/kernel/
    wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.9.37.tar.gz

    该方法下载很慢,建议迅雷下载,拷贝到osdrv/opensource/kernel/
    执行log:

dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package$ cd osdrv/opensource/kernel/
dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/opensource/kernel$ wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.9.37.tar.gz
--2020-06-29 06:13:44--  https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.9.37.tar.gz
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 147.75.95.133, 2604:1380:3000:1500::1
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|147.75.95.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 141696654 (135M) [application/x-gzip]
Saving to: ‘linux-4.9.37.tar.gz’

linux-4.9.37.tar.gz                        1%[>                                                                                ]   2.32M  8.69KB/s    eta 4h 18m 

下载yaffs2utils-0.2.9.tar.gz

cd osdrv/tools/pc/mkyaffs2image/
wget --no-check-certificate https://codeload.github.com/dorigom/yaffs2utils/tar.gz/0.2.9 -O yaffs2utils-0.2.9.tar.gz 

PS: wget指令下载https有些wget版本需要跳过https才能下载成功,使用–no-check-certificate 跳过,默认下载的文件可以使用-O参数修改文件名
执行log:

$ wget https://codeload.github.com/dorigom/yaffs2utils/tar.gz/0.2.9
--2020-06-29 06:23:09--  https://codeload.github.com/dorigom/yaffs2utils/tar.gz/0.2.9
Resolving codeload.github.com (codeload.github.com)... 13.229.189.0
Connecting to codeload.github.com (codeload.github.com)|13.229.189.0|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to:0.2.90.2.9                   [   <=>              ]  38.95K  82.5KB/s    in 0.5s    

2020-06-29 06:23:11 (82.5 KB/s) - ‘0.2.9’ saved [39880]

下载gdb-7.9.1.tar.gz

cd osdrv/tools/board/gdb/
wget http://ftp.gnu.org/gnu/gdb/gdb-7.9.1.tar.gz

下载ncurses-6.0.tar.gz

cd osdrv/tools/board/gdb/
wget http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz

下载util-linux-2.31.tar.gz

osdrv/tools/pc/cramfs_tool/
wget https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.gz

编译:

dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package$ cd osdrv/
dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv$ make all
  • 编译错误:/bin/sh: 1: pushd: not found

    解决方法:
    在dash模式下,执行:sudo dpkg-reconfigure dash,弹出的串口选择NO,执行完成后,输入exit退出

    dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv$ cd /bin
    dopi@ubuntu:/bin$ sh
    $ sudo dpkg-reconfigure dash 
    [sudo] password for dopi: 
    Removing 'diversion of /bin/sh to /bin/sh.distrib by dash'
    Adding 'diversion of /bin/sh to /bin/sh.distrib by bash'
    Removing 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by dash'
    Adding 'diversion of /usr/share/man/man1/sh.1.gz to /usr/share/man/man1/sh.distrib.1.gz by bash'
    $ sh
    sh-4.4$ exit

    在这里插入图片描述

  • 编译错误2:缺各种依赖项库
configure: WARNING: cannot find uuid library required for mkfs.ubifs
configure: mtd-utils can optionally be built without mkfs.ubifs
configure: WARNING: cannot find ZLIB library required for mkfs programs
configure: mtd-utils can optionally be built without mkfs.ubifs
configure: mtd-utils can optionally be built without mkfs.jffs2
configure: error: missing one or more dependencies
Makefile:45: recipe for target '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool/tmp/sbin/mkfs.jffs2' failed
make[1]: *** [/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool/tmp/sbin/mkfs.jffs2] Error 1
make[1]: Leaving directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool'
Makefile:342: recipe for target 'hipctools' failed
make: *** [hipctools] Error 2

解决方法:osdrv/tools/pc/jffs2_tool/的readme_cn.txt ,写得特别详细,不得不佩服海思的工程师。

dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv$ cd tools/pc/jffs2_tool/
dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool$ ls
lzo-2.09.tar.gz  Makefile  mtd-utils-2.0.2.tar.bz2  readme_cn.txt  readme_en.txt  tmp
dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool$ cat readme_cn.txt 
一、mtd-utils2.0.2依赖以下几个库,以ubuntu为例,安装方式请参考下面命令:
    sudo apt-get install zlib1g-dev liblzo2-dev uuid-dev pkg-config
二、由于mtd-utils2.0.2通过pkg-config工具检查各个库是否正常安装,因此请参考如下方式设置pkg-config工具搜索路径:
    export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig"
三、mtd-utils2.0.2依赖于automake1.15.1版本,请参考如下方式安装automake1.15.1版本:
    1、删除原有automake版本
        sudo apt-get autoremove automake
    2、下载1.15.1版本
        1)Windows系统中使用浏览器访问automake工程url并下载对应源码包:
            https://lists.gnu.org/archive/html/info-gnu/2017-06/msg00007.html
        2)linux系统中可以使用下面命令下载:
            wget ftp://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz
    3、编译安装automake1.15.1
        tar zxvf automake-1.15.1.tar.gz
        cd automake-1.15.1/
        ./configure
        make
        make install
四、编译mtd-utils2.0.2

sudo apt-get install -y zlib1g-dev liblzo2-dev uuid-dev pkg-config
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig"
wget ftp://ftp.gnu.org/gnu/automake/automake-1.15.1.tar.gz
tar zxvf automake-1.15.1.tar.gz
cd automake-1.15.1
sudo ./configure
sudo make 
sudo make install
  • 执行automake1.15.1 的./configure报错
opi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool/automake-1.15.1$ ./configure
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether ln -s works... yes
checking for perl... /usr/bin/perl
checking for tex... no
checking for yacc... no
checking for byacc... no
checking for bison... no
checking for lex... no
checking for flex... no
checking whether autoconf is installed... no
configure: error: Autoconf 2.65 or better is required.

解决方法:

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.gz

tar xzf autoconf-2.65.tar.gz

cd autoconf-2.65

 sudo ./configure

sudo make 
sudo make install
  • 安装autoconf-2.65报错:缺少:GNU M4 1.4.6
dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/jffs2_tool/autoconf-2.65$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether /bin/sh -n is known to work... yes
checking for characters that cannot appear in file names... none
checking whether directories can have trailing spaces... yes
checking for expr... /usr/bin/expr
checking for GNU M4 that supports accurate traces... configure: error: no acceptable m4 could be found in $PATH.
GNU M4 1.4.6 or later is required; 1.4.13 is recommended

解决方法:

wget http://ftp.gnu.org/gnu/m4/m4-1.4.13.tar.gz
tar m4-1.4.13.tar.gz
cd m4-1.4.13
 sudo ./configure 
 sudo make 
 sudo make install

连环嵌套报错解决之后,回头重新编译,安装autoconf-2.65,automake1.15.1。以上解决了mtd-utils的几个依赖项文件,安装完成。

下载mtd-utils2.0.2

访问:ftp://ftp.infradead.org的 /pub/mtd-utils/ 目录,找到mtd-utils2.0.2.tar下载。
执行命令:

 tar xjvf mtd-utils-2.0.2.tar.bz2 
 cd mtd-utils-2.0.2/
sudo ./configure 
sudo make
sudo make install

回头回到目录osdrv目录下,执行 make all 文件。

  • util-linux-2.31/tar错误:
    gzip: stdin: decompression OK, trailing garbage ignored
    tar: Child returned status 2
    tar: Error is not recoverable: exiting now
    Makefile:71: recipe for target '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/cramfs_tool/tmp/util-linux-2.31/tar' failed
    make[1]: *** [/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/cramfs_tool/tmp/util-linux-2.31/tar] Error 2
    make[1]: Leaving directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/cramfs_tool'
    Makefile:342: recipe for target 'hipctools' failed
    make: *** [hipctools] Error 2

解决方法:
下载的文件出错了,下载过程出错,或者从windows下载,拷贝到虚拟机的,会有问题。直接wget重新下载。
参考链接:https://blog.csdn.net/mengzuchao/article/details/81659971
回头回到目录osdrv目录下,执行 make all 文件。

  • eudev错误:
    Makefile:36: recipe for target '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/eudev-3.2.7/tmp/eudev-3.2.7/udevd' failed
    make[1]: *** [/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/eudev-3.2.7/tmp/eudev-3.2.7/udevd] Error 1
    make[1]: Leaving directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/eudev-3.2.7'
    Makefile:377: recipe for target 'hiboardtools' failed

解决方法:

dopi@ubuntu:/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/eudev-3.2.7$ cat readme_cn.txt 
注意:
eudev-3.2.7工具编译时依赖gperf工具,服务器上需要安装gperf工具。
下载网址:http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz
安装说明:
tar -xzf gperf-3.1.tar.gz
cd gperf-3.1
./configure
make 
make install
  • bison: command not found错误:
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/gdb/gdb-7.9.1/missing: line 81: bison: command not found
WARNING: 'bison' is missing on your system.

解决方法:

sudo apt-get install -y  bison

错误一:

fseeko.c: In function 'rpl_fseeko':`

`fseeko.c:110:4: error: #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."`

 `110 |  #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."`

   `|  ^~~~~`

 `CC    printf-args.o`

 `CC    printf.o`

`make[5]: *** [Makefile:1696: fseeko.o] Error 1`

`make[5]: *** Waiting for unfinished jobs....`

 `CC    printf-parse.o`

`fseterr.c: In function 'fseterr':`

`fseterr.c:78:3: error: #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."`

  `78 | #error "Please port gnulib fseterr.c to your platform! Look at the definitions of ferror and clearerr on your system, then report this to bug-gnulib."`

   `|  ^~~~~

解决方法:

修改:osdrv/tools/pc/hi_gzip/Makefile:

pushd gzip-1.8;patch -p1 < ../hi_gzip.patch;./configure;make -j12;popd

改为:

pushd gzip-1.8;patch -p1 < ../hi_gzip.patch;sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c;echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h;./configure;make -j12;popd

 

错误二:

mksquashfs.c: In function ‘create_inode’:`

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

 `987 |  unsigned int major = major(buf->st_rdev);`

   `|            ^~~~~`

`mksquashfs.c:987:16: note: declared here`

 `987 |  unsigned int major = major(buf->st_rdev);`

   `|        ^~~~~`

`mksquashfs.c:988:24: error: called object ‘minor’ is not a function or function pointer`

 `988 |  unsigned int minor = minor(buf->st_rdev);`

   `|            ^~~~~`

`mksquashfs.c:988:16: note: declared here`

 `988 |  unsigned int minor = minor(buf->st_rdev);`

   `|        ^~~~~`

`mksquashfs.c:1011:24: error: called object ‘major’ is not a function or function pointer`

 `1011 |  unsigned int major = major(buf->st_rdev);`

x   `|            ^~~~~`

`mksquashfs.c:1011:16: note: declared here`

 `1011 |  unsigned int major = major(buf->st_rdev);`

   `|        ^~~~~`

`mksquashfs.c:1012:24: error: called object ‘minor’ is not a function or function pointer`

 `1012 |  unsigned int minor = minor(buf->st_rdev);`

   `|            ^~~~~`

`mksquashfs.c:1012:16: note: declared here`

 `1012 |  unsigned int minor = minor(buf->st_rdev);

解决方法:

修改: osdrv/tools/pc/squashfs4.3/Makefile

SQUASHFS    := squashfs4.3

改为:

SQUASHFS    := squashfs4.4

这里就是脚本补丁和readme中有差异的地方,为了解决这个错误,我们使用了squashfs4.4而不是squashfs4.3
wget https://jaist.dl.sourceforge.net/project/squashfs/squashfs/squashfs4.4/squashfs4.4.tar.gz

经过以上两个修改,在ubuntu20.04上就可以完成了SDK的整包编译了。

7.建议:

重复编译过程中很可能出现以下情况。原因是因为重复打补丁,因此建议如果编译失败时,再次进行编译前建议进行make clean一下,这样就不会出现下面这种情况了。当然,在出现这个情况时也可以选择跳过,小A就是一路Enter下来的。

 

 

编译log,太多了,拷贝最后面一部分:

/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/mtd-utils
cp -rf /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/mtd-utils/mtd-utils-2.0.2/bin/sbin/* bin/
make[1]: Leaving directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/mtd-utils'
cp /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/board/mtd-utils/bin/* /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/board_uclibc
---------task [7] build rootfs
chmod 777 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/board_uclibc/*
chmod 777 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc/*
rm /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/dev/* -rf
rm /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/bin/himm -rf
rm /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/bin/himc -rf
rm /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/bin/himd -rf
rm /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/bin/himd.l -rf
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc;ln -s sbin/init init;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc; chmod 750 * -R; chmod 750 usr/* -R; popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc; chmod -w usr/bin -R; chmod -w usr/sbin -R; chmod -w sbin -R; popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkfs.jffs2 -d /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc -l -e 0x40000 -o /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_256k.jffs2;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkfs.jffs2 -d /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc -l -e 0x20000 -o /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_128k.jffs2;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkfs.jffs2 -d /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc -l -e 0x10000 -o /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_64k.jffs2;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
cp /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/tools/pc/ubi_sh/mkubiimg.sh /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc
chmod +x /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/mkubiimg.sh
# build the pagesize = 2k, blocksize = 128k, part_size = 32M #
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc;./mkubiimg.sh hi3516ev200 2k 128k /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc 32M /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc/mkfs.ubifs -F -d /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc -m 2048 -o rootfs_hi3516ev200_2k_128k_32M.ubiimg -e 126976 -c 256

/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc/ubinize -o rootfs_hi3516ev200_2k_128k_32M.ubifs -m 2048 -p 131072 rootfs_hi3516ev200_2k_128k_32M.ubicfg
ubinize: volume size was not specified in section "ubifs-volumn", assume minimum to fit image "rootfs_hi3516ev200_2k_128k_32M.ubiimg"5206016 bytes (4.9 MiB)
--------- rootfs_hi3516ev200_2k_128k_32M.ubifs is prepared !!
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
# build the pagesize = 4k, blocksize = 256k, part_size = 50M #
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc;./mkubiimg.sh hi3516ev200 4k 256k /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc 50M /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc/mkfs.ubifs -F -d /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc -m 4096 -o rootfs_hi3516ev200_4k_256k_50M.ubiimg -e 253952 -c 200

/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc/ubinize -o rootfs_hi3516ev200_4k_256k_50M.ubifs -m 4096 -p 262144 rootfs_hi3516ev200_4k_256k_50M.ubicfg
ubinize: volume size was not specified in section "ubifs-volumn", assume minimum to fit image "rootfs_hi3516ev200_4k_256k_50M.ubiimg"6602752 bytes (6.2 MiB)
--------- rootfs_hi3516ev200_4k_256k_50M.ubifs is prepared !!
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
rm /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/mkubiimg.sh
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkyaffs2image100 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/ /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_2k_4bit.yaffs2 1 2;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
mkyaffs2 0.2.9: image building tool for YAFFS2.
warning: non-root users.

stage 1: scanning directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/'... [done]
scanning complete, total 466 objects.

stage 2: creating image '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_2k_4bit.yaffs2'
[==================================================================================================================================================] 467/466 100%

operation complete,
467 objects in 3772 NAND pages.
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
chmod 644 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_2k_4bit.yaffs2
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkyaffs2image100 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/ /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_2k_24bit.yaffs2 1 4;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
mkyaffs2 0.2.9: image building tool for YAFFS2.
warning: non-root users.

stage 1: scanning directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/'... [done]
scanning complete, total 466 objects.

stage 2: creating image '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_2k_24bit.yaffs2'
[==================================================================================================================================================] 467/466 100%

operation complete,
467 objects in 3772 NAND pages.
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
chmod 644 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_2k_24bit.yaffs2
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkyaffs2image100 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/ /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_4k_4bit.yaffs2 2 2;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
mkyaffs2 0.2.9: image building tool for YAFFS2.
warning: non-root users.

stage 1: scanning directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/'... [done]
scanning complete, total 466 objects.

stage 2: creating image '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_4k_4bit.yaffs2'
[==================================================================================================================================================] 467/466 100%

operation complete,
467 objects in 2139 NAND pages.
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
chmod 644 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_4k_4bit.yaffs2
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc;./mkyaffs2image100 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/ /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_4k_24bit.yaffs2 2 4;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/bin/pc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
mkyaffs2 0.2.9: image building tool for YAFFS2.
warning: non-root users.

stage 1: scanning directory '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/'... [done]
scanning complete, total 466 objects.

stage 2: creating image '/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_4k_24bit.yaffs2'
[==================================================================================================================================================] 467/466 100%

operation complete,
467 objects in 2139 NAND pages.
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
chmod 644 /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/hi3516ev200_spi_image_uclibc/rootfs_hi3516ev200_4k_24bit.yaffs2
find /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc/ -name '*svn' | xargs rm -rf
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc; chmod +w usr/bin -R; chmod +w usr/sbin -R; chmod +w sbin -R; popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub/rootfs_uclibc /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
pushd /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub;tar czf rootfs_uclibc.tgz rootfs_uclibc;rm rootfs_uclibc -rf;popd
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv/pub /usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
/usr/dopi/Hi3516EV200_SDK_V1.0.1.0/package/osdrv
---------finish osdrv work