# Copyright 2017-2018 NXP require imx-mkimage_git.inc DESCRIPTION = "Generate Boot Loader for i.MX 8 device" LICENSE = "GPLv2" LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" SECTION = "BSP" IMX_EXTRA_FIRMWARE = "firmware-imx-8 imx-sc-firmware" IMX_EXTRA_FIRMWARE_mx8m = "firmware-imx-8m" IMX_EXTRA_FIRMWARE_mx8x = "firmware-imx-8x imx-sc-firmware" DEPENDS += " \ firmware-imx \ ${IMX_EXTRA_FIRMWARE} \ imx-atf \ " DEPENDS_append_mx8m = " dtc-native" BOOT_NAME = "imx-boot" PROVIDES = "${BOOT_NAME}" inherit deploy # Add CFLAGS with native INCDIR & LIBDIR for imx-mkimage build CFLAGS = "-O2 -Wall -std=c99 -I ${STAGING_INCDIR_NATIVE} -L ${STAGING_LIBDIR_NATIVE}" # This package aggregates output deployed by other packages, # so set the appropriate dependencies do_compile[depends] += " \ virtual/bootloader:do_deploy \ ${@' '.join('%s:do_deploy' % r for r in '${IMX_EXTRA_FIRMWARE}'.split() )} \ imx-atf:do_deploy \ " SC_FIRMWARE_NAME ?= "scfw_tcm.bin" ATF_MACHINE_NAME ?= "bl31-imx8qm.bin" ATF_MACHINE_NAME_mx8qm = "bl31-imx8qm.bin" ATF_MACHINE_NAME_mx8qxp = "bl31-imx8qx.bin" ATF_MACHINE_NAME_mx8mq = "bl31-imx8mq.bin" ATF_MACHINE_NAME_mx8mm = "bl31-imx8mm.bin" ATF_MACHINE_NAME_append = "${@bb.utils.contains('COMBINED_FEATURES', 'optee', '-optee', '', d)}" UBOOT_NAME = "u-boot-${MACHINE}.bin-${UBOOT_CONFIG}" BOOT_CONFIG_MACHINE = "${BOOT_NAME}-${MACHINE}-${UBOOT_CONFIG}.bin" TOOLS_NAME ?= "mkimage_imx8" SOC_TARGET ?= "INVALID" SOC_TARGET_mx8qm = "iMX8QM" SOC_TARGET_mx8qxp = "iMX8QX" SOC_TARGET_mx8mq = "iMX8M" SOC_TARGET_mx8mm = "iMX8MM" IMXBOOT_TARGETS ?= \ "${@bb.utils.contains('UBOOT_CONFIG', 'fspi', 'flash_flexspi', \ bb.utils.contains('UBOOT_CONFIG', 'nand', 'flash_nand', \ 'flash flash_dcd', d), d)}" IMXBOOT_TARGETS_mx8qxp = \ "${@bb.utils.contains('UBOOT_CONFIG', 'fspi', 'flash_flexspi', \ bb.utils.contains('UBOOT_CONFIG', 'nand', 'flash_nand', \ 'flash', d), d)}" IMXBOOT_TARGETS_mx8qxpa0 = \ "${@bb.utils.contains('UBOOT_CONFIG', 'fspi', 'flash_flexspi_a0', \ bb.utils.contains('UBOOT_CONFIG', 'nand', 'flash_nand_a0', \ 'flash_a0 flash_dcd_a0', d), d)}" BOOT_STAGING = "${S}/${SOC_TARGET}" BOOT_STAGING_mx8mm = "${S}/iMX8M" SOC_FAMILY = "INVALID" SOC_FAMILY_mx8 = "mx8" SOC_FAMILY_mx8m = "mx8m" SOC_FAMILY_mx8x = "mx8x" compile_mx8m() { bbnote 8MQ/8MM boot binary build for ddr_firmware in ${DDR_FIRMWARE_NAME}; do bbnote "Copy ddr_firmware: ${ddr_firmware} from ${DEPLOY_DIR_IMAGE} -> ${BOOT_STAGING} " cp ${DEPLOY_DIR_IMAGE}/${ddr_firmware} ${BOOT_STAGING} done cp ${DEPLOY_DIR_IMAGE}/signed_dp_imx8m.bin ${BOOT_STAGING} cp ${DEPLOY_DIR_IMAGE}/signed_hdmi_imx8m.bin ${BOOT_STAGING} cp ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} \ ${BOOT_STAGING}/u-boot-spl.bin cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${UBOOT_DTB_NAME} ${BOOT_STAGING} cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}-${UBOOT_CONFIG} \ ${BOOT_STAGING}/u-boot-nodtb.bin cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/mkimage_uboot ${BOOT_STAGING} cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME} ${BOOT_STAGING}/u-boot.bin } compile_mx8() { bbnote 8QM boot binary build cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${SC_FIRMWARE_NAME} ${BOOT_STAGING}/scfw_tcm.bin cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME} ${BOOT_STAGING}/u-boot.bin cp ${DEPLOY_DIR_IMAGE}/mx8qm-ahab-container.img ${BOOT_STAGING} } compile_mx8x() { bbnote 8QX boot binary build cp ${DEPLOY_DIR_IMAGE}/mx8qx-ahab-container.img ${BOOT_STAGING} cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${SC_FIRMWARE_NAME} ${BOOT_STAGING}/scfw_tcm.bin cp ${DEPLOY_DIR_IMAGE}/${BOOT_TOOLS}/${ATF_MACHINE_NAME} ${BOOT_STAGING}/bl31.bin cp ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME} ${BOOT_STAGING}/u-boot.bin } do_compile() { compile_${SOC_FAMILY} # mkimage for i.MX8 for target in ${IMXBOOT_TARGETS}; do bbnote "building ${SOC_TARGET} - ${target}" make SOC=${SOC_TARGET} ${target} if [ -e "${BOOT_STAGING}/flash.bin" ]; then cp ${BOOT_STAGING}/flash.bin ${S}/${BOOT_CONFIG_MACHINE}-${target} fi done } do_install () { install -d ${D}/boot for target in ${IMXBOOT_TARGETS}; do install -m 0644 ${S}/${BOOT_CONFIG_MACHINE}-${target} ${D}/boot/ done } deploy_mx8m() { install -d ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0644 ${DEPLOY_DIR_IMAGE}/u-boot-spl.bin-${MACHINE}-${UBOOT_CONFIG} \ ${DEPLOYDIR}/${BOOT_TOOLS} for ddr_firmware in ${DDR_FIRMWARE_NAME}; do install -m 0644 ${DEPLOY_DIR_IMAGE}/${ddr_firmware} ${DEPLOYDIR}/${BOOT_TOOLS} done install -m 0644 ${BOOT_STAGING}/signed_dp_imx8m.bin ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0644 ${BOOT_STAGING}/signed_hdmi_imx8m.bin ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0755 ${BOOT_STAGING}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0755 ${BOOT_STAGING}/mkimage_fit_atf.sh ${DEPLOYDIR}/${BOOT_TOOLS} } deploy_mx8() { install -d ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0644 ${BOOT_STAGING}/mx8qm-ahab-container.img ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} } deploy_mx8x() { install -d ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0644 ${BOOT_STAGING}/mx8qx-ahab-container.img ${DEPLOYDIR}/${BOOT_TOOLS} install -m 0755 ${S}/${TOOLS_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} } do_deploy() { deploy_${SOC_FAMILY} # copy the tool mkimage to deploy path and sc fw, dcd and uboot install -m 0644 ${DEPLOY_DIR_IMAGE}/${UBOOT_NAME} ${DEPLOYDIR}/${BOOT_TOOLS} # copy makefile (soc.mak) for reference install -m 0644 ${BOOT_STAGING}/soc.mak ${DEPLOYDIR}/${BOOT_TOOLS} # copy the generated boot image to deploy path for target in ${IMXBOOT_TARGETS}; do # Use first "target" as IMAGE_IMXBOOT_TARGET if [ "$IMAGE_IMXBOOT_TARGET" = "" ]; then IMAGE_IMXBOOT_TARGET="$target" echo "Set boot target as $IMAGE_IMXBOOT_TARGET" fi install -m 0644 ${S}/${BOOT_CONFIG_MACHINE}-${target} ${DEPLOYDIR} done cd ${DEPLOYDIR} ln -sf ${BOOT_CONFIG_MACHINE}-${IMAGE_IMXBOOT_TARGET} ${BOOT_NAME} cd - } addtask deploy before do_build after do_compile PACKAGE_ARCH = "${MACHINE_ARCH}" FILES_${PN} = "/boot" COMPATIBLE_MACHINE = "(mx8)"