xref: /OK3568_Linux_fs/buildroot/board/chromebook/elm/sign.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2
3# This script creates u-boot FIT image containing the kernel and the DT,
4# then signs it using futility from vboot-utils.
5# The resulting file is called uImage.kpart.
6
7BOARD_DIR=$(dirname $0)/${BOARD_NAME}
8mkimage=$HOST_DIR/bin/mkimage
9futility=$HOST_DIR/bin/futility
10devkeys=$HOST_DIR/share/vboot/devkeys
11
12run() { echo "$@"; "$@"; }
13die() { echo "$@" >&2; exit 1; }
14test -f $BINARIES_DIR/Image  || \
15	die "No kernel image found"
16test -x $mkimage || \
17	die "No mkimage found (host-uboot-tools has not been built?)"
18test -x $futility || \
19	die "No futility found (host-vboot-utils has not been built?)"
20
21# kernel.its references Image and mt8173-elm.dtb, and all three
22# files must be in current directory for mkimage.
23run cp $BOARD_DIR/kernel.its $BINARIES_DIR/kernel.its || exit 1
24echo "# entering $BINARIES_DIR for the next command"
25(cd $BINARIES_DIR && run $mkimage -f kernel.its uImage.itb) || exit 1
26
27# futility requires non-empty file to be supplied with --bootloader
28# even if it does not make sense for the target platform.
29echo > $BINARIES_DIR/dummy.txt
30
31run $futility vbutil_kernel \
32	--keyblock $devkeys/kernel.keyblock \
33	--signprivate $devkeys/kernel_data_key.vbprivk \
34	--arch aarch64 \
35	--version 1 \
36	--config $BOARD_DIR/kernel.args \
37	--vmlinuz $BINARIES_DIR/uImage.itb \
38	--bootloader $BINARIES_DIR/dummy.txt \
39	--pack $BINARIES_DIR/uImage.kpart || exit 1
40
41rm -f $BINARIES_DIR/kernel.its $BINARIES_DIR/dummy.txt
42