SmartAudio/lichee/brandy/build.sh

149 lines
3.5 KiB
Bash
Raw Normal View History

2018-07-13 01:31:50 +00:00
#!/bin/bash
set -e
PLATFORM="sun8iw11p1"
MODE=""
OUTPUT=""
2018-12-13 10:48:25 +00:00
localpath=$(cd $(dirname $0) && pwd)
argnum=$#
2018-07-13 01:31:50 +00:00
show_help()
{
printf "\nbuild.sh - Top level build scritps\n"
echo "Valid Options:"
echo " -h Show help message"
echo " -p <platform> platform, e.g. sun5i, sun6i, sun8iw1p1, sun8iw3p1, sun9iw1p1"
echo " -m <mode> mode, e.g. ota_test"
echo " -o <output> output, e.g. uboot, uboot_nor, boot0"
echo " -t install gcc tools chain"
printf "\n\n"
}
prepare_toolchain()
{
local ARCH="arm";
local GCC="";
local GCC_PREFIX="";
local toolchain_archive_aarch64="./toolchain/gcc-linaro-aarch64.tar.xz";
local toolchain_archive_arm="./toolchain/gcc-linaro-arm.tar.xz";
local tooldir_aarch64="./toolchain/gcc-aarch64";
local tooldir_arm="./toolchain/gcc-arm";
echo "Prepare toolchain ..."
if [ ! -d "${tooldir_aarch64}" ]; then
mkdir -p ${tooldir_aarch64} || exit 1
tar --strip-components=1 -xf ${toolchain_archive_aarch64} -C ${tooldir_aarch64} || exit 1
fi
if [ ! -d "${tooldir_arm}" ]; then
mkdir -p ${tooldir_arm} || exit 1
tar --strip-components=1 -xf ${toolchain_archive_arm} -C ${tooldir_arm} || exit 1
fi
}
2018-12-13 10:48:25 +00:00
select_uboot()
2018-07-13 01:31:50 +00:00
{
if [ "x${PLATFORM}" = "xsun50iw1p1" ] || \
[ "x${PLATFORM}" = "xsun50iw2p1" ] || \
[ "x${PLATFORM}" = "xsun50iw6p1" ] || \
[ "x${PLATFORM}" = "xsun50iw3p1" ] || \
[ "x${PLATFORM}" = "xsun3iw1p1" ] || \
[ "x${PLATFORM}" = "xsun8iw12p1" ] || \
[ "x${PLATFORM}" = "xsun8iw10p1" ] || \
[ "x${PLATFORM}" = "xsun8iw11p1" ] || \
[ "x${PLATFORM}" = "xsun8iw12p1" ] || \
2018-12-13 10:48:25 +00:00
[ "x${PLATFORM}" = "xsun8iw8p1" ] || \
2018-07-13 01:31:50 +00:00
[ "x${PLATFORM}" = "xsun8iw15p1" ] || \
2018-12-13 10:48:25 +00:00
[ "x${PLATFORM}" = "xsun8iw15p1_axp2231" ] || \
2018-07-13 01:31:50 +00:00
[ "x${PLATFORM}" = "xsun8iw17p1" ];then
2018-12-13 10:48:25 +00:00
if [ x"${TARGET_PLATFORM}" = x"banjo" ]; then
echo "u-boot-2011.09"
else
echo "u-boot-2014.07"
fi
2018-07-13 01:31:50 +00:00
else
2018-12-13 10:48:25 +00:00
echo "u-boot-2011.09"
fi
}
get_platform()
{
if [ $argnum -eq 0 ] && [ -f $localpath/../.buildconfig ]; then
local LICHEE_CHIP=$(grep LICHEE_CHIP $localpath/../.buildconfig | sed 's/[^=]*= *//g')
local LICHEE_BUSSINESS=$(grep LICHEE_BUSSINESS $localpath/../.buildconfig | sed 's/[^=]*= *//g')
if [ -n "$LICHEE_CHIP" ]; then
PLATFORM=$LICHEE_CHIP
if [ -n "$LICHEE_BUSSINESS" ]; then
local boardcfg=$localpath/$(select_uboot)/boards.cfg
local parten=1
[ $(select_uboot) == "u-boot-2014.07" ] && parten=7
[ -n "$(sed -e '/^#/d' $boardcfg | awk '{print $'"$parten"'}' | \
grep ${PLATFORM}_${LICHEE_BUSSINESS})" ] && \
PLATFORM=${PLATFORM}_${LICHEE_BUSSINESS}
fi
fi
echo "Get PLATFORM from lichee buildconfig: $PLATFORM"
2018-07-13 01:31:50 +00:00
fi
2018-12-13 10:48:25 +00:00
}
build_uboot()
{
get_platform
cd $(select_uboot)
2018-07-13 01:31:50 +00:00
make distclean
if [ "x$MODE" = "xota_test" ] ; then
export "SUNXI_MODE=ota_test"
fi
make ${PLATFORM}_config
if [ "x$OUTPUT" = "xuboot" -o "x$OUTPUT" = "x" ] ; then
make -j16
fi
if [ "x$OUTPUT" = "xboot0" -o "x$OUTPUT" = "x" ] ; then
make spl
make fes
fi
if [ "x$OUTPUT" = "xuboot" -o x$OUTPUT = "xuboot_nor" -o x$OUTPUT = "x" ] ; then
if [ ${PLATFORM} = "sun8iw11p1" -o ${PLATFORM} = "sun3iw1p1" -o ${PLATFORM} = "sun8iw8p1" -o ${PLATFORM} = "sun50iw1p1" ]; then
make distclean
make ${PLATFORM}_nor_config
make -j16
fi
fi
cd - 1>/dev/null
}
while getopts p:m:o:t OPTION
do
case $OPTION in
p)
PLATFORM=$OPTARG
;;
m)
MODE=$OPTARG
;;
o)
OUTPUT=$OPTARG
;;
t)
prepare_toolchain
exit
;;
*) show_help
exit
;;
esac
done
build_uboot