^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) # Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) set -e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) usage() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) cat >&2 << USAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) usage: $0 [-h] --dtb DTB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) optional arguments:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) -h, --help show this help message and exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) --dtb DTB the dtb file name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) USAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # Parse command-line arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) while [ $# -gt 0 ]; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) case $1 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) --dtb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) DTB=$2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) shift 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) -h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) --help)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) exit 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) shift
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) srctree=${srctree-"."}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) objtree=${objtree-"."}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if [ "${ARCH}" == "" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if [ "$($srctree/scripts/config --state CONFIG_ARM)" == "y" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) ARCH=arm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ARCH=arm64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) LOGO_PATH=${srctree}/logo.bmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) [ -f ${LOGO_PATH} ] && LOGO=logo.bmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) LOGO_KERNEL_PATH=${srctree}/logo_kernel.bmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) [ -f ${LOGO_KERNEL_PATH} ] && LOGO_KERNEL=logo_kernel.bmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) KERNEL_IMAGE_PATH=${objtree}/arch/${ARCH}/boot/Image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) KERNEL_IMAGE_ARG="--kernel ${KERNEL_IMAGE_PATH}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) if [ "${ARCH}" == "arm" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) DTB_PATH=${objtree}/arch/arm/boot/dts/${DTB}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ZIMAGE=zImage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) DTB_PATH=${objtree}/arch/arm64/boot/dts/rockchip/${DTB}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) ZIMAGE=Image.lz4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) KERNEL_ZIMAGE_PATH=${objtree}/arch/${ARCH}/boot/${ZIMAGE}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) KERNEL_ZIMAGE_ARG="--kernel ${KERNEL_ZIMAGE_PATH}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if [ ! -f ${DTB_PATH} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) echo "No dtb" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) OUT=out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ITB=${BOOT_IMG}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ITS=${OUT}/boot.its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) MKIMAGE=${MKIMAGE-"mkimage"}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) MKIMAGE_ARG="-E -p 0x800"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) make_boot_img()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) RAMDISK_IMG_PATH=${objtree}/ramdisk.img
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) [ -f ${RAMDISK_IMG_PATH} ] && RAMDISK_IMG=ramdisk.img && RAMDISK_ARG="--ramdisk ${RAMDISK_IMG_PATH}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ${srctree}/scripts/mkbootimg \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) ${KERNEL_IMAGE_ARG} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) ${RAMDISK_ARG} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) --second resource.img \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) -o boot.img && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) echo " Image: boot.img (with Image ${RAMDISK_IMG} resource.img) is ready";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ${srctree}/scripts/mkbootimg \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ${KERNEL_ZIMAGE_ARG} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) ${RAMDISK_ARG} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) --second resource.img \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) -o zboot.img && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) echo " Image: zboot.img (with ${ZIMAGE} ${RAMDISK_IMG} resource.img) is ready"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) repack_boot_img()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) ${srctree}/scripts/repack-bootimg \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) --boot_img ${BOOT_IMG} --out ${OUT} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ${KERNEL_IMAGE_ARG} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) --second resource.img \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) --dtb ${DTB_PATH} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) -o boot.img &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) echo " Image: boot.img (${BOOT_IMG} + Image) is ready";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) ${srctree}/scripts/repack-bootimg \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) --boot_img ${BOOT_IMG} --out ${OUT} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) ${KERNEL_ZIMAGE_ARG} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) --second resource.img \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) --dtb ${DTB_PATH} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) -o zboot.img && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) echo " Image: zboot.img (${BOOT_IMG} + ${ZIMAGE}) is ready"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) check_mkimage()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) MKIMAGE=$(type -p ${MKIMAGE} || true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if [ -z "${MKIMAGE}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) # Doesn't exist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) echo '"mkimage" command not found - U-Boot images will not be built' >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) exit 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) unpack_itb()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) rm -rf ${OUT}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) mkdir -p ${OUT}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) for NAME in $(fdtget -l ${ITB} /images)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) # generate image
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) NODE="/images/${NAME}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) OFFS=$(fdtget -ti ${ITB} ${NODE} data-position)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) SIZE=$(fdtget -ti ${ITB} ${NODE} data-size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) if [ -z ${OFFS} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) if [ ${SIZE} -ne 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) dd if=${ITB} of=${OUT}/${NAME} bs=${SIZE} count=1 skip=${OFFS} iflag=skip_bytes >/dev/null 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) touch ${OUT}/${NAME}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) [ ! -f ${OUT}/kernel ] && echo "FIT ${ITB} no kernel" >&2 && exit 1 || true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) gen_its()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) TMP_ITB=${OUT}/boot.tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) # add placeholder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) cp ${ITB} ${TMP_ITB}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) for NAME in $(fdtget -l ${ITB} /images); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) fdtput -t s ${TMP_ITB} /images/${NAME} data "/INCBIN/(${NAME})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) dtc -I dtb -O dts ${TMP_ITB} -o ${ITS} >/dev/null 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) rm -f ${TMP_ITB}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) # fixup placeholder: data = "/INCBIN/(...)"; -> data = /incbin/("...");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) sed -i "s/\"\/INCBIN\/(\(.*\))\"/\/incbin\/(\"\1\")/" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) # remove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) sed -i "/memreserve/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) sed -i "/timestamp/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) sed -i "/data-size/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) sed -i "/data-position/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) sed -i "/value/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) sed -i "/hashed-strings/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) sed -i "/hashed-nodes/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) sed -i "/signer-version/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) sed -i "/signer-name/d" ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) gen_itb()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) [ -f ${OUT}/fdt ] && cp -a ${DTB_PATH} ${OUT}/fdt && FDT=" + ${DTB}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) [ -f ${OUT}/resource ] && cp -a resource.img ${OUT}/resource && RESOURCE=" + resource.img"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) COMP=$(fdtget ${ITB} /images/kernel compression)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) case "${COMP}" in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) gzip) EXT=".gz";;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) lz4) EXT=".lz4";;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) bzip2) EXT=".bz2";;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) lzma) EXT=".lzma";;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) lzo) EXT=".lzo";;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) cp -a ${KERNEL_IMAGE_PATH}${EXT} ${OUT}/kernel && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} boot.img >/dev/null && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) echo " Image: boot.img (FIT ${BOOT_IMG} + Image${EXT}${FDT}${RESOURCE}) is ready";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if [ "${EXT}" == "" ] && [ -f ${KERNEL_ZIMAGE_PATH} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) cp -a ${KERNEL_ZIMAGE_PATH} ${OUT}/kernel && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) ${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} zboot.img >/dev/null && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) echo " Image: zboot.img (FIT ${BOOT_IMG} + zImage${FDT}${RESOURCE}) is ready";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) repack_itb()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) check_mkimage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) unpack_itb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) gen_its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) gen_itb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) # Create U-Boot FIT Image use ${BOOT_ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) make_fit_boot_img()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) ITS=${OUT}/boot.its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) check_mkimage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) mkdir -p ${OUT}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) rm -f ${OUT}/fdt ${OUT}/kernel ${OUT}/resource ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) cp -a ${BOOT_ITS} ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) cp -a ${DTB_PATH} ${OUT}/fdt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) cp -a ${KERNEL_ZIMAGE_PATH} ${OUT}/kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) cp -a resource.img ${OUT}/resource
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if [ "${ARCH}" == "arm64" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) sed -i -e 's/arch = ""/arch = "arm64"/g' -e 's/compression = ""/compression = "lz4"/' ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) sed -i -e 's/arch = ""/arch = "arm"/g' -e 's/compression = ""/compression = "none"/' ${ITS}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) FIT_DESC=$(${MKIMAGE} ${MKIMAGE_ARG} -f ${ITS} boot.img | grep "FIT description" | sed 's/FIT description: //')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) echo " Image: boot.img (${FIT_DESC}) is ready";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if [ -x ${srctree}/scripts/bmpconvert ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) if [ -f ${LOGO_PATH} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ${srctree}/scripts/bmpconvert ${LOGO_PATH};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if [ -f ${LOGO_KERNEL_PATH} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) ${srctree}/scripts/bmpconvert ${LOGO_KERNEL_PATH};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if [ "${srctree}" != "${objtree}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if [ -f ${LOGO_PATH} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) cp -a ${LOGO_PATH} ${objtree}/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) if [ -f ${LOGO_KERNEL_PATH} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) cp -a ${LOGO_KERNEL_PATH} ${objtree}/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) scripts/resource_tool ${DTB_PATH} ${LOGO} ${LOGO_KERNEL} >/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) echo " Image: resource.img (with ${DTB} ${LOGO} ${LOGO_KERNEL}) is ready"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if [ -f "${BOOT_IMG}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) if file -L -p -b ${BOOT_IMG} | grep -q 'Device Tree Blob' ; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) repack_itb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) elif [ -x ${srctree}/scripts/repack-bootimg ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) repack_boot_img;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) elif [ -f "${BOOT_ITS}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) make_fit_boot_img;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) elif [ -x ${srctree}/scripts/mkbootimg ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) make_boot_img;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) fi