BS_DIR_TOP=$(cd `dirname $0` ; pwd)
BS_DIR_OUTPUT=${BS_DIR_TOP}/output
BS_DIR_COPY_CHIPRAM=${BS_DIR_TOP}/bsp/out/ums512_1h10/dist/chipram
BS_DIR_COPY_UBOOT=${BS_DIR_TOP}/bsp/out/ums512_1h10/dist/u-boot15
BS_DIR_COPY_MODULES_KO=${BS_DIR_TOP}/bsp/out/ums512_1h10/dist/modules
BS_DIR_COPY=${BS_DIR_TOP}/out/target/product/ums512_1h10
BS_DIR_COPY_ALL=${BS_DIR_TOP}/vendor/sprd/release/IDH/ImageFiles
COLOURS_RED=" 33[31m"
COLOURS_GREEN=" 33[32m"
COLOURS_END=" 33[0m"
if [ ! -d "output" ];then
mkdir output
fi
build_chipram()
{
echo -e " ${COLOURS_GREEN} start compile to chipram ..... ${COLOURS_END}"
cd ${BS_DIR_TOP}/bsp
. build/envsetup.sh
lunch ums512_1h10_ctcc-userdebug-androidq
make chipram -j${threads}
cp -rf ${BS_DIR_COPY_CHIPRAM}/ddr_scan-sign.bin ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_CHIPRAM}/fdl1-sign.bin ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_CHIPRAM}/u-boot-spl-16k-sign.bin ${BS_DIR_OUTPUT}
echo "end compile to chipram ....."
cd ${BS_DIR_TOP}
return 0
}
build_bootloader_uboot()
{
echo -e " ${COLOURS_GREEN} start compile to uboot ..... ${COLOURS_END}"
cd ${BS_DIR_TOP}/bsp
. build/envsetup.sh
lunch ums512_1h10_ctcc-userdebug-androidq
make bootloader -j${threads} || return 1
cp -rf ${BS_DIR_COPY_UBOOT}/u-boot-sign.bin ${BS_DIR_OUTPUT}
echo "end compile to uboot ....."
cd ${BS_DIR_TOP}
return 0
}
build_kernel()
{
echo "start compile to kernel ....."
cd ${BS_DIR_TOP}
# . build/envsetup.sh
# lunch ums512_1h10_ctcc-userdebug-androidq
# make bootimage -j${threads}|| return 1
. zq_envsetup.sh
lunch ums512_1h10_ctcc-userdebug-androidq
cd vendor/sprd/release/IDH/Script
./build_pac.sh -a ${LUNCH_NAME} -b build -j200
cp -rf ${BS_DIR_COPY}/u-boot-sign.bin ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY}/boot.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY}/dtbo.img ${BS_DIR_OUTPUT}
cd ${BS_DIR_TOP}
echo "end compile to kernel ....."
cd ${BS_DIR_TOP}
return 0
}
build_modules()
{
echo "start compile to modules ....."
cd ${BS_DIR_TOP}
. build/envsetup.sh
lunch ums512_1h10_ctcc-userdebug-androidq
make sockoimage -j${threads} || return 1
cp -rf ${BS_DIR_COPY}/socko.img ${BS_DIR_OUTPUT}
#make vendorimage -j${threads} || return 1
#cp -rf ${BS_DIR_COPY}/vendor.img ${BS_DIR_OUTPUT}
echo "end compile to modules ....."
cd ${BS_DIR_TOP}
return 0
}
build_modules_ko()
{
echo -e " ${COLOURS_GREEN} start compile to build_modules_ko ..... ${COLOURS_END}"
cd ${BS_DIR_TOP}/bsp
. build/envsetup.sh
lunch ums512_1h10_ctcc-userdebug-androidq
make modules -j${threads} || return 1 #Compile all Ko's
#make modules –m sprd_camera.ko || return 1
#make modules –m sprd_sensor.ko || return 1
#make modules –m sprd_fd.ko || return 1
cp -rf ${BS_DIR_COPY_MODULES_KO}/sprd_camera.ko ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_MODULES_KO}/sprd_sensor.ko ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_MODULES_KO}/sprd_fd.ko ${BS_DIR_OUTPUT}
cd ${BS_DIR_TOP}
echo -e " ${COLOURS_GREEN} end compile to build_modules_ko success..... ${COLOURS_END}"
return 0
}
build_android()
{
echo "start compile to modules ....."
cd ${BS_DIR_TOP}
. zq_envsetup.sh
#m
mmm vendor/sprd/modules/libcamera/ -j100
if [ ! -d "${BS_DIR_OUTPUT}/lib" ];then
mkdir ${BS_DIR_OUTPUT}/lib
fi
if [ ! -d "${BS_DIR_OUTPUT}/lib64" ];then
mkdir ${BS_DIR_OUTPUT}/lib64
fi
cd ${BS_DIR_TOP}
cp -rf ${BS_DIR_COPY}/vendor/lib/libsensor_tp9950.so ${BS_DIR_OUTPUT}/lib
cp -rf ${BS_DIR_COPY}/vendor/lib64/libsensor_tp9950.so ${BS_DIR_OUTPUT}/lib64
echo "end compile to modules ....."
cd ${BS_DIR_TOP}
return 0
}
build_default()
{
cd ${BS_DIR_TOP}
. zq_envsetup.sh
./zq_build_ota_system.sh
cp -rf ${BS_DIR_COPY_ALL}/fdl1-sign.bin ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/fdl2-sign.bin ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/sharkl5pro_pubcp_nvitem.bin ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/prodnv.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/vbmeta-sign.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/vbmeta_system.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/vbmeta_vendor.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/userdata.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/super.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/boot.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/dtbo.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/socko.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/vbmeta_vendor.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/userdata.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/super.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/cache.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/recovery.img ${BS_DIR_OUTPUT}
cp -rf ${BS_DIR_COPY_ALL}/config.bin ${BS_DIR_OUTPUT}
}
threads=$(grep processor /proc/cpuinfo | awk '{field=$NF};END{print field+1}')
uboot=no
kernel=no
modules=no
chipram=no
android=no
modules_ko=no
default=no
if [ -z $1 ]; then
uboot=yes
kernel=yes
modules=yes
chipram=yes
android=yes
modules_ko=yes
default=yes
fi
while [ "$1" ]; do
case "$1" in
-j=*)
x=$1
threads=${x#-j=}
;;
-u|--uboot)
uboot=yes
;;
-k|--kernel)
kernel=yes
;;
-m|--modules)
modules=yes
;;
-c|--chipram)
chipram=yes
;;
-A|--android)
android=yes
;;
-M|--modules_ko)
modules_ko=yes
;;
-a|--all)
default=yes
;;
-h|--help)
echo -e "${COLOURS_GREEN}
Usage: ./mk.sh [OPTION]
Build script for compile the source of telechips project.
-j=n using n threads when building source project (example: -j=16)
-u, --uboot build bootloader uboot from source
-k, --kernel build kernel from source
-m, --modules build modules from source
-M, --modules_ko build modules_ko from source
-c, --chipram build chipram from source
-A, --android build android from source
-a, --all build all, include anything
-h, --help display this help and exit
${COLOURS_END}"
exit 0
;;
*)
exit 1
;;
esac
shift
done
if [ "${uboot}" = yes ]; then
build_bootloader_uboot || exit 1
fi
if [ "${kernel}" = yes ]; then
build_kernel || exit 1
fi
if [ "${modules}" = yes ]; then
build_modules || exit 1
fi
if [ "${modules_ko}" = yes ]; then
build_modules_ko || exit 1
fi
if [ "${chipram}" = yes ]; then
build_chipram || exit 1
fi
if [ "${android}" = yes ]; then
build_android || exit 1
fi
if [ "${default}" = yes ]; then
build_default || exit 1
fi
exit 0