Jamin Lin | eed879f | 2021-12-17 15:45:25 +0800 | [diff] [blame] | 1 | # ASPEED AST2600 devices can use Aspeed's utility 'otptool' |
| 2 | # to create OTP image |
| 3 | # The variables below carry default values to the create_otp() |
| 4 | # function below. |
| 5 | OTPTOOL_CONFIG ?= "" |
| 6 | OTPTOOL_KEY_DIR ?= "" |
| 7 | OTPTOOL_EXTRA_OPTS ?= "" |
| 8 | OTPTOOL_EXTRA_DEPENDS ?= " socsec-native" |
| 9 | DEPENDS += '${@oe.utils.conditional("SOCSEC_SIGN_ENABLE", "1", "${OTPTOOL_EXTRA_DEPENDS}", "", d)}' |
| 10 | |
| 11 | # Creates the OTP image |
| 12 | create_otp_helper() { |
| 13 | if [ "${SOC_FAMILY}" != "aspeed-g6" ] ; then |
| 14 | bbwarn "OTP creation is only supported on AST2600 boards" |
| 15 | elif [ ! -e "${OTPTOOL_CONFIG}" ] ; then |
| 16 | bbfatal "Invalid otptool config: ${OTPTOOL_CONFIG}" |
| 17 | elif [ ! -d "${OTPTOOL_KEY_DIR}" ] ; then |
| 18 | bbfatal "Invalid otptool signing key directory: ${OTPTOOL_KEY_DIR}" |
| 19 | else |
Andrew Jeffery | c1c74d0 | 2022-08-08 21:05:05 +0930 | [diff] [blame^] | 20 | otptool_config_slug="$(basename ${OTPTOOL_CONFIG} .json)" |
| 21 | otptool_config_outdir="${B}"/"${CONFIG_B_PATH}"/"${otptool_config_slug}" |
| 22 | mkdir -p "${otptool_config_outdir}" |
Jamin Lin | eed879f | 2021-12-17 15:45:25 +0800 | [diff] [blame] | 23 | otptool make_otp_image \ |
| 24 | --key_folder ${OTPTOOL_KEY_DIR} \ |
Andrew Jeffery | c1c74d0 | 2022-08-08 21:05:05 +0930 | [diff] [blame^] | 25 | --output_folder "${otptool_config_outdir}" \ |
Jamin Lin | eed879f | 2021-12-17 15:45:25 +0800 | [diff] [blame] | 26 | ${OTPTOOL_CONFIG} \ |
| 27 | ${OTPTOOL_EXTRA_OPTS} |
| 28 | |
| 29 | if [ $? -ne 0 ]; then |
| 30 | bbfatal "Generated OTP image failed." |
| 31 | fi |
| 32 | |
Andrew Jeffery | c1c74d0 | 2022-08-08 21:05:05 +0930 | [diff] [blame^] | 33 | otptool print "${otptool_config_outdir}"/otp-all.image |
Jamin Lin | eed879f | 2021-12-17 15:45:25 +0800 | [diff] [blame] | 34 | |
| 35 | if [ $? -ne 0 ]; then |
| 36 | bbfatal "Printed OTP image failed." |
| 37 | fi |
| 38 | |
Andrew Jeffery | c1c74d0 | 2022-08-08 21:05:05 +0930 | [diff] [blame^] | 39 | install -m 0644 -T \ |
| 40 | "${otptool_config_outdir}"/otp-all.image \ |
| 41 | ${DEPLOYDIR}/"${otptool_config_slug}"-otp-all.image |
Jamin Lin | eed879f | 2021-12-17 15:45:25 +0800 | [diff] [blame] | 42 | fi |
| 43 | } |
| 44 | |
| 45 | create_otp() { |
| 46 | mkdir -p ${DEPLOYDIR} |
| 47 | if [ -n "${UBOOT_CONFIG}" ]; then |
| 48 | for config in ${UBOOT_MACHINE}; do |
| 49 | CONFIG_B_PATH="${config}" |
| 50 | cd ${B}/${config} |
| 51 | create_otp_helper |
| 52 | done |
| 53 | else |
| 54 | CONFIG_B_PATH="" |
| 55 | cd ${B} |
| 56 | create_otp_helper |
| 57 | fi |
| 58 | } |
| 59 | |
| 60 | do_deploy:prepend() { |
| 61 | if [ "${SOCSEC_SIGN_ENABLE}" = "1" ] ; then |
| 62 | create_otp |
| 63 | fi |
| 64 | } |