Makefile.spl 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. # SPDX-License-Identifier: GPL-2.0+
  2. #
  3. # (C) Copyright 2000-2011
  4. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. #
  6. # (C) Copyright 2011
  7. # Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
  8. #
  9. # (C) Copyright 2011
  10. # Texas Instruments Incorporated - http://www.ti.com/
  11. # Aneesh V <aneesh@ti.com>
  12. # Based on top-level Makefile.
  13. #
  14. src := $(obj)
  15. # Create output directory if not already present
  16. _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
  17. include $(srctree)/scripts/Kbuild.include
  18. -include include/config/auto.conf
  19. -include $(obj)/include/autoconf.mk
  20. UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
  21. KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
  22. ifeq ($(CONFIG_TPL_BUILD),y)
  23. KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
  24. endif
  25. ifeq ($(CONFIG_TPL_BUILD),y)
  26. SPL_BIN := u-boot-tpl
  27. SPL_NAME := tpl
  28. else
  29. SPL_BIN := u-boot-spl
  30. SPL_NAME := spl
  31. endif
  32. export SPL_NAME
  33. ifdef CONFIG_SPL_BUILD
  34. SPL_ := SPL_
  35. ifeq ($(CONFIG_TPL_BUILD),y)
  36. SPL_TPL_ := TPL_
  37. else
  38. SPL_TPL_ := SPL_
  39. endif
  40. else
  41. SPL_ :=
  42. SPL_TPL_ :=
  43. endif
  44. ifeq ($(obj)$(CONFIG_SUPPORT_SPL),spl)
  45. $(error You cannot build SPL without enabling CONFIG_SUPPORT_SPL)
  46. endif
  47. ifeq ($(obj)$(CONFIG_SUPPORT_TPL),tpl)
  48. $(error You cannot build TPL without enabling CONFIG_SUPPORT_TPL)
  49. endif
  50. include $(srctree)/config.mk
  51. include $(srctree)/arch/$(ARCH)/Makefile
  52. include $(srctree)/scripts/Makefile.lib
  53. # Enable garbage collection of un-used sections for SPL
  54. KBUILD_CFLAGS += -ffunction-sections -fdata-sections
  55. LDFLAGS_FINAL += --gc-sections
  56. ifeq ($(CONFIG_$(SPL_TPL_)STACKPROTECTOR),y)
  57. KBUILD_CFLAGS += -fstack-protector-strong
  58. else
  59. KBUILD_CFLAGS += -fno-stack-protector
  60. endif
  61. # FIX ME
  62. cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
  63. $(NOSTDINC_FLAGS)
  64. c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
  65. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
  66. libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
  67. libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  68. ifeq ($(CONFIG_TPL_BUILD),y)
  69. libs-$(CONFIG_TPL_FRAMEWORK) += common/spl/
  70. else
  71. libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
  72. endif
  73. libs-y += common/init/
  74. # Special handling for a few options which support SPL/TPL
  75. ifeq ($(CONFIG_TPL_BUILD),y)
  76. libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
  77. libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/
  78. else
  79. libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
  80. libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
  81. ifdef CONFIG_SPL_FRAMEWORK
  82. libs-$(CONFIG_PARTITIONS) += disk/
  83. endif
  84. endif
  85. libs-y += drivers/
  86. libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/dwc3/
  87. libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/cdns3/
  88. libs-y += dts/
  89. libs-y += fs/
  90. libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
  91. libs-$(CONFIG_SPL_NET_SUPPORT) += net/
  92. libs-$(CONFIG_SPL_UNIT_TEST) += test/
  93. head-y := $(addprefix $(obj)/,$(head-y))
  94. libs-y := $(addprefix $(obj)/,$(libs-y))
  95. u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y)))
  96. libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
  97. # Add GCC lib
  98. ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
  99. PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
  100. PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
  101. endif
  102. u-boot-spl-init := $(head-y)
  103. u-boot-spl-main := $(libs-y)
  104. ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA
  105. platdata-hdr := include/generated/dt-structs-gen.h include/generated/dt-decl.h
  106. platdata-inst := $(obj)/dts/dt-uclass.o $(obj)/dts/dt-device.o
  107. platdata-noinst := $(obj)/dts/dt-plat.o
  108. ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA_INST
  109. u-boot-spl-platdata := $(platdata-inst)
  110. u-boot-spl-old-platdata := $(platdata-noinst)
  111. else
  112. u-boot-spl-platdata := $(platdata-noinst)
  113. u-boot-spl-old-platdata := $(platdata-inst)
  114. endif
  115. # Files we need to generate
  116. u-boot-spl-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-platdata))
  117. # Files we won't generate and should remove
  118. u-boot-spl-old-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-old-platdata))
  119. endif # OF_PLATDATA
  120. # Linker Script
  121. # First test whether there's a linker-script for the specific stage defined...
  122. ifneq ($(CONFIG_$(SPL_TPL_)LDSCRIPT),)
  123. # need to strip off double quotes
  124. LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_$(SPL_TPL_)LDSCRIPT:"%"=%))
  125. else
  126. # ...then fall back to the generic SPL linker-script
  127. ifneq ($(CONFIG_SPL_LDSCRIPT),)
  128. # need to strip off double quotes
  129. LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
  130. endif
  131. endif
  132. ifeq ($(wildcard $(LDSCRIPT)),)
  133. LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds
  134. endif
  135. ifeq ($(wildcard $(LDSCRIPT)),)
  136. LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds
  137. endif
  138. ifeq ($(wildcard $(LDSCRIPT)),)
  139. LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds
  140. endif
  141. ifeq ($(wildcard $(LDSCRIPT)),)
  142. $(error could not find linker script)
  143. endif
  144. # Special flags for CPP when processing the linker script.
  145. # Pass the version down so we can handle backwards compatibility
  146. # on the fly.
  147. LDPPFLAGS += \
  148. -include $(srctree)/include/u-boot/u-boot.lds.h \
  149. -include $(objtree)/include/config.h \
  150. -DCPUDIR=$(CPUDIR) \
  151. $(shell $(LD) --version | \
  152. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  153. # Turn various CONFIG symbols into IMAGE symbols for easy reuse of
  154. # the scripts between SPL and TPL.
  155. ifneq ($(CONFIG_$(SPL_TPL_)MAX_SIZE),)
  156. LDPPFLAGS += -DIMAGE_MAX_SIZE=$(CONFIG_$(SPL_TPL_)MAX_SIZE)
  157. endif
  158. ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
  159. LDPPFLAGS += -DIMAGE_TEXT_BASE=$(CONFIG_$(SPL_TPL_)TEXT_BASE)
  160. endif
  161. MKIMAGEOUTPUT ?= /dev/null
  162. quiet_cmd_mkimage = MKIMAGE $@
  163. cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
  164. >$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
  165. quiet_cmd_mkfitimage = MKIMAGE $@
  166. cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -f $(SPL_ITS) -E $@ \
  167. $(if $(KBUILD_VERBOSE:1=), MKIMAGEOUTPUT)
  168. MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE)
  169. MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
  170. MLO MLO.byteswap: $(obj)/u-boot-spl.bin FORCE
  171. $(call if_changed,mkimage)
  172. ifeq ($(CONFIG_SYS_SOC),"at91")
  173. MKIMAGEFLAGS_boot.bin = -T atmelimage
  174. ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y)
  175. MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params)
  176. $(obj)/boot.bin: $(obj)/../tools/atmel_pmecc_params
  177. endif
  178. $(obj)/boot.bin: $(obj)/u-boot-spl.bin FORCE
  179. $(call if_changed,mkimage)
  180. else
  181. ifdef CONFIG_ARCH_ZYNQ
  182. MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE)
  183. endif
  184. ifdef CONFIG_ARCH_ZYNQMP
  185. ifneq ($(CONFIG_PMUFW_INIT_FILE),"")
  186. spl/boot.bin: zynqmp-check-pmufw
  187. zynqmp-check-pmufw: FORCE
  188. ( cd $(srctree) && test -r $(CONFIG_PMUFW_INIT_FILE) ) \
  189. || ( echo "Cannot read $(CONFIG_PMUFW_INIT_FILE)" && false )
  190. endif
  191. MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) \
  192. -n "$(shell cd $(srctree); readlink -f $(CONFIG_PMUFW_INIT_FILE))"
  193. endif
  194. $(obj)/$(SPL_BIN)-align.bin: $(obj)/$(SPL_BIN).bin
  195. @dd if=$< of=$@ conv=block,sync bs=4 2>/dev/null;
  196. spl/boot.bin: $(obj)/$(SPL_BIN)-align.bin FORCE
  197. $(call if_changed,mkimage)
  198. endif
  199. INPUTS-y += $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN).sym
  200. ifdef CONFIG_SAMSUNG
  201. INPUTS-y += $(obj)/$(BOARD)-spl.bin
  202. endif
  203. ifneq ($(CONFIG_TARGET_SOCFPGA_GEN5)$(CONFIG_TARGET_SOCFPGA_ARRIA10),)
  204. INPUTS-y += $(obj)/$(SPL_BIN).sfp
  205. endif
  206. INPUTS-$(CONFIG_TARGET_SOCFPGA_SOC64) += $(obj)/u-boot-spl-dtb.hex
  207. ifdef CONFIG_ARCH_SUNXI
  208. INPUTS-y += $(obj)/sunxi-spl.bin
  209. ifdef CONFIG_NAND_SUNXI
  210. INPUTS-y += $(obj)/sunxi-spl-with-ecc.bin
  211. endif
  212. endif
  213. ifeq ($(CONFIG_SYS_SOC),"at91")
  214. INPUTS-y += $(obj)/boot.bin
  215. endif
  216. ifdef CONFIG_TPL_BUILD
  217. INPUTS-$(CONFIG_TPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-tpl.bin \
  218. $(obj)/u-boot-x86-reset16-tpl.bin
  219. else
  220. INPUTS-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-spl.bin \
  221. $(obj)/u-boot-x86-reset16-spl.bin
  222. endif
  223. INPUTS-$(CONFIG_ARCH_ZYNQ) += $(obj)/boot.bin
  224. INPUTS-$(CONFIG_ARCH_ZYNQMP) += $(obj)/boot.bin
  225. INPUTS-$(CONFIG_ARCH_MEDIATEK) += $(obj)/u-boot-spl-mtk.bin
  226. all: $(INPUTS-y)
  227. quiet_cmd_cat = CAT $@
  228. cmd_cat = cat $(filter-out $(PHONY), $^) > $@
  229. quiet_cmd_copy = COPY $@
  230. cmd_copy = cp $< $@
  231. ifneq ($(CONFIG_SPL_MULTI_DTB_FIT),y)
  232. FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).dtb
  233. else ifeq ($(CONFIG_SPL_MULTI_DTB_FIT_LZO),y)
  234. FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.lzo
  235. else ifeq ($(CONFIG_SPL_MULTI_DTB_FIT_GZIP),y)
  236. FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.gz
  237. else
  238. FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit
  239. endif
  240. # Build the .dtb file if:
  241. # - we are not using OF_PLATDATA
  242. # - we are using OF_CONTROL
  243. # - we have either OF_SEPARATE or OF_HOSTFILE
  244. build_dtb :=
  245. ifeq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA),)
  246. ifneq ($(CONFIG_$(SPL_TPL_)OF_CONTROL),)
  247. ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_OF_HOSTFILE),y)
  248. build_dtb := y
  249. endif
  250. endif
  251. endif
  252. ifneq ($(build_dtb),)
  253. $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
  254. $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
  255. $(FINAL_DTB_CONTAINER) FORCE
  256. $(call if_changed,cat)
  257. $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE
  258. $(call if_changed,copy)
  259. else
  260. $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-nodtb.bin FORCE
  261. $(call if_changed,copy)
  262. endif
  263. # Create a file that pads from the end of u-boot-spl-nodtb.bin to bss_end
  264. $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN)
  265. @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " toupper(size)}' | bc); \
  266. dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null;
  267. $(obj)/$(SPL_BIN).dtb: $(obj)/dts/dt-$(SPL_NAME).dtb FORCE
  268. $(call if_changed,copy)
  269. pythonpath = PYTHONPATH=scripts/dtc/pylibfdt
  270. DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \
  271. -d $(obj)/$(SPL_BIN).dtb -p $(SPL_NAME)
  272. ifneq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA_INST),)
  273. DTOC_ARGS += -i
  274. endif
  275. quiet_cmd_dtoc = DTOC $@
  276. cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all
  277. quiet_cmd_plat = PLAT $@
  278. cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
  279. $(obj)/dts/dt-%.o: $(obj)/dts/dt-%.c $(platdata-hdr)
  280. $(call if_changed,plat)
  281. # Don't use dts_dir here, since it forces running this expensive rule every time
  282. $(platdata-hdr) $(u-boot-spl-platdata_c) &: $(obj)/$(SPL_BIN).dtb
  283. @[ -d $(obj)/dts ] || mkdir -p $(obj)/dts
  284. @# Remove old files since which ones we generate depends on the setting
  285. @# of OF_PLATDATA_INST and this might change between builds. Leaving old
  286. @# ones around is confusing and it is possible that switching the
  287. @# setting again will use the old one instead of regenerating it.
  288. @rm -f $(u-boot-spl-all-platdata_c) $(u-boot-spl-all-platdata)
  289. $(call if_changed,dtoc)
  290. ifdef CONFIG_SAMSUNG
  291. ifdef CONFIG_VAR_SIZE_SPL
  292. VAR_SIZE_PARAM = --vs
  293. else
  294. VAR_SIZE_PARAM =
  295. endif
  296. $(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
  297. $(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
  298. $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
  299. $(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
  300. endif
  301. quiet_cmd_objcopy = OBJCOPY $@
  302. cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
  303. OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary \
  304. $(if $(CONFIG_$(SPL_TPL_)X86_16BIT_INIT),-R .start16 -R .resetvec)
  305. $(obj)/$(SPL_BIN)-nodtb.bin: $(obj)/$(SPL_BIN) FORCE
  306. $(call if_changed,objcopy)
  307. OBJCOPYFLAGS_u-boot-x86-start16-spl.bin := -O binary -j .start16
  308. $(obj)/u-boot-x86-start16-spl.bin: $(obj)/u-boot-spl FORCE
  309. $(call if_changed,objcopy)
  310. OBJCOPYFLAGS_u-boot-x86-start16-tpl.bin := -O binary -j .start16
  311. $(obj)/u-boot-x86-start16-tpl.bin: $(obj)/u-boot-tpl FORCE
  312. $(call if_changed,objcopy)
  313. OBJCOPYFLAGS_u-boot-x86-reset16-spl.bin := -O binary -j .resetvec
  314. $(obj)/u-boot-x86-reset16-spl.bin: $(obj)/u-boot-spl FORCE
  315. $(call if_changed,objcopy)
  316. OBJCOPYFLAGS_u-boot-x86-reset16-tpl.bin := -O binary -j .resetvec
  317. $(obj)/u-boot-x86-reset16-tpl.bin: $(obj)/u-boot-tpl FORCE
  318. $(call if_changed,objcopy)
  319. LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
  320. # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
  321. LDFLAGS_$(SPL_BIN) += $(call ld-option, --no-dynamic-linker)
  322. LDFLAGS_$(SPL_BIN) += --build-id=none
  323. # Pick the best-match (i.e. SPL_TEXT_BASE for SPL, TPL_TEXT_BASE for TPL)
  324. ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
  325. LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_$(SPL_TPL_)TEXT_BASE)
  326. endif
  327. ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
  328. MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage_v1
  329. else
  330. MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage
  331. endif
  332. $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE
  333. $(call if_changed,mkimage)
  334. MKIMAGEFLAGS_sunxi-spl.bin = -T sunxi_egon \
  335. -n $(CONFIG_DEFAULT_DEVICE_TREE)
  336. OBJCOPYFLAGS_u-boot-spl-dtb.hex := -I binary -O ihex --change-address=$(CONFIG_SPL_TEXT_BASE)
  337. $(obj)/u-boot-spl-dtb.hex: $(obj)/u-boot-spl-dtb.bin FORCE
  338. $(call if_changed,objcopy)
  339. $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE
  340. $(call if_changed,mkimage)
  341. quiet_cmd_sunxi_spl_image_builder = SUNXI_SPL_IMAGE_BUILDER $@
  342. cmd_sunxi_spl_image_builder = $(objtree)/tools/sunxi-spl-image-builder \
  343. -c $(CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH)/$(CONFIG_NAND_SUNXI_SPL_ECC_SIZE) \
  344. -p $(CONFIG_SYS_NAND_PAGE_SIZE) \
  345. -o $(CONFIG_SYS_NAND_OOBSIZE) \
  346. -u $(CONFIG_NAND_SUNXI_SPL_USABLE_PAGE_SIZE) \
  347. -e $(CONFIG_SYS_NAND_BLOCK_SIZE) \
  348. -s -b $< $@
  349. $(obj)/sunxi-spl-with-ecc.bin: $(obj)/sunxi-spl.bin
  350. $(call if_changed,sunxi_spl_image_builder)
  351. # MediaTek's specific SPL build
  352. MKIMAGEFLAGS_u-boot-spl-mtk.bin = -T mtk_image \
  353. -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) \
  354. -n "$(patsubst "%",%,$(CONFIG_MTK_BROM_HEADER_INFO))"
  355. $(obj)/u-boot-spl-mtk.bin: $(obj)/u-boot-spl.bin FORCE
  356. $(call if_changed,mkimage)
  357. quiet_cmd_sym ?= SYM $@
  358. cmd_sym ?= $(OBJDUMP) -t $< > $@
  359. $(obj)/$(SPL_BIN).sym: $(obj)/$(SPL_BIN) FORCE
  360. $(call if_changed,sym)
  361. # Generate linker list symbols references to force compiler to not optimize
  362. # them away when compiling with LTO
  363. ifdef CONFIG_LTO
  364. u-boot-spl-keep-syms-lto := $(obj)/keep-syms-lto.o
  365. u-boot-spl-keep-syms-lto_c := \
  366. $(patsubst $(obj)/%.o,$(obj)/%.c,$(u-boot-spl-keep-syms-lto))
  367. quiet_cmd_keep_syms_lto = KSL $@
  368. cmd_keep_syms_lto = \
  369. $(srctree)/scripts/gen_ll_addressable_symbols.sh $(NM) $^ > $@
  370. quiet_cmd_keep_syms_lto_cc = KSLCC $@
  371. cmd_keep_syms_lto_cc = \
  372. $(CC) $(filter-out $(LTO_CFLAGS),$(c_flags)) -c -o $@ $<
  373. $(u-boot-spl-keep-syms-lto_c): $(u-boot-spl-main) $(u-boot-spl-platdata)
  374. $(call if_changed,keep_syms_lto)
  375. $(u-boot-spl-keep-syms-lto): $(u-boot-spl-keep-syms-lto_c)
  376. $(call if_changed,keep_syms_lto_cc)
  377. else
  378. u-boot-spl-keep-syms-lto :=
  379. endif
  380. # Rule to link u-boot-spl
  381. # May be overridden by arch/$(ARCH)/config.mk
  382. ifdef CONFIG_LTO
  383. quiet_cmd_u-boot-spl ?= LTO $@
  384. cmd_u-boot-spl ?= \
  385. ( \
  386. cd $(obj) && \
  387. $(CC) -nostdlib -nostartfiles $(LTO_FINAL_LDFLAGS) $(c_flags) \
  388. $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_$(@F):%=-Wl,%) \
  389. $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
  390. -Wl,--whole-archive \
  391. $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
  392. $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
  393. $(patsubst $(obj)/%,%,$(u-boot-spl-keep-syms-lto)) \
  394. $(PLATFORM_LIBS) \
  395. -Wl,--no-whole-archive \
  396. -Wl,-Map,$(SPL_BIN).map -o $(SPL_BIN) \
  397. )
  398. else
  399. quiet_cmd_u-boot-spl ?= LD $@
  400. cmd_u-boot-spl ?= \
  401. ( \
  402. cd $(obj) && \
  403. $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_$(@F)) \
  404. $(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
  405. --whole-archive \
  406. $(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
  407. $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
  408. --no-whole-archive \
  409. $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN) \
  410. )
  411. endif
  412. $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \
  413. $(u-boot-spl-main) $(u-boot-spl-keep-syms-lto) \
  414. $(obj)/u-boot-spl.lds FORCE
  415. $(call if_changed,u-boot-spl)
  416. $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
  417. PHONY += $(u-boot-spl-dirs)
  418. $(u-boot-spl-dirs): $(u-boot-spl-platdata) prepare
  419. $(Q)$(MAKE) $(build)=$@
  420. PHONY += prepare
  421. prepare:
  422. $(Q)$(MAKE) $(build)=$(obj)/.
  423. quiet_cmd_cpp_lds = LDS $@
  424. cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
  425. -D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
  426. $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
  427. $(call if_changed_dep,cpp_lds)
  428. # read all saved command lines
  429. targets := $(wildcard $(sort $(targets)))
  430. cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
  431. ifneq ($(cmd_files),)
  432. $(cmd_files): ; # Do not try to update included dependency files
  433. include $(cmd_files)
  434. endif
  435. PHONY += FORCE
  436. FORCE:
  437. $(obj)/dts/dt-$(SPL_NAME).dtb: dts/dt.dtb
  438. $(Q)$(MAKE) $(build)=$(obj)/dts spl_dtbs
  439. PHONY += dts_dir
  440. dts_dir:
  441. $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts)
  442. # Declare the contents of the .PHONY variable as phony. We keep that
  443. # information in a variable so we can use it in if_changed and friends.
  444. .PHONY: $(PHONY)
  445. SPL_OF_LIST_TARGETS = $(patsubst %,dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
  446. SHRUNK_ARCH_DTB = $(addprefix $(obj)/,$(SPL_OF_LIST_TARGETS))
  447. .SECONDEXPANSION:
  448. $(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@) dts_dir
  449. $(call if_changed,fdtgrep)
  450. targets += $(SPL_OF_LIST_TARGETS)
  451. MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
  452. -n "Multi DTB fit image for $(SPL_BIN)" -E \
  453. $(patsubst %,-b %,$(SHRUNK_ARCH_DTB))
  454. $(obj)/$(SPL_BIN).multidtb.fit: /dev/null $(SHRUNK_ARCH_DTB) FORCE
  455. $(call if_changed,mkimage)
  456. ifneq ($(SOURCE_DATE_EPOCH),)
  457. touch -d @$(SOURCE_DATE_EPOCH) $(obj)/$(SPL_BIN).multidtb.fit
  458. chmod 0600 $(obj)/$(SPL_BIN).multidtb.fit
  459. endif
  460. $(obj)/$(SPL_BIN).multidtb.fit.gz: $(obj)/$(SPL_BIN).multidtb.fit
  461. @gzip -kf9 $< > $@
  462. $(obj)/$(SPL_BIN).multidtb.fit.lzo: $(obj)/$(SPL_BIN).multidtb.fit
  463. @lzop -f9 $< > $@
  464. ifdef CONFIG_ARCH_K3
  465. tispl.bin: $(obj)/u-boot-spl-nodtb.bin $(SHRUNK_ARCH_DTB) $(SPL_ITS) FORCE
  466. $(call if_changed,mkfitimage)
  467. endif