1#!/bin/bash 2set -e 3BIN_PATH_FIXUP="--replace tools/rk_tools/ ./" 4 5pack_loader_image() 6{ 7 local files ini 8 9 files=`ls ./RKBOOT/*MINIALL*.ini` 10 for ini in $files 11 do 12 if [ -f "$ini" ]; then 13 # Ignore unused 14 if [ "$ini" = "./RKBOOT/RK302AMINIALL.ini" -o \ 15 "$ini" = "./RKBOOT/RK30BMINIALL.ini" -o \ 16 "$ini" = "./RKBOOT/RK30MINIALL.ini" -o \ 17 "$ini" = "./RKBOOT/RK310BMINIALL.ini" ]; then 18 continue; 19 fi 20 21 echo "pack Input: $ini" 22 ./tools/boot_merger ${BIN_PATH_FIXUP} $ini 23 rm *loader*.bin 24 echo 25 fi 26 done 27} 28 29pack_trust_image() 30{ 31 local files ini TOS TOS_TA 32 33# Pack 32-bit trust 34 files=`ls ./RKTRUST/*TOS*.ini` 35 for ini in $files 36 do 37 if [ -f "$ini" ]; then 38 echo "pack Input: $ini" 39 40 # Parse orignal path 41 TOS=`sed -n "/TOS=/s/TOS=//p" $ini|tr -d '\r'` 42 TOS_TA=`sed -n "/TOSTA=/s/TOSTA=//p" $ini|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 trust*.img 59 echo 60 fi 61 done 62 63# Pack 64-bit trust 64 files=`ls ./RKTRUST/*TRUST*.ini` 65 for ini in $files 66 do 67 if [ -f "$ini" ]; then 68 echo "pack Input: $ini" 69 ./tools/trust_merger ${BIN_PATH_FIXUP} $ini 70 rm trust*.img 71 echo 72 fi 73 done 74} 75 76finish() 77{ 78 echo "Packing loader and trust successfully." 79 echo 80} 81 82pack_loader_image 83pack_trust_image 84finish 85