blob: 0af88d9f582d7787727fafb194ff0d527c0411b0 [file] [log] [blame]
Klaus Heinrich Kiwi92f659d2021-03-09 21:03:42 -03001# ASPEED AST2600 devices can use Aspeed's utility 'socsec'
2# to sign the SPL (pubkey written to OTP region)
3# The variables below carry default values to the spl_sign()
4# function below.
5SOCSEC_SIGN_ENABLE ?= "0"
6SOCSEC_SIGN_KEY ?= ""
7SOCSEC_SIGN_SOC ?= "2600"
8SOCSEC_SIGN_ALGO ?= "RSA4096_SHA512"
9SOCSEC_SIGN_HELPER ?= ""
10# u-boot-aspeed-sdk commit '2c3b53489c ast2600: Modify SPL SRAM layout'
11# changes the SDRAM layout so that the verification region does NOT
12# intersects the stack. The parameter below can be used to instruct
13# socsec to work in either mode (ommitting it throws a warning), but
14# newer (post v00.03.03) u-boot-aspeed-sdk need this set to false
15SOCSEC_SIGN_EXTRA_OPTS ?= "--stack_intersects_verification_region=false"
16DEPENDS += '${@oe.utils.conditional("SOCSEC_SIGN_ENABLE", "1", " socsec-native", "", d)}'
17
18
19# Signs the SPL binary with a pre-established key
20sign_spl_helper() {
21 signing_helper_args=""
22
23 if [ "${SOC_FAMILY}" != "aspeed-g6" ] ; then
24 echo "Warning: SPL signing is only supported on AST2600 boards"
25 elif [ ! -e "${SOCSEC_SIGN_KEY}" ] ; then
Andrew Jefferybf97bbd2021-08-26 10:26:03 +093026 echo "Error: Invalid socsec signing key: ${SOCSEC_SIGN_KEY}"
27 exit 1
Klaus Heinrich Kiwi92f659d2021-03-09 21:03:42 -030028 else
29 rm -f ${SPL_BINARY}.staged
30
31 if [ -n "${SOCSEC_SIGN_HELPER}" ] ; then
32 signing_helper_args="--signing_helper ${SOCSEC_SIGN_HELPER}"
33 fi
34 socsec make_secure_bl1_image \
35 --soc ${SOCSEC_SIGN_SOC} \
36 --algorithm ${SOCSEC_SIGN_ALGO} \
37 --rsa_sign_key ${SOCSEC_SIGN_KEY} \
38 --bl1_image ${DEPLOYDIR}/${SPL_IMAGE} \
39 ${signing_helper_args} \
40 ${SOCSEC_SIGN_EXTRA_OPTS} \
41 --output ${SPL_BINARY}.staged
42 cp -f ${SPL_BINARY}.staged ${B}/${CONFIG_B_PATH}/${SPL_BINARY}
43 mv -f ${SPL_BINARY}.staged ${DEPLOYDIR}/${SPL_IMAGE}
44 fi
45}
46
47sign_spl() {
48 mkdir -p ${DEPLOYDIR}
49 if [ -n "${UBOOT_CONFIG}" ]; then
50 for config in ${UBOOT_MACHINE}; do
51 CONFIG_B_PATH="${config}"
52 cd ${B}/${config}
53 sign_spl_helper
54 done
55 else
56 CONFIG_B_PATH=""
57 cd ${B}
58 sign_spl_helper
59 fi
60}
61
62
Patrick Williamsb9799be2021-08-06 09:13:33 -050063do_deploy:append() {
Klaus Heinrich Kiwi92f659d2021-03-09 21:03:42 -030064 if [ "${SOCSEC_SIGN_ENABLE}" = "1" -a -n "${SPL_BINARY}" ] ; then
65 sign_spl
66 fi
67}