oweals/u-boot.git
4 years agocommon: fdt_support: Add missing cpu_to_fdt32() to fdt_pci_dma_ranges()
Marek Vasut [Tue, 9 Jul 2019 00:49:29 +0000 (02:49 +0200)]
common: fdt_support: Add missing cpu_to_fdt32() to fdt_pci_dma_ranges()

The fdt_pci_dma_ranges() cannot work on e.g. ARM, since the DT entries
endianness is not adjusted at all. Fix this.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
4 years agodm: Fix parameter description of dev_read_name()
Bin Meng [Fri, 5 Jul 2019 16:23:18 +0000 (09:23 -0700)]
dm: Fix parameter description of dev_read_name()

The comments of dev_read_name() wrongly describe "node" as its
parameter.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agodm: core: Set correct "status" value for a node
Bin Meng [Fri, 5 Jul 2019 16:23:17 +0000 (09:23 -0700)]
dm: core: Set correct "status" value for a node

Per device tree spec, "status" property can have a value of "okay",
or "disabled", but not "disable".

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agodm: core: Call clk_set_defaults() during probe() only for a valid ofnode
Bin Meng [Fri, 5 Jul 2019 16:23:16 +0000 (09:23 -0700)]
dm: core: Call clk_set_defaults() during probe() only for a valid ofnode

Without a valid ofnode, it's meaningless to call clk_set_defaults()
to process various properties.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agodm: timer: Skip device that does not have a valid ofnode in pre_probe()
Bin Meng [Fri, 5 Jul 2019 16:23:15 +0000 (09:23 -0700)]
dm: timer: Skip device that does not have a valid ofnode in pre_probe()

It is possible that a timer device has a null ofnode, hence there is
no need to further parse DT for the clock rate.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
4 years agofdt: make fdt_get_base_address() return OF_BAD_ADDR when "reg" not found
Masahiro Yamada [Thu, 27 Jun 2019 07:39:57 +0000 (16:39 +0900)]
fdt: make fdt_get_base_address() return OF_BAD_ADDR when "reg" not found

Currently, fdt_get_base_address() returns 0 if the "reg" property is
missing. Since 0 is a valid value, it is not suitable for the error
handling. Return OF_BAD_ADDR instead.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
4 years agobinman: Add a test for nested and aligned sections
Simon Glass [Mon, 8 Jul 2019 20:25:53 +0000 (14:25 -0600)]
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>
4 years agobinman: Add an 'extract' command
Simon Glass [Mon, 8 Jul 2019 20:25:52 +0000 (14:25 -0600)]
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>
4 years agobinman: Support reading from CBFS entries
Simon Glass [Mon, 8 Jul 2019 20:25:51 +0000 (14:25 -0600)]
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>
4 years agobinman: Allow reading an entry from an image
Simon Glass [Mon, 8 Jul 2019 20:25:50 +0000 (14:25 -0600)]
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>
4 years agobinman: Allow for logging information to be displayed
Simon Glass [Mon, 8 Jul 2019 20:25:49 +0000 (14:25 -0600)]
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>
4 years agobinman: Support listing an image
Simon Glass [Mon, 8 Jul 2019 20:25:48 +0000 (14:25 -0600)]
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>
4 years agobinman: Convert Image to a subclass of Entry
Simon Glass [Mon, 8 Jul 2019 20:25:47 +0000 (14:25 -0600)]
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>
4 years agobinman: Support reading an image into an Image object
Simon Glass [Mon, 8 Jul 2019 20:25:46 +0000 (14:25 -0600)]
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>
4 years agobinman: Support locating an image header
Simon Glass [Mon, 8 Jul 2019 20:25:45 +0000 (14:25 -0600)]
binman: Support locating an image header

Add support for locating an image header in an image.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Support locating an FDT map
Simon Glass [Mon, 8 Jul 2019 20:25:44 +0000 (14:25 -0600)]
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>
4 years agobinman: Allow listing the entries in an image
Simon Glass [Mon, 8 Jul 2019 20:25:43 +0000 (14:25 -0600)]
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>
4 years agobinman: Detect bad CBFS file types
Simon Glass [Mon, 8 Jul 2019 20:25:42 +0000 (14:25 -0600)]
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>
4 years agobinman: Support FDT update for CBFS
Simon Glass [Mon, 8 Jul 2019 20:25:41 +0000 (14:25 -0600)]
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>
4 years agobinman: Use the cbfs memlen field only for uncompressed length
Simon Glass [Mon, 8 Jul 2019 20:25:40 +0000 (14:25 -0600)]
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>
4 years agobinman: Provide the actual data address for cbfs files
Simon Glass [Mon, 8 Jul 2019 20:25:39 +0000 (14:25 -0600)]
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>
4 years agobinman: Allow device-tree entries to be compressed
Simon Glass [Mon, 8 Jul 2019 20:25:38 +0000 (14:25 -0600)]
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>
4 years agobinman: Allow entries to expand after packing
Simon Glass [Mon, 8 Jul 2019 20:25:37 +0000 (14:25 -0600)]
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>
4 years agobinman: Add a control for post-pack entry expansion
Simon Glass [Mon, 8 Jul 2019 20:25:36 +0000 (14:25 -0600)]
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>
4 years agobinman: Add a return value to ProcessContentsUpdate()
Simon Glass [Mon, 8 Jul 2019 20:25:35 +0000 (14:25 -0600)]
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>
4 years agobinman: Call ProcessUpdateContents() consistently
Simon Glass [Mon, 8 Jul 2019 20:25:34 +0000 (14:25 -0600)]
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>
4 years agobinman: Fix up ProcessUpdateContents error and comments
Simon Glass [Mon, 8 Jul 2019 20:25:33 +0000 (14:25 -0600)]
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>
4 years agobinman: Allow easy importing of entry modules
Simon Glass [Mon, 8 Jul 2019 20:25:32 +0000 (14:25 -0600)]
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>
4 years agobinman: Drop an unused arg in Entry.Lookup()
Simon Glass [Mon, 8 Jul 2019 20:25:31 +0000 (14:25 -0600)]
binman: Drop an unused arg in Entry.Lookup()

The first argument is not used. Remove it.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Move compression into the Entry base class
Simon Glass [Mon, 8 Jul 2019 20:25:30 +0000 (14:25 -0600)]
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>
4 years agobinman: Convert to use ArgumentParser
Simon Glass [Mon, 8 Jul 2019 20:25:29 +0000 (14:25 -0600)]
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>
4 years agobinman: Add an image header
Simon Glass [Mon, 8 Jul 2019 20:25:28 +0000 (14:25 -0600)]
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>
4 years agobinman: Add an FDT map
Simon Glass [Mon, 8 Jul 2019 20:25:27 +0000 (14:25 -0600)]
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>
4 years agobinman: Add a convenience functions for real-DTB tests
Simon Glass [Mon, 8 Jul 2019 20:25:26 +0000 (14:25 -0600)]
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>
4 years agobinman: Update help for new features
Simon Glass [Mon, 8 Jul 2019 20:25:25 +0000 (14:25 -0600)]
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>
4 years agobinman: Update future features
Simon Glass [Mon, 8 Jul 2019 20:25:24 +0000 (14:25 -0600)]
binman: Update future features

A few features have been completed and a few items are added.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Simplify the entry test
Simon Glass [Mon, 8 Jul 2019 20:25:23 +0000 (14:25 -0600)]
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>
4 years agobinman: Add support for fixed-offset files in CBFS
Simon Glass [Mon, 8 Jul 2019 19:18:56 +0000 (13:18 -0600)]
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>
4 years agobinman: Pad empty areas of the CBFS with files
Simon Glass [Mon, 8 Jul 2019 19:18:55 +0000 (13:18 -0600)]
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>
4 years agobinman: Add support for Intel IFWI entries
Simon Glass [Mon, 8 Jul 2019 19:18:54 +0000 (13:18 -0600)]
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>
4 years agobinman: Add support for CBFS entries
Simon Glass [Mon, 8 Jul 2019 19:18:53 +0000 (13:18 -0600)]
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>
4 years agobinman: Add a utility library for coreboot CBFS
Simon Glass [Mon, 8 Jul 2019 19:18:52 +0000 (13:18 -0600)]
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>
4 years agopatman: Add a function to write ifwitool
Simon Glass [Mon, 8 Jul 2019 19:18:51 +0000 (13:18 -0600)]
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>
4 years agobinman: Pass the toolpath to tests
Simon Glass [Mon, 8 Jul 2019 19:18:50 +0000 (13:18 -0600)]
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>
4 years agobinman: Allow preserving test directories
Simon Glass [Mon, 8 Jul 2019 19:18:49 +0000 (13:18 -0600)]
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>
4 years agobinman: Allow verbosity control when running tests
Simon Glass [Mon, 8 Jul 2019 19:18:48 +0000 (13:18 -0600)]
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>
4 years agobinman: Fix up the _DoTestFile() function -u argument
Simon Glass [Mon, 8 Jul 2019 19:18:47 +0000 (13:18 -0600)]
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>
4 years agobinman: Support ELF files for TPL
Simon Glass [Mon, 8 Jul 2019 19:18:46 +0000 (13:18 -0600)]
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>
4 years agobinman: Correct comment in u_boot_spl_elf
Simon Glass [Mon, 8 Jul 2019 19:18:45 +0000 (13:18 -0600)]
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>
4 years agobinman: Use tools compression function for blob handling
Simon Glass [Mon, 8 Jul 2019 19:18:44 +0000 (13:18 -0600)]
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>
4 years agobinman: Drop unnecessary debug handling
Simon Glass [Mon, 8 Jul 2019 19:18:43 +0000 (13:18 -0600)]
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>
4 years agobinman: Use the tools.Decompress method
Simon Glass [Mon, 8 Jul 2019 19:18:42 +0000 (13:18 -0600)]
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>
4 years agopatman: Add functions to compress and decompress data
Simon Glass [Mon, 8 Jul 2019 19:18:41 +0000 (13:18 -0600)]
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>
4 years agobinman: Allow text directly in the node
Simon Glass [Mon, 8 Jul 2019 19:18:40 +0000 (13:18 -0600)]
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>
4 years agobinman: Update entry.SetOffsetSize to be optional
Simon Glass [Mon, 8 Jul 2019 19:18:39 +0000 (13:18 -0600)]
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>
4 years agobinman: Don't assume there is an ME region
Simon Glass [Mon, 8 Jul 2019 19:18:38 +0000 (13:18 -0600)]
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>
4 years agobinman: Assume Intel descriptor is at the start of the image
Simon Glass [Mon, 8 Jul 2019 19:18:37 +0000 (13:18 -0600)]
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>
4 years agobinman: Ensure that coverage has access to site packages
Simon Glass [Mon, 8 Jul 2019 19:18:36 +0000 (13:18 -0600)]
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>
4 years agobinman: Add a function to decode an ELF file
Simon Glass [Mon, 8 Jul 2019 19:18:35 +0000 (13:18 -0600)]
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>
4 years agobinman: Add a function to create a sample ELF file
Simon Glass [Mon, 8 Jul 2019 19:18:34 +0000 (13:18 -0600)]
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>
4 years agobinman: Detect skipped tests
Simon Glass [Mon, 8 Jul 2019 19:18:33 +0000 (13:18 -0600)]
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>
4 years agobinman: Use a better error for missing Intel descriptor
Simon Glass [Mon, 8 Jul 2019 19:18:32 +0000 (13:18 -0600)]
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>
4 years agobinman: Tidy up help for --indir
Simon Glass [Mon, 8 Jul 2019 19:18:31 +0000 (13:18 -0600)]
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>
4 years agobinman: Add missing comments toentry
Simon Glass [Mon, 8 Jul 2019 19:18:30 +0000 (13:18 -0600)]
binman: Add missing comments toentry

At present GetOffsets() lacks a function comment. Add one.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add missing comments to bsection
Simon Glass [Mon, 8 Jul 2019 19:18:29 +0000 (13:18 -0600)]
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>
4 years agobinman: Add a --toolpath option to set the tool search path
Simon Glass [Mon, 8 Jul 2019 19:18:28 +0000 (13:18 -0600)]
binman: Add a --toolpath option to set the tool search path

Sometimes tools used by binman may not be in the normal PATH search path,
such as when the tool is built by the U-Boot build itself (e.g. mkimage).
Provide a way to specify an additional search path for tools. The flag
can be used multiple times.

Update the help to describe this option.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agopatman: Add a way to set the search path for tools
Simon Glass [Mon, 8 Jul 2019 19:18:27 +0000 (13:18 -0600)]
patman: Add a way to set the search path for tools

Sometimes tools can be located by looking in other locations. Add a way to
direct the search.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Add coverage tools info for Python 3
Simon Glass [Mon, 8 Jul 2019 19:18:26 +0000 (13:18 -0600)]
binman: Add coverage tools info for Python 3

Test coverage with Python 3 requires a new package. Add details about
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Correct two typos in function names in ftest
Simon Glass [Mon, 8 Jul 2019 19:18:25 +0000 (13:18 -0600)]
binman: Correct two typos in function names in ftest

Two functions have incorrect names. Fix them.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agobinman: Fix comment in bsection.GetEntries()
Simon Glass [Mon, 8 Jul 2019 19:18:24 +0000 (13:18 -0600)]
binman: Fix comment in bsection.GetEntries()

This comment is out of date as it does not correctly describe the return
value. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agotools: Drop duplicate raise_on_error argument
Simon Glass [Mon, 8 Jul 2019 19:18:23 +0000 (13:18 -0600)]
tools: Drop duplicate raise_on_error argument

If kwargs contains raise_on_error then this function generates an error
due to a duplicate argument. Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agocbfs: Rename checksum to attributes_offset
Simon Glass [Mon, 8 Jul 2019 19:18:22 +0000 (13:18 -0600)]
cbfs: Rename checksum to attributes_offset

It seems that this field has been renamed in later version of coreboot.
Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agocbfs: Add an enum and comment for the magic number
Simon Glass [Mon, 8 Jul 2019 19:18:21 +0000 (13:18 -0600)]
cbfs: Add an enum and comment for the magic number

This field is not commented in the original file. Add a comment.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agox86: Add ifwitool for Intel Integrated Firmware Image
Simon Glass [Mon, 8 Jul 2019 19:18:20 +0000 (13:18 -0600)]
x86: Add ifwitool for Intel Integrated Firmware Image

Some Intel SoCs from about 2016 boot using an internal microcontroller via
an 'IFWI' image. This is a special format which can hold firmware images.
In U-Boot's case it holds u-boot-tpl.bin.

Add this tool, taken from coreboot, so that we can build bootable images
on apollolake SoCs.

This tool itself has no tests. Some amount of coverage will be provided by
the binman tests that use it, so enable building the tool on sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
4 years agoMerge tag 'u-boot-stm32-20190723' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm
Tom Rini [Tue, 23 Jul 2019 18:16:21 +0000 (14:16 -0400)]
Merge tag 'u-boot-stm32-20190723' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm

- add rtc driver for stm32mp1
- add remoteproc driver for stm32mp1
- use kernel qspi compatible string for stm32

4 years agoMerge tag 'rockchip-for-v2019.07-2' of https://gitlab.denx.de/u-boot/custodians/u...
Tom Rini [Tue, 23 Jul 2019 13:48:16 +0000 (09:48 -0400)]
Merge tag 'rockchip-for-v2019.07-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip

- rk3399 sdhci driver fixup
- TPL BANNER fixup

4 years agorockchip: TPL banner should depend on CONFIG_TPL_BANNER_PRINT
Chris Webb [Fri, 19 Jul 2019 13:23:55 +0000 (14:23 +0100)]
rockchip: TPL banner should depend on CONFIG_TPL_BANNER_PRINT

The generic code in common/spl/spl.c allows TPL/SPL banners to be
silenced by unsetting CONFIG_TPL_BANNER_PRINT or CONFIG_SPL_BANNER_PRINT
respectively. However, arch/arm/mach-rockchip/tpl.c prints this banner
unconditionally.

Fix the rockchip-specific tpl.c so that the TPL banner depends on
CONFIG_TPL_BANNER_PRINT in the same way as the generic code.

Signed-off-by: <chris@arachsys.com>
Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>
4 years agorockchip: Fix TPL build without CONFIG_TPL_SERIAL_SUPPORT
Chris Webb [Fri, 19 Jul 2019 13:23:11 +0000 (14:23 +0100)]
rockchip: Fix TPL build without CONFIG_TPL_SERIAL_SUPPORT

If CONFIG_DEBUG_UART is set but CONFIG_TPL_SERIAL_SUPPORT is not, the
serial output should be available in SPL and full U-Boot, but not built
in TPL. However, the rockchip tpl.c instead fails to compile with
undefined references to the debug UART.

Instead, initialise the debug UART and print the TPL banner only if both
CONFIG_DEBUG_UART and CONFIG_TPL_SERIAL_SUPPORT are set.

Signed-off-by: <chris@arachsys.com>
Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>
4 years agortc: Add rtc driver for stm32mp1
Patrick Delaunay [Mon, 22 Jul 2019 09:02:34 +0000 (11:02 +0200)]
rtc: Add rtc driver for stm32mp1

Add support of STM32MP1 rtc driver.
Enable it for basic and trusted configurations.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
4 years agoclk: stm32mp1: Add RTC clock entry
Patrick Delaunay [Thu, 11 Jul 2019 10:03:37 +0000 (12:03 +0200)]
clk: stm32mp1: Add RTC clock entry

Add RTCAPB and RTC clock support.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
4 years agodoc: device-tree-bindings: alignment with v5.2-rc6 for spi-stm32-qspi.txt
Patrice Chotard [Fri, 28 Jun 2019 13:03:01 +0000 (15:03 +0200)]
doc: device-tree-bindings: alignment with v5.2-rc6 for spi-stm32-qspi.txt

Align doc/device-tree-bindings/spi/spi-stm32-qspi.txt with kernel v5.2-rc6

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
4 years agospi: stm32_qspi: Remove "st, stm32-qspi" compatible string
Patrice Chotard [Fri, 28 Jun 2019 13:03:00 +0000 (15:03 +0200)]
spi: stm32_qspi: Remove "st, stm32-qspi" compatible string

"st,stm32-qspi" is no more used, remove it.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoARM: dts: stm32: Use kernel qspi compatible string for stm32f469-disco-uboot.dtsi
Patrice Chotard [Fri, 28 Jun 2019 13:02:59 +0000 (15:02 +0200)]
ARM: dts: stm32: Use kernel qspi compatible string for stm32f469-disco-uboot.dtsi

For STM32 QSPI driver, "st,stm32-qspi" compatible string was first
introduced in U-boot. But later in kernel side, "st,stm32f469-qspi"
was used.
To simplify, align U-boot QSPI compatible string with kernel one.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoARM: dts: stm32: Use kernel qspi compatible string for stm32f7-uboot.dtsi
Patrice Chotard [Fri, 28 Jun 2019 13:02:58 +0000 (15:02 +0200)]
ARM: dts: stm32: Use kernel qspi compatible string for stm32f7-uboot.dtsi

For STM32 QSPI driver, "st,stm32-qspi" compatible string was first
introduced in U-boot. But later in kernel side, "st,stm32f469-qspi"
was used.
To simplify, align U-boot QSPI compatible string with kernel one.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
4 years agoconfigs: stm32mp15: enable stm32 remoteproc
Patrick Delaunay [Mon, 22 Jul 2019 09:04:31 +0000 (11:04 +0200)]
configs: stm32mp15: enable stm32 remoteproc

Activate the remote processor support for stm32mp15 configs.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
4 years agoMAINTAINERS: Add stm32 remoteproc driver
Fabien Dessenne [Fri, 31 May 2019 13:11:35 +0000 (15:11 +0200)]
MAINTAINERS: Add stm32 remoteproc driver

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
4 years agoremoteproc: Introduce STM32 Cortex-M4 remoteproc driver
Fabien Dessenne [Fri, 31 May 2019 13:11:34 +0000 (15:11 +0200)]
remoteproc: Introduce STM32 Cortex-M4 remoteproc driver

This patch introduces support of Cortex-M4 remote processor for STM32
MCU and MPU families.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
4 years agoremoteproc: add elf file load support
Fabien Dessenne [Fri, 31 May 2019 13:11:33 +0000 (15:11 +0200)]
remoteproc: add elf file load support

The current implementation supports only binary file load.
Add helpers to support ELF32 format (sanity check, and load).
Note that since an ELF32 image is built for the remote processor, the
load function uses the device_to_virt ops to translate the addresses.
Implement a basic translation for sandbox_testproc.

Add related tests. Test result:
=> ut dm remoteproc_elf
Test: dm_test_remoteproc_elf: remoteproc.c
Test: dm_test_remoteproc_elf: remoteproc.c (flat tree)
Failures: 0

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agoremoteproc: add device_to_virt ops
Fabien Dessenne [Fri, 31 May 2019 13:11:32 +0000 (15:11 +0200)]
remoteproc: add device_to_virt ops

Introduce the device_to_virt function to allow translation between
device address (remote processor view) and virtual address (main
processor view).

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agoremoteproc: fix function headers
Fabien Dessenne [Fri, 31 May 2019 13:11:31 +0000 (15:11 +0200)]
remoteproc: fix function headers

Add full function comment headers.
Fix rproc_is_initialized() return value description.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>
4 years agodm: core: Introduce xxx_translate_dma_address()
Fabien Dessenne [Fri, 31 May 2019 13:11:30 +0000 (15:11 +0200)]
dm: core: Introduce xxx_translate_dma_address()

Add the following functions to translate DMA address to CPU address:
- dev_translate_dma_address()
- ofnode_translate_dma_address()
- of_translate_dma_address()
- fdt_translate_dma_address()
These functions work the same way as xxx_translate_address(), with the
difference that the translation relies on the "dma-ranges" property
instead of the "ranges" property.

Add related test. Test report:
=> ut dm fdt_translation
Test: dm_test_fdt_translation: test-fdt.c
Test: dm_test_fdt_translation: test-fdt.c (flat tree)
Failures: 0

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
4 years agoMerge tag 'rockchip-for-v2019.07' of https://gitlab.denx.de/u-boot/custodians/u-boot...
Tom Rini [Sun, 21 Jul 2019 19:40:21 +0000 (15:40 -0400)]
Merge tag 'rockchip-for-v2019.07' of https://gitlab.denx.de/u-boot/custodians/u-boot-rockchip

- rk3399 lpddr4 support
- rk3399-rock960 board support improvement
- Eliminate pyelftools dependency by make_fit_atf.py
- clean up rockchip dts to use -u-boot.dtsi
- use ARM arch/generic timer instead of rk_timer
- clean up Kconfig options for board support

4 years agorockchip: sdhci: Fix sdhci mmc driver probe abort
Kever Yang [Fri, 19 Jul 2019 10:01:11 +0000 (18:01 +0800)]
rockchip: sdhci: Fix sdhci mmc driver probe abort

This patch fix mmc driver abort caused by below patch:
3d296365e4 mmc: sdhci: Add support for sdhci-caps-mask

After the patch sdhci_setup_cfg() access to host->mmc->dev,
so we have to do init before make the call to the function()

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
4 years agorockchip: Remove obsolete references to pyelftools
Chris Webb [Tue, 16 Jul 2019 19:53:26 +0000 (20:53 +0100)]
rockchip: Remove obsolete references to pyelftools

make_fit_atf.py no longer requires pyelftools, and nothing else in the
rockchip build requires it either, so remove references to installing it
from the documentation.

Signed-off-by: Chris Webb <chris@arachsys.com>
Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>
4 years agorockchip: make_fit_atf.py: Eliminate pyelftools dependency
Chris Webb [Tue, 16 Jul 2019 19:52:57 +0000 (20:52 +0100)]
rockchip: make_fit_atf.py: Eliminate pyelftools dependency

make_fit_aft.py depends on the non-standard library pyelftools to pull
out PT_LOAD segments from ELF files. However, this is as easy to do
manually, without imposing the extra dependency on users.

Structures in the ELF file are unpacked into variables named to exactly
match the ELF spec to ensure the destructuring code is reasonably
self-documenting.

Signed-off-by: Chris Webb <chris@arachsys.com>
Reviewed-by: Andy Yan <andy.yan@rock-chips.com>
Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>
4 years agorockchip: enable rk322x TPL_BOOTROM_SUPPORT in Kconfig
Kever Yang [Tue, 16 Jul 2019 12:40:17 +0000 (20:40 +0800)]
rockchip: enable rk322x TPL_BOOTROM_SUPPORT in Kconfig

The TPL_BOOTROM_SUPPORT is needed for boot from bootrom like
other storages.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
4 years agorockchip: video: rk3288_hdmi: Add missing call to dw_hdmi_enable()
Niklas Schulze [Sun, 14 Jul 2019 10:40:13 +0000 (10:40 +0000)]
rockchip: video: rk3288_hdmi: Add missing call to dw_hdmi_enable()

The RK3288 HDMI driver's rk3288_hdmi_enable() currently lacks a call to
dw_hdmi_enable(). Thus, the HDMI output never gets enabled.

Signed-off-by: Niklas Schulze <me@jns.io>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
4 years agorockchip: rk3399: use common TPL board file
Kever Yang [Tue, 9 Jul 2019 14:06:01 +0000 (22:06 +0800)]
rockchip: rk3399: use common TPL board file

Use common tpl.c instead of rk3399-board-tpl.c

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
4 years agorockchip: rk3399: remove TPL_BOARD_INIT
Kever Yang [Tue, 9 Jul 2019 14:06:00 +0000 (22:06 +0800)]
rockchip: rk3399: remove TPL_BOARD_INIT

RK3399 TPL do not need a dedicate board init, print the firmware
info when debug init instead.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
4 years agorockchip: rk3399: use common secure_timer_init() for spl/tpl
Kever Yang [Tue, 9 Jul 2019 14:05:59 +0000 (22:05 +0800)]
rockchip: rk3399: use common secure_timer_init() for spl/tpl

SPL/TPL share the same secure_timer_init(), update to use
one copy source code and update to use CONFIG_ROCKCHIP_STIMER_BASE
as base address and rename to function name to rockchip_stimer_init().

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>