Klaus Heinrich Kiwi | 92f659d | 2021-03-09 21:03:42 -0300 | [diff] [blame] | 1 | # 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. |
| 5 | SOCSEC_SIGN_ENABLE ?= "0" |
| 6 | SOCSEC_SIGN_KEY ?= "" |
| 7 | SOCSEC_SIGN_SOC ?= "2600" |
| 8 | SOCSEC_SIGN_ALGO ?= "RSA4096_SHA512" |
| 9 | SOCSEC_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 |
| 15 | SOCSEC_SIGN_EXTRA_OPTS ?= "--stack_intersects_verification_region=false" |
| 16 | DEPENDS += '${@oe.utils.conditional("SOCSEC_SIGN_ENABLE", "1", " socsec-native", "", d)}' |
| 17 | |
| 18 | |
| 19 | # Signs the SPL binary with a pre-established key |
| 20 | sign_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 Jeffery | bf97bbd | 2021-08-26 10:26:03 +0930 | [diff] [blame] | 26 | echo "Error: Invalid socsec signing key: ${SOCSEC_SIGN_KEY}" |
| 27 | exit 1 |
Klaus Heinrich Kiwi | 92f659d | 2021-03-09 21:03:42 -0300 | [diff] [blame] | 28 | 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 | |
| 47 | sign_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 Williams | b9799be | 2021-08-06 09:13:33 -0500 | [diff] [blame] | 63 | do_deploy:append() { |
Klaus Heinrich Kiwi | 92f659d | 2021-03-09 21:03:42 -0300 | [diff] [blame] | 64 | if [ "${SOCSEC_SIGN_ENABLE}" = "1" -a -n "${SPL_BINARY}" ] ; then |
| 65 | sign_spl |
| 66 | fi |
| 67 | } |