From patchwork Sat Dec 7 04:41:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1205344 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DPQ9I9Ac"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47VH4z24h2z9sPL for ; Sat, 7 Dec 2019 15:47:47 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CDD78168E; Sat, 7 Dec 2019 05:46:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DPQ9I9Ac"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 41D608168E; Sat, 7 Dec 2019 05:46:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9056381670 for ; Sat, 7 Dec 2019 05:46:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x144.google.com with SMTP id p8so8079015iln.12 for ; Fri, 06 Dec 2019 20:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TomKlRdwoTOW2FSzu9cb8YMUxVpHgh1xrb/pA3EtliY=; b=DPQ9I9Ac6W8H+bHJFUSUYjqyxlTDFZDYSiiYwjMY0Yn3nkv7Vq7CTD9GRc/5rbrxwC 274HicJvPHf5uXkhVT+CR8ajlxSqPju2Vt/cFIXGjnZnxnuPq+Az/v+6PR4nvtg2zMKP jDHPBEpipWNWFmJm8vc683C8d6Ci/DEsJtD6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TomKlRdwoTOW2FSzu9cb8YMUxVpHgh1xrb/pA3EtliY=; b=jR5Kfg29MzAhhiTj2SpnHwBXN9W7qcS7BYj8080koZP+cuEicECFon7alt8booi+Do mddIh75UO40AZOU3X7l/hjO+6a4hRABo5qz/0acOTl1JjBX8uz7yjtO++bpq3K/dBrty AmdUgIal5ymYh3sB1QKMK4CvxqEYTlAA/m8ohCKv8CHMJGhBg7+AVsWSfmp1j4QtiGeh cQguTjmpxYTcaAIf3Q8RVAdnqYSoCWIhokJnN6pQ5pWY78cWCP29x1/+TgquyMZb3WKZ UvtUsSPmkq/CnDmAqXBymHw+zZ9TPGQSP80b2wJagsh8vMdnogq5nNUj+cFU+SX2h+YG NmLA== X-Gm-Message-State: APjAAAXs5bi3vtaxdXrKllbp8dbK/xqBlq0oO6kZuGfFNnvcpmOy1cvh 8oy7iPEmxanAMzrFIKJML0ZFdgorXVo= X-Google-Smtp-Source: APXvYqx2jd51sTUTzZrUgIlxMIp7pydUTQ6fQos1aP3vETjpF2PMMMHyQk8CG7rWgurLey7to7YKwg== X-Received: by 2002:a92:47c9:: with SMTP id e70mr17720035ilk.144.1575693982376; Fri, 06 Dec 2019 20:46:22 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id o7sm4549410ilo.58.2019.12.06.20.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 20:46:22 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Subject: [PATCH v6 011/102] fdt: Show the preprocessed .dts file on error Date: Fri, 6 Dec 2019 21:41:44 -0700 Message-Id: <20191206213936.v6.11.If3f82501255df1ffcf086953cbd1ed9b65432073@changeid> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191207044315.51770-1-sjg@chromium.org> References: <20191207044315.51770-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jerry Van Baren Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean When device-tree compilation fails it is sometimes tricky to see which line is broken, since the input file to dtc is a pre-processed version of the device tree. Add a line that points to the file that needs to be checked: When the error is in the main .dts file, output is something like this: output: 'Error: arch/x86/dts/.chromebook_coral.dtb.pre.tmp:478.46-47 syntax error FATAL ERROR: Unable to parse input tree but in fact looking at that file shows nothing useful: PAD_CFG_NF_IOSSTATE_IOSTERM(GPIO_157, UP_20K, DEEP, NF1, HIZCRX1, DISPUPD) Instead we need to look at the preprocessed file, which shows: 163 ((1U << 30) | (1 << 10)) ((0xb << 10) | PAD_CFG1_IOSSTATE_HIZCRX1) Here it is clear that PAD_CFG1_IOSSTATE_HIZCRX1 is not defined and so is not being resolved by the preprocessor. This commit adds an additional useful message: Check arch/x86/dts/.chromebook_coral.dtb.dts.tmp for errors Note that if the error is reported in an included file, such as u-boot.dtsi then the output is the following: Error: arch/x86/dts/u-boot.dtsi:137.14-15 syntax error FATAL ERROR: Unable to parse input tree But again, if the error is due to a preprocessor failure, like this: filename = CONFIG_IFW_INPUT_FILE; then you can't tell what the problem is by looking at the source. All you see is the original code: intel-ifwi { filename = CONFIG_IFW_INPUT_FILE; ... }; }; intel-fsp-m { filename = CONFIG_FSP_FILE_M; }; Everything looks fine. But looking at the output of the preprocessor: intel-ifwi { filename = CONFIG_IFW_INPUT_FILE; ... }; intel-fsp-m { filename = "fsp_m.bin"; }; This shows that the filename (normally "fitimage.bin") has not been inserted the preprocess, leading to the realisation that the value should be CONFIG_IFWI_INPUT_FILE. If the above does not make sense, I encourage people to try introducing errors in the device tree preprocessed values. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v6: None Changes in v5: None Changes in v4: - One last desperate attempt to try to explain the purpose of this commit - Update the message to mention the preprocessed file, not un-preprocessed Changes in v3: - Update example error message to better show the intended purpose Changes in v2: None scripts/Makefile.lib | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ef116e0e0a..c10cd83a0a 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -300,7 +300,9 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $(pre-tmp) ; \ $(DTC) -O dtb -o $@ -b 0 \ -i $(dir $<) $(DTC_FLAGS) \ - -d $(depfile).dtc.tmp $(dtc-tmp) ; \ + -d $(depfile).dtc.tmp $(dtc-tmp) || \ + (echo "Check $(shell pwd)/$(pre-tmp) for errors" && false) \ + ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) ; \ sed -i "s:$(pre-tmp):$(<):" $(depfile)