138 lines
6.3 KiB
Bash
Executable File
138 lines
6.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
BL33_BIN_SIZE="1572864"
|
|
export FIP_FOLDER=./fip/
|
|
export CUR_SOC=./s6/
|
|
if [[ $1 =~ "s6" ]];
|
|
then
|
|
source ./bl33/v2023/configs/amlogic/$1_defconfig
|
|
fi;
|
|
export CHIPSET_NAME=S905C5
|
|
|
|
if [[ $1 =~ "s6" ]];
|
|
then
|
|
PROJECT=`cat ./bl33/v2023/configs/amlogic/$1_defconfig | grep 'CONFIG_CHIPSET_NAME' | awk -F '=' '{print $2}' `
|
|
PRJ=`echo $PROJECT | tr -d "\""`
|
|
echo $PRJ
|
|
export PRJ
|
|
fi;
|
|
|
|
|
|
if [[ $1 == "ta_seg_id" ]]; ## generate dfu&device keys
|
|
then
|
|
mkdir -p ./fip/s6/nocs/efuse/input
|
|
mkdir -p ./fip/s6/nocs/efuse/output
|
|
./fip/s6/bin/efuse-gen.sh --ta-segid $2 -o ./fip/s6/nocs/efuse/input/ta-segid.obj
|
|
|
|
elif [[ $2 == "generate_keys" ]]; ## generate dfu&device keys
|
|
then
|
|
echo "Start to build Uboot";
|
|
if [ ! -f "dv_scs_keys/root/rsa/$PRJ/roothash/hash-device-rootcert-rsa.bin" ];
|
|
then echo "generate dfu keys";
|
|
./fip/s6/generate-device-keys/gen_all_device_key.sh --key-dir ./dv_scs_keys --rsa-size 4096 --project $PRJ --rootkey-index 0 --template-dir ./soc/templates/s6/ --out-dir ./bl33/v2023/board/amlogic/$1/device-keys --sig-scheme "rsa"
|
|
./fip/s6/nocs/createtemplate.sh $1
|
|
./fip/s6/generate-device-keys/bin/dvuk_gen.sh fip/s6/nocs/dvuk
|
|
mkdir -p ./fip/s6/nocs/efuse/input
|
|
mkdir -p ./fip/s6/nocs/efuse/output
|
|
./fip/s6/bin/efuse-gen.sh --dfu-device-roothash ./dv_scs_keys/root/rsa/$PRJ/roothash/hash-device-rootcert-rsa.bin -o ./fip/s6/nocs/efuse/input/dfu_device_roothash.obj
|
|
./fip/s6/bin/efuse-gen.sh --dvgk ./dv_scs_keys/root/dvgk/$PRJ/dvgk.bin -o ./fip/s6/nocs/efuse/input/dvgk.obj
|
|
./fip/s6/bin/efuse-gen.sh --dvuk ./fip/s6/nocs/dvuk.bin -o ./fip/s6/nocs/efuse/input/dvuk.obj
|
|
else
|
|
./fip/s6/nocs/createtemplate.sh $1
|
|
echo "no need generate dfu keys";
|
|
fi;
|
|
## generate device keys
|
|
cp ./dv_scs_keys/root/dvgk/$PRJ/dvgk.bin ./fip/s6/nocs
|
|
cd ./fip/s6/nocs
|
|
|
|
if [ ! -f "./stage-3a-stbm-generate-keysets/output/data-stbm/keydir/boot-blobs/rsa/$PRJ/trustchain-0/key/level-2-rsa-pub.pem" ];
|
|
then echo "generate device key";
|
|
./run-generate-key.sh
|
|
else
|
|
echo "no need generate device key";
|
|
fi;
|
|
elif [[ $2 == "production" ]];
|
|
then
|
|
if [ ! -s "./fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin" ];then
|
|
echo "!!!PLEASE PUT NAGRA SIGNED FILE to ./fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin";
|
|
exit;
|
|
fi;
|
|
|
|
if [ ! -L "./fip/s6/nocs/stage-5-stbm-process-signed/input/refImgSigned.bin" ]; then
|
|
echo "error ./fip/s6/nocs/stage-5-stbm-process-signed/input/refImgSigned.bin shall be symbolic link to ./fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin"
|
|
exit;
|
|
fi
|
|
|
|
if ! cmp -s ./fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin ./fip/s6/nocs/stage-5-stbm-process-signed/input/refImgSigned.bin; then
|
|
echo "!!! ./fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin AND ./fip/s6/nocs/stage-5-stbm-process-signed/input/refImgSigned.bin ARE DIFFERENT. PLEASE CHECK NAGRA SIGNED FILE";
|
|
exit;
|
|
fi
|
|
|
|
echo "update device vendor segid"
|
|
c1=$(xxd -ps -s 24816 -c4 -g4 -l1 fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin)
|
|
c2=$(xxd -ps -s 24817 -c4 -g4 -l1 fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin)
|
|
c3=$(xxd -ps -s 24818 -c4 -g4 -l1 fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin)
|
|
c4=$(xxd -ps -s 24819 -c4 -g4 -l1 fip/s6/nocs/stage-4-nagra-signing/output/refImgSigned.bin)
|
|
|
|
vendsg="DEVICE_VENDOR_SEGID=0x$c4$c3$c2$c1"
|
|
scssg="DEVICE_SCS_SEGID=0x$c4$c3$c2$c1"
|
|
echo $vendsg
|
|
echo $scssg
|
|
sed -i 's/DEVICE_VENDOR_SEGID.*/'$vendsg'/' bl33/v2023/board/amlogic/$1/fw_arb.cfg
|
|
sed -i 's/DEVICE_SCS_SEGID.*/'$scssg'/' bl33/v2023/board/amlogic/$1/fw_arb.cfg
|
|
mkdir -p ./fip/s6/nocs/efuse/input/
|
|
mkdir -p ./fip/s6/nocs/efuse/output/
|
|
./fip/s6/bin/efuse-gen.sh --device-vendor-segid 0x$c4$c3$c2$c1 -o ./fip/s6/nocs/efuse/input/device-vendor.obj
|
|
./fip/s6/nocs/createtemplate.sh $1
|
|
cd ./fip/s6/nocs
|
|
./package-uboot.sh usb
|
|
cd -
|
|
./fip/s6/bin/device-vendor-scs-signing.sh --key-dir bl33/v2023/board/amlogic/$1/device-keys/ --project $PRJ --sig-scheme "rsa" --input-dir ./fip/s6/nocs/usb/ --rootkey-index 0 --chipset-variant nocs-jts-a --arb-config ./bl33/v2023/board/amlogic/$1/fw_arb.cfg --out-dir ./fip/s6/nocs/usb/
|
|
cd ./fip/s6/nocs
|
|
./run-post.sh
|
|
./package-uboot.sh sto
|
|
./installkeys.sh $1 stage-3a-stbm-generate-keysets/
|
|
if [[ $3 =~ "nasc_nagra_tier_1" ]];
|
|
then
|
|
cp stage-4-nagra-signing/output/bl33-payload.bin sto/bl33-payload.bin
|
|
bl33_size=`stat -c %s sto/bl33-payload.bin`
|
|
if [[ ${bl33_size} -gt ${BL33_BIN_SIZE} ]]; then
|
|
echo size of bl33-payload.bin is ${bl33_size}, large than ${BL33_BIN_SIZE}
|
|
exit -1
|
|
fi
|
|
|
|
dd if=/dev/zero of=sto/tmp.bin bs=${BL33_BIN_SIZE} count=1 &> /dev/null
|
|
dd if=sto/bl33-payload.bin of=sto/tmp.bin conv=notrunc &> /dev/null
|
|
mv sto/tmp.bin sto/bl33-payload.bin
|
|
fi;
|
|
cd -
|
|
./fip/s6/bin/device-vendor-scs-signing.sh --key-dir bl33/v2023/board/amlogic/$1/device-keys/ --project $PRJ --sig-scheme "rsa" --input-dir ./fip/s6/nocs/sto/ --rootkey-index 0 --chipset-variant nocs-jts-a --arb-config ./bl33/v2023/board/amlogic/$1/fw_arb.cfg --out-dir ./fip/s6/nocs/sto/
|
|
cp ./fip/_tmp/* ./fip/s6/nocs/sto/
|
|
cd -
|
|
cp stage-5-stbm-process-signed/output/bb1st.bin sto/bb1st.sto.nocs-jts-a.bin.device.signed
|
|
cp stage-5-stbm-process-signed/output/blob-bl2e.bin sto/blob-bl2e.sto.nocs-jts-a.bin.device.signed
|
|
cd -
|
|
cp ./fip/_tmp/ddr-fip.bin ./fip/s6/nocs/sto/
|
|
source ./fip/s6/build.sh
|
|
mk_uboot ./fip/s6/nocs/sto/ ./fip/s6/nocs/sto/ .device.signed .sto .nocs-jts-a
|
|
mk_uboot ./fip/s6/nocs/usb/ ./fip/s6/nocs/usb/ .device.signed .usb .nocs-jts-a
|
|
cd -
|
|
#merge efuse files.
|
|
cat ./efuse/input/*.obj > ./efuse/output/all.obj
|
|
cd -
|
|
rm -f ./build/u-boot.bin.sd.*
|
|
cp fip/s6/nocs/usb/u-boot.bin.usb.* ./build
|
|
cp fip/s6/nocs/sto/u-boot.bin.device.* ./build/u-boot.bin.device.signed
|
|
echo "please use ./build/u-boot.bin.usb.device.signed for dfu mode";
|
|
echo "please use ./build/u-boot.bin.device.signed for normal mode uboot";
|
|
echo "please program ./fip/s6/nocs/efuse/out/all.obj into chipset OTP space";
|
|
else #//build usb and sto mode u-boot
|
|
sed -i 's/\/\/#define\ CONFIG_AML_SIGNED_UBOOT.*/'#define\ CONFIG_AML_SIGNED_UBOOT\ \ \ 1'/' bl33/v2023/board/amlogic/configs/$1.h
|
|
sed -i 's/#define\ CONFIG_AML_SIGNED_UBOOT /\/\/#define\ CONFIG_AML_SIGNED_UBOOT /' bl33/v2023/board/amlogic/configs/$1.h
|
|
./mk $1 --chip-variant nocs-jts-a $2
|
|
cd ./fip/s6/nocs
|
|
./run-pre.sh
|
|
cd -
|
|
echo "NOW PLEASE RUN <./fip/s6/nocs/run-all.sh s6_blxxx production> to generate complete U-boot.bin under fip/s6/nocs/sto";
|
|
fi;
|