xref: /rkbin/scripts/checkpatch.sh (revision 9d00b70a2e44e54c4d5f21932e60529b5635d24b)
1#!/bin/bash
2set -e
3
4pack_loader_image()
5{
6	local files ini
7
8	files=`ls ./RKBOOT/*MINIALL*.ini`
9	for ini in ${files}
10	do
11		if [ -f "${ini}" ]; then
12			# Ignore unused
13			if [ "${ini}" = "./RKBOOT/RK302AMINIALL.ini" -o \
14				 "${ini}" = "./RKBOOT/RK30BMINIALL.ini" -o \
15				 "${ini}" = "./RKBOOT/RK30MINIALL.ini" -o \
16				 "${ini}" = "./RKBOOT/RK310BMINIALL.ini" ]; then
17				continue;
18			fi
19
20			if grep  -q '^PATH=img/' ${ini}; then
21				continue;
22			fi
23
24			echo "pack Input: ${ini}"
25			./tools/boot_merger ${ini}
26			rm *loader*.bin
27			echo
28		fi
29	done
30}
31
32pack_trust_image()
33{
34	local files ini TOS TOS_TA
35
36# Pack 32-bit trust
37	files=`ls ./RKTRUST/*TOS*.ini`
38	for ini in ${files}
39	do
40		if grep  -q '^PATH=img/' ${ini}; then
41			continue;
42		fi
43
44		if [ -f "${ini}" ]; then
45			echo "pack Input: ${ini}"
46
47			# Parse orignal path
48			TOS=`sed -n "/TOS=/s/TOS=//p" ${ini}|tr -d '\r'`
49			TOS_TA=`sed -n "/TOSTA=/s/TOSTA=//p" ${ini}|tr -d '\r'`
50
51			# replace "./tools/rk_tools/" with "./" to compatible legacy ini content of rkdevelop branch
52			TOS=$(echo ${TOS} | sed "s/tools\/rk_tools\//\.\//g")
53			TOS_TA=$(echo ${TOS_TA} | sed "s/tools\/rk_tools\//\.\//g")
54
55			if [ x${TOS_TA} != x -a x${TOS} != x ]; then
56				./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000
57				./tools/loaderimage --pack --trustos ${TOS_TA} ./trust_with_ta.img 0x68400000
58			elif [ ${TOS} ]; then
59				./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000
60			elif [ ${TOS_TA} ]; then
61				./tools/loaderimage --pack --trustos ${TOS_TA} ./trust.img 0x68400000
62			else
63				exit 1
64			fi
65			rm trust*.img
66			echo
67		fi
68	done
69
70# Pack 64-bit trust
71	files=`ls ./RKTRUST/*TRUST*.ini`
72	for ini in ${files}
73	do
74		if grep  -q '^PATH=img/' ${ini}; then
75			continue;
76		fi
77
78		if [ -f "${ini}" ]; then
79			echo "pack Input: ${ini}"
80			./tools/trust_merger ${ini}
81			rm trust*.img
82			echo
83		fi
84	done
85}
86
87check_dirty()
88{
89	for file in `find -name '*spl*.bin' -o -name '*tpl*.bin' -o -name '*usbplug*.bin'`; do
90		if strings ${file} | grep '\-dirty ' ; then
91			echo "ERROR: ${file} is dirty"
92			exit 1
93		fi
94	done
95}
96
97finish()
98{
99	echo "Packing loader and trust successfully."
100	echo
101}
102
103check_dirty
104pack_loader_image
105pack_trust_image
106finish
107