672 lines
22 KiB
Bash
Executable File
672 lines
22 KiB
Bash
Executable File
#!/bin/bash
|
|
usage()
|
|
{
|
|
echo "USAGE: [-U] [-CK] [-A] [-p] [-o] [-u] [-v VERSION_NAME] "
|
|
echo "No ARGS means use default build option "
|
|
echo "WHERE: -U = build uboot "
|
|
echo " -C = build kernel with Clang "
|
|
echo " -K = build kernel "
|
|
echo " -A = build android "
|
|
echo " -p = will build packaging in IMAGE "
|
|
echo " -o = build OTA package "
|
|
echo " -u = build update.img "
|
|
echo " -v = build android with 'user' or 'userdebug' "
|
|
echo " -d = huild kernel dts name "
|
|
echo " -V = build version "
|
|
echo " -J = build jobs "
|
|
echo " init = init rp board config"
|
|
echo " batch = batch compilation image"
|
|
echo " all = batch compile all images on the current platform"
|
|
exit 1
|
|
}
|
|
|
|
|
|
function select_platform()
|
|
{
|
|
echo "Please choose platform:"
|
|
|
|
PLATFPRM_PATH=device/rockchip
|
|
PLATFORMS=( $(cd $PLATFPRM_PATH && ls -d rk* | sort) )
|
|
echo "${PLATFORMS[@]}" |xargs -n 1 | sed "=" | sed "N;s/\n/. /"
|
|
|
|
read -p "Please input num: " INDEX
|
|
INDEX=$((${INDEX:-0} - 1))
|
|
|
|
if echo $INDEX | grep -vq [^0-9]; then
|
|
if ((INDEX >= 0 && INDEX < ${#PLATFORMS[@]})); then
|
|
|
|
TARGET_PLATFORM="${PLATFORMS[$INDEX]}"
|
|
echo "build target platform : $TARGET_PLATFORM"
|
|
echo $TARGET_PLATFORM > $PLATFPRM_PATH/.targe_platform
|
|
|
|
else
|
|
echo "Invalid selection"
|
|
select_platform
|
|
fi
|
|
else
|
|
echo "Invalid input, please retry!!"
|
|
select_platform
|
|
fi
|
|
}
|
|
|
|
function select_board()
|
|
{
|
|
echo "Please choose board:"
|
|
BOARD_DIR=$PLATFPRM_PATH/$TARGET_PLATFORM/rp_boards
|
|
if [ ! -d $BOARD_DIR ];then
|
|
echo "Not yet adapted to this platform. exit!!!"
|
|
exit -1
|
|
fi
|
|
|
|
BOARDS=( $(cd $BOARD_DIR && ls *.mk | sort) )
|
|
echo "${BOARDS[@]}" |xargs -n 1 | sed "=" | sed "N;s/\n/. /"
|
|
|
|
read -p "Please input num: " INDEX
|
|
INDEX=$((${INDEX:-0} - 1))
|
|
|
|
if echo $INDEX | grep -vq [^0-9]; then
|
|
if ((INDEX >= 0 && INDEX < ${#BOARDS[@]})); then
|
|
|
|
TARGET_BOARD="${BOARDS[$INDEX]}"
|
|
echo "build target board : $TARGET_BOARD"
|
|
echo $TARGET_BOARD >> $PLATFPRM_PATH/.targe_platform
|
|
ln -sf rp_boards/$TARGET_BOARD $BOARD_DIR/../BoardConfig.mk
|
|
else
|
|
echo "Invalid selection"
|
|
select_board
|
|
fi
|
|
else
|
|
echo "Invalid input"
|
|
select_board
|
|
fi
|
|
}
|
|
|
|
function build_init()
|
|
{
|
|
select_platform
|
|
select_board
|
|
|
|
echo
|
|
echo "========================================================="
|
|
echo "build platform: ${TARGET_PLATFORM}, board: $TARGET_BOARD"
|
|
echo "========================================================="
|
|
}
|
|
|
|
function lunch_platform()
|
|
{
|
|
TARGET_PLATFORM_PATH=device/rockchip/.targe_platform
|
|
|
|
if [ ! -e $TARGET_PLATFORM_PATH ];then
|
|
build_init
|
|
fi
|
|
|
|
TARGET_PLATFORM=$(sed -n '1p' device/rockchip/.targe_platform)
|
|
TARGET_BOARD=$(sed -n '2p' device/rockchip/.targe_platform)
|
|
source build/envsetup.sh >/dev/null
|
|
|
|
case $TARGET_PLATFORM in
|
|
rk3588)
|
|
lunch rk3588_t-user
|
|
;;
|
|
rk356x)
|
|
if [[ "$TARGET_BOARD" =~ "rk3566" ]];then
|
|
lunch rk3566_t-userdebug
|
|
else
|
|
lunch rk3568_t-userdebug
|
|
fi
|
|
;;
|
|
rk3399)
|
|
lunch rk3399_t-userdebug
|
|
;;
|
|
rk3562)
|
|
lunch rk3562_t-userdebug
|
|
;;
|
|
*)
|
|
echo "$TARGET_PLATFORM 平台暂未适配!"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
|
|
function batch_compile() {
|
|
if [ ! -d release_dir ];then
|
|
mkdir release_dir
|
|
fi
|
|
# choose board
|
|
build_init
|
|
TARGET_BOARD_T=${TARGET_BOARD//.mk/}
|
|
DTS_DIR=kernel-5.10/arch/arm64/boot/dts/rockchip/$TARGET_PLATFORM/$TARGET_BOARD_T.dts
|
|
IMAGE_PATH_T="rockdev/Image-rk$(echo $TARGET_BOARD_T | grep -oP 'rk\K\d+')_t"
|
|
|
|
IMAGE_OUT_PATH=$(mkdir -p "release_dir/$TARGET_BOARD_T" && echo "release_dir/$TARGET_BOARD_T")
|
|
# get all lcd.dtsi
|
|
i=0
|
|
IFS=$'\n'
|
|
for line in `grep -r "rp-lcd" $DTS_DIR | sed 's/\///g'`
|
|
do
|
|
if [[ "$TARGET_PLATFORM" == "rk3588" || "$TARGET_PLATFORM" == "rk3399" ]]; then
|
|
if [[ ${line} != *'rp-lcd-multi-hdmi0-hdmi1-dp0.dtsi'* && ${line} != *'rp-lcd-hdmi.dtsi'* && ${line} != *'rp-lcd-typec-dp0.dtsi'* && ${line} != *'rp-lcd-hdmi0.dtsi'* && ${line} != *'rp-lcd-hdmi1.dtsi'* ]]; then
|
|
DTSI_ARRAY1[${i}]=$line
|
|
let i=${i}+1
|
|
fi
|
|
else
|
|
DTSI_ARRAY1[${i}]=$line
|
|
let i=${i}+1
|
|
fi
|
|
done
|
|
unset IFS
|
|
|
|
# print lcd.dtsi
|
|
echo -n "------------ ready build image num is "
|
|
echo -n ${#DTSI_ARRAY1[@]}
|
|
echo " -------------"
|
|
for ((i=0; i<${#DTSI_ARRAY1[@]}; i++))
|
|
do
|
|
echo ${DTSI_ARRAY1[$i]} #| sed 's/include/& /'
|
|
done
|
|
|
|
# find null line in dts
|
|
DTS_LINE=`grep -rn "rp-lcd" $DTS_DIR | awk 'END {print}' | cut -d ":" -f 1`
|
|
sed -i "${DTS_LINE}a //nullLine" $DTS_DIR # add null line after last lcd dtsi
|
|
NULL_LINE=`expr $DTS_LINE + 1`
|
|
STRING=`cat $DTS_DIR | tail -n +$NULL_LINE | head -1`
|
|
if [ -z $STRING ] ; then
|
|
echo -n $TARGET_BOARD_T
|
|
echo -n " +"
|
|
echo -n $NULL_LINE
|
|
echo " is NULL"
|
|
fi
|
|
|
|
# start build
|
|
DTSI_LENGTH=${#DTSI_ARRAY1[*]}
|
|
sed -i '/^#include "rp-lcd/ s/^/\/\//' $DTS_DIR # comment lcd dtsi that have included
|
|
# Uncomment the specific dtsi if they are commented
|
|
if [ "$TARGET_PLATFORM" == "rk3588" ]; then
|
|
sed -i 's/^\/\/#include "rp-lcd-multi-hdmi0-hdmi1-dp0.dtsi"/#include "rp-lcd-multi-hdmi0-hdmi1-dp0.dtsi"/' $DTS_DIR
|
|
sed -i 's/^\/\/#include "rp-lcd-hdmi0.dtsi"/#include "rp-lcd-hdmi0.dtsi"/' $DTS_DIR
|
|
sed -i 's/^\/\/#include "rp-lcd-typec-dp0.dtsi"/#include "rp-lcd-typec-dp0.dtsi"/' $DTS_DIR
|
|
elif [ "$TARGET_PLATFORM" == "rk3399" ]; then
|
|
sed -i 's/^\/\/#include "rp-lcd-hdmi.dtsi"/#include "rp-lcd-hdmi.dtsi"/' $DTS_DIR
|
|
fi
|
|
|
|
|
|
for((i=0;i<$DTSI_LENGTH;i++));
|
|
do
|
|
echo -e "\n\t====> now, screen board and dtsi is $TARGET_BOARD_T:${DTSI_ARRAY1[$i]}\n"
|
|
sed -i -e "${NULL_LINE}s/.*$/${DTSI_ARRAY1[$i]}/" ${DTS_DIR}
|
|
./build.sh
|
|
if [ $? -ne 0 ];then
|
|
echo -e "\n\t====> build.sh fail!\n"
|
|
exit -3
|
|
else
|
|
screen=${DTSI_ARRAY1[$i]}
|
|
screen=${screen#*lcd-} && screen=${screen%.*}
|
|
if [[ $screen =~ "ai" ]];then
|
|
screen=${screen#*ai-}
|
|
fi
|
|
|
|
TIME=`date +%Y%m%d-%H%M%S`
|
|
TARGET_IMAGE_NAME=update-$TARGET_BOARD_T-android13-$screen-$TIME
|
|
|
|
mv $IMAGE_PATH_T/update-*.img $IMAGE_OUT_PATH/$TARGET_IMAGE_NAME.img
|
|
fi
|
|
done
|
|
echo -e "\e[32m finish batch pack\e[0m"
|
|
sed -i -e "${NULL_LINE}d" $DTS_DIR # pack finished, remove null line
|
|
}
|
|
|
|
function batch_compile_all() {
|
|
if [ ! -d release_dir ];then
|
|
mkdir release_dir
|
|
fi
|
|
|
|
# choose platform
|
|
select_platform
|
|
|
|
# choose board
|
|
BOARD_DIR=$PLATFPRM_PATH/$TARGET_PLATFORM/rp_boards
|
|
BOARDS=( $(cd $BOARD_DIR && ls *.mk | sort) )
|
|
|
|
for TARGET_BOARD in "${BOARDS[@]}"; do
|
|
echo "build target board : $TARGET_BOARD"
|
|
echo $TARGET_BOARD >> $PLATFPRM_PATH/.targe_platform
|
|
ln -sf rp_boards/$TARGET_BOARD $BOARD_DIR/../BoardConfig.mk
|
|
|
|
TARGET_BOARD_T=${TARGET_BOARD//.mk/}
|
|
DTS_DIR=kernel-5.10/arch/arm64/boot/dts/rockchip/$TARGET_PLATFORM/$TARGET_BOARD_T.dts
|
|
IMAGE_PATH_T="rockdev/Image-rk$(echo $TARGET_BOARD_T | grep -oP 'rk\K\d+')_t"
|
|
|
|
IMAGE_OUT_PATH=$(mkdir -p "release_dir/$TARGET_BOARD_T" && echo "release_dir/$TARGET_BOARD_T")
|
|
# get all lcd.dtsi
|
|
i=0
|
|
IFS=$'\n'
|
|
for line in `grep -r "rp-lcd" $DTS_DIR | sed 's/\///g'`
|
|
do
|
|
if [[ "$TARGET_PLATFORM" == "rk3588" || "$TARGET_PLATFORM" == "rk3399" ]]; then
|
|
if [[ ${line} != *'rp-lcd-multi-hdmi0-hdmi1-dp0.dtsi'* && ${line} != *'rp-lcd-hdmi.dtsi'* && ${line} != *'rp-lcd-typec-dp0.dtsi'* && ${line} != *'rp-lcd-hdmi0.dtsi'* && ${line} != *'rp-lcd-hdmi1.dtsi'* ]]; then
|
|
DTSI_ARRAY1[${i}]=$line
|
|
let i=${i}+1
|
|
fi
|
|
else
|
|
DTSI_ARRAY1[${i}]=$line
|
|
let i=${i}+1
|
|
fi
|
|
done
|
|
unset IFS
|
|
|
|
# print lcd.dtsi
|
|
echo -n "------------ ready build image num is "
|
|
echo -n ${#DTSI_ARRAY1[@]}
|
|
echo " -------------"
|
|
for ((i=0; i<${#DTSI_ARRAY1[@]}; i++))
|
|
do
|
|
echo ${DTSI_ARRAY1[$i]} #| sed 's/include/& /'
|
|
done
|
|
|
|
# find null line in dts
|
|
DTS_LINE=`grep -rn "rp-lcd" $DTS_DIR | awk 'END {print}' | cut -d ":" -f 1`
|
|
sed -i "${DTS_LINE}a //nullLine" $DTS_DIR # add null line after last lcd dtsi
|
|
NULL_LINE=`expr $DTS_LINE + 1`
|
|
STRING=`cat $DTS_DIR | tail -n +$NULL_LINE | head -1`
|
|
if [ -z $STRING ] ; then
|
|
echo -n $TARGET_BOARD_T
|
|
echo -n " +"
|
|
echo -n $NULL_LINE
|
|
echo " is NULL"
|
|
fi
|
|
|
|
# start build
|
|
DTSI_LENGTH=${#DTSI_ARRAY1[*]}
|
|
# Comment all the dtsi files that have included
|
|
sed -i '/^#include "rp-lcd/ s/^/\/\//' $DTS_DIR
|
|
|
|
# Uncomment the specific dtsi if they are commented
|
|
if [ "$TARGET_PLATFORM" == "rk3588" ]; then
|
|
sed -i 's/^\/\/#include "rp-lcd-multi-hdmi0-hdmi1-dp0.dtsi"/#include "rp-lcd-multi-hdmi0-hdmi1-dp0.dtsi"/' $DTS_DIR
|
|
sed -i 's/^\/\/#include "rp-lcd-hdmi0.dtsi"/#include "rp-lcd-hdmi0.dtsi"/' $DTS_DIR
|
|
sed -i 's/^\/\/#include "rp-lcd-typec-dp0.dtsi"/#include "rp-lcd-typec-dp0.dtsi"/' $DTS_DIR
|
|
elif [ "$TARGET_PLATFORM" == "rk3399" ]; then
|
|
sed -i 's/^\/\/#include "rp-lcd-hdmi.dtsi"/#include "rp-lcd-hdmi.dtsi"/' $DTS_DIR
|
|
fi
|
|
|
|
for((i=0;i<$DTSI_LENGTH;i++));
|
|
do
|
|
echo -e "\n\t====> now, screen board and dtsi is $TARGET_BOARD_T:${DTSI_ARRAY1[$i]}\n"
|
|
sed -i -e "${NULL_LINE}s/.*$/${DTSI_ARRAY1[$i]}/" ${DTS_DIR}
|
|
./build.sh
|
|
if [ $? -ne 0 ];then
|
|
echo -e "\n\t====> build.sh fail!\n"
|
|
exit -3
|
|
else
|
|
screen=${DTSI_ARRAY1[$i]}
|
|
screen=${screen#*lcd-} && screen=${screen%.*}
|
|
if [[ $screen =~ "ai" ]];then
|
|
screen=${screen#*ai-}
|
|
fi
|
|
|
|
TIME=`date +%Y%m%d-%H%M%S`
|
|
TARGET_IMAGE_NAME=update-$TARGET_BOARD_T-android13-$screen-$TIME
|
|
|
|
mv $IMAGE_PATH_T/update-*.img $IMAGE_OUT_PATH/$TARGET_IMAGE_NAME.img
|
|
fi
|
|
done
|
|
echo -e "\e[32m finish batch pack\e[0m"
|
|
sed -i -e "${NULL_LINE}d" $DTS_DIR # pack finished, remove null line
|
|
done
|
|
}
|
|
|
|
if [ "$1" == "init" ];then
|
|
build_init
|
|
exit 0
|
|
elif [ "$1" == "batch" ]; then
|
|
batch_compile
|
|
exit 0
|
|
elif [ "$1" == "all" ]; then
|
|
batch_compile_all
|
|
exit 0
|
|
fi
|
|
|
|
lunch_platform
|
|
#source build/envsetup.sh >/dev/null
|
|
BUILD_UBOOT=false
|
|
BUILD_KERNEL_WITH_CLANG=false
|
|
BUILD_KERNEL=false
|
|
BUILD_ANDROID=false
|
|
BUILD_AB_IMAGE=`get_build_var BOARD_USES_AB_IMAGE`
|
|
BUILD_UPDATE_IMG=false
|
|
BUILD_OTA=false
|
|
BUILD_PACKING=false
|
|
BUILD_VARIANT=`get_build_var TARGET_BUILD_VARIANT`
|
|
KERNEL_DTS=""
|
|
BUILD_VERSION=""
|
|
BUILD_JOBS=16
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Not input any arg, will build all images"
|
|
# build all images
|
|
BUILD_ANDROID=true
|
|
BUILD_UBOOT=true
|
|
BUILD_KERNEL=true
|
|
BUILD_KERNEL_WITH_CLANG=true
|
|
BUILD_KERNEL=true
|
|
BUILD_UPDATE_IMG=true
|
|
fi
|
|
|
|
# check pass argument
|
|
while getopts "UCKABpouv:d:V:J:" arg
|
|
do
|
|
case $arg in
|
|
U)
|
|
echo "will build u-boot"
|
|
BUILD_UBOOT=true
|
|
;;
|
|
C)
|
|
echo "will build kernel with Clang"
|
|
BUILD_KERNEL=true
|
|
BUILD_KERNEL_WITH_CLANG=true
|
|
;;
|
|
K)
|
|
echo "will build kernel"
|
|
BUILD_KERNEL=true
|
|
;;
|
|
A)
|
|
echo "will build android"
|
|
BUILD_ANDROID=true
|
|
;;
|
|
B)
|
|
echo "will build AB Image"
|
|
BUILD_AB_IMAGE=true
|
|
;;
|
|
p)
|
|
echo "will build packaging in IMAGE"
|
|
BUILD_PACKING=true
|
|
;;
|
|
o)
|
|
echo "will build ota package"
|
|
BUILD_OTA=true
|
|
;;
|
|
u)
|
|
echo "will build update.img"
|
|
BUILD_UPDATE_IMG=true
|
|
;;
|
|
v)
|
|
BUILD_VARIANT=$OPTARG
|
|
;;
|
|
V)
|
|
BUILD_VERSION=$OPTARG
|
|
;;
|
|
d)
|
|
KERNEL_DTS=$OPTARG
|
|
;;
|
|
J)
|
|
BUILD_JOBS=$OPTARG
|
|
;;
|
|
?)
|
|
usage ;;
|
|
esac
|
|
done
|
|
|
|
TARGET_PRODUCT=`get_build_var TARGET_PRODUCT`
|
|
TARGET_BOARD_PLATFORM=`get_build_var TARGET_BOARD_PLATFORM`
|
|
|
|
#set jdk version
|
|
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
|
|
export PATH=$JAVA_HOME/bin:$PATH
|
|
export PATH=$ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/clang-r450784d/bin:$PATH
|
|
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
|
|
|
|
# source environment and chose target product
|
|
BUILD_NUMBER=`get_build_var BUILD_NUMBER`
|
|
BUILD_ID=`get_build_var BUILD_ID`
|
|
# only save the version code
|
|
SDK_VERSION=`get_build_var CURRENT_SDK_VERSION`
|
|
UBOOT_DEFCONFIG=`get_build_var PRODUCT_UBOOT_CONFIG`
|
|
KERNEL_VERSION=`get_build_var PRODUCT_KERNEL_VERSION`
|
|
KERNEL_ARCH=`get_build_var PRODUCT_KERNEL_ARCH`
|
|
KERNEL_DEFCONFIG=`get_build_var PRODUCT_KERNEL_CONFIG`
|
|
if [ "$KERNEL_DTS" = "" ] ; then
|
|
KERNEL_DTS=`get_build_var PRODUCT_KERNEL_DTS`
|
|
fi
|
|
LOCAL_KERNEL_PATH=kernel-$KERNEL_VERSION
|
|
echo "-------------------KERNEL_VERSION:$KERNEL_VERSION"
|
|
echo "-------------------KERNEL_DTS:$KERNEL_DTS"
|
|
|
|
if [ "$KERNEL_VERSION" = "5.10" ] ; then
|
|
echo "Force use clang and llvm to build kernel-$KERNEL_VERSION"
|
|
BUILD_KERNEL_WITH_CLANG=true
|
|
fi
|
|
|
|
PACK_TOOL_DIR=RKTools/linux/Linux_Pack_Firmware
|
|
IMAGE_PATH=rockdev/Image-$TARGET_PRODUCT
|
|
export PROJECT_TOP=`gettop`
|
|
|
|
lunch $TARGET_PRODUCT-$BUILD_VARIANT
|
|
|
|
DATE=$(date +%Y%m%d.%H%M)
|
|
STUB_PATH=Image/"$TARGET_PRODUCT"_"$BUILD_VARIANT"_"$KERNEL_DTS"_"$BUILD_VERSION"_"$DATE"
|
|
STUB_PATH="$(echo $STUB_PATH | tr '[:lower:]' '[:upper:]')"
|
|
export STUB_PATH=$PROJECT_TOP/$STUB_PATH
|
|
export STUB_PATCH_PATH=$STUB_PATH/PATCHES
|
|
|
|
# build uboot
|
|
if [ "$BUILD_UBOOT" = true ] ; then
|
|
echo "start build uboot"
|
|
cd u-boot && make clean && make mrproper && make distclean && ./make.sh $UBOOT_DEFCONFIG && cd -
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build uboot ok!"
|
|
else
|
|
echo "Build uboot failed!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$BUILD_KERNEL_WITH_CLANG" = true ] ; then
|
|
if [ "$KERNEL_ARCH" = "arm64" ]; then
|
|
ADDON_ARGS="CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 LLVM_IAS=1"
|
|
else
|
|
ADDON_ARGS="CC=clang LD=ld.lld"
|
|
fi
|
|
fi
|
|
# build kernel
|
|
if [ "$BUILD_KERNEL" = true ] ; then
|
|
echo "Start build kernel"
|
|
cd $LOCAL_KERNEL_PATH && make clean && make $ADDON_ARGS ARCH=$KERNEL_ARCH $KERNEL_DEFCONFIG && make $ADDON_ARGS ARCH=$KERNEL_ARCH $KERNEL_DTS.img -j$BUILD_JOBS && cd -
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build kernel ok!"
|
|
else
|
|
echo "Build kernel failed!"
|
|
exit 1
|
|
fi
|
|
# build exteranl wifi driver
|
|
LOCAL_EXT_WIFI_DRIVER_PATH=external/wifi_driver
|
|
if [ -d $LOCAL_EXT_WIFI_DRIVER_PATH ]; then
|
|
source $LOCAL_EXT_WIFI_DRIVER_PATH/set_android_version.sh $LOCAL_EXT_WIFI_DRIVER_PATH
|
|
echo "Start build exteranl wifi driver"
|
|
cd $LOCAL_EXT_WIFI_DRIVER_PATH && make $ADDON_ARGS ARCH=$KERNEL_ARCH -C ../../$LOCAL_KERNEL_PATH M=$PWD clean && cd -
|
|
cd $LOCAL_EXT_WIFI_DRIVER_PATH && make $ADDON_ARGS ARCH=$KERNEL_ARCH -C ../../$LOCAL_KERNEL_PATH M=$PWD -j$BUILD_JOBS && cd -
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build exteranl wifi driver ok!"
|
|
else
|
|
echo "Build exteranl wifi driver failed!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$KERNEL_ARCH" = "arm64" ]; then
|
|
KERNEL_DEBUG=$LOCAL_KERNEL_PATH/arch/arm64/boot/Image
|
|
else
|
|
KERNEL_DEBUG=$LOCAL_KERNEL_PATH/arch/arm/boot/zImage
|
|
fi
|
|
cp -rf $KERNEL_DEBUG $OUT/kernel
|
|
fi
|
|
|
|
echo "package resoure.img with charger images"
|
|
cd u-boot && ./scripts/pack_resource.sh ../$LOCAL_KERNEL_PATH/resource.img && cp resource.img ../$LOCAL_KERNEL_PATH/resource.img && cd -
|
|
|
|
# build android
|
|
if [ "$BUILD_ANDROID" = true ] ; then
|
|
# build OTA
|
|
if [ "$BUILD_OTA" = true ] ; then
|
|
INTERNAL_OTA_PACKAGE_OBJ_TARGET=obj/PACKAGING/target_files_intermediates/$TARGET_PRODUCT-target_files-*.zip
|
|
INTERNAL_OTA_PACKAGE_TARGET=$TARGET_PRODUCT-ota-*.zip
|
|
if [ "$BUILD_AB_IMAGE" = true ] ; then
|
|
echo "make ab image and generate ota package"
|
|
make installclean
|
|
make -j$BUILD_JOBS
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
|
|
make dist -j$BUILD_JOBS
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
./mkimage_ab.sh ota
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "generate ota package"
|
|
make installclean
|
|
make -j$BUILD_JOBS
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
make dist -j$BUILD_JOBS
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
./mkimage.sh ota
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
cp $OUT/$INTERNAL_OTA_PACKAGE_TARGET $IMAGE_PATH/
|
|
cp $OUT/$INTERNAL_OTA_PACKAGE_OBJ_TARGET $IMAGE_PATH/
|
|
else # regular build without OTA
|
|
echo "start build android"
|
|
make installclean
|
|
make -j$BUILD_JOBS
|
|
# check the result of make
|
|
if [ $? -eq 0 ]; then
|
|
echo "Build android ok!"
|
|
else
|
|
echo "Build android failed!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
else # repack v2 boot
|
|
echo "Repacking header 2 boot..."
|
|
BOOT_CMDLINE=`get_build_var BOARD_KERNEL_CMDLINE`
|
|
SECURITY_LEVEL=`get_build_var PLATFORM_SECURITY_PATCH`
|
|
mkbootfs -d $OUT/system $OUT/ramdisk | minigzip > $OUT/ramdisk.img
|
|
mkbootimg --kernel $OUT/kernel --ramdisk $OUT/ramdisk.img --dtb $OUT/dtb.img --cmdline "$BOOT_CMDLINE" --os_version 12 --os_patch_level $SECURITY_LEVEL --second $LOCAL_KERNEL_PATH/resource.img --header_version 2 --output $OUT/boot.img
|
|
fi
|
|
|
|
if [ "$BUILD_OTA" != true ] ; then
|
|
# mkimage.sh
|
|
echo "make and copy android images"
|
|
./mkimage.sh
|
|
if [ $? -eq 0 ]; then
|
|
echo "Make image ok!"
|
|
else
|
|
echo "Make image failed!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ "$BUILD_UPDATE_IMG" = true ] ; then
|
|
mkdir -p $PACK_TOOL_DIR/rockdev/Image/
|
|
cp -f $IMAGE_PATH/* $PACK_TOOL_DIR/rockdev/Image/
|
|
|
|
echo "Make update.img"
|
|
if [[ $TARGET_PRODUCT =~ "PX30" ]]; then
|
|
cd $PACK_TOOL_DIR/rockdev && ./mkupdate.sh px30 Image
|
|
elif [[ $TARGET_PRODUCT =~ "rk356x_box" ]]; then
|
|
if [ "$BUILD_AB_IMAGE" = true ] ; then
|
|
cd $PACK_TOOL_DIR/rockdev && ./mkupdate_ab_$TARGET_PRODUCT.sh
|
|
else
|
|
cd $PACK_TOOL_DIR/rockdev && ./mkupdate_$TARGET_PRODUCT.sh
|
|
fi
|
|
else
|
|
cd $PACK_TOOL_DIR/rockdev && ./mkupdate.sh $TARGET_BOARD_PLATFORM Image
|
|
fi
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "Make update image ok!"
|
|
else
|
|
echo "Make update image failed!"
|
|
exit 1
|
|
fi
|
|
cd -
|
|
|
|
#rpdzkj add
|
|
PRODUCT_KERNEL_DTS=`get_build_var PRODUCT_KERNEL_DTS`
|
|
if echo "$PRODUCT_KERNEL_DTS" | grep -q '/'; then
|
|
TARGET_BUILD_DTB=$(echo "$PRODUCT_KERNEL_DTS" | cut -d'/' -f2)
|
|
else
|
|
TARGET_BUILD_DTB="$PRODUCT_KERNEL_DTS"
|
|
fi
|
|
TARGET_BUILD_DTB=${TARGET_BUILD_DTB:-$TARGET_PRODUCT}
|
|
BOARD_PREBUILT_DTBIMAGE_DIR=`get_build_var BOARD_PREBUILT_DTBIMAGE_DIR`
|
|
RK_ANDROID13_DTS_DIR=$BOARD_PREBUILT_DTBIMAGE_DIR/$TARGET_BUILD_DTB.dts
|
|
LCD_NAME=`grep '^#include.*rp.*lcd-[^g][^p]' $RK_ANDROID13_DTS_DIR | grep -v hdmi | grep -v typec| sed 's/^#include.*-lcd-//g' | sed 's/.dts.*//g'`
|
|
LCD_NAME=${LCD_NAME:-lcd}
|
|
TIME=`date +%Y%m%d-%H%M%S`
|
|
|
|
mv $PACK_TOOL_DIR/rockdev/update.img $IMAGE_PATH/update-$TARGET_BUILD_DTB-android13-$LCD_NAME-$TIME.img -f
|
|
rm $PACK_TOOL_DIR/rockdev/Image -rf
|
|
fi
|
|
|
|
if [ "$BUILD_PACKING" = true ] ; then
|
|
echo "make and copy packaging in IMAGE "
|
|
|
|
mkdir -p $STUB_PATH
|
|
mkdir -p $STUB_PATH/IMAGES/
|
|
cp $IMAGE_PATH/* $STUB_PATH/IMAGES/
|
|
|
|
#Generate patches
|
|
|
|
.repo/repo/repo forall -c "$PROJECT_TOP/device/rockchip/common/gen_patches_body.sh"
|
|
.repo/repo/repo manifest -r -o out/commit_id.xml
|
|
#Copy stubs
|
|
cp out/commit_id.xml $STUB_PATH/manifest_${DATE}.xml
|
|
|
|
mkdir -p $STUB_PATCH_PATH/kernel
|
|
cp $LOCAL_KERNEL_PATH/.config $STUB_PATCH_PATH/kernel
|
|
cp $LOCAL_KERNEL_PATH/vmlinux $STUB_PATCH_PATH/kernel
|
|
|
|
cp build.sh $STUB_PATH/build.sh
|
|
#Save build command info
|
|
echo "Build as $LOCAL_KERNEL_PATH" >> $STUB_PATH/build_cmd_info.txt
|
|
echo "uboot: ./make.sh $UBOOT_DEFCONFIG" >> $STUB_PATH/build_cmd_info.txt
|
|
echo "kernel: make ARCH=$KERNEL_ARCH $KERNEL_DEFCONFIG && make ARCH=$KERNEL_ARCH $KERNEL_DTS.img" >> $STUB_PATH/build_cmd_info.txt
|
|
echo "android: lunch $TARGET_PRODUCT-$BUILD_VARIANT && make installclean && make" >> $STUB_PATH/build_cmd_info.txt
|
|
echo "version: $SDK_VERSION" >> $STUB_PATH/build_cmd_info.txt
|
|
echo "finger: $BUILD_ID/$BUILD_NUMBER/$BUILD_VARIANT" >> $STUB_PATH/build_cmd_info.txt
|
|
fi
|