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