summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2019-07-23patman: Add functions to compress and decompress dataSimon Glass
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-23binman: Allow text directly in the nodeSimon Glass
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-23binman: Update entry.SetOffsetSize to be optionalSimon Glass
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-23binman: Don't assume there is an ME regionSimon Glass
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-23binman: Assume Intel descriptor is at the start of the imageSimon Glass
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-23binman: Ensure that coverage has access to site packagesSimon Glass
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-23binman: Add a function to decode an ELF fileSimon Glass
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-23binman: Add a function to create a sample ELF fileSimon Glass
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-23binman: Detect skipped testsSimon Glass
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-23binman: Use a better error for missing Intel descriptorSimon Glass
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-23binman: Tidy up help for --indirSimon Glass
The current help is confusing. Adjust it to indicate what the flag actually does. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23binman: Add missing comments toentrySimon Glass
At present GetOffsets() lacks a function comment. Add one. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23binman: Add missing comments to bsectionSimon Glass
Some functions lack comments in this file. Add comments to cover this functionality. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23binman: Add a --toolpath option to set the tool search pathSimon Glass
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>
2019-07-23patman: Add a way to set the search path for toolsSimon Glass
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>
2019-07-23binman: Add coverage tools info for Python 3Simon Glass
Test coverage with Python 3 requires a new package. Add details about this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23binman: Correct two typos in function names in ftestSimon Glass
Two functions have incorrect names. Fix them. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-23binman: Fix comment in bsection.GetEntries()Simon Glass
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>
2019-07-23tools: Drop duplicate raise_on_error argumentSimon Glass
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>
2019-07-23x86: Add ifwitool for Intel Integrated Firmware ImageSimon Glass
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>
2019-07-18tools: mkenvimage: Always consider non-regular filesAndre Przywara
At the moment mkenvimage has two separate read paths: One to read from a potential pipe, while dynamically increasing the buffer size, and a second one using mmap(2), using the input file's size. This is problematic for two reasons: - The "pipe" path will be chosen if the input filename is missing or "-". Any named, but non-regular file will use the other path, which typically will cause mmap() to fail: $ mkenvimage -s 256 -o out <(echo "foo=bar") - There is no reason to have *two* ways of reading a file, since the "pipe way" will always work, even for regular files. Fix this (and simplify the code on the way) by always using the method of dynamically resizing the buffer. The existing distinction between the two cases will merely be used to use the open() syscall or not. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2019-07-18tools: mkenvimage: Fix reading from slow pipeAndre Przywara
It is perfectly fine for the read(2) syscall to return with less than the requested number of bytes read (short read, see the "RETURN VALUE" section of the man page). This typically happens with slow input (keyboard, network) or with complex pipes. So far mkenvimage expects the exact number of requested bytes to be read, assuming an end-of-file condition otherwise. This wrong behaviour can be easily shown with: $ (echo "foo=bar"; sleep 1; echo "bar=baz") | mkenvimage -s 256 -o out - The second line will be missing from the output. Correct this by checking for any positive, non-zero return value. This fixes a problem with a complex pipe in one of my scripts, where the environment consist of two parts. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Acked-by: Alexander Dahl <ada@thorsis.com>
2019-07-18lib: rsa: add support to other openssl engine types than pkcs11Vesa Jääskeläinen
There are multiple other openssl engines used by HSMs that can be used to sign FIT images instead of forcing users to use pkcs11 type of service. Relax engine selection so that other openssl engines can be specified and use generic key id definition formula. Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com> Cc: Tom Rini <trini@konsulko.com>
2019-07-10trace: do not limit trace buffer to 2GiBHeinrich Schuchardt
There is no good reason to limit the trace buffer to 2GiB on a 64bit system. Adjust the types of the relevant parameters. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-07-10Add a simple script to remove boardsSimon Glass
This script attempts to create a git commit which removes a single board. It is quite fallible and everything it does needs checking. But it can help speed up the process. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Chris Packham <judge.packham@gmail.com>
2019-07-10patman: Update cover-coverage tests for Python 3Simon Glass
We need slightly different commands to run code coverage with Python 3. Update the RunTestCoverage() function to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Update the README.entries fileSimon Glass
A few minor changes have been made including one new entry. Update the documentation with: $ binman -E >tools/binman/README.entries Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Document parallel testsSimon Glass
Since binman can run tests in parallel, document this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Read map files as textSimon Glass
These files are text files so should be read as such, so that string-equality assertions work as expected. With this binman tests work correctly on Python 2 and Python 3: PYTHONPATH=/tmp/b/sandbox_spl/scripts/dtc/pylibfdt \ python ./tools/binman/binman -t Change first line of binman.py to end "python3": PYTHONPATH=~/cosarm/dtc/pylibfdt:tools/patman \ python3 ./tools/binman/binman -t Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Fix up a format string in AssertInList()Simon Glass
Add the missing 's' to the required '%s' here. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Update 'text' entry for Python 3Simon Glass
This code reads a binary value and then uses it as a string to look up another value. Add conversions to make this work as expected on Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Update fmap code for Python 3Simon Glass
This needs special care to ensure that the bytes type is used for binary data. Add conversion code to deal with strings and bytes correctly. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Update entry_test to support Python 3Simon Glass
The reload() function is in a different place in Python 3. Update the code to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Convert to use bytes typeSimon Glass
With Python 3 we want to use the 'bytes' type instead of 'str'. Adjust the code accordingly so that it works on both Python 2 and Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Avoid changing a dict during iterationSimon Glass
This code works OK in Python 2 but Python 3 complains. Adjust it to avoid deleting elements from a dict while iterating through it. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Allow reading files in text modeSimon Glass
While reading files in binary mode is the norm, sometimes we want to use text mode. Add an optional parameter to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Update dtb_platdata to support Python 3Simon Glass
The only change needed is to update get_value() to support the 'bytes' type correctly with Python 3. With this the dtoc unit tests pass with both Python 2 and 3: PYTHONPATH=/tmp/b/sandbox_spl/scripts/dtc/pylibfdt python \ ./tools/dtoc/dtoc -t PYTHONPATH=~/cosarm/dtc/pylibfdt:tools/patman python3 \ ./tools/dtoc/dtoc -t Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Update fdt_util for Python 3Simon Glass
Since we are now using the bytes type in Python 3, the conversion in fdt32_to_cpu() is not necessary, so drop it. Also use 'int' instead of 'long' to convert the integer value, since 'long' is not present in Python 3. With this, test_fdt passes with both Python 2 and 3: PYTHONPATH=/tmp/b/sandbox_spl/scripts/dtc/pylibfdt python \ ./tools/dtoc/test_fdt -t PYTHONPATH=~/cosarm/dtc/pylibfdt:tools/patman python3 \ ./tools/dtoc/test_fdt -t Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Add a unit test for BytesToValue()Simon Glass
Add a simple unit test for one of the cases of this function, so that any fault can be seen directly, rather than appearing through the failure of another test. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Test full 64-bit properties with FdtCellsToCpu()Simon Glass
At present this test does not check the upper 32 bits of the returned value. Add some additional tests to cover this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Use binary mode for reading filesSimon Glass
The .dtb files are binary so we should open them as binary files. This allows Python 3 to use the correct 'bytes' type. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Convert the Fdt.Node class to Python 3Simon Glass
Update this class to work correctly on Python 3 and to pass its unit tests. The only required change is to deal with a difference in the behaviour of sorting with a None value. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Convert the Fdt.Prop class to Python 3Simon Glass
Update this class to work correctly on Python 3 and to pass its unit tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Use byte type instead of str in fdtSimon Glass
In Python 3 bytes and str are separate types. Use bytes to ensure that the code functions correctly with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Updates BytesToValue() for Python 3Simon Glass
The difference between the bytes and str types in Python 3 requires a number of minor changes to this function. Update it to handle the input data using the 'bytes' type. Create two useful helper functions which can be used by other modules too. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Move BytesToValue() out of the Prop classSimon Glass
This method does not actually use any members of the Prop class. Move it out of the class so that it is easier to add unit tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Use GetBytes() to obtain repeating bytesSimon Glass
Use this helper function which works on both Python 2 and Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Sort platdata output from dtocSimon Glass
At present the order of struct field emitted by this tool depends on the internal workings of a Python dictionary. Sort the fields to remove this uncertainty, so that tests are deterministic. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10dtoc: Adjust code for Python 3Simon Glass
Update a few things in this tool so that they support Python 3: - print statements - iteritems() - xrange() Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Don't require Python 2Simon Glass
Update the shebang to allow either Python 2 or Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>