Commit Graph

1766 Commits

Author SHA1 Message Date
Heinrich Schuchardt
2b7a3882e0 trace: do not limit trace buffer to 2GiB
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-10 16:52:58 -06:00
Simon Glass
00ba3b1edc Add a simple script to remove boards
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-10 16:52:58 -06:00
Simon Glass
9550f9acd6 patman: Update cover-coverage tests for Python 3
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-10 16:52:58 -06:00
Simon Glass
5385f5a018 binman: Update the README.entries file
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-10 16:52:58 -06:00
Simon Glass
55660d08a0 binman: Document parallel tests
Since binman can run tests in parallel, document this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
eb546ac181 binman: Read map files as text
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-10 16:52:58 -06:00
Simon Glass
1fc62de19f binman: Fix up a format string in AssertInList()
Add the missing 's' to the required '%s' here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
e16b7b6c49 binman: Update 'text' entry for Python 3
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-10 16:52:58 -06:00
Simon Glass
f3a58c8a78 patman: Update fmap code for Python 3
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-10 16:52:58 -06:00
Simon Glass
0199d19349 binman: Update entry_test to support Python 3
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-10 16:52:58 -06:00
Simon Glass
c6c10e77fb binman: Convert to use bytes type
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-10 16:52:58 -06:00
Simon Glass
58632a7f44 binman: Avoid changing a dict during iteration
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-10 16:52:58 -06:00
Simon Glass
3c47e4105e patman: Allow reading files in text mode
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-10 16:52:58 -06:00
Simon Glass
9b044f7e3d dtoc: Update dtb_platdata to support Python 3
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-10 16:52:58 -06:00
Simon Glass
209a55976b dtoc: Update fdt_util for Python 3
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-10 16:52:58 -06:00
Simon Glass
b5f0dafd4b dtoc: Add a unit test for BytesToValue()
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-10 16:52:58 -06:00
Simon Glass
e66d318fef dtoc: Test full 64-bit properties with FdtCellsToCpu()
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-10 16:52:58 -06:00
Simon Glass
2ab6e13e01 dtoc: Use binary mode for reading files
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-10 16:52:58 -06:00
Simon Glass
635180538e dtoc: Convert the Fdt.Node class to Python 3
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-10 16:52:58 -06:00
Simon Glass
928527f686 dtoc: Convert the Fdt.Prop class to Python 3
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-10 16:52:58 -06:00
Simon Glass
f6b64815dd dtoc: Use byte type instead of str in fdt
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-10 16:52:58 -06:00
Simon Glass
2b6ed5e92e dtoc: Updates BytesToValue() for Python 3
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-10 16:52:58 -06:00
Simon Glass
7e6952df36 dtoc: Move BytesToValue() out of the Prop class
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-10 16:52:58 -06:00
Simon Glass
194b8d5e71 dtoc: Use GetBytes() to obtain repeating bytes
Use this helper function which works on both Python 2 and Python 3.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
1953ce7531 dtoc: Sort platdata output from dtoc
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-10 16:52:58 -06:00
Simon Glass
90a8132f4d dtoc: Adjust code for Python 3
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-10 16:52:58 -06:00
Simon Glass
b2e73125b2 patman: Don't require Python 2
Update the shebang to allow either Python 2 or Python 3.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
f6a6aafceb patman: Tidy up a few more unicode conversions
Use the new functions in the tools module to handle conversion.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
e6dca5e8f8 patman: Adjust functional tests for Python 3
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-10 16:52:58 -06:00
Simon Glass
7ebb45c7e2 patman: Avoid unicode type in settings unit tests
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-10 16:52:58 -06:00
Simon Glass
b644c66f69 patman: Sort series output for repeatabily
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-10 16:52:58 -06:00
Simon Glass
513eace47d patman: Move unicode helpers to tools
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-10 16:52:58 -06:00
Simon Glass
ade1e3864f patman: Support use of stringIO in Python 3
With Python 3 this class has moved. Update the code to handle both cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
e6d85ff9f2 binman: Handle repeated bytes for Python 3
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-10 16:52:58 -06:00
Simon Glass
6d1d641864 binman: Drop an unused input file
Drop this line which is not used or needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:58 -06:00
Simon Glass
b8f0876f1e binman: Use binary mode when compressing data
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-10 16:52:58 -06:00
Simon Glass
a92939a4aa patman: Provide a way to get program output in binary mode
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-10 16:52:57 -06:00
Simon Glass
3e4b51e8d6 tools: dtoc: Open all binary files in binary mode
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-10 16:52:45 -06:00
Simon Glass
1d0ebf7d63 tools: binman: Open all binary files in binary mode
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-10 16:52:45 -06:00
Simon Glass
5097915428 binman: Use items() instead of iteritems()
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-10 16:52:45 -06:00
Simon Glass
4a4c5dd43f patman: Use items() instead of iteritems()
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-10 16:52:45 -06:00
Simon Glass
d141f6c1ca binman: Remove use of Set()
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-10 16:52:45 -06:00
Simon Glass
35343dc414 binman: Don't show errors for failed tests
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-10 16:52:45 -06:00
Simon Glass
2ca8468026 binman: Convert print statements to Python 3
Update all print statements to be functions, as required by Python 3.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:45 -06:00
Simon Glass
5a1af1dafe patman: Convert print statements to Python 3
Update all print statements to be functions, as required by Python 3.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10 16:52:45 -06:00
Simon Glass
b1793a531e patman: Update cros_subprocess to use bytes
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-10 16:52:43 -06:00
Markus Klotzbuecher
b237d358b4 moveconfig: expand simple expressions
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>
2019-07-09 07:00:04 +02:00
Alex Kiernan
a762311a6c fw_env: Add missing write failure check
If flash_write fails, whilst we propagate this up to our caller, we need
to avoid swapping in the new file (if we're on a filesystem) in this
case.

Fixes: dbc3432379 ("tools: env: Implement atomic replace for filesystem")
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
2019-06-20 10:57:08 -04:00
Simon Goldschmidt
c78b5cb7d3 tools: add tools/spl_size_limit to ignore list
This tool has just been added but it seems I forgot to add it to
the ignore list. So to prevent the built binary being marked as
unversioned, add it to the ignore list.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-06-14 16:10:48 -04:00
Simon Goldschmidt
2577015dc5 spl: add overall SPL size check
This adds a size check for SPL that can dynamically check generated
SPL binaries (including devicetree) for a size limit that ensures
this image plus global data, heap and stack fit in initial SRAM.

Since some of these sizes are not available to make, a new host tool
'spl_size_limit' is added that dumps the resulting maximum size for
an SPL binary to stdout. This tool is used in toplevel Makefile to
implement the size check on SPL binaries.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-06-07 11:03:39 -04:00