2021-02-02 18:04:33 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2017 Hauke Mehrtens
|
2021-02-10 02:47:53 +00:00
|
|
|
# Copyright (C) 2021 Daniel Golle
|
2021-02-02 18:04:33 +00:00
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
|
|
|
PKG_NAME:=arm-trusted-firmware-mediatek
|
|
|
|
PKG_RELEASE:=$(AUTORELEASE)
|
|
|
|
|
|
|
|
PKG_SOURCE_PROTO:=git
|
|
|
|
PKG_SOURCE_URL=https://github.com/mtk-openwrt/arm-trusted-firmware.git
|
|
|
|
PKG_SOURCE_DATE:=2020-11-09
|
|
|
|
PKG_SOURCE_VERSION:=03017334ccd8c0fac12e7db36749b95b9a7d745f
|
|
|
|
PKG_MIRROR_HASH:=b211b2f9143d4debc7ad8dc959cb606888af20af790855dd66c87e451b6a1bc7
|
|
|
|
|
|
|
|
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
PKG_LICENSE_FILES:=LICENCE.mediatek
|
|
|
|
|
|
|
|
BLOBS_TARBALL:=tfa-mtk-files-for-2020-11-09.tgz
|
|
|
|
BROMIMAGE_EXEC:=bromimage-x64
|
|
|
|
|
2021-02-03 14:48:45 +00:00
|
|
|
include $(INCLUDE_DIR)/trusted-firmware-a.mk
|
2021-02-02 18:04:33 +00:00
|
|
|
include $(INCLUDE_DIR)/package.mk
|
|
|
|
|
2021-02-24 18:55:56 +00:00
|
|
|
PKG_LICENSE+=proprietary
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Download/tfa-files
|
2021-02-23 18:02:40 +00:00
|
|
|
URL:=@OPENWRT
|
2021-02-10 02:47:53 +00:00
|
|
|
URL_FILE:=$(BLOBS_TARBALL)
|
|
|
|
FILE:=$(BLOBS_TARBALL)
|
|
|
|
HASH:=689b097e4531d3eeca0c477675ab3dc3cace6ba4ed8a339116a9ede6537839d7
|
|
|
|
endef
|
|
|
|
|
2021-02-02 18:04:33 +00:00
|
|
|
define Download/mt7622-header-emmc
|
|
|
|
URL:=https://raw.githubusercontent.com/frank-w/BPI-R64-ATF/a36efa5f7435b8079479d13b562fedc0aa0d42f0
|
|
|
|
URL_FILE:=header_emmc.bin
|
|
|
|
FILE:=mt7622-header_emmc.bin
|
|
|
|
HASH:=0a09c55d90c5fc375c59468a4331555f77cbc3e1dd107ca83b5b8c9625f38d8c
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Download/mt7622-header-sdmmc
|
|
|
|
URL:=https://raw.githubusercontent.com/frank-w/BPI-R64-ATF/a36efa5f7435b8079479d13b562fedc0aa0d42f0
|
|
|
|
URL_FILE:=header_sdmmc.bin
|
|
|
|
FILE:=mt7622-header_sdmmc.bin
|
|
|
|
HASH:=242908c04e25289d25ba9fab61a1930425af173051c43d275d1ac9877d6accb1
|
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Trusted-Firmware-A/Default
|
|
|
|
BUILD_TARGET:=mediatek
|
|
|
|
BUILD_SUBTARGET:=mt7622
|
|
|
|
PLAT:=mt7622
|
|
|
|
TFA_IMAGE:=bl2.img bl31.bin
|
|
|
|
BOOT_DEVICE:=
|
|
|
|
DDR_BLOB:=
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Trusted-Firmware-A/mt7622-nor-1ddr
|
|
|
|
NAME:=MediaTek MT7622 (SPI-NOR, 1x DDR3)
|
|
|
|
BOOT_DEVICE:=nor
|
|
|
|
DDR_BLOB:=1
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Trusted-Firmware-A/mt7622-nor-2ddr
|
|
|
|
NAME:=MediaTek MT7622 (SPI-NOR, 2x DDR3)
|
|
|
|
BOOT_DEVICE:=nor
|
|
|
|
DDR_BLOB:=2
|
2021-02-02 18:04:33 +00:00
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Trusted-Firmware-A/mt7622-snand-1ddr
|
|
|
|
NAME:=MediaTek MT7622 (SPI-NAND, 1x DDR3)
|
|
|
|
BOOT_DEVICE:=snand
|
|
|
|
DDR_BLOB:=1
|
2021-02-02 18:04:33 +00:00
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Trusted-Firmware-A/mt7622-snand-2ddr
|
|
|
|
NAME:=MediaTek MT7622 (SPI-SNAND, 2x DDR3)
|
|
|
|
BOOT_DEVICE:=snand
|
|
|
|
DDR_BLOB:=2
|
2021-02-02 18:04:33 +00:00
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Trusted-Firmware-A/mt7622-emmc-1ddr
|
|
|
|
NAME:=MediaTek MT7622 (eMMC, 1x DDR3)
|
|
|
|
BOOT_DEVICE:=emmc
|
|
|
|
DDR_BLOB:=1
|
2021-02-02 18:04:33 +00:00
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Trusted-Firmware-A/mt7622-emmc-2ddr
|
|
|
|
NAME:=MediaTek MT7622 (eMMC, 2x DDR3)
|
|
|
|
BOOT_DEVICE:=emmc
|
|
|
|
DDR_BLOB:=2
|
2021-02-02 18:04:33 +00:00
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Trusted-Firmware-A/mt7622-sdmmc-1ddr
|
|
|
|
NAME:=MediaTek MT7622 (SDcard, 1x DDR3)
|
|
|
|
BOOT_DEVICE:=sdmmc
|
|
|
|
DDR_BLOB:=1
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Trusted-Firmware-A/mt7622-sdmmc-2ddr
|
|
|
|
NAME:=MediaTek MT7622 (SDcard, 2x DDR3)
|
|
|
|
BOOT_DEVICE:=sdmmc
|
|
|
|
DDR_BLOB:=2
|
|
|
|
endef
|
|
|
|
|
|
|
|
TFA_TARGETS:= \
|
|
|
|
mt7622-nor-1ddr \
|
|
|
|
mt7622-nor-2ddr \
|
|
|
|
mt7622-snand-1ddr \
|
|
|
|
mt7622-snand-2ddr \
|
|
|
|
mt7622-emmc-1ddr \
|
|
|
|
mt7622-emmc-2ddr \
|
|
|
|
mt7622-sdmmc-1ddr \
|
|
|
|
mt7622-sdmmc-2ddr
|
2021-02-02 18:04:33 +00:00
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
TFA_MAKE_FLAGS += BOOT_DEVICE=$(BOOT_DEVICE) all
|
2021-02-02 18:04:33 +00:00
|
|
|
|
|
|
|
define Build/Prepare
|
|
|
|
$(call Build/Prepare/Default)
|
2021-02-10 02:47:53 +00:00
|
|
|
ifeq ($(BOOT_DEVICE),emmc)
|
2021-02-02 18:04:33 +00:00
|
|
|
$(eval $(call Download,mt7622-header-emmc))
|
|
|
|
endif
|
2021-02-10 02:47:53 +00:00
|
|
|
ifeq ($(BOOT_DEVICE),sdmmc)
|
2021-02-02 18:04:33 +00:00
|
|
|
$(eval $(call Download,mt7622-header-sdmmc))
|
|
|
|
endif
|
2021-02-10 02:47:53 +00:00
|
|
|
$(eval $(call Download,tfa-files))
|
|
|
|
# replace 'bromimage' tool by static version
|
|
|
|
$(TAR) -vxzf $(DL_DIR)/$(BLOBS_TARBALL) --wildcards \
|
|
|
|
-O "*/$(BROMIMAGE_EXEC)" > $(PKG_BUILD_DIR)/tools/mediatek/bromimage/bromimage
|
|
|
|
$(TAR) -vxzf $(DL_DIR)/$(BLOBS_TARBALL) --wildcards \
|
|
|
|
-C $(PKG_BUILD_DIR) \
|
|
|
|
--strip-components=1 */LICENCE.mediatek
|
2021-02-02 18:04:33 +00:00
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
define Build/Configure
|
|
|
|
$(call Build/Configure/Default)
|
|
|
|
# replace DRAM calib blobs if needed (variant '2' is shipped upstream)
|
|
|
|
ifeq ($(DDR_BLOB),1)
|
|
|
|
$(TAR) -vxzf $(DL_DIR)/$(BLOBS_TARBALL) --wildcards \
|
|
|
|
-C $(PKG_BUILD_DIR)/plat/mediatek/mt7622/drivers/dram/release \
|
|
|
|
--strip-components=1 */*.o
|
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Package/trusted-firmware-a/install
|
2021-02-02 18:04:33 +00:00
|
|
|
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
|
2021-02-10 02:47:53 +00:00
|
|
|
$(INSTALL_DATA) $(PKG_BUILD_DIR)/build/mt7622/release/bl2.img $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-bl2.img
|
|
|
|
$(INSTALL_DATA) $(PKG_BUILD_DIR)/build/mt7622/release/bl31.bin $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-bl31.bin
|
|
|
|
ifeq ($(BOOT_DEVICE),emmc)
|
|
|
|
$(INSTALL_DATA) $(DL_DIR)/mt7622-header_emmc.bin $(STAGING_DIR_IMAGE)/
|
2021-02-02 18:04:33 +00:00
|
|
|
endif
|
2021-02-10 02:47:53 +00:00
|
|
|
ifeq ($(BOOT_DEVICE),sdmmc)
|
|
|
|
$(INSTALL_DATA) $(DL_DIR)/mt7622-header_sdmmc.bin $(STAGING_DIR_IMAGE)/
|
2021-02-02 18:04:33 +00:00
|
|
|
endif
|
|
|
|
endef
|
|
|
|
|
2021-02-10 02:47:53 +00:00
|
|
|
$(eval $(call BuildPackage/Trusted-Firmware-A))
|