binman: Add support for a cros_ec image

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 <sjg@chromium.org>
This commit is contained in:
Simon Glass 2018-07-17 13:25:39 -06:00
parent 11e36ccea1
commit ec127af042
5 changed files with 108 additions and 0 deletions

View file

@ -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:
- <xxx>-path: Filename containing the contents of this entry (optional,
defaults to 0)
where <xxx> 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
----------------------------------------------------

View file

@ -0,0 +1,34 @@
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2018 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# Entry-type module for a blob where the filename comes from a property in the
# node or an entry argument. The property is called '<blob_fname>-path' where
# <blob_fname> 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:
- <xxx>-path: Filename containing the contents of this entry (optional,
defaults to 0)
where <xxx> 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)])

View file

@ -0,0 +1,22 @@
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2018 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# 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')

View file

@ -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()

View file

@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-2.0+
/dts-v1/;
/ {
#address-cells = <1>;
#size-cells = <1>;
binman {
cros-ec-rw {
};
};
};