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 |
| 20 | otptool make_otp_image \ |
| 21 | --key_folder ${OTPTOOL_KEY_DIR} \ |
| 22 | ${OTPTOOL_CONFIG} \ |
| 23 | ${OTPTOOL_EXTRA_OPTS} |
| 24 | |
| 25 | if [ $? -ne 0 ]; then |
| 26 | bbfatal "Generated OTP image failed." |
| 27 | fi |
| 28 | |
| 29 | otptool \ |
| 30 | print \ |
| 31 | ${B}/${CONFIG_B_PATH}/otp-all.image |
| 32 | |
| 33 | if [ $? -ne 0 ]; then |
| 34 | bbfatal "Printed OTP image failed." |
| 35 | fi |
| 36 | |
| 37 | install -m 0644 ${B}/${CONFIG_B_PATH}/otp-* ${DEPLOYDIR} |
| 38 | fi |
| 39 | } |
| 40 | |
| 41 | create_otp() { |
| 42 | mkdir -p ${DEPLOYDIR} |
| 43 | if [ -n "${UBOOT_CONFIG}" ]; then |
| 44 | for config in ${UBOOT_MACHINE}; do |
| 45 | CONFIG_B_PATH="${config}" |
| 46 | cd ${B}/${config} |
| 47 | create_otp_helper |
| 48 | done |
| 49 | else |
| 50 | CONFIG_B_PATH="" |
| 51 | cd ${B} |
| 52 | create_otp_helper |
| 53 | fi |
| 54 | } |
| 55 | |
| 56 | do_deploy:prepend() { |
| 57 | if [ "${SOCSEC_SIGN_ENABLE}" = "1" ] ; then |
| 58 | create_otp |
| 59 | fi |
| 60 | } |