From patchwork Tue Oct 18 15:07:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 78070 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp931528qge; Tue, 18 Oct 2016 08:07:37 -0700 (PDT) X-Received: by 10.99.204.5 with SMTP id x5mr1237180pgf.96.1476803257705; Tue, 18 Oct 2016 08:07:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si30256027paf.32.2016.10.18.08.07.37; Tue, 18 Oct 2016 08:07:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751902AbcJRPHg (ORCPT + 7 others); Tue, 18 Oct 2016 11:07:36 -0400 Received: from mail-qt0-f171.google.com ([209.85.216.171]:34818 "EHLO mail-qt0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753245AbcJRPHf (ORCPT ); Tue, 18 Oct 2016 11:07:35 -0400 Received: by mail-qt0-f171.google.com with SMTP id f6so163271232qtd.2 for ; Tue, 18 Oct 2016 08:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=mO+ygbHkqP6VBLzeTFfbdv1YEy4ci55cWCbIPm02wcE=; b=FlSBA/NETZMLvZfhOp4V81i6I4oI84cxFFr/XOaTHjre/tAS+kJrjTnRzWM+d7icD9 rrRadA85otXnC1IGvqJvAzzycTB88B8Xao09tQ9etrALi/fe2Nl9YDmH7d6rdKDG6V3F MkuvfFjym28nhbOPdF/krKJ4p2+JXdfteHbFA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mO+ygbHkqP6VBLzeTFfbdv1YEy4ci55cWCbIPm02wcE=; b=SnSXW2H6Omyc0i1rdp3rb6+qwC4C0tmZnO7xsg3k5Y+APbEyQwMcxZR/HJI3twvWq6 5VAerJPjE+/Xf4APibNVXM0NwsNTm6XQ445wjZVf2zVQvjPygLoUQqgs6YIh5YuYiODm 0rM1jRd3oyhcfWT7GpNIsI5k3KiHN5yidYVA4ThtCSRfmrPX0zUfgRr57+IB7SOTq73p 3pLSYlCg/qT2X/5X37nKHXnHutPGZv81gC15FA88d0X7SxSKFJ3B06fwIXwOPXh7csLe QQGHKrKLsNVgCIrGdajle18ZOXh6dGfmGGv6hYSQSzrAKzHi22mcf6H7VZi/MoZGUk9e lKHw== X-Gm-Message-State: AA6/9Rk6bw5jqec+XV9L7NPVHrfr8J66AgyEcm61iT9aml6EOcx9YcNUcCKhiRQPYiX15DuE X-Received: by 10.194.216.37 with SMTP id on5mr514617wjc.162.1476803254572; Tue, 18 Oct 2016 08:07:34 -0700 (PDT) Received: from localhost.localdomain (cpc89244-aztw30-2-0-cust4998.18-1.cable.virginm.net. [86.31.179.135]) by smtp.gmail.com with ESMTPSA id ce6sm63427784wjc.27.2016.10.18.08.07.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 08:07:33 -0700 (PDT) From: Peter Griffin To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@stlinux.com, jan.kiszka@siemens.com, kieran@ksquared.org.uk Cc: peter.griffin@linaro.org, lee.jones@linaro.org, devicetree@vger.kernel.org Subject: [PATCH 1/2] scripts/gdb: add lx-fdtdump command Date: Tue, 18 Oct 2016 16:07:28 +0100 Message-Id: <1476803249-23328-1-git-send-email-peter.griffin@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org lx-fdtdump dumps the flatenned device tree passed to the kernel from the bootloader to a file called fdtdump.dtb to allow further post processing on the machine running GDB. The fdt header is also also printed in the GDB console. For example: (gdb) lx-fdtdump fdt_magic: 0xD00DFEED fdt_totalsize: 0xC108 off_dt_struct: 0x38 off_dt_strings: 0x3804 off_mem_rsvmap: 0x28 version: 17 last_comp_version: 16 Dumped fdt to fdtdump.dtb >fdtdump fdtdump.dtb | less This command is useful as the bootloader can often re-write parts of the device tree, and this can sometimes cause the kernel to not boot. Signed-off-by: Peter Griffin --- scripts/gdb/linux/constants.py.in | 8 +++++ scripts/gdb/linux/proc.py | 70 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in index 7986f4e..43c6241 100644 --- a/scripts/gdb/linux/constants.py.in +++ b/scripts/gdb/linux/constants.py.in @@ -14,6 +14,7 @@ #include #include +#include /* We need to stringify expanded macros so that they can be parsed */ @@ -50,3 +51,10 @@ LX_VALUE(MNT_NOEXEC) LX_VALUE(MNT_NOATIME) LX_VALUE(MNT_NODIRATIME) LX_VALUE(MNT_RELATIME) + +/* linux/of_fdt.h> */ +LX_VALUE(OF_DT_HEADER) + +/* Kernel Configs */ +LX_CONFIG(CONFIG_OF) + diff --git a/scripts/gdb/linux/proc.py b/scripts/gdb/linux/proc.py index 38b1f09..f20fcfa 100644 --- a/scripts/gdb/linux/proc.py +++ b/scripts/gdb/linux/proc.py @@ -16,7 +16,7 @@ from linux import constants from linux import utils from linux import tasks from linux import lists - +from struct import * class LxCmdLine(gdb.Command): """ Report the Linux Commandline used in the current kernel. @@ -195,3 +195,71 @@ values of that process namespace""" info_opts(MNT_INFO, m_flags))) LxMounts() + +class LxFdtDump(gdb.Command): + """Output Flattened Device Tree header and dump FDT blob to a file + Equivalent to 'cat /proc/fdt > fdtdump.dtb' on a running target""" + + def __init__(self): + super(LxFdtDump, self).__init__("lx-fdtdump", gdb.COMMAND_DATA) + + def fdthdr_to_cpu(self, fdt_header): + + fdt_header_be = ">IIIIIII" + fdt_header_le = "