From ea1e225fb9a6a0dbd5a810a1de711e308bc4b175 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 21 Jun 2011 08:48:56 -0700 Subject: fdt: Add DEV_TREE_SEPARATE to provide an fdt separate from image This adds support for an FDT to be concatenated to the u-boot-bin binary. This is located at run-time by U-Boot. BUG=chromium-os:11623 TEST=Either emerge with http://gerrit.chromium.org/gerrit/2961 or build manually: make ... DEV_TREE_SEPARATE=true and check that u-boot.dtb is built. Change-Id: I7c8b1315d721bc957ef3fd07f167d86345868036 Reviewed-on: http://gerrit.chromium.org/gerrit/2962 Reviewed-by: Simon Glass Tested-by: Simon Glass --- Makefile | 7 +++++++ README | 5 +++++ arch/arm/lib/board.c | 3 +++ config.mk | 4 ++++ dts/Makefile | 13 ++++++++++--- include/configs/tegra2-common.h | 6 +++++- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4d0d53d7480..ebce9398f68 100644 --- a/Makefile +++ b/Makefile @@ -225,6 +225,9 @@ endif ifeq ($(CPU),ixp) LIBS += arch/arm/cpu/ixp/npe/libnpe.o endif +ifdef DEV_TREE_SEPARATE +ALL += $(obj)u-boot.dtb +endif ifeq ($(CONFIG_OF_EMBED),y) LIBS += dts/dt.o endif @@ -378,6 +381,10 @@ $(obj)u-boot-cflags.mk: echo $(CFLAGS) | \ awk -v RS='[ \t\n]+' -v ORS='' -- '$(AWK_SRC)' >> $@ +$(obj)u-boot.dtb: $(obj)u-boot + $(MAKE) -C dts binary + mv $(obj)dts/dt.dtb $@ + $(obj)u-boot.hex: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ diff --git a/README b/README index 38a421555cb..991010f67e6 100644 --- a/README +++ b/README @@ -764,6 +764,11 @@ The following options need to be configured: is then picked up in board_init_f() and made available through the global data structure as gd->blob. + CONFIG_OF_SEPARATE + If this variable is defined, U-Boot will build a device tree + binary. It will be called u-boot.dtb. Architecture-specific + code will locate it at run-time. + - Watchdog: CONFIG_WATCHDOG If this variable is defined, it enables watchdog diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 3bb80fc100a..2f34677e873 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -297,6 +297,9 @@ void board_init_f (ulong bootflag) #ifdef CONFIG_OF_EMBED /* Get a pointer to the FDT */ gd->blob = _binary_dt_dtb_start; +#elif defined CONFIG_OF_SEPARATE + /* FDT is at end of image */ + gd->blob = (void*)(_end_ofs + _TEXT_BASE); #endif for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { diff --git a/config.mk b/config.mk index 4d035177ee5..ae9bbca93ae 100644 --- a/config.mk +++ b/config.mk @@ -188,6 +188,10 @@ ifdef VBOOT CPPFLAGS += -I$(VBOOT)/include/vboot endif +ifdef DEV_TREE_SEPARATE +CPPFLAGS += -DCONFIG_OF_SEPARATE +endif + CPPFLAGS += -I$(TOPDIR)/include CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \ -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) diff --git a/dts/Makefile b/dts/Makefile index b885077f6a6..8863c041236 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -24,6 +24,9 @@ include $(TOPDIR)/config.mk LIB = $(obj)libdts.o +# We use DEV_TREE_SRC as the name of the device tree, if defined +# If not, we use CONFIG_DEFAULT_DEVICE_TREE + ifeq ($(DEV_TREE_SRC),) $(if $(CONFIG_DEFAULT_DEVICE_TREE),,\ $(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header \ @@ -38,9 +41,11 @@ endif # the filename. DT_BIN := $(obj)dt.dtb -# TODO: get arch properly for objcopy line. -$(obj)dt.o: $(TOPDIR)/board/$(BOARDDIR)/$(DEVICE_TREE).dts +$(DT_BIN): $(TOPDIR)/board/$(BOARDDIR)/$(DEVICE_TREE).dts $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} $< + +# TODO: get arch properly for objcopy line. +$(obj)dt.o: $(DT_BIN) cd $(dir ${DT_BIN}) && \ $(OBJCOPY) -B armv5te -I binary -O elf32-littlearm \ $(notdir ${DT_BIN}) $@ @@ -54,7 +59,9 @@ OBJS := $(addprefix $(obj),$(OBJS)) all: $(obj).depend $(LIB) -$(LIB): $(OBJS) +binary: $(DT_BIN) + +$(LIB): $(OBJS) $(DTB) $(call cmd_link_o_target, $(OBJS)) clean: diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-common.h index ae5d83fb479..629c8d1924b 100644 --- a/include/configs/tegra2-common.h +++ b/include/configs/tegra2-common.h @@ -36,7 +36,11 @@ /* FDT support */ #define CONFIG_OF_LIBFDT /* Device tree support */ #define CONFIG_OF_CONTROL /* Use the device tree to set up U-Boot */ -#define CONFIG_OF_EMBED /* Embed the device tree in U-Boot */ + +/* Embed the device tree in U-Boot, if not otherwise handled */ +#ifndef CONFIG_OF_SEPARATE +#define CONFIG_OF_EMBED +#endif /* * High Level Configuration Options -- cgit v1.2.3