dm: Reduce SPL device tree size
The SPL device tree size must be minimised to save memory. Only include properties that are needed by SPL - this is determined by the presence of the "u-boot,dm-pre-reloc" property. Also remove a predefined list of unused properties from the nodes that remain. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
1043d0a029
commit
fa78e0a371
2
Makefile
2
Makefile
|
@ -1259,7 +1259,7 @@ u-boot.lds: $(LDSCRIPT) prepare FORCE
|
||||||
|
|
||||||
spl/u-boot-spl.bin: spl/u-boot-spl
|
spl/u-boot-spl.bin: spl/u-boot-spl
|
||||||
@:
|
@:
|
||||||
spl/u-boot-spl: tools prepare
|
spl/u-boot-spl: tools prepare $(if $(CONFIG_OF_SEPARATE),dts/dt.dtb)
|
||||||
$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
|
$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
|
||||||
|
|
||||||
spl/sunxi-spl.bin: spl/u-boot-spl
|
spl/sunxi-spl.bin: spl/u-boot-spl
|
||||||
|
|
|
@ -66,7 +66,7 @@ SECTIONS
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
__bss_end = .;
|
__bss_end = .;
|
||||||
}
|
}
|
||||||
|
__bss_size = __bss_end - __bss_start;
|
||||||
.dynsym _image_binary_end : { *(.dynsym) }
|
.dynsym _image_binary_end : { *(.dynsym) }
|
||||||
.dynbss : { *(.dynbss) }
|
.dynbss : { *(.dynbss) }
|
||||||
.dynstr : { *(.dynstr*) }
|
.dynstr : { *(.dynstr*) }
|
||||||
|
|
12
dts/Kconfig
12
dts/Kconfig
|
@ -56,4 +56,16 @@ config DEFAULT_DEVICE_TREE
|
||||||
It can be overridden from the command line:
|
It can be overridden from the command line:
|
||||||
$ make DEVICE_TREE=<device-tree-name>
|
$ make DEVICE_TREE=<device-tree-name>
|
||||||
|
|
||||||
|
config OF_SPL_REMOVE_PROPS
|
||||||
|
string "List of device tree properties to drop for SPL"
|
||||||
|
depends on OF_CONTROL && SPL
|
||||||
|
default "pinctrl-0 pinctrl-names clocks clock-names interrupt-parent"
|
||||||
|
help
|
||||||
|
Since SPL normally runs in a reduced memory space, the device tree
|
||||||
|
is cut down to only what is needed to load and start U-Boot. Only
|
||||||
|
nodes marked with the property "u-boot,dm-pre-reloc" will be
|
||||||
|
included. In addition, some properties are not used by U-Boot and
|
||||||
|
can be discarded. This option defines the list of properties to
|
||||||
|
discard.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -151,6 +151,8 @@ boot.bin: $(obj)/u-boot-spl.bin
|
||||||
|
|
||||||
ALL-y += $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN).cfg
|
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
|
ifdef CONFIG_SAMSUNG
|
||||||
ALL-y += $(obj)/$(BOARD)-spl.bin
|
ALL-y += $(obj)/$(BOARD)-spl.bin
|
||||||
endif
|
endif
|
||||||
|
@ -165,6 +167,32 @@ endif
|
||||||
|
|
||||||
all: $(ALL-y)
|
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 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; " toupper(size)}' | bc); \
|
||||||
|
dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null;
|
||||||
|
|
||||||
|
# Pass the original device tree file through fdtgrep twice. The first pass
|
||||||
|
# removes any unwanted nodes (i.e. those which don't have the
|
||||||
|
# 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
|
||||||
|
# pass removes various unused properties from the remaining nodes.
|
||||||
|
# The output is typically a much smaller device tree file.
|
||||||
|
quiet_cmd_fdtgrep = FDTGREP $@
|
||||||
|
cmd_fdtgrep = $(objtree)/tools/fdtgrep -b u-boot,dm-pre-reloc -RT $< \
|
||||||
|
-n /chosen -O dtb | \
|
||||||
|
$(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
|
||||||
|
$(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
|
||||||
|
|
||||||
|
$(obj)/$(SPL_BIN).dtb: dts/dt.dtb
|
||||||
|
$(call cmd,fdtgrep)
|
||||||
|
|
||||||
quiet_cmd_cpp_cfg = CFG $@
|
quiet_cmd_cpp_cfg = CFG $@
|
||||||
cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
|
cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
|
||||||
-DDO_DEPS_ONLY -D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $@ $<
|
-DDO_DEPS_ONLY -D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $@ $<
|
||||||
|
|
Loading…
Reference in New Issue