
For SPL we want to support building device tree files. Due to limited memory some boards will include only a subset of the full device tree file. So build these files separately for SPL.
SPL does not relocate itself so we cannot use the BSS space for the device tree. Instead we place it at the end of BSS and provide a 'pad' file to overlay on the BSS space.
So far, CONFIG_OF_EMBED is not supported for SPL. There does not seem to be any reason for it other than debugging.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/cpu/u-boot-spl.lds | 2 +- arch/arm/dts/Makefile | 2 +- dts/Makefile | 9 ++++++--- scripts/Makefile.lib | 12 ++++++++---- scripts/Makefile.spl | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds index a8be204..4b6e0f6 100644 --- a/arch/arm/cpu/u-boot-spl.lds +++ b/arch/arm/cpu/u-boot-spl.lds @@ -66,7 +66,7 @@ SECTIONS . = ALIGN(4); __bss_end = .; } - + __bss_size = __bss_end - __bss_start; .dynsym _image_binary_end : { *(.dynsym) } .dynbss : { *(.dynbss) } .dynstr : { *(.dynstr*) } diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 121725e..6b9d8ea 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -56,7 +56,7 @@ targets += $(dtb-y) DTC_FLAGS += -R 4
PHONY += dtbs -dtbs: $(addprefix $(obj)/, $(dtb-y)) +dtbs: $(addprefix $(DTB_PATH)$(obj)/, $(dtb-y)) @:
clean-files := *.dtb diff --git a/dts/Makefile b/dts/Makefile index d3122aa..f8f06f0 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -6,6 +6,7 @@
# This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is # enabled. See doc/README.fdt-control for more details. +# DTB_PATH is empty for U-Boot proper, and "spl/" for SPL
DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%) ifeq ($(DEVICE_TREE),) @@ -13,11 +14,13 @@ DEVICE_TREE := unset endif
ifneq ($(EXT_DTB),) -DTB := $(EXT_DTB) +BASE_DTB := $(EXT_DTB) else -DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb +BASE_DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb endif
+DTB := $(DTB_PATH)$(BASE_DTB) + $(obj)/dt.dtb: $(DTB) FORCE $(call if_changed,shipped)
@@ -33,7 +36,7 @@ $(DTB): arch-dtbs /bin/false)
arch-dtbs: - $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs + $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts DTB_PATH=$(DTB_PATH) dtbs
.SECONDARY: $(obj)/dt.dtb.S
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 13af604..04d9b50 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -150,11 +150,11 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
ld_flags = $(LDFLAGS) $(ldflags-y)
-# Modified for U-Boot +# Modified for U-Boot, include KBUILD_CPPFLAGS for CONFIG_SPL/TPL_BUILD dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/dts \ -I$(srctree)/arch/$(ARCH)/dts/include \ - -undef -D__DTS__ + -undef -D__DTS__ $(KBUILD_CPPFLAGS)
# Finds the multi-part object the current object will be linked into modname-multi = $(sort $(foreach m,$(multi-used),\ @@ -272,15 +272,19 @@ cmd_dt_S_dtb= \ $(obj)/%.dtb.S: $(obj)/%.dtb $(call cmd,dt_S_dtb)
+# Can we remove the duplication here? +quiet_cmd_dtcspl = DTC SPL $@ +# Modified for U-Boot quiet_cmd_dtc = DTC $@ # Modified for U-Boot -cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ +cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ dtc -O dtb -o $@ -b 0 \ -i $(dir $<) $(DTC_FLAGS) \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
-$(obj)/%.dtb: $(src)/%.dts FORCE +$(obj)/%.dtb spl/$(obj)/%.dtb tpl/$(obj)/%.dtb: $(src)/%.dts FORCE + $(Q)mkdir -p $(dir $@) $(call if_changed_dep,dtc)
dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index ea67137..def962c 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -31,10 +31,14 @@ endif
ifeq ($(CONFIG_TPL_BUILD),y) SPL_BIN := u-boot-tpl +DTB_PATH := tpl/ else SPL_BIN := u-boot-spl +DTB_PATH := spl/ endif
+export DTB_PATH + include $(srctree)/config.mk include $(srctree)/arch/$(ARCH)/Makefile
@@ -50,6 +54,7 @@ HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makef
libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/) libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ +libs-$(CONFIG_OF_EMBED) += dts/
libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/ libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ @@ -151,6 +156,8 @@ boot.bin: $(obj)/u-boot-spl.bin
ALL-y += $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN).cfg
+ALL-$(CONFIG_OF_SEPARATE) += $(obj)/$(SPL_BIN)-pad.bin $(obj)/$(SPL_BIN)-dtb.bin + ifdef CONFIG_SAMSUNG ALL-y += $(obj)/$(BOARD)-spl.bin endif @@ -163,8 +170,36 @@ ifeq ($(CONFIG_SYS_SOC),"at91") ALL-y += boot.bin endif
+checkdtc: + @if test $(call dtc-version) -lt 0104; then \ + echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ + false; \ + fi + all: $(ALL-y)
+quiet_cmd_cat = CAT $@ +cmd_cat = cat $(filter-out $(PHONY), $^) > $@ + +$(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN)-pad.bin \ + $(obj)/$(SPL_BIN).dtb FORCE + $(call if_changed,cat) + +# Create a file that provings pads from the end of u-boot-spl.bin to bss_end +$(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN) + @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " size}' | bc); \ + dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null; + +quiet_cmd_copy = COPY $@ + cmd_copy = cp $< $@ + +$(obj)/$(SPL_BIN).dtb: $(obj)/dts/dt.dtb + $(call cmd,copy) + +PHONY += dtbs +dtbs $(obj)/dts/dt.dtb: checkdtc $(obj)/$(SPL_BIN) + $(Q)$(MAKE) $(build)=$(obj)/dts DTB_PATH=$(DTB_PATH) dtbs + quiet_cmd_cpp_cfg = CFG $@ cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \ -D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $@ $<