make.sh: clean up and simplify
There are so many commands in make.sh, we have to clean and seperate command into individual script file. And some command is to be the official option for outside. By the way, adding nm command to analyze image size. Signed-off-by: Joseph Chen <chenjh@rock-chips.com> Change-Id: I37ba38b621216f6db79325fada5980a54ca987cb
This commit is contained in:
parent
3965b9dee4
commit
b42d2103f1
820
make.sh
820
make.sh
|
|
@ -8,6 +8,7 @@
|
||||||
set -e
|
set -e
|
||||||
JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
|
JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
|
||||||
SUPPORT_LIST=`ls configs/*[r,p][x,v,k][0-9][0-9]*_defconfig`
|
SUPPORT_LIST=`ls configs/*[r,p][x,v,k][0-9][0-9]*_defconfig`
|
||||||
|
CMD_ARGS=$1
|
||||||
|
|
||||||
# @LOADER: map to $RKCHIP_LOADER for loader ini
|
# @LOADER: map to $RKCHIP_LOADER for loader ini
|
||||||
# @TRUST: map to $RKCHIP_TRUST for trust ini
|
# @TRUST: map to $RKCHIP_TRUST for trust ini
|
||||||
|
|
@ -54,11 +55,6 @@ CHIP_CFG_FIXUP_TABLE=(
|
||||||
"CONFIG_ROCKCHIP_RV1126 3 - -,- -,- -,- -,- - -"
|
"CONFIG_ROCKCHIP_RV1126 3 - -,- -,- -,- -,- - -"
|
||||||
)
|
)
|
||||||
|
|
||||||
CHIP_TPL_MAGIC_TABLE=(
|
|
||||||
"CONFIG_ROCKCHIP_PX30 RK33"
|
|
||||||
"CONFIG_ROCKCHIP_RV1126 110B"
|
|
||||||
)
|
|
||||||
|
|
||||||
########################################### User can modify #############################################
|
########################################### User can modify #############################################
|
||||||
# User's rkbin tool relative path
|
# User's rkbin tool relative path
|
||||||
RKBIN_TOOLS=../rkbin/tools
|
RKBIN_TOOLS=../rkbin/tools
|
||||||
|
|
@ -68,14 +64,14 @@ ADDR2LINE_ARM32=arm-linux-gnueabihf-addr2line
|
||||||
ADDR2LINE_ARM64=aarch64-linux-gnu-addr2line
|
ADDR2LINE_ARM64=aarch64-linux-gnu-addr2line
|
||||||
OBJ_ARM32=arm-linux-gnueabihf-objdump
|
OBJ_ARM32=arm-linux-gnueabihf-objdump
|
||||||
OBJ_ARM64=aarch64-linux-gnu-objdump
|
OBJ_ARM64=aarch64-linux-gnu-objdump
|
||||||
|
NM_ARM32=arm-linux-gnueabihf-nm
|
||||||
|
NM_ARM64=aarch64-linux-gnu-nm
|
||||||
GCC_ARM32=arm-linux-gnueabihf-
|
GCC_ARM32=arm-linux-gnueabihf-
|
||||||
GCC_ARM64=aarch64-linux-gnu-
|
GCC_ARM64=aarch64-linux-gnu-
|
||||||
TOOLCHAIN_ARM32=../prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin
|
TOOLCHAIN_ARM32=../prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin
|
||||||
TOOLCHAIN_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
|
TOOLCHAIN_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
|
||||||
|
|
||||||
########################################### User not touch #############################################
|
########################################### User not touch #############################################
|
||||||
RKTOOLS=./tools
|
|
||||||
|
|
||||||
# Declare global INI file searching index name for every chip, update in select_chip_info()
|
# Declare global INI file searching index name for every chip, update in select_chip_info()
|
||||||
RKCHIP="-"
|
RKCHIP="-"
|
||||||
RKCHIP_LABEL="-"
|
RKCHIP_LABEL="-"
|
||||||
|
|
@ -90,15 +86,23 @@ RKBIN=
|
||||||
|
|
||||||
# Declare global toolchain path for CROSS_COMPILE, updated in select_toolchain()
|
# Declare global toolchain path for CROSS_COMPILE, updated in select_toolchain()
|
||||||
TOOLCHAIN_GCC=
|
TOOLCHAIN_GCC=
|
||||||
|
TOOLCHAIN_NM=
|
||||||
TOOLCHAIN_OBJDUMP=
|
TOOLCHAIN_OBJDUMP=
|
||||||
TOOLCHAIN_ADDR2LINE=
|
TOOLCHAIN_ADDR2LINE=
|
||||||
|
|
||||||
# Declare global plaform configure, updated in fixup_platform_configure()
|
# Declare global plaform configure, updated in fixup_platform_configure()
|
||||||
PLATFORM_RSA=
|
PLAT_RSA=
|
||||||
PLATFORM_SHA=
|
PLAT_SHA=
|
||||||
PLATFORM_UBOOT_SIZE=
|
PLAT_UBOOT_SIZE=
|
||||||
PLATFORM_TRUST_SIZE=
|
PLAT_TRUST_SIZE=
|
||||||
PLATFORM_TYPE="RKFW"
|
PLAT_TYPE="RKFW" # default
|
||||||
|
|
||||||
|
SRCTREE=`pwd`
|
||||||
|
SCRIPT_ATF="${SRCTREE}/scripts/atf.sh"
|
||||||
|
SCRIPT_TOS="${SRCTREE}/scripts/tos.sh"
|
||||||
|
SCRIPT_SPL="${SRCTREE}/scripts/spl.sh"
|
||||||
|
SCRIPT_UBOOT="${SRCTREE}/scripts/uboot.sh"
|
||||||
|
SCRIPT_LOADER="${SRCTREE}/scripts/loader.sh"
|
||||||
|
|
||||||
#########################################################################################################
|
#########################################################################################################
|
||||||
function help()
|
function help()
|
||||||
|
|
@ -108,8 +112,8 @@ function help()
|
||||||
echo " ./make.sh [board|sub-command]"
|
echo " ./make.sh [board|sub-command]"
|
||||||
echo
|
echo
|
||||||
echo " - board: board name of defconfig"
|
echo " - board: board name of defconfig"
|
||||||
echo " - sub-command: elf*|loader*|spl*|tpl*|itb|trust*|uboot|map|sym|<addr>"
|
echo " - sub-command: elf*|loader|trust|uboot|--spl|--tpl|itb|map|sym|<addr>"
|
||||||
echo " - ini: assigned ini file to pack trust/loader"
|
echo " - ini: ini file to pack trust/loader"
|
||||||
echo
|
echo
|
||||||
echo "Output:"
|
echo "Output:"
|
||||||
echo " When board built okay, there are uboot/trust/loader images in current directory"
|
echo " When board built okay, there are uboot/trust/loader images in current directory"
|
||||||
|
|
@ -129,17 +133,17 @@ function help()
|
||||||
echo " ./make.sh trust <ini> --- pack trust img with assigned ini file"
|
echo " ./make.sh trust <ini> --- pack trust img with assigned ini file"
|
||||||
echo " ./make.sh loader --- pack loader bin"
|
echo " ./make.sh loader --- pack loader bin"
|
||||||
echo " ./make.sh loader <ini> --- pack loader img with assigned ini file"
|
echo " ./make.sh loader <ini> --- pack loader img with assigned ini file"
|
||||||
echo " ./make.sh spl --- pack loader with u-boot-spl.bin and u-boot-tpl.bin"
|
echo " ./make.sh --spl --- pack loader with u-boot-spl.bin"
|
||||||
echo " ./make.sh spl-s --- pack loader only replace miniloader with u-boot-spl.bin"
|
echo " ./make.sh --tpl --- pack loader with u-boot-tpl.bin"
|
||||||
echo " ./make.sh itb --- pack u-boot.itb(TODO: bl32 is not included for ARMv8)"
|
echo " ./make.sh --tpl --spl --- pack loader with u-boot-tpl.bin and u-boot-spl.bin"
|
||||||
echo
|
echo
|
||||||
echo "3. Debug:"
|
echo "3. Debug:"
|
||||||
echo " ./make.sh elf --- dump elf file with -D(default)"
|
echo " ./make.sh elf --- dump elf file with -D(default)"
|
||||||
echo " ./make.sh elf-S --- dump elf file with -S"
|
echo " ./make.sh elf-S --- dump elf file with -S"
|
||||||
echo " ./make.sh elf-d --- dump elf file with -d"
|
echo " ./make.sh elf-d --- dump elf file with -d"
|
||||||
echo " ./make.sh elf-* --- dump elf file with -*"
|
echo " ./make.sh elf-* --- dump elf file with -*"
|
||||||
echo " ./make.sh <no reloc_addr> --- dump function symbol and code position of address(no relocated)"
|
echo " ./make.sh <no reloc_addr> --- unwind address(no relocated)"
|
||||||
echo " ./make.sh <reloc_addr-reloc_off> --- dump function symbol and code position of address(relocated)"
|
echo " ./make.sh <reloc_addr-reloc_off> --- unwind address(relocated)"
|
||||||
echo " ./make.sh map --- cat u-boot.map"
|
echo " ./make.sh map --- cat u-boot.map"
|
||||||
echo " ./make.sh sym --- cat u-boot.sym"
|
echo " ./make.sh sym --- cat u-boot.sym"
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +163,7 @@ function prepare()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q '^CONFIG_ROCKCHIP_FIT_IMAGE_PACK=y' .config ; then
|
if grep -q '^CONFIG_ROCKCHIP_FIT_IMAGE_PACK=y' .config ; then
|
||||||
PLATFORM_TYPE="FIT"
|
PLAT_TYPE="FIT"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,46 +171,25 @@ function process_args()
|
||||||
{
|
{
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--help|-help|help|--h|-h)
|
*help|--h|-h)
|
||||||
help
|
help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
# '': build with exist .config
|
||||||
''|loader|trust|uboot|spl*|tpl*|debug*|itb|env|fit*)
|
# loader|trust|uboot: pack image
|
||||||
ARG_CMD=$1
|
# debug*|map|sym|elf*|nm: debug command
|
||||||
shift 1
|
# env: build env tool
|
||||||
;;
|
# itb: pack itb image
|
||||||
|
# fit: pack non-secure uboot.img && boot.img
|
||||||
--sz-trust)
|
''|loader|trust|uboot|debug*|itb|env|fit|map|sym|elf*|nm)
|
||||||
ARG_TRUST_SIZE="--size $2 $3"
|
|
||||||
shift 3
|
|
||||||
;;
|
|
||||||
|
|
||||||
--sz-uboot)
|
|
||||||
ARG_UBOOT_SIZE="--size $2 $3"
|
|
||||||
shift 3
|
|
||||||
;;
|
|
||||||
|
|
||||||
--no-pack)
|
|
||||||
ARG_NO_PACK="y"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
--no-uboot)
|
|
||||||
ARG_NO_UBOOT="y"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
map|sym|elf*)
|
|
||||||
ARG_CMD=$1
|
|
||||||
if [ "$2" == "spl" -o "$2" == "tpl" ]; then
|
if [ "$2" == "spl" -o "$2" == "tpl" ]; then
|
||||||
ARG_S_TPL=$2
|
ARG_TSPL=$2
|
||||||
shift 1
|
shift 1
|
||||||
fi
|
fi
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
# trust/loader ini files for packing trust.img/loader.img
|
||||||
*.ini)
|
*.ini|*.INI)
|
||||||
if [ ! -f $1 ]; then
|
if [ ! -f $1 ]; then
|
||||||
echo "ERROR: No $1"
|
echo "ERROR: No $1"
|
||||||
fi
|
fi
|
||||||
|
|
@ -217,19 +200,42 @@ function process_args()
|
||||||
fi
|
fi
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
|
--sz-trust) # set trust size
|
||||||
|
ARG_TRUST_SIZE="--size $2 $3"
|
||||||
|
shift 3
|
||||||
|
;;
|
||||||
|
--sz-uboot) # set uboot size
|
||||||
|
ARG_UBOOT_SIZE="--size $2 $3"
|
||||||
|
shift 3
|
||||||
|
;;
|
||||||
|
--no-pack) # FIT: build but not pack image
|
||||||
|
ARG_NO_PACK="y"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--no-uboot) # FIT: pack uboot.img without u-boot
|
||||||
|
ARG_NO_UBOOT="y"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--tpl|tpl) # use tpl file
|
||||||
|
ARG_TPL_BIN="tpl/u-boot-tpl.bin"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
--spl|spl*) # use spl file
|
||||||
|
ARG_SPL_BIN="spl/u-boot-spl.bin"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# out scripts args
|
#1. FIT scripts args
|
||||||
NUM=$(./scripts/fit-mkimg.sh --p-check $1)
|
NUM=$(./scripts/fit-mkimg.sh --arg-check $1)
|
||||||
if [ ${NUM} -ne 0 ]; then
|
if [ ${NUM} -ne 0 ]; then
|
||||||
[ ${NUM} -eq 1 ] && ARG_LIST_FIT="${ARG_LIST_FIT} $1"
|
[ ${NUM} -eq 1 ] && ARG_LIST_FIT="${ARG_LIST_FIT} $1"
|
||||||
[ ${NUM} -eq 2 ] && ARG_LIST_FIT="${ARG_LIST_FIT} $1 $2"
|
[ ${NUM} -eq 2 ] && ARG_LIST_FIT="${ARG_LIST_FIT} $1 $2"
|
||||||
shift ${NUM}
|
shift ${NUM}
|
||||||
continue
|
continue
|
||||||
# FUNC address
|
#2. unwind function address
|
||||||
elif [ -z $(echo $1 | sed 's/[0-9,a-f,A-F,x,X,-]//g') ]; then
|
elif [ -z $(echo $1 | sed 's/[0-9,a-f,A-F,x,X,-]//g') ]; then
|
||||||
ARG_FUNCADDR=$1
|
ARG_FUNCADDR=$1
|
||||||
# xxx_defconfig
|
#3. make defconfig
|
||||||
else
|
else
|
||||||
ARG_BOARD=$1
|
ARG_BOARD=$1
|
||||||
if [ ! -f configs/${ARG_BOARD}_defconfig -a ! -f configs/${ARG_BOARD}.config ]; then
|
if [ ! -f configs/${ARG_BOARD}_defconfig -a ! -f configs/${ARG_BOARD}.config ]; then
|
||||||
|
|
@ -266,6 +272,7 @@ function select_toolchain()
|
||||||
if grep -q '^CONFIG_ARM64=y' .config ; then
|
if grep -q '^CONFIG_ARM64=y' .config ; then
|
||||||
if [ -d ${TOOLCHAIN_ARM64} ]; then
|
if [ -d ${TOOLCHAIN_ARM64} ]; then
|
||||||
absolute_path=$(cd `dirname ${TOOLCHAIN_ARM64}`; pwd)
|
absolute_path=$(cd `dirname ${TOOLCHAIN_ARM64}`; pwd)
|
||||||
|
TOOLCHAIN_NM=${absolute_path}/bin/${NM_ARM64}
|
||||||
TOOLCHAIN_GCC=${absolute_path}/bin/${GCC_ARM64}
|
TOOLCHAIN_GCC=${absolute_path}/bin/${GCC_ARM64}
|
||||||
TOOLCHAIN_OBJDUMP=${absolute_path}/bin/${OBJ_ARM64}
|
TOOLCHAIN_OBJDUMP=${absolute_path}/bin/${OBJ_ARM64}
|
||||||
TOOLCHAIN_ADDR2LINE=${absolute_path}/bin/${ADDR2LINE_ARM64}
|
TOOLCHAIN_ADDR2LINE=${absolute_path}/bin/${ADDR2LINE_ARM64}
|
||||||
|
|
@ -276,6 +283,7 @@ function select_toolchain()
|
||||||
else
|
else
|
||||||
if [ -d ${TOOLCHAIN_ARM32} ]; then
|
if [ -d ${TOOLCHAIN_ARM32} ]; then
|
||||||
absolute_path=$(cd `dirname ${TOOLCHAIN_ARM32}`; pwd)
|
absolute_path=$(cd `dirname ${TOOLCHAIN_ARM32}`; pwd)
|
||||||
|
TOOLCHAIN_NM=${absolute_path}/bin/${NM_ARM32}
|
||||||
TOOLCHAIN_GCC=${absolute_path}/bin/${GCC_ARM32}
|
TOOLCHAIN_GCC=${absolute_path}/bin/${GCC_ARM32}
|
||||||
TOOLCHAIN_OBJDUMP=${absolute_path}/bin/${OBJ_ARM32}
|
TOOLCHAIN_OBJDUMP=${absolute_path}/bin/${OBJ_ARM32}
|
||||||
TOOLCHAIN_ADDR2LINE=${absolute_path}/bin/${ADDR2LINE_ARM32}
|
TOOLCHAIN_ADDR2LINE=${absolute_path}/bin/${ADDR2LINE_ARM32}
|
||||||
|
|
@ -286,130 +294,6 @@ function select_toolchain()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function sub_commands()
|
|
||||||
{
|
|
||||||
# skip "--" parameter, such as "--rollback-index-..."
|
|
||||||
if [[ "${ARG_CMD}" != "--*" ]]; then
|
|
||||||
cmd=${ARG_CMD%-*}
|
|
||||||
arg=${ARG_CMD#*-}
|
|
||||||
else
|
|
||||||
cmd=${ARG_CMD}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${ARG_S_TPL}" == "tpl" -o "${ARG_S_TPL}" == "spl" ]; then
|
|
||||||
elf=`find -name u-boot-${ARG_S_TPL}`
|
|
||||||
map=`find -name u-boot-${ARG_S_TPL}.map`
|
|
||||||
sym=`find -name u-boot-${ARG_S_TPL}.sym`
|
|
||||||
else
|
|
||||||
elf=u-boot
|
|
||||||
map=u-boot.map
|
|
||||||
sym=u-boot.sym
|
|
||||||
fi
|
|
||||||
|
|
||||||
case ${cmd} in
|
|
||||||
elf)
|
|
||||||
if [ ! -f ${elf} ]; then
|
|
||||||
echo "ERROR: No elf: ${elf}"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
if [ "${cmd}" == "elf" -a "${arg}" == "elf" ]; then
|
|
||||||
arg=D # default
|
|
||||||
fi
|
|
||||||
${TOOLCHAIN_OBJDUMP} -${arg} ${elf} | less
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
debug)
|
|
||||||
./scripts/rkpatch.sh ${arg}
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
fit)
|
|
||||||
if [ "${arg}" == "ns" ]; then
|
|
||||||
./scripts/fit-mkimg.sh --uboot-itb --boot-itb --no-vboot ${ARG_LIST_FIT}
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
map)
|
|
||||||
cat ${map} | less
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
sym)
|
|
||||||
cat ${sym} | less
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
trust)
|
|
||||||
pack_trust_image
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
loader)
|
|
||||||
pack_loader_image
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
tpl|spl)
|
|
||||||
pack_spl_loader_image ${ARG_CMD}
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
itb)
|
|
||||||
pack_uboot_itb_image
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
uboot)
|
|
||||||
pack_uboot_image
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
env)
|
|
||||||
make CROSS_COMPILE=${TOOLCHAIN_GCC} envtools
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
|
|
||||||
--rollback-index*)
|
|
||||||
pack_fit_image ${ARG_LIST_FIT}
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# Search function and code position of address
|
|
||||||
FUNCADDR=${ARG_FUNCADDR}
|
|
||||||
RELOC_OFF=${FUNCADDR#*-}
|
|
||||||
FUNCADDR=${FUNCADDR%-*}
|
|
||||||
if [ -z $(echo ${FUNCADDR} | sed 's/[0-9,a-f,A-F,x,X,-]//g') ] && [ ${FUNCADDR} ]; then
|
|
||||||
# With prefix: '0x' or '0X'
|
|
||||||
if [ `echo ${FUNCADDR} | sed -n "/0[x,X]/p" | wc -l` -ne 0 ]; then
|
|
||||||
FUNCADDR=`echo ${FUNCADDR} | awk '{ print strtonum($0) }'`
|
|
||||||
FUNCADDR=`echo "obase=16;${FUNCADDR}"|bc |tr '[A-Z]' '[a-z]'`
|
|
||||||
fi
|
|
||||||
if [ `echo ${RELOC_OFF} | sed -n "/0[x,X]/p" | wc -l` -ne 0 ] && [ ${RELOC_OFF} ]; then
|
|
||||||
RELOC_OFF=`echo ${RELOC_OFF} | awk '{ print strtonum($0) }'`
|
|
||||||
RELOC_OFF=`echo "obase=16;${RELOC_OFF}"|bc |tr '[A-Z]' '[a-z]'`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If reloc address is assigned, do sub
|
|
||||||
if [ "${FUNCADDR}" != "${RELOC_OFF}" ]; then
|
|
||||||
# Hex -> Dec -> SUB -> Hex
|
|
||||||
FUNCADDR=`echo $((16#${FUNCADDR}))`
|
|
||||||
RELOC_OFF=`echo $((16#${RELOC_OFF}))`
|
|
||||||
FUNCADDR=$((FUNCADDR-RELOC_OFF))
|
|
||||||
FUNCADDR=$(echo "obase=16;${FUNCADDR}"|bc |tr '[A-Z]' '[a-z]')
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
sed -n "/${FUNCADDR}/p" ${sym}
|
|
||||||
${TOOLCHAIN_ADDR2LINE} -e ${elf} ${FUNCADDR}
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# We select chip info to do:
|
# We select chip info to do:
|
||||||
# 1. RKCHIP: fixup platform configure
|
# 1. RKCHIP: fixup platform configure
|
||||||
|
|
@ -424,16 +308,16 @@ function select_chip_info()
|
||||||
# - PX30, PX3SE
|
# - PX30, PX3SE
|
||||||
# - RK????, RK????X
|
# - RK????, RK????X
|
||||||
# - RV????
|
# - RV????
|
||||||
chip_pattern='^CONFIG_ROCKCHIP_[R,P][X,V,K][0-9ESX]{1,5}'
|
CHIP_PATTERN='^CONFIG_ROCKCHIP_[R,P][X,V,K][0-9ESX]{1,5}'
|
||||||
RKCHIP=`egrep -o ${chip_pattern} .config`
|
RKCHIP=`egrep -o ${CHIP_PATTERN} .config`
|
||||||
|
|
||||||
# default
|
# default
|
||||||
RKCHIP=${RKCHIP##*_}
|
RKCHIP=${RKCHIP##*_}
|
||||||
# fixup ?
|
# fixup ?
|
||||||
for item in "${CHIP_TYPE_FIXUP_TABLE[@]}"
|
for item in "${CHIP_TYPE_FIXUP_TABLE[@]}"
|
||||||
do
|
do
|
||||||
config_xxx=`echo ${item} | awk '{ print $1 }'`
|
CONFIG_ROCKCHIP_XXX=`echo ${item} | awk '{ print $1 }'`
|
||||||
if grep -q "^${config_xxx}=y" .config ; then
|
if grep -q "^${CONFIG_ROCKCHIP_XXX}=y" .config ; then
|
||||||
RKCHIP=`echo ${item} | awk '{ print $2 }'`
|
RKCHIP=`echo ${item} | awk '{ print $2 }'`
|
||||||
RKCHIP_LOADER=`echo ${item} | awk '{ print $3 }'`
|
RKCHIP_LOADER=`echo ${item} | awk '{ print $3 }'`
|
||||||
RKCHIP_TRUST=`echo ${item} | awk '{ print $4 }'`
|
RKCHIP_TRUST=`echo ${item} | awk '{ print $4 }'`
|
||||||
|
|
@ -455,27 +339,27 @@ function select_chip_info()
|
||||||
# Priority: default < CHIP_CFG_FIXUP_TABLE() < make.sh args
|
# Priority: default < CHIP_CFG_FIXUP_TABLE() < make.sh args
|
||||||
function fixup_platform_configure()
|
function fixup_platform_configure()
|
||||||
{
|
{
|
||||||
u_kb="-" u_num="-" t_kb="-" t_num="-" sha="-" rsa="-"
|
U_KB="-" U_NUM="-" T_KB="-" T_NUM="-" SHA="-" RSA="-"
|
||||||
|
|
||||||
for item in "${CHIP_CFG_FIXUP_TABLE[@]}"
|
for item in "${CHIP_CFG_FIXUP_TABLE[@]}"
|
||||||
do
|
do
|
||||||
config_xxx=`echo ${item} | awk '{ print $1 }'`
|
config_xxx=`echo ${item} | awk '{ print $1 }'`
|
||||||
if grep -q "^${config_xxx}=y" .config ; then
|
if grep -q "^${config_xxx}=y" .config ; then
|
||||||
# <*> Fixup rsa/sha pack mode for platforms
|
# <*> Fixup rsa/sha pack mode for platforms
|
||||||
rsa=`echo ${item} | awk '{ print $2 }'`
|
RSA=`echo ${item} | awk '{ print $2 }'`
|
||||||
sha=`echo ${item} | awk '{ print $3 }'`
|
SHA=`echo ${item} | awk '{ print $3 }'`
|
||||||
|
|
||||||
# <*> Fixup images size pack for platforms, and ini file
|
# <*> Fixup images size pack for platforms, and ini file
|
||||||
if grep -q '^CONFIG_ARM64=y' .config ; then
|
if grep -q '^CONFIG_ARM64=y' .config ; then
|
||||||
u_kb=`echo ${item} | awk '{ print $4 }' | awk -F "," '{ print $1 }'`
|
U_KB=`echo ${item} | awk '{ print $4 }' | awk -F "," '{ print $1 }'`
|
||||||
t_kb=`echo ${item} | awk '{ print $4 }' | awk -F "," '{ print $2 }'`
|
T_KB=`echo ${item} | awk '{ print $4 }' | awk -F "," '{ print $2 }'`
|
||||||
u_num=`echo ${item} | awk '{ print $5 }' | awk -F "," '{ print $1 }'`
|
U_NUM=`echo ${item} | awk '{ print $5 }' | awk -F "," '{ print $1 }'`
|
||||||
t_num=`echo ${item} | awk '{ print $5 }' | awk -F "," '{ print $2 }'`
|
T_NUM=`echo ${item} | awk '{ print $5 }' | awk -F "," '{ print $2 }'`
|
||||||
else
|
else
|
||||||
u_kb=`echo ${item} | awk '{ print $6 }' | awk -F "," '{ print $1 }'`
|
U_KB=`echo ${item} | awk '{ print $6 }' | awk -F "," '{ print $1 }'`
|
||||||
t_kb=`echo ${item} | awk '{ print $6 }' | awk -F "," '{ print $2 }'`
|
T_KB=`echo ${item} | awk '{ print $6 }' | awk -F "," '{ print $2 }'`
|
||||||
u_num=`echo ${item} | awk '{ print $7 }' | awk -F "," '{ print $1 }'`
|
U_NUM=`echo ${item} | awk '{ print $7 }' | awk -F "," '{ print $1 }'`
|
||||||
t_num=`echo ${item} | awk '{ print $7 }' | awk -F "," '{ print $2 }'`
|
T_NUM=`echo ${item} | awk '{ print $7 }' | awk -F "," '{ print $2 }'`
|
||||||
# AArch32
|
# AArch32
|
||||||
if grep -q '^CONFIG_ARM64_BOOT_AARCH32=y' .config ; then
|
if grep -q '^CONFIG_ARM64_BOOT_AARCH32=y' .config ; then
|
||||||
PADDING=`echo ${item} | awk '{ print $8 }'`
|
PADDING=`echo ${item} | awk '{ print $8 }'`
|
||||||
|
|
@ -492,26 +376,26 @@ function fixup_platform_configure()
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "${sha}" != "-" ]; then
|
if [ "${SHA}" != "-" ]; then
|
||||||
PLATFORM_SHA="--sha ${sha}"
|
PLAT_SHA="--sha ${SHA}"
|
||||||
fi
|
fi
|
||||||
if [ "${rsa}" != "-" ]; then
|
if [ "${RSA}" != "-" ]; then
|
||||||
PLATFORM_RSA="--rsa ${rsa}"
|
PLAT_RSA="--rsa ${RSA}"
|
||||||
fi
|
fi
|
||||||
if [ "${u_kb}" != "-" ]; then
|
if [ "${U_KB}" != "-" ]; then
|
||||||
PLATFORM_UBOOT_SIZE="--size ${u_kb} ${u_num}"
|
PLAT_UBOOT_SIZE="--size ${U_KB} ${U_NUM}"
|
||||||
fi
|
fi
|
||||||
if [ "${t_kb}" != "-" ]; then
|
if [ "${T_KB}" != "-" ]; then
|
||||||
PLATFORM_TRUST_SIZE="--size ${t_kb} ${t_num}"
|
PLAT_TRUST_SIZE="--size ${T_KB} ${T_NUM}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# args
|
# args
|
||||||
if [ ! -z "${ARG_UBOOT_SIZE}" ]; then
|
if [ ! -z "${ARG_UBOOT_SIZE}" ]; then
|
||||||
PLATFORM_UBOOT_SIZE=${ARG_UBOOT_SIZE}
|
PLAT_UBOOT_SIZE=${ARG_UBOOT_SIZE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "${ARG_TRUST_SIZE}" ]; then
|
if [ ! -z "${ARG_TRUST_SIZE}" ]; then
|
||||||
PLATFORM_TRUST_SIZE=${ARG_TRUST_SIZE}
|
PLAT_TRUST_SIZE=${ARG_TRUST_SIZE}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -537,293 +421,284 @@ function select_ini_file()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# args
|
# args
|
||||||
if [ "${ARG_INI_TRUST}" != "" ]; then
|
if [ ! -z "${ARG_INI_TRUST}" ]; then
|
||||||
INI_TRUST=${ARG_INI_TRUST}
|
INI_TRUST=${ARG_INI_TRUST}
|
||||||
fi
|
fi
|
||||||
if [ "${ARG_INI_LOADER}" != "" ]; then
|
if [ ! -z "${ARG_INI_LOADER}" ]; then
|
||||||
INI_LOADER=${ARG_INI_LOADER}
|
INI_LOADER=${ARG_INI_LOADER}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sub_commands()
|
||||||
|
{
|
||||||
|
# skip "--" parameter, such as "--rollback-index-..."
|
||||||
|
if [[ ${CMD_ARGS} != --* ]]; then
|
||||||
|
CMD=${CMD_ARGS%-*}
|
||||||
|
ARG=${CMD_ARGS#*-}
|
||||||
|
else
|
||||||
|
CMD=${CMD_ARGS}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARG_TSPL}" == "tpl" -o "${ARG_TSPL}" == "spl" ]; then
|
||||||
|
ELF=`find -name u-boot-${ARG_TSPL}`
|
||||||
|
MAP=`find -name u-boot-${ARG_TSPL}.map`
|
||||||
|
SYM=`find -name u-boot-${ARG_TSPL}.sym`
|
||||||
|
else
|
||||||
|
ELF=u-boot
|
||||||
|
MAP=u-boot.map
|
||||||
|
SYM=u-boot.sym
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${CMD} in
|
||||||
|
elf|nm)
|
||||||
|
if [ "${CMD}" == "nm" ]; then
|
||||||
|
${TOOLCHAIN_NM} -r --size ${ELF} | less
|
||||||
|
else
|
||||||
|
if [ "${CMD}" == "elf" -a "${ARG}" == "elf" ]; then
|
||||||
|
ARG=D # default
|
||||||
|
fi
|
||||||
|
${TOOLCHAIN_OBJDUMP} -${ARG} ${ELF} | less
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
map|sym)
|
||||||
|
if [ ${CMD} == "map" ]; then
|
||||||
|
cat ${MAP} | less
|
||||||
|
else
|
||||||
|
cat ${SYM} | less
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
debug)
|
||||||
|
./scripts/rkpatch.sh ${ARG}
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
fit)
|
||||||
|
# Non-secure
|
||||||
|
./scripts/fit-mkimg.sh --uboot-itb --boot-itb --no-vboot ${ARG_LIST_FIT}
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
uboot)
|
||||||
|
pack_uboot_image
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
trust)
|
||||||
|
pack_trust_image
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
loader)
|
||||||
|
pack_loader_image
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
itb)
|
||||||
|
pack_uboot_itb_image
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
env)
|
||||||
|
make CROSS_COMPILE=${TOOLCHAIN_GCC} envtools
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--tpl|--spl|tpl|spl)
|
||||||
|
pack_spl_loader_image
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
unwind_addr_or_continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function unwind_addr_or_continue()
|
||||||
|
{
|
||||||
|
FUNCADDR=${ARG_FUNCADDR}
|
||||||
|
RELOCOFF=${FUNCADDR#*-}
|
||||||
|
FUNCADDR=${FUNCADDR%-*}
|
||||||
|
|
||||||
|
if [ -z $(echo ${FUNCADDR} | sed 's/[0-9,a-f,A-F,x,X,-]//g') ] && [ ${FUNCADDR} ]; then
|
||||||
|
# With prefix: '0x' or '0X'
|
||||||
|
if [ `echo ${FUNCADDR} | sed -n "/0[x,X]/p" | wc -l` -ne 0 ]; then
|
||||||
|
FUNCADDR=`echo ${FUNCADDR} | awk '{ print strtonum($0) }'`
|
||||||
|
FUNCADDR=`echo "obase=16;${FUNCADDR}"|bc | tr '[A-Z]' '[a-z]'`
|
||||||
|
fi
|
||||||
|
if [ `echo ${RELOCOFF} | sed -n "/0[x,X]/p" | wc -l` -ne 0 ] && [ ${RELOCOFF} ]; then
|
||||||
|
RELOCOFF=`echo ${RELOCOFF} | awk '{ print strtonum($0) }'`
|
||||||
|
RELOCOFF=`echo "obase=16;${RELOCOFF}"|bc | tr '[A-Z]' '[a-z]'`
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If reloc address is assigned, do sub
|
||||||
|
if [ "${FUNCADDR}" != "${RELOCOFF}" ]; then
|
||||||
|
# Hex -> Dec -> SUB -> Hex
|
||||||
|
FUNCADDR=`echo $((16#${FUNCADDR}))`
|
||||||
|
RELOCOFF=`echo $((16#${RELOCOFF}))`
|
||||||
|
FUNCADDR=$((FUNCADDR-RELOCOFF))
|
||||||
|
FUNCADDR=$(echo "obase=16;${FUNCADDR}"|bc | tr '[A-Z]' '[a-z]')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
sed -n "/${FUNCADDR}/p" ${SYM}
|
||||||
|
${TOOLCHAIN_ADDR2LINE} -e ${ELF} ${FUNCADDR}
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function pack_uboot_itb_image()
|
||||||
|
{
|
||||||
|
INI=${INI_TRUST}
|
||||||
|
if [ ! -f ${INI} ]; then
|
||||||
|
echo "ERROR: No ${INI}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARM64_TRUSTZONE}" == "y" ]; then
|
||||||
|
BL31_ELF=`sed -n '/_bl31_/s/PATH=//p' ${INI} | tr -d '\r'`
|
||||||
|
cp ${RKBIN}/${BL31_ELF} bl31.elf
|
||||||
|
make CROSS_COMPILE=${TOOLCHAIN_GCC} u-boot.itb
|
||||||
|
echo "pack u-boot.itb okay! Input: ${INI}"
|
||||||
|
else
|
||||||
|
# TOS
|
||||||
|
TOS=`sed -n "/TOS=/s/TOS=//p" ${INI} | tr -d '\r'`
|
||||||
|
TOSTA=`sed -n "/TOSTA=/s/TOSTA=//p" ${INI} | tr -d '\r'`
|
||||||
|
if [ ! -z "${TOSTA}" ]; then
|
||||||
|
cp ${RKBIN}/${TOSTA} tee.bin
|
||||||
|
elif [ ! -z "${TOS}" ]; then
|
||||||
|
cp ${RKBIN}/${TOS} tee.bin
|
||||||
|
else
|
||||||
|
echo "ERROR: No tee bin"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TEE_OFFSET=`sed -n "/ADDR=/s/ADDR=//p" ${INI} | tr -d '\r'`
|
||||||
|
if [ "${TEE_OFFSET}" == "" ]; then
|
||||||
|
TEE_OFFSET=0x8400000
|
||||||
|
fi
|
||||||
|
|
||||||
|
# MCU
|
||||||
|
MCU_ENABLED=`awk -F"," '/MCU=/ { printf $3 }' ${INI} | tr -d ' '`
|
||||||
|
if [ "${MCU_ENABLED}" == "enabled" -o "${MCU_ENABLED}" == "okay" ]; then
|
||||||
|
MCU=`awk -F"," '/MCU=/ { printf $1 }' ${INI} | tr -d ' ' | cut -c 5-`
|
||||||
|
cp ${RKBIN}/${MCU} mcu.bin
|
||||||
|
MCU_OFFSET=`awk -F"," '/MCU=/ { printf $2 }' ${INI} | tr -d ' '`
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPRESSION=`awk -F"," '/COMPRESSION=/ { printf $1 }' ${INI} | tr -d ' ' | cut -c 13-`
|
||||||
|
if [ -z "${COMPRESSION}" ]; then
|
||||||
|
COMPRESSION="none"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# its
|
||||||
|
SPL_FIT_SOURCE=`sed -n "/CONFIG_SPL_FIT_SOURCE=/s/CONFIG_SPL_FIT_SOURCE=//p" .config | tr -d '""'`
|
||||||
|
if [ ! -z ${SPL_FIT_SOURCE} ]; then
|
||||||
|
cp ${SPL_FIT_SOURCE} u-boot.its
|
||||||
|
else
|
||||||
|
SPL_FIT_GENERATOR=`sed -n "/CONFIG_SPL_FIT_GENERATOR=/s/CONFIG_SPL_FIT_GENERATOR=//p" .config | tr -d '""'`
|
||||||
|
if [ ! -z ${MCU_OFFSET} ]; then
|
||||||
|
${SPL_FIT_GENERATOR} -u -t ${TEE_OFFSET} -c ${COMPRESSION} -m ${MCU_OFFSET} > u-boot.its
|
||||||
|
else
|
||||||
|
${SPL_FIT_GENERATOR} -u -t ${TEE_OFFSET} -c ${COMPRESSION} > u-boot.its
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
./tools/mkimage -f u-boot.its -E u-boot.itb
|
||||||
|
echo "pack u-boot.itb okay! Input: ${INI}"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
function pack_spl_loader_image()
|
||||||
|
{
|
||||||
|
rm *_loader_*.bin -f
|
||||||
|
cd ${RKBIN}
|
||||||
|
if [ ! -z "${ARG_SPL_BIN}" -a ! -z "${ARG_TPL_BIN}" ]; then
|
||||||
|
${SCRIPT_SPL} --ini ${INI_LOADER} --tpl ${SRCTREE}/${ARG_TPL_BIN} --spl ${SRCTREE}/${ARG_SPL_BIN}
|
||||||
|
elif [ ! -z "${ARG_TPL_BIN}" ]; then
|
||||||
|
${SCRIPT_SPL} --ini ${INI_LOADER} --tpl ${SRCTREE}/${ARG_TPL_BIN}
|
||||||
|
else
|
||||||
|
${SCRIPT_SPL} --ini ${INI_LOADER} --spl ${SRCTREE}/${ARG_SPL_BIN}
|
||||||
|
fi
|
||||||
|
cd -
|
||||||
|
if [ -f ${RKBIN}/*_loader_*.bin ]; then
|
||||||
|
mv ${RKBIN}/*_loader_*.bin ./
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function pack_uboot_image()
|
||||||
|
{
|
||||||
|
rm u-boot.img u-boot-dtb.img -f
|
||||||
|
LOAD_ADDR=`sed -n "/CONFIG_SYS_TEXT_BASE=/s/CONFIG_SYS_TEXT_BASE=//p" include/autoconf.mk|tr -d '\r'`
|
||||||
|
${SCRIPT_UBOOT} --load ${LOAD_ADDR} ${PLAT_UBOOT_SIZE}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pack_loader_image()
|
||||||
|
{
|
||||||
|
rm *_loader_*.bin -f
|
||||||
|
cd ${RKBIN}
|
||||||
|
${SCRIPT_LOADER} --ini ${INI_LOADER}
|
||||||
|
cd -
|
||||||
|
if [ -f ${RKBIN}/*_loader_*.bin ]; then
|
||||||
|
mv ${RKBIN}/*_loader_*.bin ./
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function pack_trust_image()
|
||||||
|
{
|
||||||
|
DRAM_BASE=`sed -n "/CONFIG_SYS_SDRAM_BASE=/s/CONFIG_SYS_SDRAM_BASE=//p" include/autoconf.mk|tr -d '\r'`
|
||||||
|
|
||||||
|
rm trust*.img -f
|
||||||
|
cd ${RKBIN}
|
||||||
|
if [ "${ARM64_TRUSTZONE}" == "y" ]; then
|
||||||
|
${SCRIPT_ATF} --ini ${INI_TRUST} ${PLAT_SHA} ${PLAT_RSA} ${PLAT_TRUST_SIZE}
|
||||||
|
else
|
||||||
|
${SCRIPT_TOS} --ini ${INI_TRUST} --base ${DRAM_BASE} ${PLAT_TRUST_SIZE}
|
||||||
|
fi
|
||||||
|
cd -
|
||||||
|
if [ -f ${RKBIN}/trust*.img ]; then
|
||||||
|
mv ${RKBIN}/trust*.img ./
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function pack_fit_image()
|
||||||
|
{
|
||||||
|
# If we don't plan to have uboot in uboot.img in case of: SPL => Trust => Kernel, creating empty files.
|
||||||
|
if [ "${ARG_NO_UBOOT}" == "y" ]; then
|
||||||
|
rm u-boot-nodtb.bin u-boot.dtb -f
|
||||||
|
touch u-boot-nodtb.bin u-boot.dtb
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verified boot=1: must build both uboot.img and boot.img
|
||||||
|
# Verified boot=0: build uboot.img
|
||||||
|
if grep -q '^CONFIG_FIT_SIGNATURE=y' .config ; then
|
||||||
|
./scripts/fit-mkimg.sh --uboot-itb --boot-itb ${ARG_LIST_FIT}
|
||||||
|
else
|
||||||
|
rm uboot.img trust*.img -f
|
||||||
|
./scripts/fit-mkimg.sh --uboot-itb --no-vboot --no-rebuild ${ARG_LIST_FIT}
|
||||||
|
echo "pack uboot.img okay! Input: ${INI_TRUST}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function handle_args_late()
|
function handle_args_late()
|
||||||
{
|
{
|
||||||
ARG_LIST_FIT="${ARG_LIST_FIT} --ini-trust ${INI_TRUST} --ini-loader ${INI_LOADER}"
|
ARG_LIST_FIT="${ARG_LIST_FIT} --ini-trust ${INI_TRUST} --ini-loader ${INI_LOADER}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function pack_uboot_image()
|
function clean_files()
|
||||||
{
|
{
|
||||||
if [ "${PLATFORM_TYPE}" != "RKFW" ]; then
|
rm spl/u-boot-spl.dtb tpl/u-boot-tpl.dtb u-boot.dtb -f
|
||||||
return
|
rm spl/u-boot-spl tpl/u-boot-tpl u-boot -f
|
||||||
fi
|
|
||||||
|
|
||||||
# Check file size
|
|
||||||
head_kb=2
|
|
||||||
uboot_kb=`ls -l u-boot.bin | awk '{ print $5 }'`
|
|
||||||
if [ "${PLATFORM_UBOOT_SIZE}" == "" ]; then
|
|
||||||
uboot_max_kb=1046528
|
|
||||||
else
|
|
||||||
uboot_max_kb=`echo ${PLATFORM_UBOOT_SIZE} | awk '{print strtonum($2)}'`
|
|
||||||
uboot_max_kb=$(((uboot_max_kb-head_kb)*1024))
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${uboot_kb} -gt ${uboot_max_kb} ]; then
|
|
||||||
echo
|
|
||||||
echo "ERROR: pack uboot failed! u-boot.bin actual: ${uboot_kb} bytes, max limit: ${uboot_max_kb} bytes"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Pack
|
|
||||||
uboot_load_addr=`sed -n "/CONFIG_SYS_TEXT_BASE=/s/CONFIG_SYS_TEXT_BASE=//p" include/autoconf.mk|tr -d '\r'`
|
|
||||||
if [ -z ${uboot_load_addr} ]; then
|
|
||||||
echo "ERROR: No CONFIG_SYS_TEXT_BASE for u-boot";
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
${RKTOOLS}/loaderimage --pack --uboot u-boot.bin uboot.img ${uboot_load_addr} ${PLATFORM_UBOOT_SIZE}
|
|
||||||
rm u-boot.img u-boot-dtb.img -rf
|
|
||||||
echo "pack uboot okay! Input: u-boot.bin"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_uboot_itb_image()
|
|
||||||
{
|
|
||||||
ini=${INI_TRUST}
|
|
||||||
if [ ! -f ${INI_TRUST} ]; then
|
|
||||||
echo "pack trust failed! Can't find: ${INI_TRUST}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${ARM64_TRUSTZONE}" == "y" ]; then
|
|
||||||
bl31=`sed -n '/_bl31_/s/PATH=//p' ${ini} |tr -d '\r'`
|
|
||||||
cp ${RKBIN}/${bl31} bl31.elf
|
|
||||||
make CROSS_COMPILE=${TOOLCHAIN_GCC} u-boot.itb
|
|
||||||
echo "pack u-boot.itb okay! Input: ${ini}"
|
|
||||||
else
|
|
||||||
tos_image=`sed -n "/TOS=/s/TOS=//p" ${ini} |tr -d '\r'`
|
|
||||||
tosta_image=`sed -n "/TOSTA=/s/TOSTA=//p" ${ini} |tr -d '\r'`
|
|
||||||
if [ ${tosta_image} ]; then
|
|
||||||
cp ${RKBIN}/${tosta_image} tee.bin
|
|
||||||
elif [ ${tos_image} ]; then
|
|
||||||
cp ${RKBIN}/${tos_image} tee.bin
|
|
||||||
else
|
|
||||||
echo "ERROR: No any tee bin"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
tee_offset=`sed -n "/ADDR=/s/ADDR=//p" ${ini} |tr -d '\r'`
|
|
||||||
if [ "${tee_offset}" == "" ]; then
|
|
||||||
tee_offset=0x8400000
|
|
||||||
fi
|
|
||||||
|
|
||||||
mcu_enabled=`awk -F"," '/MCU=/ { printf $3 }' ${ini} | tr -d ' '`
|
|
||||||
if [ "${mcu_enabled}" == "enabled" ]; then
|
|
||||||
mcu_image=`awk -F"," '/MCU=/ { printf $1 }' ${ini} | tr -d ' ' | cut -c 5-`
|
|
||||||
cp ${RKBIN}/${mcu_image} mcu.bin
|
|
||||||
mcu_offset=`awk -F"," '/MCU=/ { printf $2 }' ${ini} | tr -d ' '`
|
|
||||||
optional_mcu="-m "${mcu_offset}
|
|
||||||
else
|
|
||||||
optional_mcu=
|
|
||||||
fi
|
|
||||||
|
|
||||||
compression=`awk -F"," '/COMPRESSION=/ { printf $1 }' ${ini} | tr -d ' ' | cut -c 13-`
|
|
||||||
if [ -z "${compression}" ]; then
|
|
||||||
compression="none"
|
|
||||||
fi
|
|
||||||
|
|
||||||
SPL_FIT_SOURCE=`sed -n "/CONFIG_SPL_FIT_SOURCE=/s/CONFIG_SPL_FIT_SOURCE=//p" .config | tr -d '""'`
|
|
||||||
if [ ! -z ${SPL_FIT_SOURCE} ]; then
|
|
||||||
cp ${SPL_FIT_SOURCE} u-boot.its
|
|
||||||
else
|
|
||||||
SPL_FIT_GENERATOR=`sed -n "/CONFIG_SPL_FIT_GENERATOR=/s/CONFIG_SPL_FIT_GENERATOR=//p" .config | tr -d '""'`
|
|
||||||
${SPL_FIT_GENERATOR} -u -t ${tee_offset} -c ${compression} ${optional_mcu} > u-boot.its
|
|
||||||
fi
|
|
||||||
./tools/mkimage -f u-boot.its -E u-boot.itb
|
|
||||||
echo "pack u-boot.itb okay! Input: ${ini}"
|
|
||||||
fi
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_spl_loader_image()
|
|
||||||
{
|
|
||||||
mode=$1
|
|
||||||
tmpdir=${RKBIN}/tmp
|
|
||||||
tmpini=${tmpdir}/${RKCHIP_LOADER}MINIALL.ini
|
|
||||||
ini=${INI_LOADER}
|
|
||||||
if [ ! -f ${INI_LOADER} ]; then
|
|
||||||
echo "pack loader failed! Can't find: ${INI_LOADER}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Find magic for TPL
|
|
||||||
for item in "${CHIP_TPL_MAGIC_TABLE[@]}"
|
|
||||||
do
|
|
||||||
config_xxx=`echo ${item} | awk '{ print $1 }'`
|
|
||||||
if grep -q "^${config_xxx}=y" .config ; then
|
|
||||||
header=`echo ${item} | awk '{ print $2 }'`
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -z ${header} ]; then
|
|
||||||
header=`sed -n '/NAME=/s/NAME=//p' ${ini}`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Prepare files
|
|
||||||
rm ${tmpdir} -rf && mkdir ${tmpdir} -p
|
|
||||||
cp spl/u-boot-spl.bin ${tmpdir}/ && cp ${ini} ${tmpini}
|
|
||||||
|
|
||||||
if [ "${mode}" == "tpl-spl" ]; then # pack tpl+spl
|
|
||||||
label="TPL+SPL"
|
|
||||||
cp tpl/u-boot-tpl.bin ${tmpdir}/
|
|
||||||
dd if=${tmpdir}/u-boot-tpl.bin of=${tmpdir}/tpl.bin bs=1 skip=4
|
|
||||||
sed -i "1s/^/${header:0:4}/" ${tmpdir}/tpl.bin
|
|
||||||
sed -i "s/FlashData=.*$/FlashData=.\/tmp\/tpl.bin/" ${tmpini}
|
|
||||||
sed -i "0,/Path1=.*/s/Path1=.*$/Path1=.\/tmp\/tpl.bin/" ${tmpini}
|
|
||||||
sed -i "s/FlashBoot=.*$/FlashBoot=.\/tmp\/u-boot-spl.bin/" ${tmpini}
|
|
||||||
elif [ "${mode}" == "tpl" ]; then # pack tpl
|
|
||||||
label="TPL"
|
|
||||||
cp tpl/u-boot-tpl.bin ${tmpdir}/
|
|
||||||
dd if=${tmpdir}/u-boot-tpl.bin of=${tmpdir}/tpl.bin bs=1 skip=4
|
|
||||||
sed -i "1s/^/${header:0:4}/" ${tmpdir}/tpl.bin
|
|
||||||
sed -i "s/FlashData=.*$/FlashData=.\/tmp\/tpl.bin/" ${tmpini}
|
|
||||||
sed -i "0,/Path1=.*/s/Path1=.*$/Path1=.\/tmp\/tpl.bin/" ${tmpini}
|
|
||||||
else
|
|
||||||
label="SPL"
|
|
||||||
sed -i "s/FlashBoot=.*$/FlashBoot=.\/tmp\/u-boot-spl.bin/" ${tmpini}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Pack
|
|
||||||
cd ${RKBIN}
|
|
||||||
${RKTOOLS}/boot_merger ${tmpini}
|
|
||||||
|
|
||||||
rm ${tmpdir} -rf && cd -
|
|
||||||
rm *_loader_*.bin -rf && mv ${RKBIN}/*_loader_*.bin ./
|
|
||||||
filename=`basename *_loader_*.bin`
|
|
||||||
if [[ ${filename} != *spl* ]]; then
|
|
||||||
rename 's/loader_/spl_loader_/' *_loader_*.bin
|
|
||||||
fi
|
|
||||||
echo "pack loader(${label}) okay! Input: ${ini}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_loader_image()
|
|
||||||
{
|
|
||||||
ini=${INI_LOADER}
|
|
||||||
if [ ! -f ${INI_LOADER} ]; then
|
|
||||||
echo "pack loader failed! Can't find: ${INI_LOADER}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm *_loader_*.bin -rf
|
|
||||||
numline=`cat ${ini} | wc -l`
|
|
||||||
if [ ${numline} -eq 1 ]; then
|
|
||||||
image=`sed -n "/PATH=/p" ${ini} | tr -d '\r' | cut -d '=' -f 2`
|
|
||||||
cp ${RKBIN}/${image} ./
|
|
||||||
else
|
|
||||||
cd ${RKBIN}
|
|
||||||
${RKTOOLS}/boot_merger ${ini}
|
|
||||||
cd - && mv ${RKBIN}/*_loader_*.bin ./
|
|
||||||
fi
|
|
||||||
|
|
||||||
file=`ls *loader*.bin`
|
|
||||||
echo "pack ${file} okay! Input: ${ini}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_arm32_trust_image()
|
|
||||||
{
|
|
||||||
ini=$1
|
|
||||||
tos_image=`sed -n "/TOS=/s/TOS=//p" ${ini} |tr -d '\r'`
|
|
||||||
tosta_image=`sed -n "/TOSTA=/s/TOSTA=//p" ${ini} |tr -d '\r'`
|
|
||||||
tee_output=`sed -n "/OUTPUT=/s/OUTPUT=//p" ${ini} |tr -d '\r'`
|
|
||||||
if [ "${tee_output}" == "" ]; then
|
|
||||||
tee_output="./trust.img"
|
|
||||||
fi
|
|
||||||
tee_offset=`sed -n "/ADDR=/s/ADDR=//p" ${ini} |tr -d '\r'`
|
|
||||||
if [ "${tee_offset}" == "" ]; then
|
|
||||||
tee_offset=0x8400000
|
|
||||||
fi
|
|
||||||
|
|
||||||
# OP-TEE is 132M(0x8400000) offset from DRAM base.
|
|
||||||
dram_base=`sed -n "/CONFIG_SYS_SDRAM_BASE=/s/CONFIG_SYS_SDRAM_BASE=//p" include/autoconf.mk|tr -d '\r'`
|
|
||||||
tee_load_addr=$((dram_base+tee_offset))
|
|
||||||
tee_load_addr=$(echo "obase=16;${tee_load_addr}"|bc) # Convert Dec to Hex
|
|
||||||
|
|
||||||
if [ ${tosta_image} ]; then
|
|
||||||
${RKTOOLS}/loaderimage --pack --trustos ${RKBIN}/${tosta_image} ${tee_output} ${tee_load_addr} ${PLATFORM_TRUST_SIZE}
|
|
||||||
elif [ ${tos_image} ]; then
|
|
||||||
${RKTOOLS}/loaderimage --pack --trustos ${RKBIN}/${tos_image} ${tee_output} ${tee_load_addr} ${PLATFORM_TRUST_SIZE}
|
|
||||||
else
|
|
||||||
echo "ERROR: No any tee bin"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "pack trust okay! Input: ${ini}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_arm64_trust_image()
|
|
||||||
{
|
|
||||||
ini=$1
|
|
||||||
cd ${RKBIN}
|
|
||||||
${RKTOOLS}/trust_merger ${PLATFORM_SHA} ${PLATFORM_RSA} ${PLATFORM_TRUST_SIZE} ${ini}
|
|
||||||
cd - && mv ${RKBIN}/trust*.img ./
|
|
||||||
echo "pack trust okay! Input: ${ini}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_trust_image()
|
|
||||||
{
|
|
||||||
if [ "${PLATFORM_TYPE}" != "RKFW" ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm trust*.img -rf
|
|
||||||
ini=${INI_TRUST}
|
|
||||||
if [ ! -f ${INI_TRUST} ]; then
|
|
||||||
echo "pack trust failed! Can't find: ${INI_TRUST}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
numline=`cat ${ini} | wc -l`
|
|
||||||
if [ ${numline} -eq 1 ]; then
|
|
||||||
image=`sed -n "/PATH=/p" ${ini} | tr -d '\r' | cut -d '=' -f 2`
|
|
||||||
cp ${RKBIN}/${image} ./trust.img
|
|
||||||
echo "pack trust okay! Input: ${ini}"
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
if [ "${ARM64_TRUSTZONE}" == "y" ]; then
|
|
||||||
pack_arm64_trust_image ${ini}
|
|
||||||
else
|
|
||||||
pack_arm32_trust_image ${ini}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function pack_fit_image()
|
|
||||||
{
|
|
||||||
if [ "${ARG_NO_UBOOT}" == "y" ]; then
|
|
||||||
rm u-boot-nodtb.bin u-boot.dtb -rf
|
|
||||||
touch u-boot-nodtb.bin u-boot.dtb
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -q '^CONFIG_FIT_SIGNATURE=y' .config ; then
|
|
||||||
./scripts/fit-mkimg.sh --uboot-itb --boot-itb ${ARG_LIST_FIT}
|
|
||||||
else
|
|
||||||
rm uboot.img trust*.img -rf
|
|
||||||
./scripts/fit-mkimg.sh --uboot-itb --no-vboot --no-rebuild ${ARG_LIST_FIT}
|
|
||||||
echo "pack uboot.img okay! Input: ${INI_TRUST}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pack_images()
|
function pack_images()
|
||||||
{
|
{
|
||||||
if [ "${ARG_NO_PACK}" != "y" ]; then
|
if [ "${ARG_NO_PACK}" == "y" ]; then
|
||||||
if [ "${PLATFORM_TYPE}" == "RKFW" ]; then
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${PLAT_TYPE}" == "RKFW" ]; then
|
||||||
pack_uboot_image
|
pack_uboot_image
|
||||||
pack_trust_image
|
pack_trust_image
|
||||||
pack_loader_image
|
pack_loader_image
|
||||||
elif [ "${PLATFORM_TYPE}" == "FIT" ]; then
|
elif [ "${PLAT_TYPE}" == "FIT" ]; then
|
||||||
pack_fit_image ${ARG_LIST_FIT}
|
pack_fit_image ${ARG_LIST_FIT}
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function clean_files()
|
|
||||||
{
|
|
||||||
rm spl/u-boot-spl.dtb tpl/u-boot-tpl.dtb u-boot.dtb -rf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish()
|
function finish()
|
||||||
|
|
@ -848,4 +723,3 @@ clean_files
|
||||||
make CROSS_COMPILE=${TOOLCHAIN_GCC} all --jobs=${JOB}
|
make CROSS_COMPILE=${TOOLCHAIN_GCC} all --jobs=${JOB}
|
||||||
pack_images
|
pack_images
|
||||||
finish
|
finish
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Rockchip Electronics Co., Ltd
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "ERROR: No args of $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--ini)
|
||||||
|
INI=$2 # mandory
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--rsa)
|
||||||
|
RSA="$1 $2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--sha)
|
||||||
|
SHA="$1 $2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--size)
|
||||||
|
SIZE="$1 $2 $3"
|
||||||
|
shift 3
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown arg: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -f ${INI} ]; then
|
||||||
|
echo "pack trust failed! Can't find: ${INI}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm trust*.img -f
|
||||||
|
|
||||||
|
COUNT=`cat ${INI} | wc -l`
|
||||||
|
if [ ${COUNT} -eq 1 ]; then
|
||||||
|
IMG=`sed -n "/PATH=/p" ${INI} | tr -d '\r' | cut -d '=' -f 2`
|
||||||
|
cp ${IMG} ./trust.img
|
||||||
|
else
|
||||||
|
./tools/trust_merger ${INI} ${SIZE} ${SHA} ${RSA}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "pack trust okay! Input: ${INI}"
|
||||||
|
echo
|
||||||
|
|
@ -62,7 +62,7 @@ function help()
|
||||||
echo " --uboot-itb"
|
echo " --uboot-itb"
|
||||||
echo " --boot-itb"
|
echo " --boot-itb"
|
||||||
echo " --boot_img"
|
echo " --boot_img"
|
||||||
echo " --p-check"
|
echo " --arg-check"
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ function fit_process_args()
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--p-check)
|
--arg-check)
|
||||||
ARG_VALIDATE=$2
|
ARG_VALIDATE=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
|
@ -188,8 +188,9 @@ function fit_process_args()
|
||||||
|
|
||||||
function fit_rebuild()
|
function fit_rebuild()
|
||||||
{
|
{
|
||||||
|
# Verified-boot: should rebuild code but don't need to repack images.
|
||||||
if [ "${ARG_NO_REBUILD}" != "y" ]; then
|
if [ "${ARG_NO_REBUILD}" != "y" ]; then
|
||||||
./make.sh --no-pack # Always no pack
|
./make.sh --no-pack # Build but not pack loader/trust/uboot, etc.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm ${FIT_DIR} -rf
|
rm ${FIT_DIR} -rf
|
||||||
|
|
@ -198,13 +199,13 @@ function fit_rebuild()
|
||||||
|
|
||||||
function fit_gen_uboot_itb()
|
function fit_gen_uboot_itb()
|
||||||
{
|
{
|
||||||
./make.sh itb ${ARG_INI_TRUST}
|
./make.sh itb ${ARG_INI_TRUST} >/dev/null 2>&1
|
||||||
check_its ${ITS_UBOOT}
|
check_its ${ITS_UBOOT}
|
||||||
|
|
||||||
if [ "${ARG_NO_VBOOT}" == "y" ]; then
|
if [ "${ARG_NO_VBOOT}" == "y" ]; then
|
||||||
${MKIMAGE} -f ${ITS_UBOOT} -E -p ${OFFS_NS_UBOOT} ${ITB_UBOOT} -v ${ARG_VER_UBOOT}
|
${MKIMAGE} -f ${ITS_UBOOT} -E -p ${OFFS_NS_UBOOT} ${ITB_UBOOT} -v ${ARG_VER_UBOOT}
|
||||||
if [ "${ARG_SPL_NEW}" == "y" ]; then
|
if [ "${ARG_SPL_NEW}" == "y" ]; then
|
||||||
./make.sh spl-s ${ARG_INI_LOADER}
|
./make.sh --spl ${ARG_INI_LOADER}
|
||||||
echo "pack loader with new: spl/u-boot-spl.bin"
|
echo "pack loader with new: spl/u-boot-spl.bin"
|
||||||
else
|
else
|
||||||
./make.sh loader ${ARG_INI_LOADER}
|
./make.sh loader ${ARG_INI_LOADER}
|
||||||
|
|
@ -294,7 +295,7 @@ function fit_gen_uboot_itb()
|
||||||
fi
|
fi
|
||||||
cat ${SPL_DTB} >> spl/u-boot-spl.bin
|
cat ${SPL_DTB} >> spl/u-boot-spl.bin
|
||||||
|
|
||||||
./make.sh spl-s ${ARG_INI_LOADER}
|
./make.sh --spl ${ARG_INI_LOADER}
|
||||||
echo "pack loader with new: spl/u-boot-spl.bin"
|
echo "pack loader with new: spl/u-boot-spl.bin"
|
||||||
else
|
else
|
||||||
./make.sh loader ${ARG_INI_LOADER}
|
./make.sh loader ${ARG_INI_LOADER}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Rockchip Electronics Co., Ltd
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "ERROR: No args of $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--ini)
|
||||||
|
INI=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown arg: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
rm *_loader_*.bin -f
|
||||||
|
|
||||||
|
if [ ! -f ${INI} ]; then
|
||||||
|
echo "pack loader failed! Can't find: ${INI}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
COUNT=`cat ${INI} | wc -l`
|
||||||
|
if [ ${COUNT} -eq 1 ]; then
|
||||||
|
IMG=`sed -n "/PATH=/p" ${INI} | tr -d '\r' | cut -d '=' -f 2`
|
||||||
|
cp ${IMG} ./
|
||||||
|
else
|
||||||
|
./tools/boot_merger ${INI}
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "pack loader okay! Input: ${INI}"
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Rockchip Electronics Co., Ltd
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "ERROR: No args of $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--ini)
|
||||||
|
INI=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--spl)
|
||||||
|
SPL_BIN=$2
|
||||||
|
if [ ! -f ${SPL_BIN} ]; then
|
||||||
|
echo "ERROR: No ${SPL_BIN}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--tpl)
|
||||||
|
TPL_BIN=$2
|
||||||
|
if [ ! -f ${TPL_BIN} ]; then
|
||||||
|
echo "ERROR: No ${TPL_BIN}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown arg: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -f ${INI} ]; then
|
||||||
|
echo "ERROR: No ${INI}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${TPL_BIN}" == "" -a "${SPL_BIN}" == "" ]; then
|
||||||
|
echo "ERROR: No SPL and TPL file"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm tmp -rf && mkdir tmp -p
|
||||||
|
TMP_INI="tmp/MINIALL.ini"
|
||||||
|
cp ${INI} ${TMP_INI}
|
||||||
|
|
||||||
|
# magic
|
||||||
|
MAGIC=`sed -n '/NAME=/s/NAME=//p' ${INI}`
|
||||||
|
if [ "${MAGIC}" == "RV1126" ]; then
|
||||||
|
MAGIC="110B"
|
||||||
|
elif [ "${MAGIC}" == "RKPX30" ]; then
|
||||||
|
MAGIC="RK33"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# replace
|
||||||
|
if [ "${TPL_BIN}" != "" -a "${SPL_BIN}" != "" ]; then
|
||||||
|
cp ${TPL_BIN} tmp/u-boot-tpl.bin
|
||||||
|
cp ${SPL_BIN} tmp/u-boot-spl.bin
|
||||||
|
dd if=tmp/u-boot-tpl.bin of=tmp/tpl.bin bs=1 skip=4
|
||||||
|
|
||||||
|
sed -i "1s/^/${MAGIC:0:4}/" tmp/tpl.bin
|
||||||
|
sed -i "s/FlashData=.*$/FlashData=.\/tmp\/tpl.bin/" ${TMP_INI}
|
||||||
|
sed -i "0,/Path1=.*/s/Path1=.*$/Path1=.\/tmp\/tpl.bin/" ${TMP_INI}
|
||||||
|
sed -i "s/FlashBoot=.*$/FlashBoot=.\/tmp\/u-boot-spl.bin/" ${TMP_INI}
|
||||||
|
LABEL="TPL+SPL"
|
||||||
|
elif [ "${TPL_BIN}" != "" ]; then
|
||||||
|
cp ${TPL_BIN} tmp/u-boot-tpl.bin
|
||||||
|
dd if=tmp/u-boot-tpl.bin of=tmp/tpl.bin bs=1 skip=4
|
||||||
|
sed -i "1s/^/${MAGIC:0:4}/" tmp/tpl.bin
|
||||||
|
sed -i "s/FlashData=.*$/FlashData=.\/tmp\/tpl.bin/" ${TMP_INI}
|
||||||
|
sed -i "0,/Path1=.*/s/Path1=.*$/Path1=.\/tmp\/tpl.bin/" ${TMP_INI}
|
||||||
|
LABEL="TPL"
|
||||||
|
else
|
||||||
|
cp ${SPL_BIN} tmp/u-boot-spl.bin
|
||||||
|
sed -i "s/FlashBoot=.*$/FlashBoot=.\/tmp\/u-boot-spl.bin/" ${TMP_INI}
|
||||||
|
LABEL="SPL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm *_loader_*.bin -f
|
||||||
|
./tools/boot_merger ${TMP_INI}
|
||||||
|
|
||||||
|
FNAME=`basename *_loader_*.bin`
|
||||||
|
if [[ ${FNAME} != *spl* ]]; then
|
||||||
|
rename 's/loader_/spl_loader_/' *_loader_*.bin
|
||||||
|
fi
|
||||||
|
rm tmp/ -rf
|
||||||
|
|
||||||
|
echo "pack loader(${LABEL}) okay! Input: ${INI}"
|
||||||
|
echo
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Rockchip Electronics Co., Ltd
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "ERROR: No args of $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--base)
|
||||||
|
DRAM_BASE=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--ini)
|
||||||
|
INI=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--size)
|
||||||
|
SIZE="$1 $2 $3"
|
||||||
|
shift 3
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown arg: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -f ${INI} ]; then
|
||||||
|
echo "pack trust failed! Can't find: ${INI}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOS=`sed -n "/TOS=/s/TOS=//p" ${INI} | tr -d '\r'`
|
||||||
|
TOSTA=`sed -n "/TOSTA=/s/TOSTA=//p" ${INI} | tr -d '\r'`
|
||||||
|
OUTPUT=`sed -n "/OUTPUT=/s/OUTPUT=//p" ${INI} | tr -d '\r'`
|
||||||
|
|
||||||
|
if [ -z "${OUTPUT}" ]; then
|
||||||
|
OUTPUT="./trust.img"
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOAD_OFFSET=`sed -n "/ADDR=/s/ADDR=//p" ${INI} | tr -d '\r'`
|
||||||
|
if [ -z "${LOAD_OFFSET}" ]; then
|
||||||
|
# default offset
|
||||||
|
LOAD_OFFSET=0x8400000
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOAD_ADDR=$((DRAM_BASE+LOAD_OFFSET))
|
||||||
|
LOAD_ADDR=$(echo "obase=16;${LOAD_ADDR}"|bc) # Convert Dec to Hex
|
||||||
|
|
||||||
|
rm trust*.img -f
|
||||||
|
|
||||||
|
COUNT=`cat ${INI} | wc -l`
|
||||||
|
if [ ${COUNT} -eq 1 ]; then
|
||||||
|
IMG=`sed -n "/PATH=/p" ${INI} | tr -d '\r' | cut -d '=' -f 2`
|
||||||
|
cp ${IMG} ./trust.img
|
||||||
|
else
|
||||||
|
if [ ! -z "${TOSTA}" ]; then
|
||||||
|
./tools/loaderimage --pack --trustos ${TOSTA} ${OUTPUT} ${LOAD_ADDR} ${SIZE}
|
||||||
|
elif [ ! -z "${TOS}" ]; then
|
||||||
|
./tools/loaderimage --pack --trustos ${TOS} ${OUTPUT} ${LOAD_ADDR} ${SIZE}
|
||||||
|
else
|
||||||
|
echo "ERROR: No tee bin"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "pack trust okay! Input: ${INI}"
|
||||||
|
echo
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Rockchip Electronics Co., Ltd
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "ERROR: No args of $0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
--load)
|
||||||
|
LOAD_ADDR=$2
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--size)
|
||||||
|
SIZE="$1 $2 $3"
|
||||||
|
shift 3
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unknown arg: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
rm uboot.img -f
|
||||||
|
|
||||||
|
if [ -z "${LOAD_ADDR}" ]; then
|
||||||
|
echo "ERROR: No load address"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
HEAD_KB=2
|
||||||
|
BIN_KB=`ls -l u-boot.bin | awk '{ print $5 }'`
|
||||||
|
if [ -z "${SIZE}" ]; then
|
||||||
|
MAX_KB=1046528
|
||||||
|
else
|
||||||
|
MAX_KB=`echo ${SIZE} | awk '{print strtonum($2)}'`
|
||||||
|
MAX_KB=$(((MAX_KB-HEAD_KB)*1024))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${BIN_KB} -gt ${MAX_KB} ]; then
|
||||||
|
echo "ERROR: pack uboot failed! u-boot.bin actual: ${BIN_KB} bytes, max limit: ${MAX_KB} bytes"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
./tools/loaderimage --pack --uboot u-boot.bin uboot.img ${LOAD_ADDR} ${SIZE}
|
||||||
|
echo "pack uboot okay! Input: u-boot.bin"
|
||||||
|
echo
|
||||||
Loading…
Reference in New Issue