From patchwork Tue Jul 17 19:25:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 945295 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 Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41VW3n1YkTz9s0w for ; Wed, 18 Jul 2018 05:45:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D5584C21C27; Tue, 17 Jul 2018 19:38:57 +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_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 B1C7DC21F51; Tue, 17 Jul 2018 19:26:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F3B06C21F2F; Tue, 17 Jul 2018 19:26:42 +0000 (UTC) Received: from mail-yb0-f202.google.com (mail-yb0-f202.google.com [209.85.213.202]) by lists.denx.de (Postfix) with ESMTPS id 9E9F7C21EDC for ; Tue, 17 Jul 2018 19:26:30 +0000 (UTC) Received: by mail-yb0-f202.google.com with SMTP id c2-v6so1083445ybl.16 for ; Tue, 17 Jul 2018 12:26:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=HmYmBitGlFFPeyNBhPZY8KhfpoF5kUJlaVkJo3i18uc=; b=nRhwsGkS5F4ZysE2GSG7QkMShfbUG6SoIh04Btufs4AUR/1A3WgvSSmkb4WNcI8bsD QTHJK3wEFP2rS7cRUgnYU/2/liAMBh5sw44gkTr6NhvMYXfWNOM5cIbgtbTYsrMk4Vkw JzIDfV+Pq4q0NS2oHzvv587tcdn5V7d4f5EQRIx8DWeMUhpfWq4Bx+F7OHrBER9TkqhB eqH3kVH1IDhn5f7SNmYJC6a3ivZjmaqN01TvqLp4+faGAiEepP7QbGYD4mgN+YoULii2 P2I0IArt5UTRFac9Ou30bbJTzaySzb5Jjnho7K0KjaSbLEC3i9YJMbtWj0BhQ39WqKyQ hUrQ== X-Gm-Message-State: AOUpUlEd8pyqIaAoNksJuuQTylQG9HQOsJoqf7l3HBkrp8BJgr1lypoh P3qqXUlhp0QfoWTJuXvpQQRZkd0= X-Google-Smtp-Source: AAOMgpdAPo27VVqLufsazTH6z8biqRU9KiZf+7rAQcLEfZ4Iax7jktbN2dsg0pk19WaaKePJmEYTKbY= MIME-Version: 1.0 X-Received: by 2002:a81:6907:: with SMTP id e7-v6mr875510ywc.121.1531855589734; Tue, 17 Jul 2018 12:26:29 -0700 (PDT) Date: Tue, 17 Jul 2018 13:25:39 -0600 In-Reply-To: <20180717192552.198496-1-sjg@chromium.org> Message-Id: <20180717192552.198496-17-sjg@chromium.org> References: <20180717192552.198496-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini Subject: [U-Boot] [PATCH 16/29] binman: Add support for a cros_ec image 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add an entry type which can hold a Chrome OS EC. To make this work a new entry type is created, which supports getting a blob filename from the command line. Signed-off-by: Simon Glass --- tools/binman/README.entries | 29 ++++++++++++++++++ tools/binman/etype/blob_named_by_arg.py | 34 ++++++++++++++++++++++ tools/binman/etype/cros_ec_rw.py | 22 ++++++++++++++ tools/binman/ftest.py | 11 +++++++ tools/binman/test/68_blob_named_by_arg.dts | 12 ++++++++ 5 files changed, 108 insertions(+) create mode 100644 tools/binman/etype/blob_named_by_arg.py create mode 100644 tools/binman/etype/cros_ec_rw.py create mode 100644 tools/binman/test/68_blob_named_by_arg.dts diff --git a/tools/binman/README.entries b/tools/binman/README.entries index 0b3be69f5e..147dd40bff 100644 --- a/tools/binman/README.entries +++ b/tools/binman/README.entries @@ -26,6 +26,35 @@ example the 'u_boot' entry which provides the filename 'u-boot.bin'. +Entry: blob-named-by-arg: A blob entry which gets its filename property from its subclass +----------------------------------------------------------------------------------------- + +Properties / Entry arguments: + - -path: Filename containing the contents of this entry (optional, + defaults to 0) + +where is the blob_fname argument to the constructor. + +This entry cannot be used directly. Instead, it is used as a parent class +for another entry, which defined blob_fname. This parameter is used to +set the entry-arg or property containing the filename. The entry-arg or +property is in turn used to set the actual filename. + +See cros_ec_rw for an example of this. + + + +Entry: cros-ec-rw: A blob entry which contains a Chromium OS read-write EC image +-------------------------------------------------------------------------------- + +Properties / Entry arguments: + - cros-ec-rw-path: Filename containing the EC image + +This entry holds a Chromium OS EC (embedded controller) image, for use in +updating the EC on startup via software sync. + + + Entry: fmap: An entry which contains an Fmap section ---------------------------------------------------- diff --git a/tools/binman/etype/blob_named_by_arg.py b/tools/binman/etype/blob_named_by_arg.py new file mode 100644 index 0000000000..344112bc42 --- /dev/null +++ b/tools/binman/etype/blob_named_by_arg.py @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2018 Google, Inc +# Written by Simon Glass +# +# Entry-type module for a blob where the filename comes from a property in the +# node or an entry argument. The property is called '-path' where +# is provided by the subclass using this entry type. + +from collections import OrderedDict + +from blob import Entry_blob +from entry import EntryArg + + +class Entry_blob_named_by_arg(Entry_blob): + """A blob entry which gets its filename property from its subclass + + Properties / Entry arguments: + - -path: Filename containing the contents of this entry (optional, + defaults to 0) + + where is the blob_fname argument to the constructor. + + This entry cannot be used directly. Instead, it is used as a parent class + for another entry, which defined blob_fname. This parameter is used to + set the entry-arg or property containing the filename. The entry-arg or + property is in turn used to set the actual filename. + + See cros_ec_rw for an example of this. + """ + def __init__(self, section, etype, node, blob_fname): + Entry_blob.__init__(self, section, etype, node) + self._filename, = self.GetEntryArgsOrProps( + [EntryArg('%s-path' % blob_fname, str)]) diff --git a/tools/binman/etype/cros_ec_rw.py b/tools/binman/etype/cros_ec_rw.py new file mode 100644 index 0000000000..261f8657a6 --- /dev/null +++ b/tools/binman/etype/cros_ec_rw.py @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2018 Google, Inc +# Written by Simon Glass +# +# Entry-type module for a Chromium OS EC image (read-write section) +# + +from blob_named_by_arg import Entry_blob_named_by_arg + + +class Entry_cros_ec_rw(Entry_blob_named_by_arg): + """A blob entry which contains a Chromium OS read-write EC image + + Properties / Entry arguments: + - cros-ec-rw-path: Filename containing the EC image + + This entry holds a Chromium OS EC (embedded controller) image, for use in + updating the EC on startup via software sync. + """ + def __init__(self, section, etype, node): + Entry_blob_named_by_arg.__init__(self, section, etype, node, + 'cros-ec-rw') diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index bd4de4e287..5428ee651a 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -46,6 +46,8 @@ MRC_DATA = 'mrc' TEXT_DATA = 'text' TEXT_DATA2 = 'text2' TEXT_DATA3 = 'text3' +CROS_EC_RW_DATA = 'ecrw' + class TestFunctional(unittest.TestCase): """Functional tests for binman @@ -92,6 +94,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('cmc.bin', CMC_DATA) TestFunctional._MakeInputFile('vbt.bin', VBT_DATA) TestFunctional._MakeInputFile('mrc.bin', MRC_DATA) + TestFunctional._MakeInputFile('ecrw.bin', CROS_EC_RW_DATA) self._output_setup = False # ELF file with a '_dt_ucode_base_size' symbol @@ -1224,6 +1227,14 @@ class TestFunctional(unittest.TestCase): fmap_util.FMAP_AREA_LEN * 3, fentries[2].size) self.assertEqual('FMAP', fentries[2].name) + def testBlobNamedByArg(self): + """Test we can add a blob with the filename coming from an entry arg""" + entry_args = { + 'cros-ec-rw-path': 'ecrw.bin', + } + data, _, _, _ = self._DoReadFileDtb('68_blob_named_by_arg.dts', + entry_args=entry_args) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/68_blob_named_by_arg.dts b/tools/binman/test/68_blob_named_by_arg.dts new file mode 100644 index 0000000000..e129f843cd --- /dev/null +++ b/tools/binman/test/68_blob_named_by_arg.dts @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0+ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + cros-ec-rw { + }; + }; +};