dts: re-write dts/Makefile more simply with Kbuild

Useful rules in scripts/Makefile.lib allows us to easily
generate a device tree blob and wrap it in assembly code.

We do not need to parse a linker script to get output format and arch.

This commit deletes ./u-boot.dtb since it is a copy of dts/dt.dtb.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
master
Masahiro Yamada 11 years ago committed by Tom Rini
parent babb4440cf
commit 6ab6b2afa0
  1. 1
      .gitignore
  2. 16
      Makefile
  3. 2
      arch/arm/lib/board.c
  4. 2
      arch/microblaze/lib/board.c
  5. 2
      arch/x86/lib/init_helpers.c
  6. 2
      common/board_f.c
  7. 2
      dts/.gitignore
  8. 72
      dts/Makefile
  9. 2
      include/common.h
  10. 12
      scripts/Makefile.lib

1
.gitignore vendored

@ -48,7 +48,6 @@
/u-boot.lds /u-boot.lds
/u-boot.ubl /u-boot.ubl
/u-boot.ais /u-boot.ais
/u-boot.dtb
/u-boot.sb /u-boot.sb
# #

@ -720,7 +720,7 @@ ALL-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl
ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.bin
ifneq ($(CONFIG_SPL_TARGET),) ifneq ($(CONFIG_SPL_TARGET),)
ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
endif endif
@ -744,11 +744,11 @@ endif
all: $(ALL-y) all: $(ALL-y)
u-boot.dtb: checkdtc u-boot PHONY += dtbs
$(MAKE) $(build)=dts binary dtbs dts/dt.dtb: checkdtc u-boot
mv dts/dt.dtb $@ $(Q)$(MAKE) $(build)=dts dtbs
u-boot-dtb.bin: u-boot.bin u-boot.dtb u-boot-dtb.bin: u-boot.bin dts/dt.dtb
cat $^ >$@ cat $^ >$@
u-boot.hex: u-boot u-boot.hex: u-boot
@ -875,8 +875,8 @@ u-boot-nodtb-tegra.bin: spl/u-boot-spl.bin u-boot.bin
rm spl/u-boot-spl-pad.bin rm spl/u-boot-spl-pad.bin
ifeq ($(CONFIG_OF_SEPARATE),y) ifeq ($(CONFIG_OF_SEPARATE),y)
u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin u-boot.dtb u-boot-dtb-tegra.bin: u-boot-nodtb-tegra.bin dts/dt.dtb
cat u-boot-nodtb-tegra.bin u-boot.dtb > $@ cat $^ > $@
endif endif
endif endif
@ -1171,7 +1171,7 @@ include/license.h: tools/bin2header COPYING
# Directories & files removed with 'make clean' # Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR) CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \ CLEAN_FILES += u-boot.lds include/bmp_logo.h include/bmp_logo_data.h \
board/*/config.tmp board/*/*/config.tmp dts/*.tmp \ board/*/config.tmp board/*/*/config.tmp \
include/autoconf.mk* include/spl-autoconf.mk \ include/autoconf.mk* include/spl-autoconf.mk \
include/tpl-autoconf.mk include/tpl-autoconf.mk

@ -280,7 +280,7 @@ void board_init_f(ulong bootflag)
gd->mon_len = _bss_end_ofs; gd->mon_len = _bss_end_ofs;
#ifdef CONFIG_OF_EMBED #ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */ /* Get a pointer to the FDT */
gd->fdt_blob = _binary_dt_dtb_start; gd->fdt_blob = __dtb_db_begin;
#elif defined CONFIG_OF_SEPARATE #elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */ /* FDT is at end of image */
gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE); gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);

@ -87,7 +87,7 @@ void board_init_f(ulong not_used)
#ifdef CONFIG_OF_EMBED #ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */ /* Get a pointer to the FDT */
gd->fdt_blob = _binary_dt_dtb_start; gd->fdt_blob = __dtb_dt_begin;
#elif defined CONFIG_OF_SEPARATE #elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */ /* FDT is at end of image */
gd->fdt_blob = (void *)__end; gd->fdt_blob = (void *)__end;

@ -92,7 +92,7 @@ int find_fdt(void)
{ {
#ifdef CONFIG_OF_EMBED #ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */ /* Get a pointer to the FDT */
gd->fdt_blob = _binary_dt_dtb_start; gd->fdt_blob = __dtb_dt_begin;
#elif defined CONFIG_OF_SEPARATE #elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */ /* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end; gd->fdt_blob = (ulong *)&_end;

@ -360,7 +360,7 @@ static int setup_fdt(void)
{ {
#ifdef CONFIG_OF_EMBED #ifdef CONFIG_OF_EMBED
/* Get a pointer to the FDT */ /* Get a pointer to the FDT */
gd->fdt_blob = _binary_dt_dtb_start; gd->fdt_blob = __dtb_dt_begin;
#elif defined CONFIG_OF_SEPARATE #elif defined CONFIG_OF_SEPARATE
/* FDT is at end of image */ /* FDT is at end of image */
# ifdef CONFIG_SYS_SYM_OFFSETS # ifdef CONFIG_SYS_SYM_OFFSETS

2
dts/.gitignore vendored

@ -0,0 +1,2 @@
*.dtb
*.dtb.S

@ -7,64 +7,32 @@
# This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
# enabled. See doc/README.fdt-control for more details. # enabled. See doc/README.fdt-control for more details.
DTS_INCDIRS = $(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
DTS_INCDIRS += $(SRCTREE)/board/$(VENDOR)/dts ifeq ($(DEVICE_TREE),)
DTS_INCDIRS += $(SRCTREE)/arch/$(ARCH)/dts DEVICE_TREE := notfound
endif
DTS_CPPFLAGS := -x assembler-with-cpp -undef -D__DTS__ \ DTS := $(srctree)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
-nostdinc $(addprefix -I,$(DTS_INCDIRS))
DTC_FLAGS := -R 4 -p 0x1000 \ DTC_FLAGS += -i $(srctree)/arch/$(ARCH)/dts -R 4 -p 0x1000
$(addprefix -i ,$(DTS_INCDIRS))
# Use a constant name for this so we can access it from C code. $(obj)/dt.dtb: $(DTS) FORCE
# objcopy doesn't seem to allow us to set the symbol name independently of $(call if_changed_dep,dtc)
# the filename.
DT_BIN := $(obj)/dt.dtb
DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%) targets += dt.dtb
ifeq ($(DEVICE_TREE),)
$(DT_BIN): FORCE
echo >&2 "Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file"
else
$(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
$(CPP) $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp
$(DTC) $(DTC_FLAGS) -O dtb -o ${DT_BIN} $(DT_BIN).dts.tmp
endif
process_lds = \ $(DTS):
$(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p' @echo >&2
@echo >&2 "Device Tree Source is not specified."
@echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"
@echo >&2 "or build with 'DEVICE_TREE=<dts-file-name>' argument"
@/bin/false
# Run the compiler and get the link script from the linker .SECONDARY: $(obj)/dt.dtb.S
GET_LDS = $(CC) $(c_flags) $(ld_flags) -Wl,--verbose 2>&1
$(obj)/dt.o: $(DT_BIN) obj-$(CONFIG_OF_EMBED) := dt.dtb.o
# We want the output format and arch.
# We also hope to win a prize for ugliest Makefile / shell interaction
# We look in the LDSCRIPT first.
# Then try the linker which should give us the answer.
# Then check it worked.
[ -n "$(LDSCRIPT)" ] && \
oformat=`$(call process_lds,cat $(LDSCRIPT),FORMAT)` && \
oarch=`$(call process_lds,cat $(LDSCRIPT),ARCH)` ;\
\
[ -z $${oformat} ] && \
oformat=`$(call process_lds,$(GET_LDS),FORMAT)` ;\
[ -z $${oarch} ] && \
oarch=`$(call process_lds,$(GET_LDS),ARCH)` ;\
\
[ -z $${oformat} ] && \
echo "Cannot read OUTPUT_FORMAT from lds file $(LDSCRIPT)" && \
exit 1 || true ;\
[ -z $${oarch} ] && \
echo "Cannot read OUTPUT_ARCH from lds file $(LDSCRIPT)" && \
exit 1 || true ;\
\
cd $(dir ${DT_BIN}) && \
$(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \
$(notdir ${DT_BIN}) $(notdir $@)
rm $(DT_BIN)
obj-$(CONFIG_OF_EMBED) := dt.o dtbs: $(obj)/dt.dtb
@:
binary: $(DT_BIN) clean-files := dt.dtb.S

@ -302,7 +302,7 @@ int checkdram (void);
int last_stage_init(void); int last_stage_init(void);
extern ulong monitor_flash_len; extern ulong monitor_flash_len;
int mac_read_from_eeprom(void); int mac_read_from_eeprom(void);
extern u8 _binary_dt_dtb_start[]; /* embedded device tree blob */ extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
int set_cpu_clk_info(void); int set_cpu_clk_info(void);
int print_cpuinfo(void); int print_cpuinfo(void);
int update_flash_size(int flash_size); int update_flash_size(int flash_size);

@ -151,9 +151,10 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \
ld_flags = $(LDFLAGS) $(ldflags-y) ld_flags = $(LDFLAGS) $(ldflags-y)
# Modified for U-Boot
dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
-I$(srctree)/arch/$(SRCARCH)/boot/dts \ -I$(srctree)/board/$(VENDOR)/dts/ \
-I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ -I$(srctree)/arch/$(ARCH)/dts \
-undef -D__DTS__ -undef -D__DTS__
# Finds the multi-part object the current object will be linked into # Finds the multi-part object the current object will be linked into
@ -247,25 +248,24 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
# Generate an assembly file to wrap the output of the device tree compiler # Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_S_dtb= DTB $@ quiet_cmd_dt_S_dtb= DTB $@
# Modified for U-Boot
cmd_dt_S_dtb= \ cmd_dt_S_dtb= \
( \ ( \
echo '\#include <asm-generic/vmlinux.lds.h>'; \
echo '.section .dtb.init.rodata,"a"'; \ echo '.section .dtb.init.rodata,"a"'; \
echo '.balign STRUCT_ALIGNMENT'; \
echo '.global __dtb_$(*F)_begin'; \ echo '.global __dtb_$(*F)_begin'; \
echo '__dtb_$(*F)_begin:'; \ echo '__dtb_$(*F)_begin:'; \
echo '.incbin "$<" '; \ echo '.incbin "$<" '; \
echo '__dtb_$(*F)_end:'; \ echo '__dtb_$(*F)_end:'; \
echo '.global __dtb_$(*F)_end'; \ echo '.global __dtb_$(*F)_end'; \
echo '.balign STRUCT_ALIGNMENT'; \
) > $@ ) > $@
$(obj)/%.dtb.S: $(obj)/%.dtb $(obj)/%.dtb.S: $(obj)/%.dtb
$(call cmd,dt_S_dtb) $(call cmd,dt_S_dtb)
quiet_cmd_dtc = DTC $@ 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) $< ; \
$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ dtc -O dtb -o $@ -b 0 \
-i $(dir $<) $(DTC_FLAGS) \ -i $(dir $<) $(DTC_FLAGS) \
-d $(depfile).dtc.tmp $(dtc-tmp) ; \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)

Loading…
Cancel
Save