1 Star 0 Fork 1

Roger-Luo/u-boot-rockchip

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
make.sh 22.56 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
#!/bin/bash
#
# Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
#
# SPDX-License-Identifier: GPL-2.0
#
set -e
JOB=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
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
# @TRUST: map to $RKCHIP_TRUST for trust ini
# @LABEL: map to $RKCHIP_LEBEL for verbose message
# @-: default state/value
CHIP_TYPE_FIXUP_TABLE=(
# CONFIG_XXX RKCHIP LOADER TRUST LABEL
"CONFIG_ROCKCHIP_RK3368 RK3368H - - -"
"CONFIG_ROCKCHIP_RV1108 RV110X - - -"
"CONFIG_ROCKCHIP_PX3SE PX3SE - - -"
"CONFIG_ROCKCHIP_RK3126 RK3126 - - -"
"CONFIG_ROCKCHIP_RK3326 RK3326 - - -"
"CONFIG_ROCKCHIP_RK3128X RK3128X - - -"
"CONFIG_ROCKCHIP_PX5 PX5 - - -"
"CONFIG_ROCKCHIP_RK3399PRO RK3399PRO - - -"
"CONFIG_ROCKCHIP_RK1806 RK1806 - - -"
"CONFIG_TARGET_GVA_RK3229 RK322X RK322XAT - -"
"CONFIG_COPROCESSOR_RK1808 RKNPU-LION RKNPULION RKNPULION -"
)
# <*> Fixup rsa/sha pack mode for platforms
# RSA: RK3308/PX30/RK3326/RK1808 use RSA-PKCS1 V2.1, it's pack magic is "3", and others use default configure.
# SHA: RK3368 use rk big endian SHA256, it's pack magic is "2", and others use default configure.
# <*> Fixup images size pack for platforms
# <*> Fixup verbose message about AARCH32
#
# @RSA: rsa mode
# @SHA: sha mode
# @A64-KB: arm64 platform image size: [uboot,trust]
# @A64-NUM: arm64 platform image number of total: [uboot,trust]
# @A32-KB: arm32 platform image size: [uboot,trust]
# @A32-NUM: arm32 platform image number of total: [uboot,trust]
# @LOADER: map to $RKCHIP_LOADER for loader ini
# @TRUST: map to $RKCHIP_TRUST for trust ini
# @-: default state/value
CHIP_CFG_FIXUP_TABLE=(
# CONFIG_XXX RSA SHA A64-KB A64-NUM A32-KB A32-NUM LOAER TRUST
"CONFIG_ROCKCHIP_RK3368 - 2 -,- -,- -,- -,- - -"
"CONFIG_ROCKCHIP_RK3036 - - 512,512 1,1 -,- -,- - -"
"CONFIG_ROCKCHIP_PX30 3 - -,- -,- -,- -,- - -"
"CONFIG_ROCKCHIP_RK3326 3 - -,- -,- -,- -,- AARCH32 -"
"CONFIG_ROCKCHIP_RK3308 3 - 1024,1024 2,2 512,512 2,2 - AARCH32"
"CONFIG_ROCKCHIP_RK1808 3 - 1024,1024 2,2 -,- -,- - -"
"CONFIG_ROCKCHIP_RV1126 3 - -,- -,- -,- -,- - -"
)
########################################### User can modify #############################################
# User's rkbin tool relative path
RKBIN_TOOLS=../rkbin/tools
# User's GCC toolchain and relative path
ADDR2LINE_ARM32=arm-linux-gnueabihf-addr2line
ADDR2LINE_ARM64=aarch64-linux-gnu-addr2line
OBJ_ARM32=arm-linux-gnueabihf-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_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_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
########################################### User not touch #############################################
# Declare global INI file searching index name for every chip, update in select_chip_info()
RKCHIP="-"
RKCHIP_LABEL="-"
RKCHIP_LOADER="-"
RKCHIP_TRUST="-"
INI_TRUST=
INI_LOADER=
# Declare rkbin repository path, updated in prepare()
RKBIN=
# Declare global toolchain path for CROSS_COMPILE, updated in select_toolchain()
TOOLCHAIN_GCC=
TOOLCHAIN_NM=
TOOLCHAIN_OBJDUMP=
TOOLCHAIN_ADDR2LINE=
# Declare global plaform configure, updated in fixup_platform_configure()
PLAT_RSA=
PLAT_SHA=
PLAT_UBOOT_SIZE=
PLAT_TRUST_SIZE=
PLAT_TYPE="RKFW" # default
SRCTREE=`pwd`
SCRIPT_FIT="${SRCTREE}/scripts/fit.sh"
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()
{
echo
echo "Usage:"
echo " ./make.sh [board|sub-command]"
echo
echo " - board: board name of defconfig"
echo " - sub-command: elf*|loader|trust|uboot|--spl|--tpl|itb|map|sym|<addr>"
echo " - ini: ini file to pack trust/loader"
echo
echo "Output:"
echo " When board built okay, there are uboot/trust/loader images in current directory"
echo
echo "Example:"
echo
echo "1. Build:"
echo " ./make.sh evb-rk3399 --- build for evb-rk3399_defconfig"
echo " ./make.sh firefly-rk3288 --- build for firefly-rk3288_defconfig"
echo " ./make.sh EXT_DTB=rk-kernel.dtb --- build with exist .config and external dtb"
echo " ./make.sh --- build with exist .config"
echo " ./make.sh env --- build envtools"
echo
echo "2. Pack:"
echo " ./make.sh uboot --- pack uboot.img"
echo " ./make.sh trust --- pack trust.img"
echo " ./make.sh trust <ini> --- pack trust img with assigned ini file"
echo " ./make.sh loader --- pack loader bin"
echo " ./make.sh loader <ini> --- pack loader img with assigned ini file"
echo " ./make.sh --spl --- pack loader with u-boot-spl.bin"
echo " ./make.sh --tpl --- pack loader with u-boot-tpl.bin"
echo " ./make.sh --tpl --spl --- pack loader with u-boot-tpl.bin and u-boot-spl.bin"
echo
echo "3. Debug:"
echo " ./make.sh elf --- dump elf file with -D(default)"
echo " ./make.sh elf-S --- dump elf file with -S"
echo " ./make.sh elf-d --- dump elf file with -d"
echo " ./make.sh elf-* --- dump elf file with -*"
echo " ./make.sh <no reloc_addr> --- unwind address(no relocated)"
echo " ./make.sh <reloc_addr-reloc_off> --- unwind address(relocated)"
echo " ./make.sh map --- cat u-boot.map"
echo " ./make.sh sym --- cat u-boot.sym"
}
function prepare()
{
if [ -d ${RKBIN_TOOLS} ]; then
absolute_path=$(cd `dirname ${RKBIN_TOOLS}`; pwd)
RKBIN=${absolute_path}
else
echo "ERROR: No ../rkbin repository"
exit 1
fi
if grep -Eq ''^CONFIG_ARM64=y'|'^CONFIG_ARM64_BOOT_AARCH32=y'' .config ; then
ARM64_TRUSTZONE="y"
fi
if grep -q '^CONFIG_ROCKCHIP_FIT_IMAGE_PACK=y' .config ; then
PLAT_TYPE="FIT"
fi
}
function process_args()
{
while [ $# -gt 0 ]; do
case $1 in
*help|--h|-h)
help
exit 0
;;
# '': build with exist .config
# loader|trust|uboot: pack image
# debug*|map|sym|elf*|nm: debug command
# env: build env tool
# itb: pack itb image
# fit: pack non-secure uboot.img && boot.img
''|loader|trust|uboot|debug*|itb|env|fit|map|sym|elf*|nm)
if [ "$2" == "spl" -o "$2" == "tpl" ]; then
ARG_TSPL=$2
shift 1
fi
shift 1
;;
# trust/loader ini files for packing trust.img/loader.img
*.ini|*.INI)
if [ ! -f $1 ]; then
echo "ERROR: No $1"
fi
if grep -q 'CODE471_OPTION' $1 ; then
ARG_INI_LOADER=$1
elif grep -Eq ''BL31_OPTION'|'TOS'' $1 ; then
ARG_INI_TRUST=$1
fi
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
;;
--idblock) # pack idblock.bin
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
;;
*)
#1. FIT scripts args
NUM=$(${SCRIPT_FIT} --arg-check $1)
if [ ${NUM} -ne 0 ]; then
[ ${NUM} -eq 1 ] && ARG_LIST_FIT="${ARG_LIST_FIT} $1"
[ ${NUM} -eq 2 ] && ARG_LIST_FIT="${ARG_LIST_FIT} $1 $2"
shift ${NUM}
continue
#2. unwind function address
elif [ -z $(echo $1 | sed 's/[0-9,a-f,A-F,x,X,-]//g') ]; then
ARG_FUNCADDR=$1
#3. make defconfig
else
ARG_BOARD=$1
if [ ! -f configs/${ARG_BOARD}_defconfig -a ! -f configs/${ARG_BOARD}.config ]; then
echo -e "\n${SUPPORT_LIST}\n"
echo "ERROR: No configs/${ARG_BOARD}_defconfig"
exit 1
elif [ -f configs/${ARG_BOARD}.config ]; then
BASE1_DEFCONFIG=`sed -n "/CONFIG_BASE_DEFCONFIG=/s/CONFIG_BASE_DEFCONFIG=//p" configs/${ARG_BOARD}.config |tr -d '\r' | tr -d '"'`
BASE0_DEFCONFIG=`sed -n "/CONFIG_BASE_DEFCONFIG=/s/CONFIG_BASE_DEFCONFIG=//p" configs/${BASE1_DEFCONFIG} |tr -d '\r' | tr -d '"'`
MAKE_CMD="make ${BASE0_DEFCONFIG} ${BASE1_DEFCONFIG} ${ARG_BOARD}.config -j${JOB}"
echo "## ${MAKE_CMD}"
make ${BASE0_DEFCONFIG} ${BASE1_DEFCONFIG} ${ARG_BOARD}.config ${OPTION}
else
MAKE_CMD="make ${ARG_BOARD}_defconfig -j${JOB}"
echo "## ${MAKE_CMD}"
make ${ARG_BOARD}_defconfig ${OPTION}
fi
fi
shift 1
;;
esac
done
if [ ! -f .config ]; then
echo
echo "ERROR: No .config"
help
exit 1
fi
}
function select_toolchain()
{
if grep -q '^CONFIG_ARM64=y' .config ; then
if [ -d ${TOOLCHAIN_ARM64} ]; then
absolute_path=$(cd `dirname ${TOOLCHAIN_ARM64}`; pwd)
TOOLCHAIN_NM=${absolute_path}/bin/${NM_ARM64}
TOOLCHAIN_GCC=${absolute_path}/bin/${GCC_ARM64}
TOOLCHAIN_OBJDUMP=${absolute_path}/bin/${OBJ_ARM64}
TOOLCHAIN_ADDR2LINE=${absolute_path}/bin/${ADDR2LINE_ARM64}
else
echo "ERROR: No toolchain: ${TOOLCHAIN_ARM64}"
exit 1
fi
else
if [ -d ${TOOLCHAIN_ARM32} ]; then
absolute_path=$(cd `dirname ${TOOLCHAIN_ARM32}`; pwd)
TOOLCHAIN_NM=${absolute_path}/bin/${NM_ARM32}
TOOLCHAIN_GCC=${absolute_path}/bin/${GCC_ARM32}
TOOLCHAIN_OBJDUMP=${absolute_path}/bin/${OBJ_ARM32}
TOOLCHAIN_ADDR2LINE=${absolute_path}/bin/${ADDR2LINE_ARM32}
else
echo "ERROR: No toolchain: ${TOOLCHAIN_ARM32}"
exit 1
fi
fi
}
#
# We select chip info to do:
# 1. RKCHIP: fixup platform configure
# 2. RKCHIP_LOADER: search ini file to pack loader
# 3. RKCHIP_TRUST: search ini file to pack trust
# 4. RKCHIP_LABEL: show build message
#
function select_chip_info()
{
# Read RKCHIP firstly from .config
# The regular expression that matching:
# - PX30, PX3SE
# - RK????, RK????X
# - RV????
CHIP_PATTERN='^CONFIG_ROCKCHIP_[R,P][X,V,K][0-9ESX]{1,5}'
RKCHIP=`egrep -o ${CHIP_PATTERN} .config`
# default
RKCHIP=${RKCHIP##*_}
# fixup ?
for item in "${CHIP_TYPE_FIXUP_TABLE[@]}"
do
CONFIG_ROCKCHIP_XXX=`echo ${item} | awk '{ print $1 }'`
if grep -q "^${CONFIG_ROCKCHIP_XXX}=y" .config ; then
RKCHIP=`echo ${item} | awk '{ print $2 }'`
RKCHIP_LOADER=`echo ${item} | awk '{ print $3 }'`
RKCHIP_TRUST=`echo ${item} | awk '{ print $4 }'`
RKCHIP_LABEL=`echo ${item} | awk '{ print $5 }'`
fi
done
if [ "${RKCHIP_LOADER}" == "-" ]; then
RKCHIP_LOADER=${RKCHIP}
fi
if [ "${RKCHIP_TRUST}" == "-" ]; then
RKCHIP_TRUST=${RKCHIP}
fi
if [ "${RKCHIP_LABEL}" == "-" ]; then
RKCHIP_LABEL=${RKCHIP}
fi
}
# Priority: default < CHIP_CFG_FIXUP_TABLE() < make.sh args
function fixup_platform_configure()
{
U_KB="-" U_NUM="-" T_KB="-" T_NUM="-" SHA="-" RSA="-"
for item in "${CHIP_CFG_FIXUP_TABLE[@]}"
do
config_xxx=`echo ${item} | awk '{ print $1 }'`
if grep -q "^${config_xxx}=y" .config ; then
# <*> Fixup rsa/sha pack mode for platforms
RSA=`echo ${item} | awk '{ print $2 }'`
SHA=`echo ${item} | awk '{ print $3 }'`
# <*> Fixup images size pack for platforms, and ini file
if grep -q '^CONFIG_ARM64=y' .config ; then
U_KB=`echo ${item} | awk '{ print $4 }' | awk -F "," '{ print $1 }'`
T_KB=`echo ${item} | awk '{ print $4 }' | awk -F "," '{ print $2 }'`
U_NUM=`echo ${item} | awk '{ print $5 }' | awk -F "," '{ print $1 }'`
T_NUM=`echo ${item} | awk '{ print $5 }' | awk -F "," '{ print $2 }'`
else
U_KB=`echo ${item} | awk '{ print $6 }' | awk -F "," '{ print $1 }'`
T_KB=`echo ${item} | awk '{ print $6 }' | awk -F "," '{ print $2 }'`
U_NUM=`echo ${item} | awk '{ print $7 }' | awk -F "," '{ print $1 }'`
T_NUM=`echo ${item} | awk '{ print $7 }' | awk -F "," '{ print $2 }'`
# AArch32
if grep -q '^CONFIG_ARM64_BOOT_AARCH32=y' .config ; then
PADDING=`echo ${item} | awk '{ print $8 }'`
if [ "${PADDING}" != "-" ]; then
RKCHIP_LOADER=${RKCHIP_LOADER}${PADDING}
fi
PADDING=`echo ${item} | awk '{ print $9 }'`
if [ "${PADDING}" != "-" ]; then
RKCHIP_TRUST=${RKCHIP_TRUST}${PADDING}
fi
RKCHIP_LABEL=${RKCHIP_LABEL}"AARCH32"
fi
fi
fi
done
if [ "${SHA}" != "-" ]; then
PLAT_SHA="--sha ${SHA}"
fi
if [ "${RSA}" != "-" ]; then
PLAT_RSA="--rsa ${RSA}"
fi
if [ "${U_KB}" != "-" ]; then
PLAT_UBOOT_SIZE="--size ${U_KB} ${U_NUM}"
fi
if [ "${T_KB}" != "-" ]; then
PLAT_TRUST_SIZE="--size ${T_KB} ${T_NUM}"
fi
# args
if [ ! -z "${ARG_UBOOT_SIZE}" ]; then
PLAT_UBOOT_SIZE=${ARG_UBOOT_SIZE}
fi
if [ ! -z "${ARG_TRUST_SIZE}" ]; then
PLAT_TRUST_SIZE=${ARG_TRUST_SIZE}
fi
}
# Priority: default < CHIP_TYPE_FIXUP_TABLE() < defconfig < make.sh args
function select_ini_file()
{
# default
INI_LOADER=${RKBIN}/RKBOOT/${RKCHIP_LOADER}MINIALL.ini
if [ "${ARM64_TRUSTZONE}" == "y" ]; then
INI_TRUST=${RKBIN}/RKTRUST/${RKCHIP_TRUST}TRUST.ini
else
INI_TRUST=${RKBIN}/RKTRUST/${RKCHIP_TRUST}TOS.ini
fi
# defconfig
NAME=`sed -n "/CONFIG_LOADER_INI=/s/CONFIG_LOADER_INI=//p" .config |tr -d '\r' | tr -d '"'`
if [ ! -z "${NAME}" ]; then
INI_LOADER=${RKBIN}/RKBOOT/${NAME}
fi
NAME=`sed -n "/CONFIG_TRUST_INI=/s/CONFIG_TRUST_INI=//p" .config |tr -d '\r' | tr -d '"'`
if [ ! -z "${NAME}" ]; then
INI_TRUST=${RKBIN}/RKTRUST/${NAME}
fi
# args
if [ ! -z "${ARG_INI_TRUST}" ]; then
INI_TRUST=${ARG_INI_TRUST}
fi
if [ ! -z "${ARG_INI_LOADER}" ]; then
INI_LOADER=${ARG_INI_LOADER}
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
${SCRIPT_FIT} --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
;;
--idblock)
pack_idblock
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_idblock()
{
INI=${INI_LOADER}
if [ ! -f ${INI} ]; then
echo "ERROR: No ${INI}"
exit 1
fi
# chip
COMMON_H=`grep "_common.h:" include/autoconf.mk.dep | awk -F "/" '{ printf $3 }'`
PLAT=${COMMON_H%_*}
# file
SPL_BIN=${RKBIN}/`sed -n "/FlashBoot=/s/FlashBoot=//p" ${INI} | tr -d '\r'`
TPL_BIN=${RKBIN}/`sed -n "/FlashData=/s/FlashData=//p" ${INI} | tr -d '\r'`
if [ ! -z "${ARG_SPL_BIN}" ]; then
SPL_BIN=${ARG_SPL_BIN}
fi
if [ ! -z "${ARG_TPL_BIN}" ]; then
TPL_BIN=${ARG_TPL_BIN}
fi
# pack
rm idblock.bin -f
./tools/mkimage -n ${PLAT} -T rksd -d ${TPL_BIN}:${SPL_BIN} idblock.bin
echo "Input:"
echo " ${INI}"
echo " ${TPL_BIN}"
echo " ${SPL_BIN}"
echo
echo "Pack ${PLAT} idblock.bin okay!"
echo
}
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'`
if [ -z "${LOAD_ADDR}" ]; then
# upstream U-Boot
LOAD_ADDR=`grep CONFIG_SYS_TEXT_BASE include/generated/autoconf.h | awk '{ print $3 }' | tr -d '\r'`
fi
if [ -z "${LOAD_ADDR}" ]; then
echo "ERROR: No CONFIG_SYS_TEXT_BASE for u-boot";
exit 1
fi
${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
${SCRIPT_FIT} --uboot-itb --boot-itb ${ARG_LIST_FIT}
else
rm uboot.img trust*.img -f
${SCRIPT_FIT} --uboot-itb --no-vboot --no-rebuild ${ARG_LIST_FIT}
echo "pack uboot.img okay! Input: ${INI_TRUST}"
fi
}
function handle_args_late()
{
ARG_LIST_FIT="${ARG_LIST_FIT} --ini-trust ${INI_TRUST} --ini-loader ${INI_LOADER}"
}
function clean_files()
{
rm spl/u-boot-spl.dtb tpl/u-boot-tpl.dtb u-boot.dtb -f
rm spl/u-boot-spl tpl/u-boot-tpl u-boot -f
}
function pack_images()
{
if [ "${ARG_NO_PACK}" == "y" ]; then
return
fi
if [ "${PLAT_TYPE}" == "RKFW" ]; then
pack_uboot_image
pack_trust_image
pack_loader_image
elif [ "${PLAT_TYPE}" == "FIT" ]; then
pack_fit_image ${ARG_LIST_FIT}
fi
}
function finish()
{
echo
if [ "${ARG_BOARD}" == "" ]; then
echo "Platform ${RKCHIP_LABEL} is build OK, with exist .config"
else
echo "Platform ${RKCHIP_LABEL} is build OK, with new .config(${MAKE_CMD})"
fi
}
process_args $*
prepare
select_toolchain
select_chip_info
fixup_platform_configure
select_ini_file
handle_args_late
sub_commands
clean_files
make CROSS_COMPILE=${TOOLCHAIN_GCC} all --jobs=${JOB}
pack_images
finish
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/roger521/u-boot-rockchip.git
git@gitee.com:roger521/u-boot-rockchip.git
roger521
u-boot-rockchip
u-boot-rockchip
next-dev

搜索帮助

0d507c66 1850385 C8b1a773 1850385