Skip to content

Commit 96654a3

Browse files
committed
x86_fsp: tgl: helper script
1 parent 5fd8094 commit 96654a3

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
WOLFBOOT_DIR=$(pwd)
4+
5+
# 16 MB
6+
BIOS_REGION_SIZE=16777216
7+
BIOS_REGION_PATH=/tmp/bios.bin
8+
SIGN_OPTIONS="--ecc384 --sha256"
9+
SIGN_KEY=$WOLFBOOT_DIR/wolfboot_signing_private_key.der
10+
SIGN_TOOL=./tools/keytools/sign
11+
12+
set -e
13+
14+
make_keys()
15+
{
16+
make keytools
17+
./tools/keytools/keygen --ecc384 -g wolfboot_signing_private_key.der --ecc256 -g tpm_seal_key.key -keystoreDir src/
18+
}
19+
20+
build_and_sign_image()
21+
{
22+
# compute the size differences between $FLASH_DUMP and "$WOLFBOOT_DIR"/wolfboot_stage1.bin and store it in SIZE
23+
FLASH_DUMP_SIZE=$(stat -c%s "$FLASH_DUMP")
24+
WOLFBOOT_SIZE=$(stat -c%s "$BIOS_REGION_PATH")
25+
SIZE=$((FLASH_DUMP_SIZE - WOLFBOOT_SIZE))
26+
cp "$FLASH_DUMP" "$WOLFBOOT_DIR/temp_image.bin"
27+
truncate -s $SIZE "$WOLFBOOT_DIR/temp_image.bin"
28+
cat "$WOLFBOOT_DIR/temp_image.bin" "$BIOS_REGION_PATH" > "$WOLFBOOT_DIR/final_image.bin"
29+
PCR0=$(python ./tools/x86_fsp/compute_pcr.py "$WOLFBOOT_DIR"/final_image.bin | tail -n 1)
30+
"$WOLFBOOT_DIR"/tools/tpm/policy_sign -ecc256 -key=tpm_seal_key.key -pcr=0 -pcrdigest=$PCR0
31+
IMAGE_FILE="$WOLFBOOT_DIR"/final_image.bin "$WOLFBOOT_DIR"/tools/x86_fsp/tpm_install_policy.sh policy.bin.sig
32+
}
33+
34+
assemble()
35+
{
36+
cp $WOLFBOOT_DIR/wolfboot_stage1.bin $BIOS_REGION_PATH
37+
build_and_sign_image
38+
}
39+
40+
# Parse command line options
41+
while getopts "ks:n:m:" opt; do
42+
case "$opt" in
43+
k)
44+
make_keys
45+
exit 0
46+
;;
47+
n)
48+
FLASH_DUMP="$OPTARG"
49+
IBG=0
50+
;;
51+
*)
52+
echo "Usage: $0 [-k] [-s FLASH_DUMP]"
53+
echo "-k: make keys"
54+
echo "-n FLASH_DUMP: assemble an image for being used without IBG"
55+
exit 1
56+
;;
57+
esac
58+
done
59+
60+
assemble

0 commit comments

Comments
 (0)