Commit Graph

118 Commits

Author SHA1 Message Date
Simon Glass
9c888cca5e binman: Mention section attributes in docs
Images and sections have the same attributes, since an image is mostly
just a top-level section. Update the docs to explain this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29 11:49:35 -06:00
Simon Glass
ba64a0bbb7 binman: Support expanding entries
It is useful to have entries which can grow automatically to fill
available space. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29 11:49:35 -06:00
Simon Glass
0a98b28b06 binman: Support adding files
In some cases it is useful to add a group of files to the image and be
able to access them at run-time. Of course it is possible to generate
the binman config file with a set of blobs each with a filename. But for
convenience, add an entry type which can do this.

Add required support (for adding nodes and string properties) into the
state module.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29 11:49:35 -06:00
Simon Glass
b4e1a38c29 binman: Allow zero-size sections
At present if there is only a zero-size entry in a section this is
reported as an error, e.g.:

   Offset 0x0 (0) is outside the section starting at 0x0 (0)

Adjust the logic in CheckEntries() to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29 11:49:35 -06:00
Simon Glass
83d73c2f7c binman: Support compressed entries
Add support for compressing blob entries. This can help reduce image sizes
for many types of data. It requires that the firmware be able to
decompress the data at run-time.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29 11:49:32 -06:00
Simon Glass
6ed45ba0a8 binman: Support updating all device tree files
Binman currently supports updating the main device tree with things like
the position of each entry. Extend this support to SPL and TPL as well,
since they may need (a subset of) this information.

Also adjust DTB output files to have a .out extension since this seems
clearer than having a .dtb extension with 'out' in the name somwhere.

Also add a few missing comments and update the DT setup code to use
ReadFile and WriteFile().

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
93d174135a binman: Allow control of whether a fake DT is used
We use a fake device tree in tests most of the time since tests don't
normally care about the actual data. For example, for U-Boot proper we use
U_BOOT_DTB_DATA which is just a four-character string. This makes testing
the image output against an expected value very easy.

However in some cases, such as when the test wants to check that the DT
output containing particular nodes, we do actually need the real DT. Add
support for this, along with a command-line option to select 'test mode'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
539aece516 binman: Obtain the list of device trees from the config
We always have a device tree for U-Boot proper. But we may also have one
for SPL and TPL. Add a new Entry method to find out what DTs an entry
has, and use that list when updating DTs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
f46621d255 binman: Centralise device-tree updates within binman
At present we have a few calls to device-tree functions in binman and plan
to add more as we add new entry types which need to report their results.

It makes sense to put this code in a central place so that we can make
sure all device trees are updated. At present we only have U-Boot proper,
but plan to add SPL and TPL too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
2a72cc72ca binman: Move state logic into the state module
Rather than reaching into this module from control, move the code that
needs this info into state.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
c55a50f558 binman: Move state information into a new module
At present the control module has state information in it, since it is the
primary user of this. But it is a bit odd to have entries and other
modules importing control to obtain this information.

It seems better to have a dedicated state module, which control can use as
well. Create a new module using code from control and update other modules
to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
6c234bfbf7 binman: Add an entry method for getting the default filename
Various entry implementations provide a way to obtain the default filename
for an entry. But at present there is no base-class implementation for
this function. Add one so that the API is defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
fa80c25c09 dtoc: Allow syncing of the device tree back to a file
At present we require the caller to manually update the device tree using
individual calls to libfdt functions. This is not ideal. It would be
better if we could make changes using the Python structure and then call a
Sync() function to write them back.

Add this feature to the Fdt class. Update binman and the tests to match.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
0bfa7b09ba binman: Support building a selection of images
Sometimes it is useful to build only a subset of the images provided by
the binman configuration. Add a -i option for this. It can be given
multiple times to build several images. If the option is not given, all
images are built.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
a326b495cd binman: Tidy up the vblock entry
At present if there are two vblock entries an image their contents are
written to the same file in the output directory. This prevents checking
the contents of each separately.

Fix this by adding part of the entry path to the filename, and add some
missing comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
35b384cbe5 binman: Add x86 support for starting TPL
Sometimes we want to include TPL for x86 platforms, such as when we want
to select between different SPL images (e.g. for Chrome OS verified boot).
Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
0b489364f9 binman: Generate an error when text is not provided
When the value of a text entry is not provided an execption is generated
talking about a None type. This is confusing. Add a more explanatory error
and a test for this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
d178eab8f9 binman: Allow 'fill' entry to have a size of 0
The check for this should be for None, not 0. Fix it and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Simon Glass
f069303852 binman: Move 'special properties' docs to README.entries
This information should be in the entry it relates to, not in the main
README. Move it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28 11:09:01 -06:00
Michael Heimpold
383d2568a7 binman: fix a few typos in documentation
This fixes four small typos in the README file.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-18 08:12:21 -06:00
Simon Glass
cee02e6ff4 binman: Adjust _GetPropTree() parameters
At present this function takes a filename, but it is better to use an Fdt
object so that the caller can control this, perhaps obtainint the device
tree from a bytearray. Update the method accordingly and also fix a
confusing parameter name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
15a587c9ce binman: Add a test to catch use of the old 'pos' property
This property has been changed to 'offset'. To help downstream users who
might still be using 'pos', add a check that this is not used by mistake.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
7e7c587760 binman: Rename ReadContents() to ReadBlobContents()
This function name is too generic for its purpose and is therefore
confusing. It actually only applies to blobs, so rename it to indicate
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
1be70d20d8 binman: Show the image position in the map
At present the map only shows the offset and size for each region. The
image position provides the actual position of each entry in the image,
regardless of the section hierarchy.

Add the image position to the map.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
b8ef5b6bc8 binman: Add support for adding TPL binaries
Add support for U-Boot's TPL and TPL device tree. Also fix a few comments
in the other device-tree entries.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
24d0d3c30d binman: Add an entry for a Chromium vblock
This adds support for a Chromium verified boot block, used to sign a
read-write section of the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
0ef87aa332 binman: Add support for Chromium GBB
This entry contains a Google Binary Block, used to store keys and bitmaps
in a Chromium image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
3af8e49cef binman: Add an entry filled with a repeating byte
It is sometimes useful to have an area of the image which is all zeroes,
or all 0xff. This can often be achieved by padding the size of an an
existing entry and setting the pad byte for an entry or image.

But it is useful to have an explicit means of adding blocks of repeating
data to the image. Add a 'fill' entry type to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
ec127af042 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>
2018-08-01 16:30:48 -06:00
Simon Glass
11e36ccea1 binman: Add support for flashrom FMAP
Add an entry which can hold an FMAP region as used by flashrom, an
open-source flashing tool used on Linux x86 machines. This provides a
simplified non-hierarchical view of the entries in the image and has a
signature at the start to allow flashrom to find it in the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
5a5da7ce15 binman: Create README.entries
Create a new README containing documentation for the entry types supported
by binman. This provides an easy reference in one place. It is
automatically generated from the source-code documentation.

Add a reference to this from the binman README.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
fd8d1f7962 binman: Allow creation of entry documentation
Binman supports quite a number of different entries now. The operation of
these is not always obvious but at present the source code is the only
reference for understanding how an entry works.

Add a way to create documentation (from the source code) which can be put
in a new 'README.entries' file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
3fb397bba0 binman: Expand documentation for entries
At present only the more complex entries are documented. It is useful to
have documentation for all entries in one place.

As a first step, add and expand the documentation to cover all entries.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:48 -06:00
Simon Glass
9b1a804d52 binman: Allow help to work without libfdt
At present binman needs libfdt.py to be available before it will do
anything, even print help. Import those modules later to avoid this, as it
is bad practice to fail to even show help on startup.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:47 -06:00
Simon Glass
bb74837c9a binman: Support an entry that holds text
It is useful to able to write an identifying string to the image within an
entry. Add a 'text' entry type to handle this. The actual text is
typically passed to binman on the command line. The text is not itself
nul-terminated but this can be achieved if required by setting the size of
the entry to something larger than the text.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:47 -06:00
Simon Glass
53af22a995 binman: Add support for passing arguments to entries
Sometimes it is useful to pass binman the value of an entry property from
the command line. For example some entries need access to files and it is
not always convenient to put these filenames in the image definition
(device tree).

Add a -a option which can be used like this:

   -a<prop>=<value>

where

   <prop> is the property to set
   <value> is the value to set it to

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:47 -06:00
Simon Glass
dbf6be9f7f binman: Add a new 'image-pos' property
At present each entry has an offset within its parent section. This is
useful for figuring out how entries relate to one another. However it
is sometimes necessary to locate an entry within an image, regardless
of which sections it is nested inside.

Add a new 'image-pos' property to provide this information. Also add
some documentation for the -u option binman provides, which updates the
device tree with final entry information.

Since the image position is a better symbol to use for the position of
U-Boot as obtained by SPL, update the SPL symbols to use this instead of
offset, which might be incorrect if hierarchical sections are used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:45 -06:00
Simon Glass
8122f3967f binman: Enhance the map and fdt-update output
At present the .map file produced for each image does not include the
overall image size. This is useful information.

Update the code to generate it in the .map file as well as the updated
FDT. Also fix a few comments while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:07 -06:00
Simon Glass
ea6922e3d6 binman: Tidy up some comments in the tests
A few lines are commented out and can be removed. Also fix return-value
docs for _DoReadFile() and _DoReadFileDtb().

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:07 -06:00
Simon Glass
b2b0df8f39 binman: Add comments to elf_test
The purpose of some of the tests is not obvious from the function names.
Add a few comments to help with understanding.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:07 -06:00
Simon Glass
3ab9598df7 binman: Rename 'position' to 'offset'
After some thought, I believe there is an unfortunate naming flaw in
binman. Entries have a position and size, but now that we support
hierarchical sections it is unclear whether a position should be an
absolute position within the image, or a relative position within its
parent section.

At present 'position' actually means the relative position. This indicates
a need for an 'image position' for code that wants to find the location of
an entry without having to do calculations back through parents to
discover this image position.

A better name for the current 'position' or 'pos' is 'offset'. It is not
always an absolute position, but it is always an offset from its parent
offset.

It is unfortunate to rename this concept now, 18 months after binman was
introduced. However I believe it is the right thing to do. The impact is
mostly limited to binman itself and a few changes to in-tree users to
binman:

   tegra
   sunxi
   x86

The change makes old binman definitions (e.g. downstream or out-of-tree)
incompatible if they use the 'pos = <...>' property. Later work will
adjust binman to generate an error when it is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:06 -06:00
Simon Glass
46d61a2f2a binman: Don't depend on dict order in ELF testOutsideFile()
At present this test assumes that the symbols are returned in address
order. However, objdump can list symbols in any order and dictionaries do
not guarantee any particular order when iterating through item.

Update elf.GetSymbols() to return an OrderedDict, sorted by address, to
avoid any problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:27:28 -06:00
Simon Glass
16b8d6b769 binman: Support updating the device tree with calc'd info
It is useful to write the position and size of each entry back to the
device tree so that U-Boot can access this at runtime. Add a feature to
support this, along with associated tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
078ab1a2f5 binman: Add a SetCalculatedProperties() method
Once binman has packed the image, the position and size of each entry is
known. It is then possible for binman to update the device tree with these
positions. Since placeholder values have been added, this does not affect
the size of the device tree and therefore the packing does not need to be
performed again.

Add a new SetCalculatedProperties method to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
ecab89737a binman: Add a ProcessFdt() method
Some entry types modify the device tree, e.g. to remove microcode or add a
property. So far this just modifies their local copy and does not affect
a 'shared' device tree.

Rather than doing this modification in the ObtainContents() method, and a
new ProcessFdt() method which is specifically designed to modify this
shared device tree.

Move the existing device-tree code over to use this method, reducing
ObtainContents() to the goal of just obtaining the contents without any
processing, even for device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
0a4357c4c2 binman: Complete documentation of stages
At present one of the stages is badly numbered and not described. Fix
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
c3f9454103 binman: Move capture_sys_output() to test_util
This function is useful in various tests. Move it into the common test
utility module.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
ff1fd6ccde binman: Move coverage logic into a new test_util file
At present only binman has the logic for determining Python test coverage
but this is useful for other tools also. Move it out into a separate file
so it can be used by other tools.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
5c890238c4 binman: Tidy up setting of entry contents
At present the contents of an entry are set in subclasses simply by
assigning to the data and content_size properties. Add some methods to do
this, so that we have more control. In particular, add a method to set the
contents without changing its size, so we can validate that case.

Add a test case for trying to change the size when this is not allowed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00
Simon Glass
2cd01285b5 binman: Tidy up execution of tests
Move all the test execution into the same mechanism so that we can request
a particular test (from any suite) by passing it as an argument to
'binman -t'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09 09:11:00 -06:00