From patchwork Wed May 16 01:52:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 914125 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.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" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="Za0gj762"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40lyMj51hLz9ryk for ; Wed, 16 May 2018 12:01:05 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 5E556C21C8B; Wed, 16 May 2018 01:58:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7B1A2C21DFA; Wed, 16 May 2018 01:53:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BC17FC21E49; Wed, 16 May 2018 01:53:22 +0000 (UTC) Received: from mail-it0-f66.google.com (mail-it0-f66.google.com [209.85.214.66]) by lists.denx.de (Postfix) with ESMTPS id 33A59C21DF8 for ; Wed, 16 May 2018 01:53:17 +0000 (UTC) Received: by mail-it0-f66.google.com with SMTP id 144-v6so6547305iti.5 for ; Tue, 15 May 2018 18:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=B4xuf6d2zLwSxSmFieefxSfWW1CzdDaR48QHguDg++g=; b=Za0gj762v3Yq6Tb/2rIfnx5D7WLaKEsRDCaWT2WfiW1x1t/ogeAS/qlW5NK/vFOYXJ 0HcwE9J/oScW3TrDl/YaxCAolVzI09C3uyBfgW0D9mH7OAafTuJi262cNLjM0/g4g92n N2v8VH0sNwQbzTqndVXMIq7Z3XP1dePuBsmqcUBy4b0tL4QQQpvDwmte9JwWvCSw6Kif Rxlp2/pN2V0AIhW1pZUatJL1tVnJ84fXHPOEA5FES/hF6wlUKh+N6RcTMVUENtwAzriB IoAu0ZwdgqDgIAHaeFGWJH1kxNBG+ZnLC1E+Ebv8EBkHJuK6ohQ2EhfbALMynpr5RWIF cnww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=B4xuf6d2zLwSxSmFieefxSfWW1CzdDaR48QHguDg++g=; b=OxSElqvwn35rbsejJfhiKCPs51YSGKr4DC42VZThwd6qBS/U77s9FQinVfP3S68cRh jfPVWpbDKHkU/Ahf1Lat0qq6WIoQ+0KPWxGPHWZi3k57ODN6xXfs0A+5EeKUZO7HpEtZ 4qxKO6sk8bKWhhLjjoRdUb/GAdL6UGp4BtJfHJ59sd9/BbUqdidNR7IqPUc/k0OGVCvP ehtW2/Lg99/rhYq+XYAsUyOXNWhNHyYr/vS+iBGoZkxvow6lmz7sKAOsKVcQuthy14Us Z56dlw8rVoIcbJ5zbtM1zSXXbhMGdVfO32amVgRk3YBsy+I29G6Xh2ZOHUYyrDB4/2yQ hBkg== X-Gm-Message-State: ALKqPwdv32JjkL720ZXhgsNn0LWaauhLtn286vl8eQZHWkd8T928Ia/a 7WE7karXKRYv83+VpbKYSkApeQ== X-Google-Smtp-Source: AB8JxZrngttNs4vlNAvkvouYwbgfMyMhhtDoU5hyL+2a6JIKzXHDekucJ/tIFEXnc+bNMpWn3jHb/Q== X-Received: by 2002:a24:de07:: with SMTP id d7-v6mr487237itg.93.1526435595549; Tue, 15 May 2018 18:53:15 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([100.67.80.24]) by smtp.gmail.com with ESMTPSA id z207-v6sm960157itc.34.2018.05.15.18.53.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 18:53:14 -0700 (PDT) Received: by kiwi.bld.corp.google.com (Postfix, from userid 121222) id 83116141521; Tue, 15 May 2018 19:53:14 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 15 May 2018 19:52:57 -0600 Message-Id: <20180516015258.187295-12-sjg@chromium.org> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180516015258.187295-1-sjg@chromium.org> References: <20180516015258.187295-1-sjg@chromium.org> Cc: Tom Rini Subject: [U-Boot] [PATCH 11/12] binman: Add support for adding a name prefix to entries X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Sometimes we have several sections which repeat the same entries (e.g. for a read-only and read-write version of the same section). It is useful to be able to tell these entries apart by name. Add a new 'name-prefix' property for sections, which causes all entries within that section to have a given name prefix. Signed-off-by: Simon Glass --- tools/binman/README | 8 ++++++++ tools/binman/bsection.py | 8 +++++++- tools/binman/entry.py | 13 +++++++++++-- tools/binman/ftest.py | 10 ++++++++++ tools/binman/test/56_name_prefix.dts | 28 ++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tools/binman/test/56_name_prefix.dts diff --git a/tools/binman/README b/tools/binman/README index 64e529f06b9..42ed4448bc2 100644 --- a/tools/binman/README +++ b/tools/binman/README @@ -417,11 +417,13 @@ and can be programmed: binman { section@0 { read-only; + name-prefix = "ro-"; size = <0x100000>; u-boot { }; }; section@1 { + name-prefix = "rw-"; size = <0x100000>; u-boot { }; @@ -437,6 +439,12 @@ read-only: Indicates that this section is read-only. This has no impact on binman's operation, but his property can be read at run time. +name-prefix: + This string is prepended to all the names of the binaries in the + section. In the example above, the 'u-boot' binaries which actually be + renamed to 'ro-u-boot' and 'rw-u-boot'. This can be useful to + distinguish binaries with otherwise identical names. + Special properties ------------------ diff --git a/tools/binman/bsection.py b/tools/binman/bsection.py index 2930718e11f..1861a351767 100644 --- a/tools/binman/bsection.py +++ b/tools/binman/bsection.py @@ -41,6 +41,8 @@ class Section(object): memory address (like 0xff800000) is the first entry position. This causes _skip_at_start to be set to the starting memory address. + _name_prefix: Prefix to add to the name of all entries within this + section _entries: OrderedDict() of entries """ def __init__(self, name, node, test=False): @@ -58,6 +60,7 @@ class Section(object): self._sort = False self._skip_at_start = 0 self._end_4gb = False + self._name_prefix = '' self._entries = OrderedDict() if not test: self._ReadNode() @@ -79,10 +82,13 @@ class Section(object): self._Raise("Section size must be provided when using end-at-4gb") if self._end_4gb: self._skip_at_start = 0x100000000 - self._size + self._name_prefix = fdt_util.GetString(self._node, 'name-prefix') def _ReadEntries(self): for node in self._node.subnodes: - self._entries[node.name] = Entry.Create(self, node) + entry = Entry.Create(self, node) + entry.SetPrefix(self._name_prefix) + self._entries[node.name] = entry def CheckSize(self): """Check that the section contents does not exceed its size, etc.""" diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 3811d33e420..e4d688c91f9 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -48,11 +48,11 @@ class Entry(object): pad_after: Number of pad bytes after the contents, 0 if none data: Contents of entry (string of bytes) """ - def __init__(self, section, etype, node, read_node=True): + def __init__(self, section, etype, node, read_node=True, name_prefix=''): self.section = section self.etype = etype self._node = node - self.name = node and node.name or 'none' + self.name = node and (name_prefix + node.name) or 'none' self.pos = None self.size = None self.contents_size = 0 @@ -129,6 +129,15 @@ class Entry(object): self.align_end = fdt_util.GetInt(self._node, 'align-end') self.pos_unset = fdt_util.GetBool(self._node, 'pos-unset') + def SetPrefix(self, prefix): + """Set the name prefix for a node + + Args: + prefix: Prefix to set, or '' to not use a prefix + """ + if prefix: + self.name = prefix + self.name + def ObtainContents(self): """Figure out the contents of an entry. diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 61bbb53f8c3..eb8a0793cbe 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -950,5 +950,15 @@ class TestFunctional(unittest.TestCase): 00000000 00000004 u-boot ''', map_data) + def testNamePrefix(self): + """Tests that name prefixes are used""" + _, _, map_data = self._DoReadFileDtb('56_name_prefix.dts', map=True) + self.assertEqual('''Position Size Name +00000000 00000010 section@0 + 00000000 00000004 ro-u-boot +00000010 00000010 section@1 + 00000000 00000004 rw-u-boot +''', map_data) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/56_name_prefix.dts b/tools/binman/test/56_name_prefix.dts new file mode 100644 index 00000000000..28e483fd7b5 --- /dev/null +++ b/tools/binman/test/56_name_prefix.dts @@ -0,0 +1,28 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + pad-byte = <0x26>; + size = <0x28>; + section@0 { + read-only; + name-prefix = "ro-"; + size = <0x10>; + pad-byte = <0x21>; + + u-boot { + }; + }; + section@1 { + name-prefix = "rw-"; + size = <0x10>; + pad-byte = <0x61>; + + u-boot { + }; + }; + }; +};