summaryrefslogtreecommitdiff
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* binman: Allow device-tree entries to be compressedSimon Glass2019-07-244-12/+53
| | | | | | | 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>
* binman: Allow entries to expand after packingSimon Glass2019-07-2412-25/+184
| | | | | | | | | | 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>
* binman: Add a control for post-pack entry expansionSimon Glass2019-07-241-0/+24
| | | | | | | | | 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>
* binman: Add a return value to ProcessContentsUpdate()Simon Glass2019-07-2410-15/+44
| | | | | | | | | | | | | | | | | | | | | | 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>
* binman: Call ProcessUpdateContents() consistentlySimon Glass2019-07-244-4/+4
| | | | | | | | | | 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>
* binman: Fix up ProcessUpdateContents error and commentsSimon Glass2019-07-242-5/+5
| | | | | | | | 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>
* binman: Allow easy importing of entry modulesSimon Glass2019-07-243-0/+3
| | | | | | | | | | | 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>
* binman: Drop an unused arg in Entry.Lookup()Simon Glass2019-07-241-4/+3
| | | | | | The first argument is not used. Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Move compression into the Entry base classSimon Glass2019-07-243-18/+21
| | | | | | | | | | | | 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>
* binman: Convert to use ArgumentParserSimon Glass2019-07-246-131/+128
| | | | | | | | 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>
* binman: Add an image headerSimon Glass2019-07-2410-3/+242
| | | | | | | | | | | | | 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>
* binman: Add an FDT mapSimon Glass2019-07-246-8/+211
| | | | | | | | | 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>
* binman: Add a convenience functions for real-DTB testsSimon Glass2019-07-241-2/+12
| | | | | | | 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>
* binman: Update help for new featuresSimon Glass2019-07-241-4/+3
| | | | | | | 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>
* binman: Update future featuresSimon Glass2019-07-241-4/+8
| | | | | | A few features have been completed and a few items are added. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Simplify the entry testSimon Glass2019-07-241-16/+16
| | | | | | | | | | | | | | | | | | 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>
* binman: Add support for fixed-offset files in CBFSSimon Glass2019-07-246-34/+276
| | | | | | | | | | 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>
* binman: Pad empty areas of the CBFS with filesSimon Glass2019-07-242-4/+87
| | | | | | | | | | 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>
* binman: Add support for Intel IFWI entriesSimon Glass2019-07-248-2/+245
| | | | | | | 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>
* binman: Add support for CBFS entriesSimon Glass2019-07-2413-0/+620
| | | | | | | 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>
* binman: Add a utility library for coreboot CBFSSimon Glass2019-07-243-1/+1263
| | | | | | | | | | | | | | 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>
* patman: Add a function to write ifwitoolSimon Glass2019-07-241-0/+33
| | | | | | | | 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>
* binman: Pass the toolpath to testsSimon Glass2019-07-242-4/+16
| | | | | | | | | | 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>
* binman: Allow preserving test directoriesSimon Glass2019-07-234-6/+50
| | | | | | | | | 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>
* binman: Allow verbosity control when running testsSimon Glass2019-07-232-3/+22
| | | | | | | | | | 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>
* binman: Fix up the _DoTestFile() function -u argumentSimon Glass2019-07-231-1/+1
| | | | | | | 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>
* binman: Support ELF files for TPLSimon Glass2019-07-234-0/+39
| | | | | | | | 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>
* binman: Correct comment in u_boot_spl_elfSimon Glass2019-07-232-2/+2
| | | | | | This comment mentions the wrong default filename. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Use tools compression function for blob handlingSimon Glass2019-07-231-12/+4
| | | | | | | Avoid duplicate code here by using the new compression function in the tools module. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Drop unnecessary debug handlingSimon Glass2019-07-231-5/+0
| | | | | | | | 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>
* binman: Use the tools.Decompress methodSimon Glass2019-07-231-11/+2
| | | | | | | Update the compression test to use the tools module to decompress the output data. Signed-off-by: Simon Glass <sjg@chromium.org>
* patman: Add functions to compress and decompress dataSimon Glass2019-07-232-1/+68
| | | | | | | | | | | 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>
* binman: Allow text directly in the nodeSimon Glass2019-07-234-5/+34
| | | | | | | | | | 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>
* binman: Update entry.SetOffsetSize to be optionalSimon Glass2019-07-232-7/+16
| | | | | | | | | 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>
* binman: Don't assume there is an ME regionSimon Glass2019-07-234-3/+20
| | | | | | | | | | | | | 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>
* binman: Assume Intel descriptor is at the start of the imageSimon Glass2019-07-232-0/+10
| | | | | | | | | 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>
* binman: Ensure that coverage has access to site packagesSimon Glass2019-07-231-0/+8
| | | | | | | | 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>
* binman: Add a function to decode an ELF fileSimon Glass2019-07-233-0/+102
| | | | | | | 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>
* binman: Add a function to create a sample ELF fileSimon Glass2019-07-232-0/+117
| | | | | | | | 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>
* binman: Detect skipped testsSimon Glass2019-07-231-2/+7
| | | | | | | | 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>
* binman: Use a better error for missing Intel descriptorSimon Glass2019-07-232-3/+3
| | | | | | | 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>
* binman: Tidy up help for --indirSimon Glass2019-07-231-1/+1
| | | | | | | The current help is confusing. Adjust it to indicate what the flag actually does. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add missing comments toentrySimon Glass2019-07-231-0/+15
| | | | | | At present GetOffsets() lacks a function comment. Add one. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add missing comments to bsectionSimon Glass2019-07-231-0/+23
| | | | | | | Some functions lack comments in this file. Add comments to cover this functionality. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add a --toolpath option to set the tool search pathSimon Glass2019-07-233-0/+13
| | | | | | | | | | | 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>
* patman: Add a way to set the search path for toolsSimon Glass2019-07-231-5/+37
| | | | | | | 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>
* binman: Add coverage tools info for Python 3Simon Glass2019-07-231-1/+1
| | | | | | | Test coverage with Python 3 requires a new package. Add details about this. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Correct two typos in function names in ftestSimon Glass2019-07-231-2/+2
| | | | | | Two functions have incorrect names. Fix them. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Fix comment in bsection.GetEntries()Simon Glass2019-07-231-2/+2
| | | | | | | 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>
* tools: Drop duplicate raise_on_error argumentSimon Glass2019-07-231-2/+2
| | | | | | | 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>