aboutsummaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)AuthorFilesLines
2019-07-18tools: mkenvimage: Always consider non-regular filesAndre Przywara1-49/+21
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 Przywara1-2/+1
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äinen1-1/+1
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 Schuchardt1-2/+2
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 Glass1-0/+150
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 Glass1-6/+9
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 Glass1-0/+15
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 Glass1-0/+14
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 Glass1-1/+1
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 Glass1-1/+1
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 Glass1-3/+6
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 Glass2-4/+11
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 Glass1-1/+5
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 Glass6-72/+77
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 Glass1-2/+5
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 Glass1-2/+2
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 Glass1-1/+2
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 Glass2-16/+2
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 Glass1-1/+5
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 Glass1-2/+9
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 Glass1-3/+3
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 Glass1-2/+5
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 Glass1-4/+4
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 Glass3-14/+43
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 Glass2-16/+52
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 Glass1-51/+53
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 Glass2-3/+5
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 Glass2-7/+8
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 Glass4-9/+15
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 Glass1-1/+1
Update the shebang to allow either Python 2 or Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Tidy up a few more unicode conversionsSimon Glass2-6/+3
Use the new functions in the tools module to handle conversion. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Adjust functional tests for Python 3Simon Glass1-11/+14
Change the code so that it works on both Python 2 and Python 3. This works by using unicode instead of latin1 for the test input, and ensuring that the output is converted to a string rather than a unicode object on Python 2. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Avoid unicode type in settings unit testsSimon Glass1-8/+8
The unicode type does not exist in Python 3 and when displaying strings they do not have the 'u' prefix. Adjusts the settings unit tests to deal with this difference, by converting the comparison value to a string, thus dropping the 'u'. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Sort series output for repeatabilySimon Glass2-12/+12
We use sets to produce the list of To and Cc lines for a series. This does not result in stable ordering of the recipients. Sort each list to ensure that the output is repeatable. This is necessary for tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Move unicode helpers to toolsSimon Glass4-16/+39
Create helper functions in the tools module to deal with the differences between unicode in Python 2 (where we use the 'unicode' type) and Python 3 (where we use the 'str' type). Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Support use of stringIO in Python 3Simon Glass1-1/+6
With Python 3 this class has moved. Update the code to handle both cases. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Handle repeated bytes for Python 3Simon Glass6-25/+50
The method of multiplying a character by a number works well for creating a repeated string in Python 2. But in Python 3 we need to use bytes() instead, to avoid unicode problems, since 'bytes' is no-longer just an alias of 'str'. Create a function to handle this detail and call it from the relevant places in binman. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Drop an unused input fileSimon Glass1-1/+0
Drop this line which is not used or needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Use binary mode when compressing dataSimon Glass2-2/+2
The lz4 utility inserts binary data in its output which cannot always be converted to unicode (nor should it be). Fix this by using the new binary mode for program output. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Provide a way to get program output in binary modeSimon Glass2-3/+4
At present cros_subprocess and the tools library use a string to obtain stdout from a program. This works fine on Python 2. With Python 3 we end up with unicode errors in some cases. Fix this by providing a binary mode, which returns the data as bytes() instead of a string. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10tools: dtoc: Open all binary files in binary modeSimon Glass1-1/+1
Fix an open() statement to use binary mode, so that it works as expected with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10tools: binman: Open all binary files in binary modeSimon Glass1-15/+15
At present some files are opened in text mode despite containing binary data. This works on Python 2 but not always on Python 3, due to unicode problems. BC&D are not my favourite people. Adjust the affected open() statements to use binary mode. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Use items() instead of iteritems()Simon Glass5-6/+6
Python 3 requires this, and Python 2 allows it. Convert the code over to ensure compatibility with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Use items() instead of iteritems()Simon Glass1-1/+1
Python 3 requires this, and Python 2 allows it. Convert the code over to ensure compatibility with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Remove use of Set()Simon Glass3-9/+6
A new built-in set() is used in both Python 2 and 3 now. Move it to use that instead of Set(). Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Don't show errors for failed testsSimon Glass1-0/+12
An unfortunate new feature in Python 3.5 causes binman to print errors for non-existent tests, when the test filter is used. Work around this by detecting the unwanted tests and removing them from the result. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Convert print statements to Python 3Simon Glass2-8/+12
Update all print statements to be functions, as required by Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Convert print statements to Python 3Simon Glass3-15/+14
Update all print statements to be functions, as required by Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10patman: Update cros_subprocess to use bytesSimon Glass2-20/+29
At present this function uses lists and strings. This does not work so well with Python 3, and testing against '' does not work for a bytearray. Update the code to fix these issues. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-09moveconfig: expand simple expressionsMarkus Klotzbuecher1-0/+41
Add support for expanding simple expressions and sizes such as "(4 * 1024)", "(512 << 10)" or "(SZ_256K)". This can help to significantly reduce the number of "suspicious" moves, such as 'CONFIG_ENV_SIZE="(64 << 10)"' was removed by savedefconfig. If the expansion fails, it falls back to the original string. Signed-off-by: Markus Klotzbuecher <markus.klotzbuecher@kistler.com> Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Heiko Schocher <hs@denx.de>