make/fit.sh: simplify and support sign uboot.img only

Remove some unnecessary args.

Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Change-Id: I03c8a59f76bb79af07af399ad4cf479d7258cec5
This commit is contained in:
Joseph Chen 2020-10-25 13:42:11 +08:00
parent 811f8a32ef
commit 2d11b8685e
2 changed files with 48 additions and 71 deletions

39
make.sh
View File

@ -209,8 +209,8 @@ function process_args()
ARG_UBOOT_SIZE="--size $2 $3"
shift 3
;;
--no-pack) # FIT: build but not pack image
ARG_NO_PACK="y"
--raw-compile) # FIT: build but not pack image
ARG_RAW_COMPILE="y"
shift 1
;;
--no-uboot) # FIT: pack uboot.img without u-boot
@ -230,7 +230,7 @@ function process_args()
;;
*)
#1. FIT scripts args
NUM=$(${SCRIPT_FIT} --arg-check $1)
NUM=$(${SCRIPT_FIT} --args $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"
@ -480,7 +480,7 @@ function sub_commands()
;;
fit)
# Non-secure
${SCRIPT_FIT} --uboot-itb --boot-itb --no-vboot ${ARG_LIST_FIT}
${SCRIPT_FIT} --boot_img_dir images/ ${ARG_LIST_FIT}
exit 0
;;
uboot)
@ -723,15 +723,10 @@ function pack_fit_image()
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
rm uboot.img trust*.img -rf
${SCRIPT_FIT} ${ARG_LIST_FIT}
echo "pack uboot.img okay! Input: ${INI_TRUST}"
}
function handle_args_late()
@ -747,16 +742,14 @@ function clean_files()
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}
if [ "${ARG_RAW_COMPILE}" != "y" ]; then
if [ "${PLAT_TYPE}" == "FIT" ]; then
pack_fit_image ${ARG_LIST_FIT}
else
pack_uboot_image
pack_trust_image
pack_loader_image
fi
fi
}

View File

@ -55,14 +55,10 @@ function help()
echo " --version-boot <decimal integer>"
echo " --ini-trust"
echo " --ini-loader"
echo " --no-vboot"
echo " --no-check"
echo " --no-rebuild"
echo " --spl-new"
echo " --uboot-itb"
echo " --boot-itb"
echo " --boot_img"
echo " --arg-check"
echo " --args"
echo
}
@ -96,7 +92,7 @@ function check_its()
function validate_arg()
{
case $1 in
--uboot-itb|--boot-itb|--no-vboot|--no-rebuild|--no-check|--spl-new)
--no-check|--spl-new)
shift=1
;;
--ini-trust|--ini-loader|--rollback-index-boot|--rollback-index-uboot|--boot_img|--version-uboot|--version-boot)
@ -118,25 +114,17 @@ function fit_process_args()
while [ $# -gt 0 ]; do
case $1 in
--arg-check)
--args)
ARG_VALIDATE=$2
shift 2
;;
--uboot-itb)
ARG_PACK_UBOOT="y"
shift 1
--boot_img) # boot.img
ARG_BOOT_IMG=$2
shift 2
;;
--boot-itb)
ARG_PACK_BOOT="y"
shift 1
;;
--no-vboot) # Force to build non-vboot image
ARG_NO_VBOOT="y"
shift 1
;;
--no-rebuild) # No rebuild with "./make.sh"
ARG_NO_REBUILD="y"
shift 1
--boot_img_dir) # boot.img components directory
ARG_BOOT_IMG_DIR=$2
shift 2
;;
--no-check) # No hostcc fit signature check
ARG_NO_CHECK="y"
@ -164,10 +152,6 @@ function fit_process_args()
arg_check_decimal $2
shift 2
;;
--boot_img) # external boot.img
ARG_EXT_BOOT=$2
shift 2
;;
--version-uboot)
ARG_VER_UBOOT=$2
arg_check_decimal $2
@ -184,17 +168,19 @@ function fit_process_args()
;;
esac
done
if grep -q '^CONFIG_FIT_SIGNATURE=y' .config ; then
ARG_SIGN="y"
fi
}
function fit_rebuild()
function fit_raw_compile()
{
# Verified-boot: should rebuild code but don't need to repack images.
if [ "${ARG_NO_REBUILD}" != "y" ]; then
./make.sh --no-pack # Build but not pack loader/trust/uboot, etc.
if [ "${ARG_SIGN}" == "y" ]; then
./make.sh --raw-compile
fi
rm ${FIT_DIR} -rf
mkdir -p ${FIT_DIR}
rm ${FIT_DIR} -rf && mkdir -p ${FIT_DIR}
}
function fit_gen_uboot_itb()
@ -202,7 +188,7 @@ function fit_gen_uboot_itb()
./make.sh itb ${ARG_INI_TRUST} >/dev/null 2>&1
check_its ${ITS_UBOOT}
if [ "${ARG_NO_VBOOT}" == "y" ]; then
if [ "${ARG_SIGN}" != "y" ]; then
${MKIMAGE} -f ${ITS_UBOOT} -E -p ${OFFS_NS_UBOOT} ${ITB_UBOOT} -v ${ARG_VER_UBOOT}
if [ "${ARG_SPL_NEW}" == "y" ]; then
./make.sh --spl ${ARG_INI_LOADER}
@ -240,7 +226,7 @@ function fit_gen_uboot_itb()
# u-boot.dtb must contains rsa key
if ! fdtget -l ${UBOOT_DTB} /signature >/dev/null 2>&1 ; then
${MKIMAGE} -f ${ITS_UBOOT} -k ${KEY_DIR} -K ${UBOOT_DTB} -E -p ${OFFS_S_UBOOT} -r ${ITB_UBOOT} -v ${ARG_VER_UBOOT}
echo "Adding RSA public key into ${UBOOT_DTB}"
echo "## Adding RSA public key into ${UBOOT_DTB}"
fi
# Pack
@ -308,8 +294,8 @@ function fit_gen_uboot_itb()
function fit_gen_boot_itb()
{
if [ ! -z ${ARG_EXT_BOOT} ]; then
${FIT_UNPACK} -f ${ARG_EXT_BOOT} -o ${FIT_DIR}/unpack
if [ ! -z ${ARG_BOOT_IMG} ]; then
${FIT_UNPACK} -f ${ARG_BOOT_IMG} -o ${FIT_DIR}/unpack
ITS_BOOT="${FIT_DIR}/unpack/image.its"
else
compression=`awk -F"," '/COMPRESSION=/ { printf $1 }' ${ARG_INI_TRUST} | tr -d ' ' | cut -c 13-`
@ -320,7 +306,7 @@ function fit_gen_boot_itb()
check_its ${ITS_BOOT}
fi
if [ "${ARG_NO_VBOOT}" == "y" ]; then
if [ "${ARG_SIGN}" != "y" ]; then
${MKIMAGE} -f ${ITS_BOOT} -E -p ${OFFS_NS_BOOT} ${ITB_BOOT} -v ${ARG_VER_BOOT}
else
if [ ! -f ${RSA_PRI_KEY} ]; then
@ -436,7 +422,7 @@ function fit_gen_boot_img()
function fit_msg_uboot()
{
if [ "${ARG_NO_VBOOT}" == "y" ]; then
if [ "${ARG_SIGN}" != "y" ]; then
MSG_SIGN="no-signed"
else
MSG_SIGN="signed"
@ -456,7 +442,7 @@ function fit_msg_uboot()
function fit_msg_boot()
{
if [ "${ARG_NO_VBOOT}" == "y" ]; then
if [ "${ARG_SIGN}" != "y" ]; then
MSG_SIGN="no-signed"
else
MSG_SIGN="signed"
@ -480,18 +466,18 @@ function fit_msg_loader()
echo "Image(no-signed): ${LOADER} (with spl, ddr, usbplug) is ready"
}
function fit_vboot_uboot()
function fit_generate_uboot()
{
fit_rebuild
fit_raw_compile
fit_gen_uboot_itb
fit_gen_uboot_img
echo
fit_msg_uboot
}
function fit_vboot()
function fit_generate_uboot_boot()
{
fit_rebuild
fit_raw_compile
fit_gen_boot_itb
fit_gen_boot_img
fit_gen_uboot_itb
@ -507,11 +493,9 @@ function fit_vboot()
fit_process_args $*
if [ ! -z "${ARG_VALIDATE}" ]; then
validate_arg ${ARG_VALIDATE}
elif [ "${ARG_PACK_UBOOT}${ARG_PACK_BOOT}" == "yy" ]; then
fit_vboot
elif [ "${ARG_PACK_UBOOT}" == "y" ]; then
fit_vboot_uboot
elif [ "${ARG_PACK_BOOT}" == "y" ]; then
fit_vboot_boot
elif [ ! -z "${ARG_BOOT_IMG}" ]; then
fit_generate_uboot_boot
else
fit_generate_uboot
fi