1 # SPDX-License-Identifier: GPL-2.0+
3 # (C) Copyright 2000-2006
4 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 # (C) Copyright 2011 Freescale Semiconductor, Inc.
8 ifeq ($(SOC),$(filter $(SOC),mx25 mx35 mx5 mx6 mx7 imx8m imx9 vf610))
12 ifeq ($(SOC),$(filter $(SOC),imx8m))
13 ifneq ($(CONFIG_SPL_BUILD),y)
14 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
16 obj-$(CONFIG_ENV_IS_IN_MMC) += mmc_env.o
17 obj-$(CONFIG_FEC_MXC) += mac.o
18 obj-$(CONFIG_DWC_ETH_QOS) += mac.o
19 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
20 obj-$(CONFIG_IMX_HAB) += hab.o
24 ifeq ($(SOC),$(filter $(SOC),mx5 mx6))
25 obj-y += cpu.o speed.o
26 ifneq ($(CONFIG_MX51),y)
29 obj-$(CONFIG_GPT_TIMER) += timer.o
30 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
32 ifeq ($(SOC),$(filter $(SOC),mx7 mx6 mxs imx8m imx8 imx9 imxrt))
34 obj-$(CONFIG_CMD_PRIBLOB) += priblob.o
35 obj-$(CONFIG_SPL_BUILD) += spl.o
37 ifeq ($(SOC),$(filter $(SOC),mx7))
39 obj-$(CONFIG_SYS_I2C_MXC) += i2c-mxv7.o
40 obj-$(CONFIG_ENV_IS_IN_MMC) += mmc_env.o
42 ifeq ($(SOC),$(filter $(SOC),mx7 imx8m))
43 ifneq ($(CONFIG_SPL_BUILD),y)
44 obj-$(CONFIG_FSL_MFGPROT) += cmd_mfgprot.o
47 ifeq ($(SOC),$(filter $(SOC),mx5 mx6 mx7))
48 obj-$(CONFIG_IMX_VIDEO_SKIP) += video.o
50 ifeq ($(SOC),$(filter $(SOC),mx6 mx7))
51 obj-y += cache.o init.o
52 obj-$(CONFIG_FEC_MXC) += mac.o
53 obj-$(CONFIG_IMX_RDC) += rdc-sema.o
54 ifneq ($(CONFIG_SPL_BUILD),y)
55 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
57 obj-$(CONFIG_$(SPL_)SATA) += sata.o
58 obj-$(CONFIG_IMX_HAB) += hab.o
59 obj-$(CONFIG_SYSCOUNTER_TIMER) += syscounter.o
61 ifeq ($(SOC),$(filter $(SOC),mx7ulp))
62 obj-y += cache.o mmdc_size.o
63 obj-$(CONFIG_IMX_HAB) += hab.o
65 ifeq ($(SOC),$(filter $(SOC),vf610))
66 obj-y += ddrmc-vf610.o
67 obj-$(CONFIG_DDRMC_VF610_CALIBRATION) += ddrmc-vf610-calibration.o
69 ifeq ($(SOC),$(filter $(SOC),imx8))
70 ifneq ($(CONFIG_SPL_BUILD),y)
71 obj-$(CONFIG_IMX_BOOTAUX) += imx_bootaux.o
74 ifneq ($(CONFIG_SPL_BUILD),y)
75 obj-$(CONFIG_CMD_BMODE) += cmd_bmode.o
76 obj-$(CONFIG_CMD_HDMIDETECT) += cmd_hdmidet.o
77 obj-$(CONFIG_CMD_DEKBLOB) += cmd_dek.o
78 obj-$(CONFIG_CMD_NANDBCB) += cmd_nandbcb.o
81 ifeq ($(CONFIG_SPL_BUILD),y)
82 obj-$(CONFIG_SPL_LOAD_IMX_CONTAINER) += image-container.o
85 ifeq ($(SOC),$(filter $(SOC),imx8ulp imx9))
86 obj-$(CONFIG_AHAB_BOOT) += ele_ahab.o
89 PLUGIN = board/$(BOARDDIR)/plugin
91 ifeq ($(CONFIG_USE_IMXIMG_PLUGIN),y)
93 $(PLUGIN).o: $(PLUGIN).S FORCE
94 $(Q)mkdir -p $(dir $@)
95 $(call if_changed_dep,as_o_S)
97 $(PLUGIN).bin: $(PLUGIN).o FORCE
98 $(Q)mkdir -p $(dir $@)
99 $(OBJCOPY) -O binary --gap-fill 0xff $< $@
106 quiet_cmd_cpp_cfg = CFGS $@
107 cmd_cpp_cfg = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -x c -o $@ $<
109 # mkimage source config file
110 IMX_CONFIG = $(CONFIG_IMX_CONFIG:"%"=%)
112 # How to create a cpp processed config file, they all use the same source
113 %.cfgout: $(IMX_CONFIG) FORCE
114 $(Q)mkdir -p $(dir $@)
115 $(call if_changed_dep,cpp_cfg)
117 IMX_CONTAINER_CFG = $(CONFIG_IMX_CONTAINER_CFG:"%"=%)
118 container.cfg: $(IMX_CONTAINER_CFG) FORCE
119 $(Q)mkdir -p $(dir $@)
120 $(call if_changed_dep,cpp_cfg)
122 ifeq ($(CONFIG_ARCH_IMX8), y)
123 CNTR_DEPFILES := $(srctree)/tools/imx_cntr_image.sh
124 IMAGE_TYPE := imx8image
125 ifeq ($(CONFIG_SPL_BUILD),y)
126 SPL_DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o spl/u-boot-spl.cfgout $(srctree)/$(IMX_CONFIG); if [ -f spl/u-boot-spl.cfgout ]; then $(CNTR_DEPFILES) spl/u-boot-spl.cfgout; echo $$?; fi)
128 DEPFILE_EXISTS := $(shell $(CPP) $(cpp_flags) -x c -o u-boot-dtb.cfgout $(srctree)/$(IMX_CONFIG); if [ -f u-boot-dtb.cfgout ]; then $(CNTR_DEPFILES) u-boot-dtb.cfgout; echo $$?; fi)
129 else ifeq ($(CONFIG_ARCH_IMX8M), y)
130 IMAGE_TYPE := imx8mimage
132 else ifeq ($(CONFIG_ARCH_IMX9)$(CONFIG_ARCH_IMX8ULP), y)
133 IMAGE_TYPE := imx8image
136 IMAGE_TYPE := imximage
140 MKIMAGEFLAGS_u-boot.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
141 -T $(IMAGE_TYPE) -e $(CONFIG_TEXT_BASE)
142 u-boot.imx: MKIMAGEOUTPUT = u-boot.imx.log
144 u-boot.imx: u-boot.bin u-boot.cfgout $(PLUGIN).bin FORCE
145 $(call if_changed,mkimage)
147 quiet_cmd_u-boot-nand_imx = GEN $@
148 cmd_u-boot-nand_imx = (dd bs=1024 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@.zero-padded ; \
149 (dd bs=10k count=1 if=/dev/zero 2>/dev/null) | cat $@.zero-padded - > $@ ; \
152 u-boot-nand.imx: u-boot.imx FORCE
153 $(call if_changed,u-boot-nand_imx)
155 ifeq ($(CONFIG_MULTI_DTB_FIT),y)
156 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
157 -T $(IMAGE_TYPE) -e $(CONFIG_TEXT_BASE)
158 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
160 u-boot-dtb.imx: u-boot-fit-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
161 ifeq ($(DEPFILE_EXISTS),0)
162 $(call if_changed,mkimage)
164 else ifeq ($(CONFIG_OF_SEPARATE),y)
165 MKIMAGEFLAGS_u-boot-dtb.imx = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
166 -T $(IMAGE_TYPE) -e $(CONFIG_TEXT_BASE)
167 u-boot-dtb.imx: MKIMAGEOUTPUT = u-boot-dtb.imx.log
169 u-boot-dtb.imx: u-boot-dtb.bin u-boot-dtb.cfgout $(PLUGIN).bin FORCE
170 ifeq ($(DEPFILE_EXISTS),0)
171 $(call if_changed,mkimage)
176 ifeq ($(CONFIG_ARCH_IMX8M), y)
178 SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
180 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout \
181 -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
182 flash.bin: MKIMAGEOUTPUT = flash.log
184 spl/u-boot-spl.cfgout: $(IMX_CONFIG) FORCE
185 $(Q)mkdir -p $(dir $@)
186 $(call if_changed_dep,cpp_cfg)
188 spl/u-boot-spl-ddr.bin: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
190 flash.bin: spl/u-boot-spl-ddr.bin u-boot.itb FORCE
191 $(call if_changed,mkimage)
194 ifeq ($(CONFIG_ARCH_IMX8), y)
197 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout -T $(IMAGE_TYPE) -e 0x100000
198 flash.bin: MKIMAGEOUTPUT = flash.log
200 MKIMAGEFLAGS_u-boot.cnt = -n container.cfg -T $(IMAGE_TYPE) -e 0x100000
201 u-boot.cnt: MKIMAGEOUTPUT = u-boot.cnt.log
203 ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y)
204 u-boot.cnt: u-boot.bin container.cfg FORCE
205 $(call if_changed,mkimage)
206 flash.bin: spl/u-boot-spl.bin FORCE
207 $(call if_changed,mkimage)
208 @flashbin_size=`wc -c flash.bin | awk '{print $$1}'`; \
209 pad_cnt=$$(((flashbin_size + 0x400 - 1) / 0x400)); \
210 echo "append u-boot.cnt at $$pad_cnt KB"; \
211 dd if=u-boot.cnt of=flash.bin bs=1K seek=$$pad_cnt;
213 flash.bin: spl/u-boot-spl.bin FORCE
214 $(call if_changed,mkimage)
218 ifeq ($(CONFIG_ARCH_IMX9)$(CONFIG_ARCH_IMX8ULP), y)
220 quiet_cmd_cpp_cfg_imx9_check = CHECK $@
221 cmd_cpp_cfg_imx9_check = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -x c -o $@ $< && $(srctree)/tools/imx9_image.sh $@
223 SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout u-boot-container.cfgout FORCE
225 MKIMAGEFLAGS_flash.bin = -n spl/u-boot-spl.cfgout -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
226 flash.bin: MKIMAGEOUTPUT = flash.log
228 spl/u-boot-spl.cfgout: $(IMX_CONFIG) FORCE
229 $(Q)mkdir -p $(dir $@)
230 $(call if_changed_dep,cpp_cfg_imx9_check)
232 spl/u-boot-spl-ddr.bin: spl/u-boot-spl.bin spl/u-boot-spl.cfgout FORCE
234 u-boot-container.cfgout: $(IMX_CONTAINER_CFG) FORCE
235 $(Q)mkdir -p $(dir $@)
236 $(call if_changed_dep,cpp_cfg_imx9_check)
238 flash.bin: spl/u-boot-spl-ddr.bin container.cfgout FORCE
239 $(call if_changed,mkimage)
243 MKIMAGEFLAGS_SPL = -n $(filter-out $(PLUGIN).bin $< $(PHONY),$^) \
244 -T $(IMAGE_TYPE) -e $(CONFIG_SPL_TEXT_BASE)
245 SPL: MKIMAGEOUTPUT = SPL.log
247 SPL: spl/u-boot-spl.bin spl/u-boot-spl.cfgout $(PLUGIN).bin FORCE
248 $(call if_changed,mkimage)
250 MKIMAGEFLAGS_u-boot.uim = -A arm -O U-Boot -a $(CONFIG_TEXT_BASE) \
251 -e $(CONFIG_TEXT_BASE) -C none -T firmware
253 u-boot.uim: u-boot.bin FORCE
254 $(call if_changed,mkimage)
256 OBJCOPYFLAGS += -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
257 append = cat $(filter-out $< $(PHONY), $^) >> $@
259 quiet_cmd_pad_cat = CAT $@
260 cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $@
262 u-boot-with-spl.imx: SPL $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
263 $(call if_changed,pad_cat)
265 u-boot-with-nand-spl.imx: spl/u-boot-nand-spl.imx $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE
266 $(call if_changed,pad_cat)
268 quiet_cmd_u-boot-nand-spl_imx = GEN $@
269 cmd_u-boot-nand-spl_imx = (printf '\000\000\000\000\106\103\102\040\001' && \
270 dd bs=1015 count=1 if=/dev/zero 2>/dev/null) | cat - $< > $@
272 spl/u-boot-nand-spl.imx: SPL FORCE
273 $(call if_changed,u-boot-nand-spl_imx)
276 targets += $(addprefix ../../../,SPL spl/u-boot-spl.cfgout u-boot-dtb.cfgout u-boot.cfgout u-boot.uim spl/u-boot-nand-spl.imx)
278 obj-$(CONFIG_MX5) += mx5/
279 obj-$(CONFIG_MX6) += mx6/
280 obj-$(CONFIG_MX7) += mx7/
281 obj-$(CONFIG_ARCH_MX7ULP) += mx7ulp/
282 obj-$(CONFIG_ARCH_IMX8ULP) += imx8ulp/
283 obj-$(CONFIG_IMX8M) += imx8m/
284 obj-$(CONFIG_ARCH_IMX8) += imx8/
285 obj-$(CONFIG_ARCH_IMX9) += imx9/
286 obj-$(CONFIG_ARCH_IMXRT) += imxrt/
288 obj-$(CONFIG_SPL_BOOTROM_SUPPORT) += spl_imx_romapi.o
289 obj-$(CONFIG_IMX8_ROMAPI) += romapi.o