Commit Graph

1926 Commits

Author SHA1 Message Date
Simon Glass
27145fd3a8 binman: Place Intel descriptor at image start
The Intel descriptor must always appear at the start of an (x86) image,
so it is supposed to position itself there always. However there is no
explicit test for this. Add one and fix a bug introduced by the recent
change to adjust Entry to read the node in a separate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
95a0f3c691 binman: Adjust fmap to ignore CBFS files
The FMAP is not intended to show the files inside a CBFS. The FMAP can be
used to locate the CBFS itself, but then the CBFS must be read to find out
what is in it.

Update the FMAP to work this way and add some debugging while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
61ec04f9ed binman: Support shrinking a entry after packing
Sometimes an entry may shrink after it has already been packed. In that
case we must repack the items. Of course it is always possible to just
leave the entry at its original size and waste space at the end. This is
what binman does by default, since there is the possibility of the entry
changing size every time binman calculates its contents, thus causing a
loop.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
79d3c58d12 binman: Update the _testing entry to support shrinkage
Sometimes entries shrink after packing. As a start towards supporting
this, update the _testing entry to handle the test case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
51014aabc2 binman: Allow updating entries that change size
So far we don't allow entries to change size when repacking. But this is
not very useful since it is common for entries to change size after an
updated binary is built, etc.

Add support for this, respecting the original offset/size/alignment
constraints of the image layout. For this to work the original image
must have been created with the 'allow-repack' property.

This does not support entry types with sub-entries such as files and
CBFS, but it does support sections.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
eba1f0cc94 binman: Add more tests for image header position
The positioning does not currently work correctly if at the end of an
image with no fixed size. Also if the header is in the middle of an image
it can cause a gap in the image since the header position is normally at
the image end, so entries after it are placed after the end of the image.

Fix these problems and add more tests to cover these cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
7400107e46 binman: Move Image.BuildImage() into a single function
Now that an Image is an Entry_section, there is no need for the separate
BuildSection() function. Drop it and add a bit of logging.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
96b6c506ca binman: Write the original input fdtmap to a file
When reading an image in, write its fdtmap to a file in the output
directory. This is useful for debugging. Update the 'ls' command to set up
the output directory; otherwise it will fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
4ab88b6f2f binman: Update documentation for image creation
There are a few more steps in the process now. Update the documentation to
reflect this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
12bb1a99c2 binman: Add info to allow safely repacking an image later
At present it is not possible to discover the contraints to repacking an
image (e.g. maximum section size) since this information is not preserved
from the original image description.

Add new 'orig-offset' and 'orig-size' properties to hold this. Add them to
the main device tree in the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
10f9d0066b binman: Support updating entries in an existing image
While it is useful and efficient to build images in a single pass from a
unified description, it is sometimes desirable to update the image later.

Add support for replace an existing file with one of the same size. This
avoids needing to repack the file. Support for more advanced updates will
come in future patches.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
a004f29464 binman: Tidy up _SetupDtb() to use its own temporary file
At present EnsureCompiled() uses an file from the 'output' directory (in
the tools module) when compiling the device tree. This is fine in most
cases, allowing useful inspection of the output files from binman.

However in functional tests, _SetupDtb() creates an output directory and
immediately removes it afterwards. This serves no benefit and just
confuses things, since the 'official' output directory is supposed to be
created and destroyed in control.Binman().

Add a new parameter for the optional temporary directory to use, and use a
separate temporary directory in _SetupDtb().

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
02fd463cfe binman: Allow the fdtmap to remain unchanged
When updating an existing image where the size of all entries remains the
same, we should not need to regenerate the fdtmap. Update the entry to
return the same fdtmap as was read from the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
6ccbfcdd96 binman: Add a constant for common entry properties
We use this same combination of properties several times in tests. Add a
constant for it to avoid typos, etc.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
c5ad04b721 binman: Add a function to obtain the image for an Entry
At present we have an 'image' property in the entry for this purpose, but
this is not necessary and seems error-prone in the presence of
inheritance. Add a function instead. The Entry_section class overrides
this with a special version, since top-level sections are in fact images,
since Image inherits Entry_section.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:06 -06:00
Simon Glass
c6bd6e235a binman: Adjust Entry to read the node in a separate call
At present the Entry constructor sets up the object and then immediately
reads its device-tree node to obtain its properties.

This breaks a convention that constructors should not do any processing.
A consequence is that we must pass all arguments to the constructor and
cannot have the node-reading proceed in a different way unless we pass
flags to that constructor. We already have a 'test' flag in a few cases,
and now need to control whether the 'orig_offset' and 'orig_size'
properties are set or not.

Adjust the code to require a separate call to ReadNode() after
construction. The Image class remains as it was.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
1411ac8d16 binman: Add an image name into the fdtmap
Since binman supports multiple images it is useful to know which one
created the image that has been read. Then it is possible to look up that
name in the 'master' device tree (containing the description of all
images).

Add a property for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
6ca0dcba5e binman: Store the entry in output_fdt_files
In some cases we want to access the Entry object for a particular device
tree. This allows us to read its contents or update it. Add this
information to output_fdt_files and provide a function to read it.

Also rename output_fdt_files since its name is no-longer descriptive.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
6a3b5b5411 binman: Allow state functions to fail to return data
At present these state functions raise an exception if they cannot find
what is requested. But in some cases the information is optional (e.g. an
fdtmap in a coming patch) so it is better to return gracefully.

Update these two functions to return None when the data cannot be found.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
d5079330f5 binman: Support loading entry data from a file
When modifying an image it is convenient to load the data from the file
into each entry so that it can be reprocessed. Add a new LoadData() method
to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
589d8f917e binman: Store image fdtmap when loading from a file
This data provides all the information about the position and size of each
entry. Store it for later use when loading an image. It can be reused as
is if the image is modified without changing offsets/sizes.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
e44bc831e2 dtoc: Update Fdt.GetNode() to handle the root node
This function currently fails if the root node is requested. Requesting
the root node is sometimes useful, so fix the bug.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
880e9ee650 dtoc: Update Fdt.FromData() to allow a name
It is confusing when something goes wrong with a device tree which was
created from data rather than a file, since there is no identifying
filename. Add an option to provide this. Use the filename as the name,
where available

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
d9dad10e3c binman: Show a helpful error when a DT property is missing
At present a Python exception is raised which does not show the node
information. Add a more helpful exception in this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
9f297b09c0 binman: Add a bit of logging in entries when packing
Use the new logging feature to log information about progress with
packing. This is useful to see how binman is figuring things out.

Also update elf.py to use the same feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
fd07336211 patman: Update tout to avoid open-coding the debug levels
Use the debug level constants instead of open-coding them in the file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
f49462e547 binman: Drop state.fdt_set as this is not needed
We can iterate through the output files so don't need this global anymore.
Remove it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
77e4ef1bf4 binman: Simplify state.fdt_subset
At present this excludes the device tree passed in to binman since it
is always returned first by GetAllFdts(). However, this is easy to ensure
by adding a check in that function. Change this dict to includes all
device trees, and rename it to fdt_set.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
fb5e8b163e binman: Adjust state.fdt_files to be keyed by entry type
It makes more sense to use entry type as the key for this dictionary,
since the filename can in principle be anything. Make this change and also
rename fdt_files and add a comment to explain it better.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
4bdd30055c binman: Adjust GetFdt() to be keyed by etype
At present the FDTs are keyed by their default filename (not their actual
filename). It seems easier to key by the entry type, since this is always
the same for each FDT type.

To do this, add a new Entry method called GetFdtEtype(). This is necessary
since some entry types contain a device tree which are not the simple
three entry types 'u-boot-dtb', 'u-boot-spl' or 'u-boot-tpl'.

The code already returns a dict for GetFdt(). Update the value of that
dict to include the filename so that existing code can work.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
726e296129 binman: Rename state.GetFdt()
This function name conflicts with Fdt.Node.GetFdt() which has a different
purpose. Rename it to avoid confusion.

The new name suggests it is indexed by entry type rather than filename.
This will be tidied up in a future commit.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
4bdd115980 binman: Rename state.GetFdts()
This function name conflicts with Entry.GetFdts() which has a different
purpose. Rename it to avoid confusion. Also update a stale comment
relating to this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
a8adb6dfeb binman: Convert GetFdtSet() to use a dict
At present this function returns a set of device-tree filenames. It has no
way of returning the actual device-tree object. Change it to a dictionary
so that we can add this feature in a future patch.

Also drop fdt_set since it is no-longer used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
a8573c4c8f binman: Move image/fdt code into PrepareImagesAndDtbs()
Further reduce the size of the main Binman() function by moving this setup
code into its own function.

Note that the 'images' value is accessed from other modules so must be made
a global.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
7b773167c0 binman: Use print() to print output
At present tout writes directly to stdout. This is not necessary and it
prevents tests from redirecting output. Change it to use print() for the
non-progress output.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
935461262e binman: Move GetFdtSet() into blob_dtb
At present we check the filename to see if an entry holds a device-tree
file. It is easier to use the base class designed for this purpose.

Move this method implementation into Entry_blob_dtb and update the default
one to return an empty set.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
b88e81c622 binman: Move image-processing code into a function
The Binman() function is very long. Split out the image code to make it
more manageable.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Simon Glass
1000096b06 dtoc: Return a non-zero exit code when tests fail
At present 'dtoc -t' return a success code even if some of the tests fail.
Fix this by checking the test result and setting the exit code. This
allows 'make qcheck' to function as expected.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29 09:38:05 -06:00
Heinrich Schuchardt
e35d533c79 tools/logos: remove black background of U-Boot logo
When generating the Sphinx documentation with command 'make htmldocs' the
U-Boot logo is displayed with a black box as a background.

Remove the black box.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2019-07-29 09:32:08 -04:00
Heiko Schocher
245b1029e1 bmp_logo: support CONFIG_DM_VIDEO
in case of bmp_logo, the video_bmp driver is used for
drawing a bmp logo. This driver supports only "full"
bmp data. Adding a logo with the bmp_logo tool to
u-boot binary adds currently only real data and drops
the bmp header.

This patch adds now the full bmp data to the u-boot
binary, so video_bmp driver works with the logo embedded
into u-boot.

Fixed also some checkpatch error poping up with this
patch.

Signed-off-by: Heiko Schocher <hs@denx.de>
2019-07-29 00:20:31 +02:00
Baruch Siach
2429613601 buildman: fix invocation examples typos
Also, make command line example indentation consistent.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
2019-07-24 12:54:08 -07:00
Simon Glass
e2705fa9c5 binman: Add a test for nested and aligned sections
Current test coverage is likely sufficient for the logic used to place
sections in the image. However it seems useful to add a test specifically
for nested sections, since these could have some unusual interactions.

Add a new test for this and aligned sections. This test failed before the
refactor to drop the bsection.py file (Section class), but passes now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
71ce0ba284 binman: Add an 'extract' command
It is useful to be able to extract all binaries from the image, or a
subset of them. Add a new 'extract' command to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
3a9c252583 binman: Support reading from CBFS entries
CBFS is a bit like a section but with a custom format. Provide the list of
entries and the compression type to binman so that it can extract the data
from the CBFS, just like any other part of the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
f667e45b1c binman: Allow reading an entry from an image
It is useful to be able to extract entry contents from an image to see
what is inside. Add a simple function to read the contents of an entry,
decompressing it by default.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
eea264ead3 binman: Allow for logging information to be displayed
Binman generally operates silently but in some cases it is useful to see
what Binman is actually doing at each step. Enable some logging output
with different logging levels selectable via the -v flag.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
61f564d15f binman: Support listing an image
Add support for listing the entries in an image. This relies on the image
having an FDT map.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
8beb11ea6e binman: Convert Image to a subclass of Entry
When support for sections (and thus hierarchical images) was added to
binman, the decision was made to create a new Section class which could
be used by both Image and an Entry_section class. The decision between
using inheritance and composition was tricky to make, but in the end it
was decided that Image was different enough from Entry that it made sense
to put the implementation of sections in an entirely separate class. It
also has the advantage that core Image code does have to rely on an entry
class in the etype directory.

This work was mostly completed in commit:

   8f1da50ccc "binman: Refactor much of the image code into 'section'

As a result of this, the Section class has its own version of things like
offset and size and these must be kept in sync with the parent
Entry_section class in some cases.

In the last year it has become apparent that the cost of keeping things in
sync is larger than expected, since more and more code wants to access
these properties.

An alternative approach, previously considered and rejected, now seems
better.

Adjust Image to be a subclass of Entry_section. Move the code from Section
(in bsection.py) to Entry_section and delete Section. Update all tests
accordingly.

This requires substantial changes to Image. Overall the changes reduce
code size by about 240 lines. While much of that is just boilerplate from
Section, there are quite a few functions in Entry_section which now do not
need to be overiden from Entry. This suggests the change is beneficial
even without further functionality being added.

A side benefit is that the properties of sections are now consistent with
other entries. This fixes a problem in testListCmd() where some properties
are missing for sections.

Unfortunately this is a very large commit since it is not feasible to do
the migration piecemeal. Given the substantial tests available and the
100% code coverage of binman, we should be able to do this safely.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
ffded7527a binman: Support reading an image into an Image object
It is possible to read an Image, locate its FDT map and then read it into
the binman data structures. This allows full access to the entries that
were written to the image. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
2d26003df7 binman: Support locating an image header
Add support for locating an image header in an image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
e1925fa520 binman: Support locating an FDT map
Add support for locating an image's Fdt map which is used to determine
the contents and structure of the image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
41b8ba090c binman: Allow listing the entries in an image
It is useful to be able to summarise all the entries in an image, e.g. to
display this to this user. Add a new ListEntries() method to Entry, and
set up a way to call it through the Image class.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
8a1ad068de binman: Detect bad CBFS file types
Detect when an unknown or unsupported file type is specified and report
an error.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
69f7cb31a0 binman: Support FDT update for CBFS
It is useful to add the CBFS file information (offset, size, etc.) into
the FDT so that the layout is complete. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
52107ee4df binman: Use the cbfs memlen field only for uncompressed length
The purpose of this badly named field is a bit ambiguous. Adjust the code
to use it only to store the uncompressed length of a file, leaving it set
to None if there is no compression used. This makes it easy to see if the
value in this field is relevant / useful.

Also set data_len for compressed fields, since it should be the length of
the compressed data, not the uncompressed data.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
1223db038a binman: Provide the actual data address for cbfs files
At present a file with no explicit CBFS offset is placed in the next
available location but there is no way to find out where it ended up.
Update and rename the get_data() function to provide this information.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
6c223fda1e binman: Allow device-tree entries to be compressed
At present the logic skips the blob class' handling of compression, so
this is not supported with device tree entries. Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
c52c9e7da8 binman: Allow entries to expand after packing
Add support for detecting entries that change size after they have already
been packed, and re-running packing when it happens.

This removes the limitation that entry size cannot change after
PackEntries() is called.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
bf6906bab4 binman: Add a control for post-pack entry expansion
We plan to support changing the size of entries after they have been
packed. For now it will always be enabled. But to aid testing of both
cases (in the event that we want to add a command-line flag, for example),
add a setting to control it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
a0dcaf2049 binman: Add a return value to ProcessContentsUpdate()
At present if this function tries to update the contents such that the
size changes, it raises an error. We plan to add the ability to change
the size of entries after packing is completed, since in some cases it is
not possible to determine the size in advance.

An example of this is with a compressed device tree, where the values
of the device tree change in SetCalculatedProperties() or
ProcessEntryContents(). While the device tree itself does not change size,
since placeholders for any new properties have already bee added by
AddMissingProperties(), we cannot predict the size of the device tree
after compression. If a value changes from 0 to 0x1234 (say), then the
compressed device tree may expand.

As a first step towards supporting this, make ProcessContentsUpdate()
return a value indicating whether the content size is OK. For now this is
always True (since otherwise binman raises an error), but later patches
will adjust this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
7f9e00a2a6 binman: Call ProcessUpdateContents() consistently
SetContents() should only be called to set the contents of an entry from
within the ObtainContents() call, since it has no guard against increasing
the size of the contents, thus triggering incorrect operation.

Change all such calls to use ProcessUpdateContents() instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
5b463fc26e binman: Fix up ProcessUpdateContents error and comments
This function raises an exception with its arguments around the wrong way
so the message is incorrect. Fix this as well as a few minor comment
problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
e430440232 binman: Allow easy importing of entry modules
At present entry modules can only be accessed using Entry.Lookup() or
Entry.Create(). Most of the time this is fine, but sometimes a module
needs to provide constants or helper functions useful to other modules.
It is easier in this case to use 'import'.

Add an __init__ file to permit this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
c073ced7a3 binman: Drop an unused arg in Entry.Lookup()
The first argument is not used. Remove it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
8287ee852d binman: Move compression into the Entry base class
Compression is currently available only with blobs. However we want to
report the compression algorithm and uncompressed size for all entries,
so that other entry types can support compression. This will help with
the forthcoming 'list' feature which lists entries in the image.

Move the compression properties into the base class. Also fix up the docs
which had the wrong property name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:08 -07:00
Simon Glass
53cd5d921d binman: Convert to use ArgumentParser
This class is the new way to handle arguments in Python. Convert binman
over to use it. At the same time, introduce commands so that we can
separate out the different parts of binman functionality.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:54:07 -07:00
Simon Glass
cf2289435c binman: Add an image header
It is useful to be able to quickly locate the FDT map in the image. An
easy way to do this is with a pointer at the start or end of the image.

Add an 'image header' entry, which places a magic number followed by a
pointer to the FDT map. This can be located at the start or end of the
image, or at a chosen location.

As part of this, update GetSiblingImagePos() to detect missing siblings.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
086cec9f98 binman: Add an FDT map
An FDT map is an entry which holds a full description of the image
entries, in FDT format. It can be discovered using the magic string at
its start. Tools can locate and read this entry to find out what entries
are in the image and where each entry is located.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
3c0813115b binman: Add a convenience functions for real-DTB tests
Quite a few tests will use a real device tree and need it updated with the
binman metadata. Add a helper function for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
5746018468 binman: Update help for new features
A few new features have been added. This has rendered part of the README
obsolete. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
488b2251fe binman: Update future features
A few features have been completed and a few items are added.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
e90fe1b40f binman: Simplify the entry test
The current test for the 'entry' module is a bit convoluted since it has
to import the module multiple times. It also relies on ordering, in that
test1EntryNoImportLib() must run before test2EntryImportLib() if they are
running in the same Python process.

This is unreliable since neither the ordering of tests nor the process
that they run in is defined.

Fix this by always reloading the entry in these two tests. Also add a
check that the expected value of have_importlib is obtained.

This corrects a code-coverage problem in the 'entry' module on some
systems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
e073d4e14f binman: Add support for fixed-offset files in CBFS
A feature of CBFS is that it allows files to be positioned at particular
offset (as with binman in general). This is useful to support
execute-in-place (XIP) code, since this may not be relocatable.

Add a new cbfs-offset property to control this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
7c173ced64 binman: Pad empty areas of the CBFS with files
When there is lots of open space in a CBFS it is normally padded with
'empty' files so that sequentially scanning the CBFS can skip from one to
the next without a break.

Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
c5ac138828 binman: Add support for Intel IFWI entries
An Integrated Firmware Image is used to hold various binaries used for
booting with Apollolake and some later devices. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
ac62fba459 binman: Add support for CBFS entries
Add support for putting CBFSs (Coreboot Filesystems) in an image. This
allows binman to produce firmware images used by coreboot to boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
4997a7ed05 binman: Add a utility library for coreboot CBFS
Coreboot uses a simple flash-based filesystem called Coreboot Filesystem
(CBFS) to organise files used during boot. This allows files to be named
and their position in the flash to be set. It has special features for
dealing with x86 devices which typically memory-map their SPI flash to the
top of 32-bit address space and need a 'boot block' ending there.

Create a library to help create and read CBFS files. This includes a
writer class, a reader class and associated other helpers. Only a subset
of features are currently supported.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
1cfdfc064a patman: Add a function to write ifwitool
This tool has quite a few arguments and options, so put the functionality
in a function so that we call it from one place and hopefully get it
right.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:46 -07:00
Simon Glass
8acce60b10 binman: Pass the toolpath to tests
Tools like ifwitool may not be available in the PATH, but are available in
the build. These tools may be needed by tests, so allow tests to use the
--toolpath flag.

Also use this flag with travis.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24 12:53:44 -07:00
Simon Glass
d5164a7970 binman: Allow preserving test directories
Sometimes when debugging tests it is useful to keep the input and output
directories so they can be examined later. Add an option for this and
update the binman tests to support it. This affects both the test class
and the tearDown() function called after each test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
ee0c9a739f binman: Allow verbosity control when running tests
At present the -v flag is ignored with tests, so that (for example) -v2
does not have any effect. Update binman to pass this flag through to tests
so that they work just like running binman normally, except in a few
special cases where we are actually testing behaviour with different
levels of verbosity.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
2569e10f5b binman: Fix up the _DoTestFile() function -u argument
This should be -u, not -up, since we don't need to preserve the output
directory in this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
4c65025799 binman: Support ELF files for TPL
We currenty support using the ELF file in U-Boot proper and SPL, but not
TPL. Add this as it is useful both with sandbox and for CBFS to allow
adding TPL as a 'stage'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
a6a520e47b binman: Correct comment in u_boot_spl_elf
This comment mentions the wrong default filename. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
c444b1a54f binman: Use tools compression function for blob handling
Avoid duplicate code here by using the new compression function in the
tools module.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
9382bb873b binman: Drop unnecessary debug handling
The -D option enables debug mode, but we only need to add -D to the
command line once. Drop the duplicate code. Also drop the comment about
enabling debugging since this can be done with -D.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:58 -07:00
Simon Glass
ff5c7e383e binman: Use the tools.Decompress method
Update the compression test to use the tools module to decompress the
output data.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
07d9e70bf9 patman: Add functions to compress and decompress data
Add utility functions to compress and decompress using lz4 and lzma
algorithms. In the latter case these use the legacy lzma support favoured
by coreboot's CBFS.

No tests are provided as these functions will be tested by the CBFS
tests in a separate patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
aa88b50d82 binman: Allow text directly in the node
At present text entries use an indirect method to specify the text to use,
with a label pointing to the text itself.

Allow the text to be directly written into the node. This is more
convenient in cases where the text is constant.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
cf54904a99 binman: Update entry.SetOffsetSize to be optional
At present this function always sets both the offset and the size of
entries. But in some cases we want to set only one or the other, for
example with the forthcoming ifwi entry, where we only set the offset.
Update the function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
fa1c937832 binman: Don't assume there is an ME region
At present having a descriptor means that there is an ME (Intel
Management Engine) entry as well. The descriptor provides the ME location
and assumes that it is present.

For some SoCs this is not true. Before providing the location of a
potentially non-existent entry, check if it is present.

Update the comment in the ME entry also.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
79a0176fae binman: Assume Intel descriptor is at the start of the image
At present binman requires that the Intel descriptor has an explicit
offset. Generally this is 0 since the descriptor is at the start of the
image. Add a default to handle this, so users don't need to specify the
offset.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
86679cefe5 binman: Ensure that coverage has access to site packages
Code coverage tests fail on binman due to dist-packages being dropped from
the python path on Ubuntu 16.04. Add them in so that we can find the
elffile module, which is required by binman.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
d8d40748dd binman: Add a function to decode an ELF file
Add a function which decodes an ELF file, working out where in memory each
part of the data should be written.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
f58558a5ae binman: Add a function to create a sample ELF file
It is useful to create an ELF file for testing purposes, with just the
right attributes used by the test. Add a function to handle this, along
with a test that it works correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
45cb9d80ae binman: Detect skipped tests
If tests are skipped we should ideally exit with an error, since there may
be a missing dependency. However at present this is not desirable since it
breaks travis tests. For now, just report the skips.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
458be45afc binman: Use a better error for missing Intel descriptor
FD is a bit confusing so write this out in full. Also avoid splitting the
string so that people can grep for the error message more easily.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
497409fec4 binman: Tidy up help for --indir
The current help is confusing. Adjust it to indicate what the flag
actually does.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
ed7dd5e61c binman: Add missing comments toentry
At present GetOffsets() lacks a function comment. Add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00
Simon Glass
36b246e71f binman: Add missing comments to bsection
Some functions lack comments in this file. Add comments to cover this
functionality.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23 20:27:57 -07:00