tfa-layerscape: fix fiptool host build
[openwrt/openwrt.git] / package / boot / tfa-layerscape / Makefile
1 #
2 # Copyright 2019 NXP
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=tfa-layerscape
11 PKG_VERSION:=lsdk-1903
12 PKG_RELEASE:=1
13
14 PKG_SOURCE_PROTO:=git
15 PKG_SOURCE_URL:=https://source.codeaurora.org/external/qoriq/qoriq-components/atf
16 PKG_SOURCE_VERSION:=7e34aebe658c7c3439d2d68b0ce6b9776e8e6996
17 PKG_MIRROR_HASH:=9cf0bc32fa589a0ee7c48c87898679e645341f29da1253d0ba5d2e82c6ea074d
18 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
19 PKG_BUILD_DEPENDS:=uboot-layerscape tfa-layerscape/host
20
21 include $(INCLUDE_DIR)/host-build.mk
22 include $(INCLUDE_DIR)/package.mk
23
24 define Package/tfa-layerscape/Config
25 define Package/tfa-$(1)
26 SECTION:=boot
27 CATEGORY:=Boot Loaders
28 TITLE:=$(2)
29 DEPENDS:=@TARGET_layerscape_armv8_64b +layerscape-rcw-$(1)
30 HIDDEN:=1
31 VARIANT:=$(1)
32 BIN_BL2:=$(3)
33 BIN_FIP:=$(4)
34 endef
35 endef
36
37 define Package/tfa-layerscape/Install
38 define Package/tfa-$(1)/install
39 $(INSTALL_DIR) $(STAGING_DIR_IMAGE)
40 $(CP) $(PKG_BUILD_DIR)/$(BIN_BL2) $(STAGING_DIR_IMAGE)/$(1)-bl2.pbl
41 $(CP) $(PKG_BUILD_DIR)/$(BIN_FIP) $(STAGING_DIR_IMAGE)/$(1)-fip.bin
42 endef
43 endef
44
45 define Build/Compile
46 $(eval $(Package/tfa-layerscape/$(BUILD_VARIANT))) \
47 $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE=$(TARGET_CROSS) \
48 fip pbl PLAT=$(PLAT) BOOT_MODE=$(BOOT_MODE) \
49 RCW=$(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-rcw.bin \
50 BL33=$(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-uboot.bin \
51 FIPTOOL=$(STAGING_DIR_HOST)/bin/fiptool
52 endef
53
54 HOST_CFLAGS += -Wall -Werror -pedantic -std=c99
55 define Host/Compile
56 $(MAKE) -C \
57 $(HOST_BUILD_DIR)/tools/fiptool \
58 CFLAGS="$(HOST_CFLAGS)" \
59 LDFLAGS="$(HOST_LDFLAGS)"
60 endef
61
62 define Host/Install
63 $(INSTALL_BIN) $(HOST_BUILD_DIR)/tools/fiptool/fiptool $(STAGING_DIR_HOST)/bin/
64 endef
65
66 define Package/tfa-layerscape/ls1012ardb
67 TITLE:=NXP LS1012ARDB Trusted Firmware
68 PLAT:=ls1012ardb
69 BOOT_MODE:=qspi
70 BIN_BL2:=build/ls1012ardb/release/bl2_qspi.pbl
71 BIN_FIP:=build/ls1012ardb/release/fip.bin
72 endef
73
74 define Package/tfa-layerscape/ls1012afrwy
75 TITLE:=NXP LS1012AFRWY Trusted Firmware
76 PLAT:=ls1012afrwy
77 BOOT_MODE:=qspi
78 BIN_BL2:=build/ls1012afrwy/release/bl2_qspi.pbl
79 BIN_FIP:=build/ls1012afrwy/release/fip.bin
80 endef
81
82 define Package/tfa-layerscape/ls1043ardb
83 TITLE:=NXP LS1043ARDB Trusted Firmware
84 PLAT:=ls1043ardb
85 BOOT_MODE:=nor
86 BIN_BL2:=build/ls1043ardb/release/bl2_nor.pbl
87 BIN_FIP:=build/ls1043ardb/release/fip.bin
88 endef
89
90 define Package/tfa-layerscape/ls1043ardb-sdboot
91 TITLE:=NXP LS1043ARDB SD Boot Trusted Firmware
92 PLAT:=ls1043ardb
93 BOOT_MODE:=sd
94 BIN_BL2:=build/ls1043ardb/release/bl2_sd.pbl
95 BIN_FIP:=build/ls1043ardb/release/fip.bin
96 endef
97
98 define Package/tfa-layerscape/ls1046ardb
99 TITLE:=NXP LS1046ARDB Trusted Firmware
100 PLAT:=ls1046ardb
101 BOOT_MODE:=qspi
102 BIN_BL2:=build/ls1046ardb/release/bl2_qspi.pbl
103 BIN_FIP:=build/ls1046ardb/release/fip.bin
104 endef
105
106 define Package/tfa-layerscape/ls1046ardb-sdboot
107 TITLE:=NXP LS1046ARDB SD Boot Trusted Firmware
108 PLAT:=ls1046ardb
109 BOOT_MODE:=sd
110 BIN_BL2:=build/ls1046ardb/release/bl2_sd.pbl
111 BIN_FIP:=build/ls1046ardb/release/fip.bin
112 endef
113
114 define Package/tfa-layerscape/ls1088ardb
115 TITLE:=NXP LS1088ARDB Trusted Firmware
116 PLAT:=ls1088ardb
117 BOOT_MODE:=qspi
118 BIN_BL2:=build/ls1088ardb/release/bl2_qspi.pbl
119 BIN_FIP:=build/ls1088ardb/release/fip.bin
120 endef
121
122 define Package/tfa-layerscape/ls1088ardb-sdboot
123 TITLE:=NXP LS1088ARDB SD Boot Trusted Firmware
124 PLAT:=ls1088ardb
125 BOOT_MODE:=sd
126 BIN_BL2:=build/ls1088ardb/release/bl2_sd.pbl
127 BIN_FIP:=build/ls1088ardb/release/fip.bin
128 endef
129
130 define Package/tfa-layerscape/ls2088ardb
131 TITLE:=NXP LS2088ARDB Trusted Firmware
132 PLAT:=ls2088ardb
133 BOOT_MODE:=nor
134 BIN_BL2:=build/ls2088ardb/release/bl2_nor.pbl
135 BIN_FIP:=build/ls2088ardb/release/fip.bin
136 endef
137
138 TFAS := \
139 ls1012ardb \
140 ls1012afrwy \
141 ls1043ardb \
142 ls1043ardb-sdboot \
143 ls1046ardb \
144 ls1046ardb-sdboot \
145 ls1088ardb \
146 ls1088ardb-sdboot \
147 ls2088ardb
148
149 $(eval $(call HostBuild))
150 $(foreach tfa,$(TFAS), \
151 $(eval $(Package/tfa-layerscape/$(tfa))) \
152 $(eval $(call Package/tfa-layerscape/Config,$(tfa),$(TITLE),$(BIN_BL2),$(BIN_FIP))) \
153 $(eval $(call Package/tfa-layerscape/Install,$(tfa))) \
154 $(eval $(call BuildPackage,tfa-$(tfa))) \
155 )