tfa-layerscape: fix create_pbl and byte_swap 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/tfa-fiptool \
52 CREATE_PBL=$(STAGING_DIR_HOST)/bin/tfa-create-pbl \
53 BYTE_SWAP=$(STAGING_DIR_HOST)/bin/tfa-byte-swap
54 endef
55
56 HOST_CFLAGS += -Wall -Werror -pedantic -std=c99
57 define Host/Compile
58 $(MAKE) -C \
59 $(HOST_BUILD_DIR)/tools/fiptool \
60 CFLAGS="$(HOST_CFLAGS)" \
61 LDFLAGS="$(HOST_LDFLAGS)"
62 $(MAKE) -C \
63 $(HOST_BUILD_DIR)/plat/nxp/tools \
64 CFLAGS="$(HOST_CFLAGS)"
65 endef
66
67 define Host/Install
68 $(INSTALL_BIN) $(HOST_BUILD_DIR)/tools/fiptool/fiptool $(STAGING_DIR_HOST)/bin/tfa-fiptool
69 $(INSTALL_BIN) $(HOST_BUILD_DIR)/plat/nxp/tools/create_pbl $(STAGING_DIR_HOST)/bin/tfa-create-pbl
70 $(INSTALL_BIN) $(HOST_BUILD_DIR)/plat/nxp/tools/byte_swap $(STAGING_DIR_HOST)/bin/tfa-byte-swap
71 endef
72
73 define Package/tfa-layerscape/ls1012ardb
74 TITLE:=NXP LS1012ARDB Trusted Firmware
75 PLAT:=ls1012ardb
76 BOOT_MODE:=qspi
77 BIN_BL2:=build/ls1012ardb/release/bl2_qspi.pbl
78 BIN_FIP:=build/ls1012ardb/release/fip.bin
79 endef
80
81 define Package/tfa-layerscape/ls1012afrwy
82 TITLE:=NXP LS1012AFRWY Trusted Firmware
83 PLAT:=ls1012afrwy
84 BOOT_MODE:=qspi
85 BIN_BL2:=build/ls1012afrwy/release/bl2_qspi.pbl
86 BIN_FIP:=build/ls1012afrwy/release/fip.bin
87 endef
88
89 define Package/tfa-layerscape/ls1043ardb
90 TITLE:=NXP LS1043ARDB Trusted Firmware
91 PLAT:=ls1043ardb
92 BOOT_MODE:=nor
93 BIN_BL2:=build/ls1043ardb/release/bl2_nor.pbl
94 BIN_FIP:=build/ls1043ardb/release/fip.bin
95 endef
96
97 define Package/tfa-layerscape/ls1043ardb-sdboot
98 TITLE:=NXP LS1043ARDB SD Boot Trusted Firmware
99 PLAT:=ls1043ardb
100 BOOT_MODE:=sd
101 BIN_BL2:=build/ls1043ardb/release/bl2_sd.pbl
102 BIN_FIP:=build/ls1043ardb/release/fip.bin
103 endef
104
105 define Package/tfa-layerscape/ls1046ardb
106 TITLE:=NXP LS1046ARDB Trusted Firmware
107 PLAT:=ls1046ardb
108 BOOT_MODE:=qspi
109 BIN_BL2:=build/ls1046ardb/release/bl2_qspi.pbl
110 BIN_FIP:=build/ls1046ardb/release/fip.bin
111 endef
112
113 define Package/tfa-layerscape/ls1046ardb-sdboot
114 TITLE:=NXP LS1046ARDB SD Boot Trusted Firmware
115 PLAT:=ls1046ardb
116 BOOT_MODE:=sd
117 BIN_BL2:=build/ls1046ardb/release/bl2_sd.pbl
118 BIN_FIP:=build/ls1046ardb/release/fip.bin
119 endef
120
121 define Package/tfa-layerscape/ls1088ardb
122 TITLE:=NXP LS1088ARDB Trusted Firmware
123 PLAT:=ls1088ardb
124 BOOT_MODE:=qspi
125 BIN_BL2:=build/ls1088ardb/release/bl2_qspi.pbl
126 BIN_FIP:=build/ls1088ardb/release/fip.bin
127 endef
128
129 define Package/tfa-layerscape/ls1088ardb-sdboot
130 TITLE:=NXP LS1088ARDB SD Boot Trusted Firmware
131 PLAT:=ls1088ardb
132 BOOT_MODE:=sd
133 BIN_BL2:=build/ls1088ardb/release/bl2_sd.pbl
134 BIN_FIP:=build/ls1088ardb/release/fip.bin
135 endef
136
137 define Package/tfa-layerscape/ls2088ardb
138 TITLE:=NXP LS2088ARDB Trusted Firmware
139 PLAT:=ls2088ardb
140 BOOT_MODE:=nor
141 BIN_BL2:=build/ls2088ardb/release/bl2_nor.pbl
142 BIN_FIP:=build/ls2088ardb/release/fip.bin
143 endef
144
145 TFAS := \
146 ls1012ardb \
147 ls1012afrwy \
148 ls1043ardb \
149 ls1043ardb-sdboot \
150 ls1046ardb \
151 ls1046ardb-sdboot \
152 ls1088ardb \
153 ls1088ardb-sdboot \
154 ls2088ardb
155
156 $(eval $(call HostBuild))
157 $(foreach tfa,$(TFAS), \
158 $(eval $(Package/tfa-layerscape/$(tfa))) \
159 $(eval $(call Package/tfa-layerscape/Config,$(tfa),$(TITLE),$(BIN_BL2),$(BIN_FIP))) \
160 $(eval $(call Package/tfa-layerscape/Install,$(tfa))) \
161 $(eval $(call BuildPackage,tfa-$(tfa))) \
162 )