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 -f *loader*.bin *download*.bin *idblock*.img 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 ! test -s ${ini}; then 41 continue; 42 elif ! grep -q '^TOS/' ${ini}; then 43 continue; 44 elif grep -q '^PATH=img/' ${ini}; then 45 continue; 46 fi 47 48 if [ -f "${ini}" ]; then 49 echo "pack Input: ${ini}" 50 51 # Parse orignal path 52 TOS=`sed -n "/TOS=/s/TOS=//p" ${ini}|tr -d '\r'` 53 TOS_TA=`sed -n "/TOSTA=/s/TOSTA=//p" ${ini}|tr -d '\r'` 54 55 # replace "./tools/rk_tools/" with "./" to compatible legacy ini content of rkdevelop branch 56 TOS=$(echo ${TOS} | sed "s/tools\/rk_tools\//\.\//g") 57 TOS_TA=$(echo ${TOS_TA} | sed "s/tools\/rk_tools\//\.\//g") 58 59 if [ x${TOS_TA} != x -a x${TOS} != x ]; then 60 ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000 61 ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust_with_ta.img 0x68400000 62 elif [ ${TOS} ]; then 63 ./tools/loaderimage --pack --trustos ${TOS} ./trust.img 0x68400000 64 elif [ ${TOS_TA} ]; then 65 ./tools/loaderimage --pack --trustos ${TOS_TA} ./trust.img 0x68400000 66 else 67 exit 1 68 fi 69 rm -f trust*.img 70 echo 71 fi 72 done 73 74# Pack 64-bit trust 75 files=`ls ./RKTRUST/*TRUST*.ini` 76 for ini in ${files} 77 do 78 if grep -q '^PATH=img/' ${ini}; then 79 continue; 80 fi 81 82 if [ -f "${ini}" ]; then 83 echo "pack Input: ${ini}" 84 ./tools/trust_merger ${ini} 85 rm trust*.img 86 echo 87 fi 88 done 89} 90 91check_dirty() 92{ 93 for file in `find -name '*spl*.bin' -o -name '*tpl*.bin' -o -name '*usbplug*.bin'`; do 94 if strings ${file} | grep '\-dirty ' ; then 95 echo "ERROR: ${file} is dirty" 96 exit 1 97 fi 98 done 99} 100 101check_stripped() 102{ 103 for elf in `find -name '*bl31*.elf'`; do 104 info=`file ${elf}` 105 if echo ${info} | grep -q "not stripped" ; then 106 echo "ERROR: ${elf} is not stripped" 107 exit 1 108 fi 109 done 110} 111 112finish() 113{ 114 echo "Packing loader and trust successfully." 115 echo 116} 117 118check_dirty 119check_stripped 120pack_loader_image 121pack_trust_image 122finish 123