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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -e
 
pack_loader_image()
{
   local files ini
 
   files=`ls ./RKBOOT/*MINIALL*.ini`
   for ini in ${files}
   do
       if [ -f "${ini}" ]; then
           # Ignore unused
           if [ "${ini}" = "./RKBOOT/RK302AMINIALL.ini" -o \
                "${ini}" = "./RKBOOT/RK30BMINIALL.ini" -o \
                "${ini}" = "./RKBOOT/RK30MINIALL.ini" -o \
                "${ini}" = "./RKBOOT/RK310BMINIALL.ini" ]; then
               continue;
           fi
 
           if grep  -q '^PATH=img/' ${ini}; then
               continue;
           fi
 
           echo "pack Input: ${ini}"
           ./tools/boot_merger ${ini}
           rm -f *loader*.bin *download*.bin *idblock*.img
           echo
       fi
   done
}
 
pack_trust_image()
{
   local files ini TOS TOS_TA
 
# Pack 32-bit trust
   files=`ls ./RKTRUST/*TOS*.ini`
   for ini in ${files}
   do
       if ! test -s ${ini}; then
           continue;
       elif ! grep  -q '^TOS/' ${ini}; then
           continue;
       elif grep  -q '^PATH=img/' ${ini}; then
           continue;
       fi
 
       if [ -f "${ini}" ]; then
           echo "pack Input: ${ini}"
 
           # Parse orignal path
           TOS=`sed -n "/TOS=/s/TOS=//p" ${ini}|tr -d '\r'`
           TOS_TA=`sed -n "/TOSTA=/s/TOSTA=//p" ${ini}|tr -d '\r'`
 
           # replace "./tools/rk_tools/" with "./" to compatible legacy ini content of rkdevelop branch
           TOS=$(echo ${TOS} | sed "s/tools\/rk_tools\//\.\//g")
           TOS_TA=$(echo ${TOS_TA} | sed "s/tools\/rk_tools\//\.\//g")
 
           if [ x${TOS_TA} != x -a x${TOS} != x ]; then
               ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000
               ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust_with_ta.img 0x68400000
           elif [ ${TOS} ]; then
               ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000
           elif [ ${TOS_TA} ]; then
               ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust.img 0x68400000
           else
               exit 1
           fi
           rm -f trust*.img
           echo
       fi
   done
 
# Pack 64-bit trust
   files=`ls ./RKTRUST/*TRUST*.ini`
   for ini in ${files}
   do
       if grep  -q '^PATH=img/' ${ini}; then
           continue;
       fi
 
       if [ -f "${ini}" ]; then
           echo "pack Input: ${ini}"
           ./tools/trust_merger ${ini}
           rm trust*.img
           echo
       fi
   done
}
 
check_dirty()
{
   for file in `find -name '*spl*.bin' -o -name '*tpl*.bin' -o -name '*usbplug*.bin'`; do
       if strings ${file} | grep '\-dirty ' ; then
           echo "ERROR: ${file} is dirty"
           exit 1
       fi
   done
}
 
check_stripped()
{
   for elf in `find -name '*bl31*.elf'`; do
       info=`file ${elf}`
       if echo ${info} | grep -q "not stripped" ; then
           echo "ERROR: ${elf} is not stripped"
           exit 1
       fi
   done
}
 
finish()
{
   echo "Packing loader and trust successfully."
   echo
}
 
check_dirty
check_stripped
pack_loader_image
pack_trust_image
finish