1. 程式人生 > >HiKey970韌體燒寫

HiKey970韌體燒寫

AOSP與Kernel編譯成功後,接著進行韌體燒寫的工作,首先我們需要生成boot.img, 步驟如下:

1.  git clone https://github.com/96boards-hikey/linux.git

2. git checkout -b hikey970-v4.9

以上步驟為下載Kernel原始碼,如之前下載過則可以忽略

3. mkdir tools (該tools建立在與linux目錄平級)

4. cp  AOSP_PATH/system/core/mkbootimg/mkbootimg  ./tools

5. cp  AOSP_PATH/out/target/product/hikey970/ramdisk.img  ./tools

6. 建立build_kernel.sh指令碼,內容如下:

#!/bin/bash

DTB=1

LOCAL_DIR=$(pwd)

KERNEL_DIR=${LOCAL_DIR}/linux

PRODUCT_OUT=${LOCAL_DIR}/out/target/product/hikey970

GEN_IMAGES_DIR=${LOCAL_DIR}/tools

HIKEY970_KERNEL=${LOCAL_DIR}/tools

MKBOOTTOOL_DIR=${LOCAL_DIR}/tools

CURRENT_DIR=${LOCAL_DIR}

NCPU=`grep -c ^processor /proc/cpuinfo`

if [ ! -e ${PRODUCT_OUT} ]

then

mkdir -p ${PRODUCT_OUT}

fi

export MINI_SYS=true

export ARCH=arm64

export CROSS_COMPILE=AOSP_PATH/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-

check_build_result()

{

if [ $? != 0 ]; then

echo -e "\033[31m $1 build fail! \033[0m"

exit -1

else

echo -e "\033[32m $1 build success! \033[0m"

fi

}

if [ "${MINI_SYS}" != true ]; then

source ./build/envsetup.sh && lunch hikey970-userdebug && make -j$[NCPU*2] $2

check_build_result "Android System"

fi

cd ${KERNEL_DIR}

make hikey970_defconfig && make -j$[NCPU*2] Image.gz modules

check_build_result "Kernel Image"

rm -f arch/arm64/configs/hikey970_temp_defconfig

cp arch/arm64/boot/Image.gz ${HIKEY970_KERNEL}

if [ $DTB -eq 1 ]; then

make hisilicon/kirin970-hikey970.dtb

check_build_result "Hikey970 dtb"

cp arch/arm64/boot/dts/hisilicon/kirin970-hikey970.dtb ${HIKEY970_KERNEL}

fi

cd ${CURRENT_DIR}

if [ ${need_repack_userdata} ];

then

make -j$[NCPU*2] userdataimage-nodeps

check_build_result "Hikey970 need repack userdataimage"

fi

if [ "${MINI_SYS}" = true ]; then

RAMDISK=${GEN_IMAGES_DIR}/ramdisk.img

else

RAMDISK=${PRODUCT_OUT}/ramdisk.img

if [ ! -e $RAMDISK ]; then

echo -e "\033[33m $RAMDISK is not exist! please build ramdisk first.

\033[0m"

echo -e "\033[33m . ./build/envsetup.sh && lunch hikey960-userdebug

&& make ramdisk \033[0m"

exit -1

fi

fi

#uefi boot.img = Image + dtb + ramdisk

cat ${KERNEL_DIR}/arch/arm64/boot/Image ${KERNEL_DIR}/arch/arm64/boot/dts/hisilicon/kirin970-hikey970.dtb > ${HIKEY970_KERNEL}/Image-dtb

check_build_result "Image-dtb"

${MKBOOTTOOL_DIR}/mkbootimg --kernel ${HIKEY970_KERNEL}/Image-dtb --ramdisk ${RAMDISK} --cmdline "androidboot.hardware=hikey970 firmware_class.path=/system/etc/firmware loglevel=15 buildvariant=userdebug androidboot.selinux=permissive clk_ignore_unused=true" --base 0x0 --tags_offset 0x07A00000 --kernel_offset 0x00080000 --ramdisk_offset 0x07c00000 --os_version 9.0 --os_patch_level 2018-11-21 --output ${PRODUCT_OUT}/boot.img

check_build_result "Boot Image"

echo -e "\033[36m build boot.img complete! \033[0m"

7. 執行上面的build_kernel.sh,然後生成boot.img

8.根據https://www.96boards.org/documentation/consumer/hikey/hikey970/installation/linux-fastboot.md.html的內容燒寫開發板