hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
 
set -e
 
SCRIPT_DIR=$(dirname $(realpath $BASH_SOURCE))
TOP_DIR=$(realpath $SCRIPT_DIR/../../..)
cd $TOP_DIR
 
source $TOP_DIR/device/rockchip/.BoardConfig.mk
ROCKDEV=$TOP_DIR/rockdev
 
fdt=0
kernel=0
ramdisk=0
resource=0
OUTPUT_TARGET_IMAGE="$1"
src_its_file="$2"
ramdisk_file_path="$3"
kernel_image="$4"
target_its_file="$ROCKDEV/.tmp_its"
 
if [ -z $kernel_image ]; then
   if [ -z $RK_KERNEL_ZIMG ]; then
       kernel_image=$TOP_DIR/$RK_KERNEL_IMG
   else
       kernel_image=$TOP_DIR/$RK_KERNEL_ZIMG
   fi
fi
 
if [ ! -f $src_its_file ]; then
   echo "Not Fount $src_its_file ..."
   exit -1
fi
 
if [ "$RK_ARCH" == "arm" ]; then
   kernel_dtb_file="kernel/arch/arm/boot/dts/$RK_KERNEL_DTS.dtb"
else
   kernel_dtb_file="kernel/arch/arm64/boot/dts/rockchip/$RK_KERNEL_DTS.dtb"
fi
 
rm -f $target_its_file
mkdir -p "`dirname $target_its_file`"
 
while read line
do
   ############################# generate fdt path
   if [ $fdt -eq 1 ];then
       echo "data = /incbin/(\"$TOP_DIR/$kernel_dtb_file\");" >> $target_its_file
       fdt=0
       continue
   fi
   if echo $line | grep -w "^fdt" |grep -v ";"; then
       fdt=1
       echo "$line" >> $target_its_file
       continue
   fi
 
   ############################# generate kernel image path
   if [ $kernel -eq 1 ];then
       echo "data = /incbin/(\"$kernel_image\");" >> $target_its_file
       kernel=0
       continue
   fi
   if echo $line | grep -w "^kernel" |grep -v ";"; then
       kernel=1
       echo "$line" >> $target_its_file
       continue
   fi
 
   ############################# generate ramdisk path
   if [ -f $ramdisk_file_path ]; then
       if [ $ramdisk -eq 1 ];then
           echo "data = /incbin/(\"$ramdisk_file_path\");" >> $target_its_file
           ramdisk=0
           continue
       fi
       if echo $line | grep -w "^ramdisk" |grep -v ";"; then
           ramdisk=1
           echo "$line" >> $target_its_file
           continue
       fi
   fi
 
   ############################# generate resource path
   if [ $resource -eq 1 ];then
       echo "data = /incbin/(\"$TOP_DIR/kernel/resource.img\");" >> $target_its_file
       resource=0
       continue
   fi
   if echo $line | grep -w "^resource" |grep -v ";"; then
       resource=1
       echo "$line" >> $target_its_file
       continue
   fi
 
   if [ "$RK_RAMDISK_SECURITY_BOOTUP" = "true" ];then
       if echo $line | grep -wq "uboot-ignore"; then
           echo "Enable Security boot, Skip uboot-ignore ..."
           continue
       fi
   fi
 
   echo "$line" >> $target_its_file
done < $src_its_file
 
$TOP_DIR/rkbin/tools/mkimage -f $target_its_file  -E -p 0x800 $OUTPUT_TARGET_IMAGE
rm -f $target_its_file