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