forked from BoatPeopleBRTIK/build-artik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mksboot.sh
executable file
·69 lines (54 loc) · 1.73 KB
/
mksboot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#code signer v2.4
CODE_SIGNER="$PREBUILT_DIR/client"
CRT_PEM="$PREBUILT_DIR/client1.cert.pem"
IP_FILE="$PREBUILT_DIR/codesigner_ip"
# Sanity check
[ -e $CODE_SIGNER ] || exit 0
[ -e $CRT_PEM ] || exit 0
[ -e $IP_FILE ] || exit 0
IP_ADDR=`cat $IP_FILE`
#u-boot infomation
UBOOT_NAME=u-boot.bin
UBOOT_DTB_NAME=u-boot-dtb.bin
UBOOT_PADD_NAME=u-boot-dtb_padd.bin
UBOOT_TARGET_BIN=sboot-dtb.bin
#bl2 information
BL2_NAME=espresso3250-spl.bin
BL2_TARGET_BIN=sespresso3250-spl.bin
OUTPUT_DIR=$1
U_BOOT_SIZE_KB=1024
SIG_SIZE_B=256
U_BOOT_SIZE_B=`expr $U_BOOT_SIZE_KB \* 1024`
U_BOOT_PADD_B=`expr $U_BOOT_SIZE_B \- 256`
pushd $OUTPUT_DIR
#Add Zero Padding
#---------------------------------------------
#u-boot: Add padding(0x00) to u-boot image.
if [ -e $UBOOT_DTB_NAME ]; then
# prefer to use u-boot-dtb.bin over u-boot.bin
cp $UBOOT_DTB_NAME $UBOOT_PADD_NAME
else
cp $UBOOT_NAME $UBOOT_PADD_NAME
fi
truncate -s $U_BOOT_PADD_B $UBOOT_PADD_NAME
#--------------------------------------------
#Add Signature
#------------------------------------------------------------------------------------------------------------
#u-boot: Add signature(256B) to the end of input binary.
$CODE_SIGNER -ip $IP_ADDR -crt $CRT_PEM -bin $UBOOT_PADD_NAME -out $UBOOT_TARGET_BIN
#bl2: Add signature(256B) to the end of input binary.
$CODE_SIGNER -ip $IP_ADDR -crt $CRT_PEM -bin $BL2_NAME -out $BL2_TARGET_BIN
#------------------------------------------------------------------------------------------------------------
cp $UBOOT_TARGET_BIN $UBOOT_NAME
if [ -f "$UBOOT_PADD_NAME" ]; then
rm -rf $UBOOT_PADD_NAME
fi
if [ -f "$UBOOT_TARGET_BIN" ]; then
rm -rf $UBOOT_TARGET_BIN
fi
cp $BL2_TARGET_BIN $BL2_NAME
if [ -f "$BL2_TARGET_BIN" ]; then
rm -rf $BL2_TARGET_BIN
fi
popd