hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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/second
   cp ${OUT}/ramdisk images/
   cp ${OUT}/rk-kernel.dtb images/dtb
   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