diff options
| -rw-r--r-- | recipes-bsp/atf/atf_2.3.bb | 175 |
1 files changed, 175 insertions, 0 deletions
diff --git a/recipes-bsp/atf/atf_2.3.bb b/recipes-bsp/atf/atf_2.3.bb new file mode 100644 index 000000000..ff83bbc87 --- /dev/null +++ b/recipes-bsp/atf/atf_2.3.bb | |||
| @@ -0,0 +1,175 @@ | |||
| 1 | require atf-${PV}.inc | ||
| 2 | |||
| 3 | DESCRIPTION = "ARM Trusted Firmware" | ||
| 4 | |||
| 5 | inherit deploy | ||
| 6 | |||
| 7 | DEPENDS += "cst-native" | ||
| 8 | do_compile[depends] += "u-boot:do_deploy rcw:do_deploy ddr-phy:do_deploy" | ||
| 9 | |||
| 10 | PACKAGE_ARCH = "${MACHINE_ARCH}" | ||
| 11 | |||
| 12 | PLATFORM = "${MACHINE}" | ||
| 13 | MBEDTLS_FOLDER ?= "${S}/mbedtls" | ||
| 14 | RCW_FOLDER ?= "${MACHINE}" | ||
| 15 | |||
| 16 | # requires CROSS_COMPILE set by hand as there is no configure script | ||
| 17 | export CROSS_COMPILE="${TARGET_PREFIX}" | ||
| 18 | export ARCH="arm64" | ||
| 19 | |||
| 20 | # Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is | ||
| 21 | # a standalone application | ||
| 22 | CFLAGS[unexport] = "1" | ||
| 23 | LDFLAGS[unexport] = "1" | ||
| 24 | AS[unexport] = "1" | ||
| 25 | LD[unexport] = "1" | ||
| 26 | |||
| 27 | EXTRA_OEMAKE += "HOSTCC='${BUILD_CC} ${BUILD_CPPFLAGS} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}'" | ||
| 28 | |||
| 29 | BOOTTYPE ?= "flexspi_nor sd emmc" | ||
| 30 | ARM_COT = "${@bb.utils.contains('DISTRO_FEATURES', 'arm-cot', 'true', 'false', d)}" | ||
| 31 | NXP_COT = "${@bb.utils.contains('DISTRO_FEATURES', 'secure', 'true', 'false', d)}" | ||
| 32 | BUILD_OPTEE = "${@bb.utils.contains('COMBINED_FEATURES', 'optee', 'true', 'false', d)}" | ||
| 33 | |||
| 34 | PACKAGECONFIG ??= " \ | ||
| 35 | ${@bb.utils.contains('DISTRO_FEATURES', 'arm-cot', 'optee', '', d)} \ | ||
| 36 | ${@bb.utils.contains('DISTRO_FEATURES', 'secure', 'optee', '', d)} \ | ||
| 37 | ${@bb.utils.filter('COMBINED_FEATURES', 'optee', d)} \ | ||
| 38 | " | ||
| 39 | PACKAGECONFIG[optee] = ",,optee-os-qoriq" | ||
| 40 | |||
| 41 | uboot_sec ?= "${DEPLOY_DIR_IMAGE}/u-boot.bin-tfa-secure-boot" | ||
| 42 | uboot ?= "${DEPLOY_DIR_IMAGE}/u-boot.bin-tfa" | ||
| 43 | |||
| 44 | do_configure[noexec] = "1" | ||
| 45 | |||
| 46 | do_compile() { | ||
| 47 | if [ "${NXP_COT}" = "true" -a "${ARM_COT}" = "true" ]; then | ||
| 48 | bbfatal " \ | ||
| 49 | Error!, Both ARM CoT and NXP CoT are enabled. Only one CoT is built in a yocto build, \ | ||
| 50 | Don't add nxp-cot and arm-cot into DISTRO_FEATURES_append at the same time." | ||
| 51 | fi | ||
| 52 | |||
| 53 | if [ "${NXP_COT}" = "true" ]; then | ||
| 54 | rm -fr ${S}/nxp-cot | ||
| 55 | mkdir -p ${S}/nxp-cot | ||
| 56 | outputdir="${S}/nxp-cot" | ||
| 57 | elif [ "${ARM_COT}" = "true" ]; then | ||
| 58 | rm -fr ${S}/arm-cot | ||
| 59 | mkdir -p ${S}/arm-cot | ||
| 60 | outputdir="${S}/arm-cot" | ||
| 61 | else | ||
| 62 | outputdir="${S}" | ||
| 63 | fi | ||
| 64 | |||
| 65 | if [ "${NXP_COT}" = "true" -o "${ARM_COT}" = "true" ]; then | ||
| 66 | if [ ! -f ${RECIPE_SYSROOT_NATIVE}/usr/bin/cst/srk.pri ]; then | ||
| 67 | ${RECIPE_SYSROOT_NATIVE}/usr/bin/cst/gen_keys 1024 | ||
| 68 | else | ||
| 69 | cp ${RECIPE_SYSROOT_NATIVE}/usr/bin/cst/srk.pri ${S} | ||
| 70 | cp ${RECIPE_SYSROOT_NATIVE}/usr/bin/cst/srk.pub ${S} | ||
| 71 | fi | ||
| 72 | |||
| 73 | bl32="${RECIPE_SYSROOT}${nonarch_base_libdir}/firmware/tee_${MACHINE}.bin" | ||
| 74 | bl33="${uboot_sec}" | ||
| 75 | secext="_sec" | ||
| 76 | else | ||
| 77 | bl33="${uboot}" | ||
| 78 | fi | ||
| 79 | |||
| 80 | for d in ${BOOTTYPE}; do | ||
| 81 | case $d in | ||
| 82 | sd) | ||
| 83 | rcwimg="${RCWSD}.bin" | ||
| 84 | ;; | ||
| 85 | emmc) | ||
| 86 | rcwimg="${RCWEMMC}.bin" | ||
| 87 | ;; | ||
| 88 | flexspi_nor) | ||
| 89 | rcwimg="${RCWXSPI}.bin" | ||
| 90 | ;; | ||
| 91 | esac | ||
| 92 | |||
| 93 | if [ -f "${DEPLOY_DIR_IMAGE}/rcw/${RCW_FOLDER}/${rcwimg}" ]; then | ||
| 94 | oe_runmake V=1 -C ${S} realclean | ||
| 95 | if [ "${ARM_COT}" = "true" ]; then | ||
| 96 | mkdir -p ${S}/build/${PLATFORM}/release | ||
| 97 | if [ -f ${outputdir}/rot_key.pem ]; then | ||
| 98 | cp -fr ${outputdir}/*.pem ${S}/build/${PLATFORM}/release | ||
| 99 | fi | ||
| 100 | oe_runmake V=1 -C ${S} fip pbl PLAT=${PLATFORM} BOOT_MODE=${d} SPD=opteed BL32=${bl32} \ | ||
| 101 | BL33=${bl33} RCW=${DEPLOY_DIR_IMAGE}/rcw/${RCW_FOLDER}/${rcwimg} TRUSTED_BOARD_BOOT=1 \ | ||
| 102 | GENERATE_COT=1 MBEDTLS_DIR=${MBEDTLS_FOLDER} CST_DIR=${RECIPE_SYSROOT_NATIVE}/usr/bin/cst | ||
| 103 | |||
| 104 | if [ ! -f ${outputdir}/ddr_fip_sec.bin ]; then | ||
| 105 | oe_runmake V=1 -C ${S} fip_ddr PLAT=${PLATFORM} TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 \ | ||
| 106 | MBEDTLS_DIR=${MBEDTLS_FOLDER} DDR_PHY_BIN_PATH=${DEPLOY_DIR_IMAGE}/ddr-phy | ||
| 107 | cp -r ${S}/build/${PLATFORM}/release/ddr_fip_sec.bin ${outputdir} | ||
| 108 | cp -r ${S}/build/${PLATFORM}/release/*.pem ${outputdir} | ||
| 109 | fi | ||
| 110 | elif [ "${NXP_COT}" = "true" ]; then | ||
| 111 | oe_runmake V=1 -C ${S} fip pbl PLAT=${PLATFORM} BOOT_MODE=${d} SPD=opteed BL32=${bl32} \ | ||
| 112 | BL33=${bl33} RCW=${DEPLOY_DIR_IMAGE}/rcw/${RCW_FOLDER}/${rcwimg} TRUSTED_BOARD_BOOT=1 \ | ||
| 113 | CST_DIR=${RECIPE_SYSROOT_NATIVE}/usr/bin/cst | ||
| 114 | |||
| 115 | if [ ! -f ${outputdir}/ddr_fip_sec.bin ]; then | ||
| 116 | oe_runmake V=1 -C ${S} fip_ddr PLAT=${PLATFORM} TRUSTED_BOARD_BOOT=1 \ | ||
| 117 | CST_DIR=${RECIPE_SYSROOT_NATIVE}/usr/bin/cst DDR_PHY_BIN_PATH=${DEPLOY_DIR_IMAGE}/ddr-phy | ||
| 118 | cp -r ${S}/build/${PLATFORM}/release/ddr_fip_sec.bin ${outputdir} | ||
| 119 | fi | ||
| 120 | elif [ "${BUILD_OPTEE}" = "true" ]; then | ||
| 121 | bl32="${RECIPE_SYSROOT}${nonarch_base_libdir}/firmware/tee_${MACHINE}.bin" | ||
| 122 | oe_runmake V=1 -C ${S} all fip pbl PLAT=${PLATFORM} BOOT_MODE=${d} SPD=opteed BL32=${bl32} \ | ||
| 123 | RCW=${DEPLOY_DIR_IMAGE}/rcw/${RCW_FOLDER}/${rcwimg} BL33=${bl33} | ||
| 124 | else | ||
| 125 | oe_runmake V=1 -C ${S} all fip pbl PLAT=${PLATFORM} BOOT_MODE=${d} \ | ||
| 126 | RCW=${DEPLOY_DIR_IMAGE}/rcw/${RCW_FOLDER}/${rcwimg} BL33=${bl33} | ||
| 127 | fi | ||
| 128 | |||
| 129 | cp -r ${S}/build/${PLATFORM}/release/bl2_${d}${secext}.pbl ${outputdir} | ||
| 130 | cp -r ${S}/build/${PLATFORM}/release/fip.bin ${outputdir} | ||
| 131 | fi | ||
| 132 | rcwimg="" | ||
| 133 | done | ||
| 134 | } | ||
| 135 | |||
| 136 | do_install() { | ||
| 137 | install -d ${D}/boot/atf | ||
| 138 | if [ "${ARM_COT}" = "true" ]; then | ||
| 139 | outputdir="${S}/arm-cot" | ||
| 140 | secext="_sec" | ||
| 141 | elif [ "${NXP_COT}" = "true" ]; then | ||
| 142 | outputdir="${S}/nxp-cot" | ||
| 143 | secext="_sec" | ||
| 144 | else | ||
| 145 | outputdir="${S}" | ||
| 146 | fi | ||
| 147 | if [ -f "${outputdir}/fip.bin" ]; then | ||
| 148 | cp -r ${outputdir}/fip.bin ${D}/boot/atf/fip_uboot${secext}.bin | ||
| 149 | fi | ||
| 150 | if [ -f "${outputdir}/ddr_fip_sec.bin" ]; then | ||
| 151 | cp -r ${outputdir}/ddr_fip_sec.bin ${D}/boot/atf/ | ||
| 152 | fi | ||
| 153 | for d in ${BOOTTYPE}; do | ||
| 154 | if [ -e ${outputdir}/bl2_${d}${secext}.pbl ]; then | ||
| 155 | cp -r ${outputdir}/bl2_${d}${secext}.pbl ${D}/boot/atf/bl2_${d}${secext}.pbl | ||
| 156 | fi | ||
| 157 | done | ||
| 158 | chown -R root:root ${D} | ||
| 159 | } | ||
| 160 | |||
| 161 | do_deploy() { | ||
| 162 | if [ "${ARM_COT}" = "true" ]; then | ||
| 163 | outputdir="atf_arm-cot" | ||
| 164 | elif [ "${NXP_COT}" = "true" ]; then | ||
| 165 | outputdir="atf_nxp-cot" | ||
| 166 | else | ||
| 167 | outputdir="atf" | ||
| 168 | fi | ||
| 169 | |||
| 170 | install -d ${DEPLOYDIR}/${outputdir} | ||
| 171 | cp -fr ${D}/boot/atf/* ${DEPLOYDIR}/${outputdir}/ | ||
| 172 | } | ||
| 173 | addtask deploy after do_install | ||
| 174 | FILES_${PN} += "/boot" | ||
| 175 | COMPATIBLE_MACHINE = "(lx2160a|lx2162a)" | ||
