From d346beb08c3a7867497000dc382635ee8ea0eedb Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 23 Sep 2020 03:25:30 +0200 Subject: [PATCH] build: Extract trusted-firmware-a.mk The include/trusted-firmware-a.mk file is based on the include/u-boot.mk file and should be used to build a Trusted Firmware-A (TFA) which was previously named Arm trusted firmware. This is useful for targets where the TFA is board specific like for Marvell SoCs and probably also NXP Layerscape SoCs. This also makes use of this abstraction in the arm-trusted-firmware-mvebu package to build board specific ATF binaries. The ATF binaries will be automatically activated and build when the board is selected in the normal build or all boards are selected. This should also activate the build when build bot creates images. Signed-off-by: Hauke Mehrtens --- include/trusted-firmware-a.mk | 93 +++++++++++ .../boot/arm-trusted-firmware-mvebu/Makefile | 158 ++++++++---------- 2 files changed, 164 insertions(+), 87 deletions(-) create mode 100644 include/trusted-firmware-a.mk diff --git a/include/trusted-firmware-a.mk b/include/trusted-firmware-a.mk new file mode 100644 index 0000000000..b89014b249 --- /dev/null +++ b/include/trusted-firmware-a.mk @@ -0,0 +1,93 @@ +PKG_NAME ?= trusted-firmware-a + +ifndef PKG_SOURCE_PROTO +PKG_SOURCE = trusted-firmware-a-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/snapshot +endif + +PKG_BUILD_DIR = $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) + +PKG_TARGETS := bin +PKG_FLAGS:=nonshared + +PKG_LICENSE:=BSD-3-Clause +PKG_LICENSE_FILES:=docs/license.rst + +PKG_BUILD_PARALLEL:=1 + +export GCC_HONOUR_COPTS=s + +define Package/trusted-firmware-a/install/default + $(CP) $(patsubst %,$(PKG_BUILD_DIR)/build/$(PLAT)/release/%,$(TFA_IMAGE)) $(1)/ +endef + +Package/trusted-firmware-a/install = $(Package/trusted-firmware-a/install/default) + +define Trusted-Firmware-A/Init + BUILD_TARGET:= + BUILD_SUBTARGET:= + BUILD_DEVICES:= + NAME:= + DEPENDS:= + HIDDEN:= + DEFAULT:= + PLAT:= + VARIANT:=$(1) + TFA_IMAGE:= +endef + +TARGET_DEP = TARGET_$(BUILD_TARGET)$(if $(BUILD_SUBTARGET),_$(BUILD_SUBTARGET)) + +define Build/Trusted-Firmware-A/Target + $(eval $(call Trusted-Firmware-A/Init,$(1))) + $(eval $(call Trusted-Firmware-A/Default,$(1))) + $(eval $(call Trusted-Firmware-A/$(1),$(1))) + + define Package/trusted-firmware-a-$(1) + SECTION:=boot + CATEGORY:=Boot Loaders + TITLE:=Trusted-Firmware-A for $(NAME) + VARIANT:=$(VARIANT) + DEPENDS:=@!IN_SDK $(DEPENDS) + HIDDEN:=$(HIDDEN) + ifneq ($(BUILD_TARGET),) + DEPENDS += @$(TARGET_DEP) + ifneq ($(BUILD_DEVICES),) + DEFAULT := y if ($(TARGET_DEP)_Default \ + $(patsubst %,|| $(TARGET_DEP)_DEVICE_%,$(BUILD_DEVICES)) \ + $(patsubst %,|| $(patsubst TARGET_%,TARGET_DEVICE_%,$(TARGET_DEP))_DEVICE_%,$(BUILD_DEVICES))) + endif + endif + $(if $(DEFAULT),DEFAULT:=$(DEFAULT)) + URL:=https://www.trustedfirmware.org/projects/tf-a/ + endef + + define Package/trusted-firmware-a-$(1)/install + $$(Package/trusted-firmware-a/install) + endef +endef + + +define Build/Compile/Trusted-Firmware-A + +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ + CROSS_COMPILE=$(TARGET_CROSS) \ + OPENSSL_DIR=$(STAGING_DIR_HOST) \ + PLAT=$(PLAT) \ + $(TFA_MAKE_FLAGS) +endef + +define BuildPackage/Trusted-Firmware-A/Defaults + Build/Configure/Default = $$$$(Build/Configure/Trusted-Firmware-A) + Build/Compile/Default = $$$$(Build/Compile/Trusted-Firmware-A) +endef + +define BuildPackage/Trusted-Firmware-A + $(eval $(call BuildPackage/Trusted-Firmware-A/Defaults)) + $(foreach type,$(if $(DUMP),$(TFA_TARGETS),$(BUILD_VARIANT)), \ + $(eval $(call Build/Trusted-Firmware-A/Target,$(type))) + ) + $(eval $(call Build/DefaultTargets)) + $(foreach type,$(if $(DUMP),$(TFA_TARGETS),$(BUILD_VARIANT)), \ + $(call BuildPackage,trusted-firmware-a-$(type)) + ) +endef diff --git a/package/boot/arm-trusted-firmware-mvebu/Makefile b/package/boot/arm-trusted-firmware-mvebu/Makefile index 38dd9d1635..1f84b8eb19 100644 --- a/package/boot/arm-trusted-firmware-mvebu/Makefile +++ b/package/boot/arm-trusted-firmware-mvebu/Makefile @@ -7,149 +7,170 @@ include $(TOPDIR)/rules.mk -PKG_NAME:=arm-trusted-firmware-mvebu PKG_VERSION:=2.3 PKG_RELEASE:=1 - -PKG_SOURCE:=trusted-firmware-a-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/snapshot PKG_HASH:=37f917922bcef181164908c470a2f941006791c0113d738c498d39d95d543b21 -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/trusted-firmware-a-$(PKG_VERSION) - -PKG_LICENSE:=BSD-3-Clause -PKG_LICENSE_FILES:=docs/license.rst PKG_MAINTAINER:=Vladimir Vid +include $(INCLUDE_DIR)/trusted-firmware-a.mk include $(INCLUDE_DIR)/package.mk -define Package/arm-trusted-firmware-mvebu - SECTION:=boot - CATEGORY:=Boot Loaders - DEPENDS:=@TARGET_mvebu_cortexa53 - VARIANT:=$(subst arm-trusted-firmware-mvebu-,,$(1)) +define Trusted-Firmware-A/Default + BUILD_TARGET:=mvebu + BUILD_SUBTARGET:=cortexa53 + TFA_IMAGE:=flash-image.bin uart-images.tgz + UBOOT:= + DDR_TOPOLOGY:= + CLOCKSPRESET:= endef -define Package/arm-trusted-firmware-mvebu-espressobin-512mb - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin (512MB) + +define Trusted-Firmware-A/espressobin-512mb + NAME:=Marvell ESPRESSObin (512MB) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin UBOOT:=espressobin DDR_TOPOLOGY:=0 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-1cs - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V3-V5 (1GB 1CS) +define Trusted-Firmware-A/espressobin-v3-v5-1gb-1cs + NAME:=Marvell ESPRESSObin V3-V5 (1GB 1CS) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin UBOOT:=espressobin DDR_TOPOLOGY:=4 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-1cs-emmc - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V3-V5 (1GB 1CS, eMMC) +define Trusted-Firmware-A/espressobin-v3-v5-1gb-1cs-emmc + NAME:=Marvell ESPRESSObin V3-V5 (1GB 1CS, eMMC) DEPENDS:=+u-boot-espressobin-emmc + BUILD_DEVICES:=globalscale_espressobin-emmc UBOOT:=espressobin-emmc DDR_TOPOLOGY:=4 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-2cs - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V3-V5 (1GB, 2CS) +define Trusted-Firmware-A/espressobin-v3-v5-1gb-2cs + NAME:=Marvell ESPRESSObin V3-V5 (1GB, 2CS) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin UBOOT:=espressobin DDR_TOPOLOGY:=2 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-2cs-emmc - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V3-V5 (1GB 2CS, eMMC) +define Trusted-Firmware-A/espressobin-v3-v5-1gb-2cs-emmc + NAME:=Marvell ESPRESSObin V3-V5 (1GB 2CS, eMMC) DEPENDS:=+u-boot-espressobin-emmc + BUILD_DEVICES:=globalscale_espressobin-emmc UBOOT:=espressobin-emmc DDR_TOPOLOGY:=2 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v3-v5-2gb - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V3-V5 (2GB) +define Trusted-Firmware-A/espressobin-v3-v5-2gb + NAME:=Marvell ESPRESSObin V3-V5 (2GB) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin UBOOT:=espressobin DDR_TOPOLOGY:=7 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v3-v5-2gb-emmc - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V3-V5 (2GB, eMMC) +define Trusted-Firmware-A/espressobin-v3-v5-2gb-emmc + NAME:=Marvell ESPRESSObin V3-V5 (2GB, eMMC) DEPENDS:=+u-boot-espressobin-emmc + BUILD_DEVICES:=globalscale_espressobin-emmc UBOOT:=espressobin-emmc DDR_TOPOLOGY:=7 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v7-1gb - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V7 (1GB) +define Trusted-Firmware-A/espressobin-v7-1gb + NAME:=Marvell ESPRESSObin V7 (1GB) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin-v7 UBOOT:=espressobin DDR_TOPOLOGY:=5 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v7-1gb-emmc - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V7 (1GB, eMMC) +define Trusted-Firmware-A/espressobin-v7-1gb-emmc + NAME:=Marvell ESPRESSObin V7 (1GB, eMMC) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin-v7-emmc UBOOT:=espressobin-emmc DDR_TOPOLOGY:=5 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v7-2gb - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V7 (2GB) +define Trusted-Firmware-A/espressobin-v7-2gb + NAME:=Marvell ESPRESSObin V7 (2GB) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin-v7 UBOOT:=espressobin DDR_TOPOLOGY:=6 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-espressobin-v7-2gb-emmc - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Marvell ESPRESSObin V7 (2GB, eMMC) +define Trusted-Firmware-A/espressobin-v7-2gb-emmc + NAME:=Marvell ESPRESSObin V7 (2GB, eMMC) DEPENDS:=+u-boot-espressobin + BUILD_DEVICES:=globalscale_espressobin-v7-emmc UBOOT:=espressobin-emmc DDR_TOPOLOGY:=6 CLOCKSPRESET:=CPU_800_DDR_800 PLAT:=a3700 endef -define Package/arm-trusted-firmware-mvebu-udpu - $(Package/arm-trusted-firmware-mvebu) - TITLE:=ARM Trusted Firmware for Methode uDPU +define Trusted-Firmware-A/udpu + NAME:=Methode uDPU DEPENDS:=+u-boot-uDPU + BUILD_DEVICES:=methode_udpu UBOOT:=uDPU DDR_TOPOLOGY:=0 CLOCKSPRESET:=CPU_1000_DDR_800 PLAT:=a3700 endef + +TFA_TARGETS:= \ + espressobin-512mb \ + espressobin-v3-v5-1gb-1cs \ + espressobin-v3-v5-1gb-1cs-emmc \ + espressobin-v3-v5-1gb-2cs \ + espressobin-v3-v5-1gb-2cs-emmc \ + espressobin-v3-v5-2gb \ + espressobin-v3-v5-2gb-emmc \ + espressobin-v7-1gb \ + espressobin-v7-1gb-emmc \ + espressobin-v7-2gb \ + espressobin-v7-2gb-emmc \ + udpu + +TFA_MAKE_FLAGS += \ + CROSS_CM3=$(STAGING_DIR_IMAGE)/$(LINARO_NAME)-$(LINARO_RELEASE).$(LINARO_VERSION)/bin/arm-linux-gnueabi- \ + BL33=$(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.bin \ + MV_DDR_PATH=$(STAGING_DIR_IMAGE)/$(MV_DDR_NAME) \ + WTP=$(STAGING_DIR_IMAGE)/$(A3700_UTILS_NAME) \ + DDR_TOPOLOGY=$(DDR_TOPOLOGY) \ + CLOCKSPRESET=$(CLOCKSPRESET) \ + all \ + fip + A3700_UTILS_NAME:=a3700-utils A3700_UTILS_RELEASE:=09679790 A3700_UTILS_SOURCE=$(A3700_UTILS_NAME)-$(A3700_UTILS_RELEASE).tar.bz2 @@ -201,41 +222,4 @@ define Build/Prepare $(TAR) -C $(STAGING_DIR_IMAGE) -xf $(DL_DIR)/$(LINARO_SOURCE) endef -export GCC_HONOUR_COPTS=s - -TARGET_CFLAGS = "" - -define Build/Compile - $(eval $(Package/arm-trusted-firmware-mvebu-$(BUILD_VARIANT))) \ - $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ - CROSS_COMPILE=$(TARGET_CROSS) \ - OPENSSL_DIR=$(STAGING_DIR_HOST) \ - CROSS_CM3=$(STAGING_DIR_IMAGE)/$(LINARO_NAME)-$(LINARO_RELEASE).$(LINARO_VERSION)/bin/arm-linux-gnueabi- \ - BL33=$(STAGING_DIR_IMAGE)/$(UBOOT)-u-boot.bin \ - MV_DDR_PATH=$(STAGING_DIR_IMAGE)/$(MV_DDR_NAME) \ - WTP=$(STAGING_DIR_IMAGE)/$(A3700_UTILS_NAME) \ - DDR_TOPOLOGY=$(DDR_TOPOLOGY) \ - CLOCKSPRESET=$(CLOCKSPRESET) \ - PLAT=$(PLAT) \ - all \ - fip -endef - -define Build/InstallDev - $(INSTALL_DIR) $(BIN_DIR)/flash-image-$(BUILD_VARIANT) - $(CP) $(PKG_BUILD_DIR)/build/$(PLAT)/release/flash-image.bin $(BIN_DIR)/flash-image-$(BUILD_VARIANT)/ - $(CP) $(PKG_BUILD_DIR)/build/$(PLAT)/release/uart-images.tgz $(BIN_DIR)/flash-image-$(BUILD_VARIANT)/ -endef - -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-512mb)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-1cs)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-1cs-emmc)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-2cs)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v3-v5-1gb-2cs-emmc)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v3-v5-2gb)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v3-v5-2gb-emmc)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v7-1gb)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v7-1gb-emmc)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v7-2gb)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-espressobin-v7-2gb-emmc)) -$(eval $(call BuildPackage,arm-trusted-firmware-mvebu-udpu)) +$(eval $(call BuildPackage/Trusted-Firmware-A)) -- 2.30.2