用户工具

站点工具


jaysnote:hi3798cv200_android_compile

hi3798cv200 android compile

  • sdk 百度云下载 密码:w11f

  • 开发环境搭建和初次编译参考Android 解决方案 开发指南.pdf- >开发环境配置

  • 烧写工具HiTool-STB-3.1.35.zip 会在成功编译镜像后自动拷贝到out文件夹。

    $ sudo find / -name HiTool-STB*
    /home/jay/hi3798cv200/HiSTBAndroidV600R002C00SPC030/out/target/product/Hi3798CV200/HiTool-STB-3.1.35.zip

提示:部分windows应用工具直接打包到了sdk,压缩成tar包。所以对于部分工具需要尝试在解压后linuxsdk 目录搜索。

sdk 目录结构

$tree
├── abi
├── art
├── bionic
├── bootable
├── build
├── cts
├── dalvik
├── developers
├── development
├── device
├── docs
├── external
├── frameworks
├── hardware
├── install_notes_cn.txt                #开发文档
├── install_notes_en.txt
├── libcore
├── libnativehelper
├── Makefile
├── ndk
├── out
├── packages
├── pdk
├── prebuilts                           #部分依赖的工具,需要提前编译
├── sdk
├── system
└── toolss

初始化编译环境

参考ServerInstall.sh进行初始化环境,主要是包含java 、python、依赖库、gcc安装,然而很多依赖版本过低,所以必须要添加 ubuntu12.04或者14.04源安装。

当前 ubuntu 源已经放弃部分老版本的更新维护,所以没有办法直接降级到文章中的 bardy 08.04 源直接安装,对于java7的安装需要更改source源到到当前维护的最低版本precise、trusty等,即:

The following releases are also available which have been superseded by later point releases (the current point release is available on releases.ubuntu.com as usual):

Ubuntu 12.04.4 LTS (Precise Pangolin)
Ubuntu 14.04.4 LTS (Trusty Tahr)
Ubuntu 16.04.4 LTS (Xenial Xerus)
Ubuntu 18.04 LTS (Bionic Beaver)

参考:Old Ubuntu Releases

java

$sudo apt-get install openjdk-7-jre

警告:不要尝试使用java8 否则后面会直接提示错误,参考[Troubleshotings/required java version is: "1.7.x"](#Troubleshotings/required java version is: "1.7.x")

设置环境变量

#~/.bashrc
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export PATH="/usr/lib/jvm/java-7-openjdk-amd64/bin":$PATH

gcc

交叉编译环境通过arm-hisiv200-linux.tar.bz2安装,解压后参考内根目录的安装脚本,主要包含建立软连接和配置环境变量。

#cross.install
TOP_DIR=/home/jay/hi3798cv200/env_init
TOOL_DIR=$TOP_DIR/arm-hisiv200-linux
TAR_BIN_DIR=$TOOL_DIR/target/bin
BIN_FILES=$TOOL_DIR/bin/arm-hisiv200-linux-gnueabi-*
LN_FILE_NAME=arm-hisiv200-linux-
TOOLS_PKG="`dirname $0`/arm-hisiv200-linux.tar.bz2"

mkdir -p $TAR_BIN_DIR
for armlinux in $BIN_FILES
do
        echo "ln $armlinux $TAR_BIN_DIR/$LN_FILE_NAME`basename $armlinux | cut -b 28-` -sv"
        ln $armlinux $TAR_BIN_DIR/$LN_FILE_NAME`basename $armlinux | cut -b 28-` -sv
done

配置环境变量

export PATH=/home/jay/hi3798cv200/env_init/arm-hisiv200-linux/target/bin":$PATH

烧写固件

  • HiBurn 工具使用指南.pdf

sch

uboot 烧写原理:HiBurn工具在开始烧写后,首选与bootrom 进行交互,工具DDR参数传送到传到bootrom,为uboot 下载阶段 5%处,然后初始化 DDR,再把uboot 传 输到DDR中,uboot 下载阶段 100%处表示传输完毕,再从 DDR启动uboot,uboot 启 动完成后,工具开始与uboot 进行交互,发送烧写命令,将 DDR中的uboot 烧 到 Flash对应地址中。
其他镜像分区烧写原理:其他镜像分区,如kernel ,rootfs 等分区,工具默认采用网口 传输的方式,客户可选 烧和非裸烧两种方式进行烧写,裸烧即为在按分区烧写或 按Emmc 烧写中勾选uboot 进行烧写,此时 uboot 会被烧写到Flash中,非裸烧即为不 勾选uboot,仅勾选其他分区进行烧写,此时需要保证当前单板上已经存在 uboot,烧 写时工具会启动uboot,与其交互,通过向 uboot 发送TFTP命令与Write命令,完成 烧写。

do

常规操作,通过串口烧写fastboot,通过tftp烧写其他分区镜像。对于目标烧写设备的静态ip地址信息需要手动指定后通过串口烧写。

网络配置

成功烧写fastboot过后可以通过串口连接打印环境变量printenv确定静态ip已经正确配置,通过ping 确定已经在同一网络。

Troubleshootings

apt update failed

jay@mxj-build:~/hi3798cv200/env_init$ sudo ./ServerInstall.sh 
E: Unable to locate package mingw32
E: Package 'uboot-mkimage' has no installation candidate
E: Package 'ia32-libs' has no installation candidate
E: Package 'gcc-4.4' has no installation candidate
E: Package 'g++-4.4' has no installation candidate
E: Unable to locate package g++-4.4-multilib
E: Couldn't find any package by glob 'g++-4.4-multilib'
E: Couldn't find any package by regex 'g++-4.4-multilib'
E: Unable to locate package gcc-4.4-multilib
E: Couldn't find any package by glob 'gcc-4.4-multilib'
E: Couldn't find any package by regex 'gcc-4.4-multilib'
Please re-login system to make new settings take effect

直接通过apt-get 安装如下依赖库和软件包提示找不到源,尝试添加老版本发布源,也不能正常下载,剔除不能正常安装的源,其他的参考初始化编译环境/gcc 安装。

$sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev x11proto-core-dev  libx11-dev libreadline6-dev libgl1-mesa-glx libgl1-mesa-dev g++-multilib mingw32 tofrodos  python-markdown libxml2-utils xsltproc zlib1g-dev xsltproc   gettext  lib32ncurses5-dev libtool autoconf

$sudo apt-get install uboot-mkimage ia32-libs gcc-4.4 g++-4.4 g++-4.4-multilib gcc-4.4-multilib
$sudo apt-get install u-boot-tools

gcc not found

参考初始化编译环境/gcc 安装并且确定已经正确配置环境变量。

required java version is: "1.7.x"

Your version is: openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.16.04.1-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode).
The required version is: "1.7.x"

Please follow the machine setup instructions at

参考初始化编译环境/java 安装openjdk-7-jre,同时不支持java1.8.0以上版本,

policy_scan.cpp' failed

ost C: libpcre_32 <= external/pcre/dist/pcre_globals.c
build/core/binary.mk:576: recipe for target 'out/host/linux-x86/obj32/EXECUTABLES/checkpolicy_intermediates/policy_scan.cpp' failed

https://www.jianshu.com/p/df547248650d

checkpolicy用于检测SELinux策略(SELinux policy)的工具,源码位于sdk external/checkpolicy/,里面*.l.y源文件需要通过flexbision解释器翻译为*.c源码再通过gcc编译。

$tree external/checkpolicy/
external/checkpolicy/
├── Android.mk
├── ChangeLog
├── checkmodule.8
├── checkmodule.c
├── checkpolicy.8
├── checkpolicy.c
├── checkpolicy.h
├── COPYING
├── Makefile
├── module_compiler.c
├── module_compiler.h
├── parse_util.c
├── parse_util.h
├── policy_define.c
├── policy_define.h
├── policy_parse.y
├── policy_scan.l
├── queue.c
├── queue.h
├── test
│   ├── dismod.c
│   ├── dispol.c
│   └── Makefile
└── VERSION

对于sdk的已经原装了bison和flex。这里之所以报错是因为版本flex版本过低。

./prebuilts/misc/linux-x86/
├── analyzer
├── bison
├── ccache
├── flex
├── protobuf
└── yasm

这里直接安装 flex和bison,然后软链接到sdk目录。

$sudo apt-get install flex bison
$~/hi3798cv200/HiSTBAndroidV600R002C00SPC030/prebuilts/misc/linux-x86/flex$ ls -al
total 3328
lrwxrwxrwx 1 jay jay      13 Dec  6 13:55 flex-2.5.39 -> /usr/bin/flex
-rwxr-xr-x 1 jay jay 1473304 Apr  1  2016 flex-2.5.39.bak

serve_image.c compiled failed

serve_image.c: In function ‘main’:
serve_image.c:32:18: error: storage size of ‘hints’ isn’t known
serve_image.c:94:19: error: ‘AI_ADDRCONFIG’ undeclared (first use in this function)
serve_image.c:94:19: note: each undeclared identifier is reported only once for each function it appears in
serve_image.c:99:3: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat]
$find ./ -name "mtd-utils-1.5.0*"
./device/hisilicon/bigfish/sdk/third_party/open_source/mtd-utils-1.5.0.tar.bz2
./out/target/product/Hi3798CV200/obj/TOOLS_OBJ/mtd-utils/tmp/mtd-utils-1.5.0

如上目录保存了mtd-utils-1.5.0.tar.bz2 会在编译过程解压编译,直接在ubuntu16.04 上面编译会因为兼容导致报错,软件包通过如下Makefile 配置。所以这里可以修改配置和替换包的方式直接更新为mtd-utils-2.0.0

$ rgrep  "mtd-utils-1.5.0" -n --color -I -C2 ./
./device/hisilicon/bigfish/sdk/tools/linux/utils/mtd-utils/Makefile-14-STRIP          := strip
./device/hisilicon/bigfish/sdk/tools/linux/utils/mtd-utils/Makefile:16:MTD_UTILS      := mtd-utils-1.5.0

需要注意的是,默认mtd-utils-2.0.0通过cmake编译,需要cmake configure,这里直接选择修改/usr/include/netdb.h在includde头文件之后定义宏,使其失效。

$vi /usr/include/netdb.h

#define __USE_XOPEN2K  0

注意:定义__USE_XOPEN2K 值为0是使其之后所有的条件编译失效,所以要尽量选择在#include头文件之后,变值被覆盖。

unsupported reloc 43

out/host/linux-x86/obj32/EXECUTABLES/third_party_libvpx_libvpx_obj_int_extract_arm_host_gyp_intermediates/third_party/libvpx/source/libvpx/build/make/obj_int_extract.o: unsupported reloc 43 against global symbol stderr
prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6//x86_64-linux/bin/ld: error: out/host/linux-x86/obj32/EXECUTABLES/third_party_libvpx_libvpx_obj_int_extract_arm_host_gyp_intermediates/third_party/libvpx/source/libvpx/build/make/obj_int_extract.o: unsupported reloc 43 

ld版本过低。https://www.cnblogs.com/blowing-in-the-wind/p/6518076.html

$cp /usr/bin/ld.gold prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/ld
jaysnote/hi3798cv200_android_compile.txt · 最后更改: 2021/06/22 23:14 (外部编辑)