From d4f6d8e395d7ca566a7c9179d5632ddf5e3b200b Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Sat, 14 Nov 2020 08:23:32 +0000 Subject: [PATCH] scripts: android2fit.sh transform Android image to FIT image Signed-off-by: Joseph Chen Change-Id: I0c448d101aa4912398efa528275119132f434f69 --- scripts/android2fit.sh | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 scripts/android2fit.sh diff --git a/scripts/android2fit.sh b/scripts/android2fit.sh new file mode 100755 index 0000000000..cb7d2c90d7 --- /dev/null +++ b/scripts/android2fit.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# +# Copyright (c) 2020 Rockchip Electronics Co., Ltd +# +# SPDX-License-Identifier: GPL-2.0 +# +set -e + +OUT="out" + +function usage() +{ + echo + echo "usage:" + echo " $0 -f [Android boot.img] -o [FIT boot.img]" + echo +} + +function args_process() +{ + if [ $# -ne 4 ]; then + usage + exit 1 + fi + + while [ $# -gt 0 ]; do + case $1 in + -f) + BOOT_IMG=$2 + shift 2 + ;; + -o) + FIT_IMG=$2 + shift 2 + ;; + *) + usage + exit 1 + ;; + esac + done + + if [ ! -f ${BOOT_IMG} ]; then + echo "ERROR: No ${ITB}" + exit 1 + fi +} + +function android2fit() +{ + if ! file ${BOOT_IMG} | grep "Android bootimg" ; then + echo "ERROR: ${BOOT_IMG} is not an Android Image" + file ${BOOT_IMG} + exit 1 + fi + + rm ${OUT}/ -rf + ./scripts/unpack_bootimg --boot_img ${BOOT_IMG} --out ${OUT}/ + ./scripts/unpack_resource.sh ${OUT}/second ${OUT}/ + mv ${OUT}/second ${OUT}/resource + + rm images/ -rf && mkdir -p images/ + cp ${OUT}/kernel images/ + cp ${OUT}/resource images/ + cp ${OUT}/ramdisk images/ + cp ${OUT}/rk-kernel.dtb images/ + rm ${OUT}/ -rf + + ./make.sh fit + if [ "boot.img" != ${FIT_IMG} ]; then + mv boot.img ${FIT_IMG} + fi + + echo "Transform OK: Android(${BOOT_IMG}) ==> FIT(${FIT_IMG}) is ready" + echo +} + +args_process $* +android2fit