From patchwork Tue May 28 19:36:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 246950 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id C25172C032E for ; Wed, 29 May 2013 05:36:51 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DAECA4A052; Tue, 28 May 2013 21:36:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0Ptrm37vkQqo; Tue, 28 May 2013 21:36:45 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9484D4A044; Tue, 28 May 2013 21:36:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 387BC4A021 for ; Tue, 28 May 2013 21:36:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mAoIFi1MMLtn for ; Tue, 28 May 2013 21:36:30 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-gh0-f201.google.com (mail-gh0-f201.google.com [209.85.160.201]) by theia.denx.de (Postfix) with ESMTPS id 6CD634A01B for ; Tue, 28 May 2013 21:36:25 +0200 (CEST) Received: by mail-gh0-f201.google.com with SMTP id r14so862799ghr.4 for ; Tue, 28 May 2013 12:36:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=YO4sMV6MwVmoryjrln0/5pE+8quyy7Rw5i9M/iALfwo=; b=g7+jMulIU1INpcQmY71H87bNDbGq0x0FiirQWTQVDGEX9gQfACKQ+CX/FOk6bm3R3a M9KCodkPTT9lTS16iyLqsD3NJRAjKqSge9t17CCMShIYd8Rr+ixnCyhD6DT0TjQ+mC0p T5TdVrSz1U6T4oSnHvCT7bv0QalsW0V2lZxIetk4PwOZg9erX6j9WfeYQUyod1YQShaF 7m+1sQAM+iGIChT8Iy5l3yEI8MNQWeo/pgkVSNMwiR4Hv5+qkRyqmyqjDDhn/PpEjDwh u+0k1/I8HUOvCXi6wRW4sUTVMeTR7x9oASbZ2lP/GTONdWgh4pfCqk0jXaMHNc2UhX5G AxSA== X-Received: by 10.236.133.235 with SMTP id q71mr17458185yhi.13.1369769782959; Tue, 28 May 2013 12:36:22 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id u47si2482456yhe.0.2013.05.28.12.36.22 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 28 May 2013 12:36:22 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id C816C5A420D; Tue, 28 May 2013 12:36:22 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 6FD12160720; Tue, 28 May 2013 12:36:22 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 28 May 2013 12:36:18 -0700 Message-Id: <1369769778-12455-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.2.1 X-Gm-Message-State: ALoCoQm+JfrkWN5FxMLxnUnRD0bsne9Umg0HndUohJWFKnSiDGX/WBw5/jPiWS2c6y47GQ9cmc/XYIaCuWkYF4R5di9yCH7xQMw2Fg1DKH52n+qEetE1aLA3b9Psy4KApELDkoHQvGU59TIsqfOnA7jSXljEIQpvihMhzWjvvKt3sytpQUVysHhdeBoqSau1Edo0bY5Qq/0k Cc: u-boot-review@google.com, Jerry Van Baren , Tom Warren , Tom Rini , Devicetree Discuss Subject: [U-Boot] [PATCH] fdt: Enhance dts/Makefile to be all things to all men X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de There are a few partially conflicting requirements in compiling the device tree, since U-Boot relies on whatever is installed on the build machine. Some versions of dtc support -i, and this is often better than using #include since you get correct line number information in errors. Unfortunately this version must be installed manually in current Linux distributions. Some device tree files use the word 'linux' which gets replaced with '1' by many version of gcc, including version 4.7. So undefine this. When an device tree file has an error we want to direct the user to the right file and line number. So instead of piping the file into dts through stdin, put it in a real file so that we get a fairly sensible error message from dts. Then print out the original file details to help further. This is based on a commit from Tom Warren. It would help if people can test it in different environments. Signed-off-by: Tom Warren Signed-off-by: Simon Glass --- dts/Makefile | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/dts/Makefile b/dts/Makefile index 03e163e..1f6fabb 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -37,11 +37,29 @@ $(if $(CONFIG_ARCH_DEVICE_TREE),,\ $(error Your architecture does not have device tree support enabled. \ Please define CONFIG_ARCH_DEVICE_TREE)) +# Provide a list of include directories for dtc +DTS_INCS-y := -i $(SRCTREE)/arch/$(ARCH)/dts + +DTS_INCS-y += -i $(SRCTREE)/board/$(VENDOR)/dts + +DTS_INCS-$(CONFIG_CHROMEOS) += -i $(SRCTREE)/cros/dts + +# Check if our dtc includes the -i option +DTS_FLAGS := $(shell if ! dtc -i 2>&1 | grep -q "invalid option"; then \ + echo $(DTS_INCS-y); fi) + # We preprocess the device tree file provide a useful define -DTS_CPPFLAGS := -x assembler-with-cpp \ +# Undefine 'linux' since it might be used in device tree files +DTS_CPPFLAGS := -x assembler-with-cpp -Ulinux \ -DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\" \ -DBOARD_DTS=\"$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts\" \ - -I$(SRCTREE)/board/$(VENDOR)/dts -I$(SRCTREE)/arch/$(ARCH)/dts + -D__ASSEMBLY__ -I$(OBJTREE)/include -I$(SRCTREE)/include \ + -I$(OBJTREE)/include2 \ + -I$(SRCTREE)/board/$(VENDOR)/dts -I$(SRCTREE)/arch/$(ARCH)/dts \ + -include $(OBJTREE)/include/config.h + +DTS_TMP := $(OBJTREE)/include/generated/$(DEVICE_TREE).dts.in +DTS_SRC := board/$(VENDOR)/dts/$(DEVICE_TREE).dts all: $(obj).depend $(LIB) @@ -50,13 +68,19 @@ all: $(obj).depend $(LIB) # the filename. DT_BIN := $(obj)dt.dtb -$(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts +DTC_CMD := $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} $(DTS_FLAGS) $(DTS_TMP) + +$(DT_BIN): $(TOPDIR)/$(DTS_SRC) rc=$$( \ - cat $< | $(CPP) -P $(DTS_CPPFLAGS) - | \ - { { $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} - 2>&1 ; \ + cat $< | $(CPP) -P $(DTS_CPPFLAGS) - > $(DTS_TMP); \ + { { $(DTC_CMD) 2>&1 ; \ echo $$? >&3 ; } | \ grep -v '^DTC: dts->dtb on file' ; \ } 3>&1 1>&2 ) ; \ + if [ $$rc != 0 ]; then \ + echo "Source file is $(DTS_SRC)"; \ + echo "Compiler: $(DTC_CMD)"; \ + fi; \ exit $$rc process_lds = \