211 lines
10 KiB
Bash
Executable File
211 lines
10 KiB
Bash
Executable File
chip_id=$1
|
|
flash_type=$2
|
|
BUILD_BRANCH=$3
|
|
BUILD_TAG=$4
|
|
echo "build log:start build" ${chip_id} ${flash_type} ${BUILD_BRANCH} ${BUILD_TAG}
|
|
|
|
tool_path=../tools
|
|
dest_rootpath=../tools/gen_img/lib_sg_sdk
|
|
cmake_folder="../../SDKCmake"
|
|
mainline_path="../"
|
|
customer_path="../tools/gen_img/customer"
|
|
export_inc_path=../export/inc/
|
|
|
|
CHIP_ID=$(echo $chip_id | tr '[a-z]' '[A-Z]') # HZ WQ
|
|
CHIP_STRING=("HZ" "WQ")
|
|
FLASH_TYPE=$(echo $flash_type | tr '[a-z]' '[A-Z]') # 1M 2M 2K 2P 4M 4P
|
|
customer_list=("htzd" "jsmt" "gldq")
|
|
customer_num=${#customer_list[*]}
|
|
module_list=("cco" "iic" "sta" "3ps")
|
|
module_num=${#module_list[*]}
|
|
pib_list=("09" "default" "09_LP" "LP")
|
|
pib_num=${#pib_list[*]}
|
|
|
|
FLASH_TYPE_STRING=("1m" "2m" "2k" "2p" "4m" "4p")
|
|
flash_type_num=${#FLASH_TYPE_STRING[*]}
|
|
GROUP_CCO_PSRAM=(4 4 8 4 8 8)
|
|
GROUP_CCO_FLASH=(1 1 1 1 4 4)
|
|
GROUP_STA_PSRAM=(0 0 2 2 0 2)
|
|
GROUP_STA_FLASH=(1 2 2 2 4 4)
|
|
#print help info.
|
|
if [ "?" == "$1" ]; then
|
|
echo "*$0 [CHIP_ID] [FLASH_TYPE] [BUILD_BRANCH] [BUILD_TAG]"
|
|
echo "* [CHIP_ID] -- Optional, to set the chip id, support HZ\WQ."
|
|
echo "* [FLASH_TYPE] -- Optional, to set the flash type, support as follows."
|
|
for ((index=0; index < flash_type_num; index++)); do
|
|
echo "* ${FLASH_TYPE_STRING[$index]} ${GROUP_CCO_BOARD[$index]} (${GROUP_CCO_FLASH[$index]}M flash ${GROUP_CCO_PSRAM[$index]}M psram) + " \
|
|
"sta ${GROUP_STA_BOARD[$index]} (${GROUP_STA_FLASH[$index]}M flash ${GROUP_STA_PSRAM[$index]}M psram)"
|
|
done
|
|
echo "* [BUILD_BRANCH] -- Optional, to set the build branch."
|
|
echo "* [BUILD_TAG] -- Optional, to set the build tag."
|
|
exit 0
|
|
fi
|
|
|
|
set -o errexit
|
|
|
|
if [ "$CHIP_ID" == "" ]; then
|
|
CHIP_ID=${CHIP_STRING[0]}
|
|
INPUT_CHIP_OK=1
|
|
else
|
|
for STR in ${CHIP_STRING[@]}; do
|
|
if [ "$CHIP_ID" == "$STR" ]; then
|
|
INPUT_CHIP_OK=1
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ "$FLASH_TYPE" == "" ]; then
|
|
FLASH_TYPE=${FLASH_TYPE_STRING[0]}
|
|
INPUT_FLASH_OK=1
|
|
else
|
|
for STR in ${FLASH_TYPE_STRING[@]}; do
|
|
if [ "$FLASH_TYPE" == "$STR" ]; then
|
|
INPUT_FLASH_OK=1
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ "$INPUT_CHIP_OK" != "1" ] || [ "$INPUT_CHIP_OK" != "1" ]; then
|
|
echo "build param error, chip_id:${CHIP_ID}, flash_type:${FLASH_TYPE}."
|
|
exit 1
|
|
fi
|
|
|
|
for((i=0;i<$customer_num;i++))
|
|
do
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/bin
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/bin
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/ld
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/tools
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/cmake
|
|
|
|
cp -r $mainline_path/app/smart_grid $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app
|
|
cp -r $cmake_folder/iot_sg_app/CMakeLists.txt $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app
|
|
cp -r $cmake_folder/iot_sg_app/main.c $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app
|
|
cp -r $mainline_path/export/* $dest_rootpath/${customer_list[i]}/sdk
|
|
cp -r $cmake_folder/cmake/* $dest_rootpath/${customer_list[i]}/sdk/cmake
|
|
|
|
if [ ${FLASH_TYPE} == "4P" ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_8m_cco.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_cco.lds
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_2m_sta.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_sta.lds
|
|
elif [ ${FLASH_TYPE} == "4M" ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_8m_cco.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_cco.lds
|
|
cp $mainline_path/startup/ldscripts/riscv/link_flash_4m_sta.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_sta.lds
|
|
elif [ ${FLASH_TYPE} == "2P" ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_4m_cco.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_cco.lds
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_2m_sta.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_sta.lds
|
|
elif [ ${FLASH_TYPE} == "2K" ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_8m_cco.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_cco.lds
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_2m_sta.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_sta.lds
|
|
else
|
|
cp $mainline_path/startup/ldscripts/riscv/link_psram_4m_cco.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_cco.lds
|
|
cp $mainline_path/startup/ldscripts/riscv/link_flash_sta.lds $dest_rootpath/${customer_list[i]}/sdk/ld/link_flash_sta.lds
|
|
fi
|
|
|
|
if [ -e $mainline_path/startup/ldscripts/riscv/sp_cco.addrs.ld ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/sp_cco.addrs.ld $dest_rootpath/${customer_list[i]}/sdk/ld
|
|
fi
|
|
|
|
if [ -e $mainline_path/startup/ldscripts/riscv/sp_sta.addrs.ld ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/sp_sta.addrs.ld $dest_rootpath/${customer_list[i]}/sdk/ld
|
|
fi
|
|
|
|
if [ -e $mainline_path/startup/ldscripts/riscv/sp.addrs.ld ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/sp.addrs.ld $dest_rootpath/${customer_list[i]}/sdk/ld
|
|
fi
|
|
|
|
if [ -e $mainline_path/startup/ldscripts/riscv/rom.addrs.ld ];then
|
|
cp $mainline_path/startup/ldscripts/riscv/rom.addrs.ld $dest_rootpath/${customer_list[i]}/sdk/ld
|
|
fi
|
|
|
|
cp $mainline_path/tools/gen_img/ah $dest_rootpath/${customer_list[i]}/sdk/tools
|
|
if [ -e $mainline_path/tools/gen_img/elzma ];then
|
|
cp $mainline_path/tools/gen_img/elzma $dest_rootpath/${customer_list[i]}/sdk/tools
|
|
fi
|
|
|
|
for((j=0;j<$module_num;j++))
|
|
do
|
|
if [ ${FLASH_TYPE} == "4M" ] || [ ${FLASH_TYPE} == "4P" ]; then
|
|
bin_size=4M
|
|
elif [ ${module_list[j]}x == "cco"x ];then
|
|
bin_size=1M
|
|
else
|
|
bin_size=2M
|
|
fi
|
|
|
|
if [ ! -d ${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]} ];then
|
|
continue
|
|
fi
|
|
|
|
mkdir -p $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}
|
|
|
|
if [ ${FLASH_TYPE} == "4M" ]; then
|
|
cp -r $cmake_folder/iot_sg_app/scripts_4m/* $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
elif [ ${FLASH_TYPE} == "4P" ]; then
|
|
cp -r $cmake_folder/iot_sg_app/scripts_4m_psram/* $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
elif [ ${FLASH_TYPE} == "2K" ]; then
|
|
cp -r $cmake_folder/iot_sg_app/scripts_2k/* $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
elif [ ${FLASH_TYPE} == "2P" ]; then
|
|
cp -r $cmake_folder/iot_sg_app/scripts_2m_psram/* $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
elif [ ${FLASH_TYPE} == "2M" ]; then
|
|
cp -r $cmake_folder/iot_sg_app/scripts_2m/* $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
else
|
|
cp -r $cmake_folder/iot_sg_app/scripts/* $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
fi
|
|
|
|
module_case=`echo ${module_list[j]}|awk '{print toupper($0)}'`
|
|
customer_case=`echo ${customer_list[i]}|awk '{print toupper($0)}'`
|
|
|
|
cp -r ${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/out/*OEM.bin $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}/oem.bin
|
|
cp -r ${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/out/kl_ram.bin $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}/ram.bin
|
|
cp -r ${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/out/kunlun_sbl.bin $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}/sbl.bin
|
|
cp -r ${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/out/sp_fw.bin $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}/sp.bin
|
|
|
|
for((m=0;m<$pib_num;m++))
|
|
do
|
|
if [ ${pib_list[m]}x != "default"x ];then
|
|
filename=${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/out/$customer_case$module_case"01_"${pib_list[m]}"_PIB.bin"
|
|
else
|
|
filename=${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/out/$customer_case$module_case"01_PIB.bin"
|
|
fi
|
|
|
|
echo $filename
|
|
|
|
if [ -e $filename ];then
|
|
if [ ${pib_list[m]}x == "default"x ];then
|
|
cp -r $filename $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}/pib.bin
|
|
elif [ ${pib_list[m]}x == "LP"x ];then
|
|
cp -r $filename $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}/lp_pib.bin
|
|
else
|
|
cp -r $filename $dest_rootpath/${customer_list[i]}/sdk/bin/${module_list[j]}
|
|
fi
|
|
|
|
cfgfile=$dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts/flash_mapping_${module_list[j]}.cfg
|
|
if [ ${pib_list[m]}x == "LP"x ];then
|
|
cfgfile=$dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts/flash_mapping_${module_list[j]}_lp.cfg
|
|
sed -i "s/key_word=.*/key_word=${CHIP_ID}-SG-${customer_case}${module_case}01-${pib_list[m]}-${BUILD_BRANCH}.${BUILD_TAG}-/g" $cfgfile
|
|
elif [ ${pib_list[m]}x == "default"x ];then
|
|
sed -i "s/key_word=.*/key_word=${CHIP_ID}-SG-${customer_case}${module_case}01-${BUILD_BRANCH}.${BUILD_TAG}-/g" $cfgfile
|
|
fi
|
|
fi
|
|
done
|
|
if [ ${module_list[j]}x == "iic"x ] || [ ${module_list[j]}x == "3ps"x ];then
|
|
upgradefile=${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/bin/*UPGRADE*.bin
|
|
rm -f $upgradefile
|
|
fi
|
|
cp ${customer_path}/${bin_size}/${customer_list[i]}/${module_list[j]}/bin/*.bin $dest_rootpath/${customer_list[i]}/bin
|
|
cd $dest_rootpath/${customer_list[i]}/sdk/examples/iot_sg_app/scripts
|
|
filepath=build-${module_list[j]}.sh
|
|
if [ -e $filepath ];then
|
|
chmod 777 $filepath
|
|
dos2unix ./$filepath
|
|
./$filepath
|
|
fi
|
|
cd -
|
|
done
|
|
done
|
|
echo "build log:end build" ${chip_id} ${flash_type} ${BUILD_BRANCH} ${BUILD_TAG}
|