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

31
make.sh
View File

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

View File

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