summaryrefslogtreecommitdiff
path: root/tools/dtoc
AgeCommit message (Collapse)Author
2020-04-26patman: Tidy up sys.path changesSimon Glass
Now that we are using absolute paths we can remove some of the sys.path mangling that appears in the tools. We only need to add the path to 'tools/' so that everything can find modules relative to that directory. The special paths for finding pylibfdt remain. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Move to absolute importsSimon Glass
At present patman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary. Move patman to use absolute imports. This requires changes in tools which use the patman libraries (which is most of them). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26dtoc: Rename the main moduleSimon Glass
Python does not like the module name being the same as the module directory. To allow dtoc modules to be used from other tools, rename it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Drop references to __future__Simon Glass
We don't need these now that the tools using Python 3. Drop them. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-17doc: fix references to driver-modelHeinrich Schuchardt
Fix some errors pointed out by 'make refcheckdocs'. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-11-04dtoc: Convert fdt.py to Python 3Simon Glass
Drop the now-unused Python 2 code to keep code coverage at 100%. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-04test_dtoc: Move to use Python 3Simon Glass
Update this test to use Python 3 to meet the 2020 deadline. Also make it executable while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-04test_fdt: Move to use Python 3Simon Glass
Update this test to use Python 3 to meet the 2020 deadline. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Update state when replacing device-tree entriesSimon Glass
Since the state module holds references to all the device trees used by binman, it must be updated when the device trees are updated. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Tidy up _SetupDtb() to use its own temporary fileSimon Glass
At present EnsureCompiled() uses an file from the 'output' directory (in the tools module) when compiling the device tree. This is fine in most cases, allowing useful inspection of the output files from binman. However in functional tests, _SetupDtb() creates an output directory and immediately removes it afterwards. This serves no benefit and just confuses things, since the 'official' output directory is supposed to be created and destroyed in control.Binman(). Add a new parameter for the optional temporary directory to use, and use a separate temporary directory in _SetupDtb(). Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29dtoc: Update Fdt.GetNode() to handle the root nodeSimon Glass
This function currently fails if the root node is requested. Requesting the root node is sometimes useful, so fix the bug. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29dtoc: Update Fdt.FromData() to allow a nameSimon Glass
It is confusing when something goes wrong with a device tree which was created from data rather than a file, since there is no identifying filename. Add an option to provide this. Use the filename as the name, where available Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Show a helpful error when a DT property is missingSimon Glass
At present a Python exception is raised which does not show the node information. Add a more helpful exception in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29dtoc: Return a non-zero exit code when tests failSimon Glass
At present 'dtoc -t' return a success code even if some of the tests fail. Fix this by checking the test result and setting the exit code. This allows 'make qcheck' to function as expected. 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-10tools: dtoc: Open all binary files in binary modeSimon Glass
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-04-26dtb_platdata.py: prevent define generation of aliasHeiko Schocher
generate define for an alias only if the struct is not created already. This prevents compilerwarning: PLAT spl/dts/dt-platdata.o spl/dts/dt-platdata.c:11:46: error: missing braces around initializer [-Werror=missing-braces] static const struct dtd_simple_bus dtv_ahb = { ^ spl/dts/dt-platdata.c:20:46: error: missing braces around initializer [-Werror=missing-braces] static const struct dtd_simple_bus dtv_apb = { ^ cc1: all warnings being treated as errors on the at91 based taurus board. Reason is in at91sam9260.dtsi is defined: ahb { compatible = "simple-bus"; ranges; and later: pinctrl: pinctrl@fffff400 { compatible = "atmel,at91rm9200-pinctrl", "simple-bus"; ranges = <0xfffff400 0xfffff400 0x600>; without this patch dtoc generates: struct dtd_atmel_at91rm9200_pinctrl { fdt32_t atmel_mux_mask[6]; fdt32_t ranges[3]; fdt32_t reg[6]; }; struct dtd_simple_bus { bool ranges; }; "#define dtd_simple_bus dtd_atmel_at91rm9200_pinctrl" and the line with "define dtd_simple_bus..." introduces the warning. This define is not needed. Signed-off-by: Heiko Schocher <hs@denx.de>
2019-01-26tests: dtoc: adapt tests to changed dtoc outputSimon Goldschmidt
The dtoc tests need to be adapted to dtoc being changed to output platdata structs as const, which has been introduced in commit 7d05d3a8e35f ("dtoc: make generated platdata structs const"). Fixes: 7d05d3a8e35f ("dtoc: make generated platdata structs const") Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
2019-01-15dtoc: make generated platdata structs constSimon Goldschmidt
The platdata initialization structs are currently generated into .rwdata. Make sure the are put into .rodata by generating them as const. Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-10-09dtoc: Fix the value of SetInt()Simon Glass
This does not set the correct value at present. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-08binman: Run tests concurrentlySimon Glass
At present the tests run one after the other using a single CPU. This is not very efficient. Bring in the concurrencytest module and run the tests concurrently, using one process for each CPU by default. A -P option allows this to be overridden, which is necessary for code-coverage to function correctly. This requires fixing a few tests which are currently not fully independent. At some point we might consider doing this across all pytests in U-Boot. There is a pytest version that supports specifying the number of processes to use, but it did not work for me. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-08buildman: dtoc: Suppress unwanted output from testSimon Glass
There are a few test cases which print output. Suppress this so that tests can run silently in the normal case. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-08binman: Fix up removal of temporary directoriesSimon Glass
At present 'make check' leaves some temporary directories around. Part of this is because we call tools.PrepareOutputDir() twice in some cases, without calling tools.FinaliseOutputDir() in between. Fix this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-08binman: Add a default path to libfdt.pySimon Glass
This module is often available in the sandbox_spl build created by 'make check'. Use this as a default path so that just typing 'binman -t' (without setting PYTHONPATH) will generally run the tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28dtoc: Add a way to create an Fdt object from a data blockSimon Glass
Support creating an Fdt object without having to write the data to a file first. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28dtoc: Add methods for adding and updating propertiesSimon Glass
Add a few more functions which allow creating and modifying property values. If only we could do this so easily in the real world. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28dtoc: Support adding new nodesSimon Glass
Add a way to add new nodes and sync them back to the blob. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28dtoc: Fixed endianness in Prop.GetEmpty()Simon Glass
This should be big endian, since that is what device tree uses. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28dtoc: Allow syncing of the device tree back to a fileSimon Glass
At present we require the caller to manually update the device tree using individual calls to libfdt functions. This is not ideal. It would be better if we could make changes using the Python structure and then call a Sync() function to write them back. Add this feature to the Fdt class. Update binman and the tests to match. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-08libfdt: Update to latest pylibfdt implementationSimon Glass
The enhanced pylibfdt support in U-Boot needed for binman was a placeholder while upstreaming of this work continued. This is now complete, so bring in the changes and update the tools as needed. There are quite a few changes since we decided to split the implementation into three fdt classes instead of two. The Fdt.del_node() method was unfortunately missed in this process and will be dealt with later. It exists in U-Boot but not upstream. Further syncing of libfdt probably needs to wait until we assess the code-size impact of all the new checking code on SPL and possibly provide a way to disable it. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01dtoc: Add a function to obtain a list of phandlesSimon Glass
Add a function which can decode a property containing a list of phandles. This is useful for finding nodes linked to a property. Also provide a way to look up a single phandle and get the Fdt object from a Node. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01dtoc: Export the _FindNode() functionSimon Glass
This is useful for clients that want to find a node. Export it so it can be used by others. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01binman: Add an entry filled with a repeating byteSimon Glass
It is sometimes useful to have an area of the image which is all zeroes, or all 0xff. This can often be achieved by padding the size of an an existing entry and setting the pad byte for an entry or image. But it is useful to have an explicit means of adding blocks of repeating data to the image. Add a 'fill' entry type to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01binman: Add support for passing arguments to entriesSimon Glass
Sometimes it is useful to pass binman the value of an entry property from the command line. For example some entries need access to files and it is not always convenient to put these filenames in the image definition (device tree). Add a -a option which can be used like this: -a<prop>=<value> where <prop> is the property to set <value> is the value to set it to Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01dtoc: Add missing comments to fdt_utilSimon Glass
This module has a few missing comments. Add them. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dtoc: Add functions to add integer propertiesSimon Glass
Add a few simple functions to add a placeholder integer property, and set its value. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dtoc: Avoid unwanted output during testsSimon Glass
At present some warnings are printed to indicate failures which are a known part of running the tests. Suppress these. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dtoc: Increase code coverage to 100%Simon Glass
Add more tests to increase dtoc code coverage to 100%. Correct a whitespace error in some test .dts files at the same time. Signed-off-by: Simon Glass <sjg@chromium.org>