2016-10-15 10:03:42 +02:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# arm-trusted-firmware
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
ARM_TRUSTED_FIRMWARE_VERSION = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_VERSION))
|
|
|
|
|
2022-06-23 16:00:24 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL),y)
|
2016-10-15 10:03:42 +02:00
|
|
|
# Handle custom ATF tarballs as specified by the configuration
|
|
|
|
ARM_TRUSTED_FIRMWARE_TARBALL = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL_LOCATION))
|
|
|
|
ARM_TRUSTED_FIRMWARE_SITE = $(patsubst %/,%,$(dir $(ARM_TRUSTED_FIRMWARE_TARBALL)))
|
|
|
|
ARM_TRUSTED_FIRMWARE_SOURCE = $(notdir $(ARM_TRUSTED_FIRMWARE_TARBALL))
|
|
|
|
else ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_SITE = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL))
|
|
|
|
ARM_TRUSTED_FIRMWARE_SITE_METHOD = git
|
|
|
|
else
|
2019-02-06 14:58:58 +01:00
|
|
|
# Handle stable official ATF versions
|
2016-10-15 10:03:42 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_SITE = $(call github,ARM-software,arm-trusted-firmware,$(ARM_TRUSTED_FIRMWARE_VERSION))
|
2019-07-14 19:32:18 +02:00
|
|
|
# The licensing of custom or from-git versions is unknown.
|
2021-09-24 18:23:49 +02:00
|
|
|
# This is valid only for the latest (i.e. known) version.
|
2020-05-30 19:07:05 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION),y)
|
2019-07-14 19:32:18 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_LICENSE = BSD-3-Clause
|
2021-09-24 18:23:49 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_LICENSE_FILES = docs/license.rst
|
2016-10-15 10:03:42 +02:00
|
|
|
endif
|
2020-05-30 19:07:05 +02:00
|
|
|
endif
|
2016-10-15 10:03:42 +02:00
|
|
|
|
2019-02-06 14:58:58 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE)$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION),y)
|
|
|
|
BR_NO_CHECK_HASH_FOR += $(ARM_TRUSTED_FIRMWARE_SOURCE)
|
|
|
|
endif
|
|
|
|
|
2016-10-15 10:03:42 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_INSTALL_IMAGES = YES
|
|
|
|
|
2020-03-18 21:50:05 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_NEEDS_DTC),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += host-dtc
|
|
|
|
endif
|
|
|
|
|
2020-03-28 06:04:30 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_NEEDS_ARM32_TOOLCHAIN),y)
|
2022-05-31 16:35:02 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += host-arm-gnu-toolchain
|
2020-03-28 06:04:30 +01:00
|
|
|
endif
|
|
|
|
|
2016-10-15 10:03:42 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_PLATFORM = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM))
|
2019-03-19 00:21:04 +01:00
|
|
|
|
2022-07-22 16:33:41 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_TARGET_BOARD = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_TARGET_BOARD))
|
|
|
|
|
2019-03-19 00:21:04 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_DEBUG),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += DEBUG=1
|
2022-07-22 16:33:41 +02:00
|
|
|
ifneq ($(ARM_TRUSTED_FIRMWARE_TARGET_BOARD),)
|
|
|
|
ARM_TRUSTED_FIRMWARE_IMG_DIR = $(@D)/build/$(ARM_TRUSTED_FIRMWARE_PLATFORM)/$(ARM_TRUSTED_FIRMWARE_TARGET_BOARD)/debug
|
|
|
|
else
|
2019-03-19 00:21:04 +01:00
|
|
|
ARM_TRUSTED_FIRMWARE_IMG_DIR = $(@D)/build/$(ARM_TRUSTED_FIRMWARE_PLATFORM)/debug
|
2022-07-22 16:33:41 +02:00
|
|
|
endif
|
|
|
|
else
|
|
|
|
ifneq ($(ARM_TRUSTED_FIRMWARE_TARGET_BOARD),)
|
|
|
|
ARM_TRUSTED_FIRMWARE_IMG_DIR = $(@D)/build/$(ARM_TRUSTED_FIRMWARE_PLATFORM)/$(ARM_TRUSTED_FIRMWARE_TARGET_BOARD)/release
|
2019-03-19 00:21:04 +01:00
|
|
|
else
|
2018-05-03 18:23:33 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_IMG_DIR = $(@D)/build/$(ARM_TRUSTED_FIRMWARE_PLATFORM)/release
|
2019-03-19 00:21:04 +01:00
|
|
|
endif
|
2022-07-22 16:33:41 +02:00
|
|
|
endif
|
2016-10-15 10:03:42 +02:00
|
|
|
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \
|
|
|
|
CROSS_COMPILE="$(TARGET_CROSS)" \
|
|
|
|
$(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_VARIABLES)) \
|
2022-07-22 16:33:41 +02:00
|
|
|
PLAT=$(ARM_TRUSTED_FIRMWARE_PLATFORM) \
|
|
|
|
TARGET_BOARD=$(ARM_TRUSTED_FIRMWARE_TARGET_BOARD)
|
2021-08-16 05:30:11 +02:00
|
|
|
|
2022-10-11 16:02:09 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_SSP),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \
|
|
|
|
ENABLE_STACK_PROTECTOR=$(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_SSP_LEVEL))
|
2022-11-13 20:09:54 +01:00
|
|
|
else
|
|
|
|
ARM_TRUSTED_FIRMWARE_CFLAGS += -fno-stack-protector
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BR2_PIC_PIE),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_CFLAGS += -fno-PIE
|
2022-10-11 16:02:09 +02:00
|
|
|
endif
|
|
|
|
|
2021-08-16 05:30:11 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_ENV += \
|
|
|
|
$(TARGET_MAKE_ENV) \
|
2022-11-13 20:09:54 +01:00
|
|
|
CFLAGS="$(ARM_TRUSTED_FIRMWARE_CFLAGS)"
|
2016-10-15 10:03:42 +02:00
|
|
|
|
2019-03-19 00:21:02 +01:00
|
|
|
ifeq ($(BR2_ARM_CPU_ARMV7A),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += ARM_ARCH_MAJOR=7
|
|
|
|
else ifeq ($(BR2_ARM_CPU_ARMV8A),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += ARM_ARCH_MAJOR=8
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BR2_arm),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += ARCH=aarch32
|
|
|
|
else ifeq ($(BR2_aarch64),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += ARCH=aarch64
|
|
|
|
endif
|
|
|
|
|
2019-03-19 00:21:03 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += optee-os
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \
|
|
|
|
BL32=$(BINARIES_DIR)/tee-header_v2.bin \
|
|
|
|
BL32_EXTRA1=$(BINARIES_DIR)/tee-pager_v2.bin \
|
|
|
|
BL32_EXTRA2=$(BINARIES_DIR)/tee-pageable_v2.bin
|
|
|
|
ifeq ($(BR2_aarch64),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += SPD=opteed
|
|
|
|
endif
|
|
|
|
ifeq ($(BR2_arm),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += AARCH32_SP=optee
|
|
|
|
endif
|
|
|
|
endif # BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL32_OPTEE
|
|
|
|
|
2023-01-19 19:50:40 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_BAREBOX_AS_BL33),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_BAREBOX_BIN = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_BAREBOX_BL33_IMAGE))
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(ARM_TRUSTED_FIRMWARE_BAREBOX_BIN)
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += barebox
|
|
|
|
endif
|
|
|
|
|
2021-05-12 20:36:15 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_EDK2_AS_BL33),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += edk2
|
|
|
|
# Since the flash device name vary between platforms, we use the variable
|
|
|
|
# provided by the EDK2 package for this. Using this variable here is OK
|
|
|
|
# as it will expand after all dependencies are resolved, inside _BUILD_CMDS.
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += \
|
|
|
|
BL33=$(BINARIES_DIR)/$(call qstrip,$(BR2_TARGET_EDK2_FD_NAME).fd)
|
|
|
|
endif
|
|
|
|
|
2017-12-03 22:48:05 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_AS_BL33),y)
|
2019-11-21 11:23:19 +01:00
|
|
|
ARM_TRUSTED_FIRMWARE_UBOOT_BIN = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_UBOOT_BL33_IMAGE))
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += BL33=$(BINARIES_DIR)/$(ARM_TRUSTED_FIRMWARE_UBOOT_BIN)
|
2017-12-03 22:48:05 +01:00
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += uboot
|
|
|
|
endif
|
|
|
|
|
2016-10-15 10:03:42 +02:00
|
|
|
ifeq ($(BR2_TARGET_VEXPRESS_FIRMWARE),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += SCP_BL2=$(BINARIES_DIR)/scp-fw.bin
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += vexpress-firmware
|
|
|
|
endif
|
|
|
|
|
2017-12-03 22:48:10 +01:00
|
|
|
ifeq ($(BR2_TARGET_BINARIES_MARVELL),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += SCP_BL2=$(BINARIES_DIR)/scp-fw.bin
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += binaries-marvell
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BR2_TARGET_MV_DDR_MARVELL),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += MV_DDR_PATH=$(MV_DDR_MARVELL_DIR)
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += mv-ddr-marvell
|
|
|
|
endif
|
|
|
|
|
2017-12-03 22:48:04 +01:00
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_TARGETS = all
|
|
|
|
|
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_FIP),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_TARGETS += fip
|
2017-12-17 09:55:53 +01:00
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += host-openssl
|
|
|
|
# fiptool only exists in newer (>= 1.3) versions of ATF, so we build
|
|
|
|
# it conditionally. We need to explicitly build it as it requires
|
|
|
|
# OpenSSL, and therefore needs to be passed proper variables to find
|
|
|
|
# the host OpenSSL.
|
|
|
|
define ARM_TRUSTED_FIRMWARE_BUILD_FIPTOOL
|
|
|
|
if test -d $(@D)/tools/fiptool; then \
|
|
|
|
$(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D)/tools/fiptool \
|
|
|
|
$(ARM_TRUSTED_FIRMWARE_MAKE_OPTS) \
|
|
|
|
CPPFLAGS="$(HOST_CPPFLAGS)" \
|
|
|
|
LDLIBS="$(HOST_LDFLAGS) -lcrypto" ; \
|
|
|
|
fi
|
|
|
|
endef
|
2017-12-03 22:48:04 +01:00
|
|
|
endif
|
|
|
|
|
2022-08-16 19:55:02 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_RCW),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += host-qoriq-rcw
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_TARGETS += pbl
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += RCW=$(BINARIES_DIR)/PBL.bin
|
|
|
|
endif
|
|
|
|
|
2017-12-03 22:48:06 +01:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31),y)
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_TARGETS += bl31
|
|
|
|
endif
|
|
|
|
|
2018-05-03 18:23:34 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31_UBOOT),y)
|
|
|
|
define ARM_TRUSTED_FIRMWARE_BL31_UBOOT_BUILD
|
|
|
|
# Get the entry point address from the elf.
|
|
|
|
BASE_ADDR=$$($(TARGET_READELF) -h $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/bl31/bl31.elf | \
|
|
|
|
sed -r '/^ Entry point address:\s*(.*)/!d; s//\1/') && \
|
2018-10-24 04:43:11 +02:00
|
|
|
$(MKIMAGE) \
|
2018-10-24 04:43:12 +02:00
|
|
|
-A $(MKIMAGE_ARCH) -O arm-trusted-firmware -C none \
|
2018-05-03 18:23:34 +02:00
|
|
|
-a $${BASE_ADDR} -e $${BASE_ADDR} \
|
|
|
|
-d $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/bl31.bin \
|
|
|
|
$(ARM_TRUSTED_FIRMWARE_IMG_DIR)/atf-uboot.ub
|
|
|
|
endef
|
|
|
|
define ARM_TRUSTED_FIRMWARE_BL31_UBOOT_INSTALL
|
|
|
|
$(INSTALL) -m 0644 $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/atf-uboot.ub \
|
|
|
|
$(BINARIES_DIR)/atf-uboot.ub
|
|
|
|
endef
|
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_OPTS += RESET_TO_BL31=1
|
|
|
|
ARM_TRUSTED_FIRMWARE_DEPENDENCIES += host-uboot-tools
|
|
|
|
endif
|
|
|
|
|
2018-11-11 22:39:42 +01:00
|
|
|
ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31_ELF),y)
|
|
|
|
define ARM_TRUSTED_FIRMWARE_BL31_UBOOT_INSTALL_ELF
|
|
|
|
$(INSTALL) -D -m 0644 $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/bl31/bl31.elf \
|
|
|
|
$(BINARIES_DIR)/bl31.elf
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
|
2020-01-29 17:58:23 +01:00
|
|
|
ARM_TRUSTED_FIRMWARE_MAKE_TARGETS += \
|
2020-02-11 21:22:00 +01:00
|
|
|
$(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_ADDITIONAL_TARGETS))
|
2020-01-29 17:58:23 +01:00
|
|
|
|
2021-07-09 11:49:25 +02:00
|
|
|
ARM_TRUSTED_FIRMWARE_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_DTS_PATH))
|
|
|
|
|
2016-10-15 10:03:42 +02:00
|
|
|
define ARM_TRUSTED_FIRMWARE_BUILD_CMDS
|
2021-07-09 11:49:25 +02:00
|
|
|
$(if $(ARM_TRUSTED_FIRMWARE_CUSTOM_DTS_PATH),
|
|
|
|
cp -f $(ARM_TRUSTED_FIRMWARE_CUSTOM_DTS_PATH) $(@D)/fdts/
|
|
|
|
)
|
2017-12-17 09:55:53 +01:00
|
|
|
$(ARM_TRUSTED_FIRMWARE_BUILD_FIPTOOL)
|
2021-08-16 05:30:11 +02:00
|
|
|
$(ARM_TRUSTED_FIRMWARE_MAKE_ENV) $(MAKE) -C $(@D) \
|
|
|
|
$(ARM_TRUSTED_FIRMWARE_MAKE_OPTS) \
|
2018-09-14 17:33:24 +02:00
|
|
|
$(ARM_TRUSTED_FIRMWARE_MAKE_TARGETS)
|
2018-05-03 18:23:34 +02:00
|
|
|
$(ARM_TRUSTED_FIRMWARE_BL31_UBOOT_BUILD)
|
2016-10-15 10:03:42 +02:00
|
|
|
endef
|
|
|
|
|
|
|
|
define ARM_TRUSTED_FIRMWARE_INSTALL_IMAGES_CMDS
|
2019-11-15 08:51:01 +01:00
|
|
|
$(foreach f,$(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_IMAGES)), \
|
|
|
|
cp -dpf $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/$(f) $(BINARIES_DIR)/
|
|
|
|
)
|
2018-05-03 18:23:34 +02:00
|
|
|
$(ARM_TRUSTED_FIRMWARE_BL31_UBOOT_INSTALL)
|
2018-11-11 22:39:42 +01:00
|
|
|
$(ARM_TRUSTED_FIRMWARE_BL31_UBOOT_INSTALL_ELF)
|
2016-10-15 10:03:42 +02:00
|
|
|
endef
|
|
|
|
|
2017-10-12 21:54:15 +02:00
|
|
|
# Configuration check
|
2016-10-15 10:03:42 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE)$(BR_BUILDING),yy)
|
|
|
|
|
2022-06-23 16:00:24 +02:00
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL),y)
|
2022-06-21 15:58:33 +02:00
|
|
|
ifeq ($(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL_LOCATION)),)
|
|
|
|
$(error No tarball location specified. Please check BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL_LOCATION)
|
2016-10-15 10:03:42 +02:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT),y)
|
|
|
|
ifeq ($(call qstrip,$(BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL)),)
|
|
|
|
$(error No repository specified. Please check BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
$(eval $(generic-package))
|