aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc
AgeCommit message (Collapse)Author
2020-08-22dtoc: Add a setup script for PythonSimon Glass
Allow dtoc to be installed by adding a suitable setup.py script. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-28dtoc: remove compatible string aliases supportWalter Lozano
After latest improvements in dtoc, compatible strings are checked against driver and driver alias list to get a valid driver name. With this new feature the list of compatible string aliases seems not useful any more. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-28dtoc: look for compatible string aliases in driver listWalter Lozano
Currently dtoc checks if the first compatible string in a dtb node matches either a driver o driver alias name, without taking into account any other compatible string in the list. In the case that no driver matches the first compatible string a warning is printed and the U_BOOT_DEVICE is not being declared correctly. This patch adds dtoc's support for try all the compatible strings in the dtb node, in an effort to find the correct driver. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-28dtoc: add coverage test for unicode errorWalter Lozano
Add an additional test to dtoc in order improve the coverage, specifically to take into account the case of unicode error when scanning drivers. Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
2020-07-25dtoc: Allow adding variable-sized data to a dtbSimon Glass
Add a method for adding a property containing arbitrary bytes. Make sure that the tree can expand as needed in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-24Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini
This reverts commit 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7, reversing changes made to 56d37f1c564107e27d873181d838571b7d7860e7. Unfortunately this is causing CI failures: https://travis-ci.org/github/trini/u-boot/jobs/711313649 Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-20dtoc: Allow adding variable-sized data to a dtbSimon Glass
Add a method for adding a property containing arbitrary bytes. Make sure that the tree can expand as needed in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-17dtoc: Support ACPI paths in of-platdataSimon Glass
The start of an ACPI path typically has backslashes in it. These are not preserved during the translation from device tree to C code, since dtc (correctly) uses the first backslash as an escape character, and dtoc therefore leaves it out of the C string. Fix this with special-case handling. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-09dtoc: add test for cd-gpiosWalter Lozano
Add a test for dtoc taking into account the cd-gpios property. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-09dtoc: update dtb_platdata to support cd-gpiosWalter Lozano
Currently dtoc does not support the property cd-gpios used to declare the gpios for card detect in mmc. This patch adds support to cd-gpios property. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-09dtoc: extend dtoc to use struct driver_info when linking nodesWalter Lozano
In the current implementation, when dtoc parses a dtb to generate a struct platdata it converts the information related to linked nodes as pointers to struct platdata of destination nodes. By doing this, it makes difficult to get pointer to udevices created based on these information. This patch extends dtoc to use struct driver_info when populating information about linked nodes, which makes it easier to later get the devices created. In this context, reimplement functions like clk_get_by_index_platdata() which made use of the previous approach. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-09dtoc: add option to disable warningsWalter Lozano
As dtoc now performs checks for valid driver names, when running dtoc tests several warnings arise as these tests don't use valid driver names. This patch adds an option to disable those warning, which is only intended for running tests. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2020-07-09dtoc: add support to scan driversWalter Lozano
Currently dtoc scans dtbs to convert them to struct platdata and to generate U_BOOT_DEVICE entries. These entries need to be filled with the driver name, but at this moment the information used is the compatible name present in the dtb. This causes that only nodes with a compatible name that matches a driver name generate a working entry. In order to improve this behaviour, this patch adds to dtoc the capability of scan drivers source code to generate a list of valid driver names and aliases. This allows to generate U_BOOT_DEVICE entries using valid driver names and rise a warning in the case a name is not valid. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org> Open files in utf-8 mode: Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-09dtoc: add missing code commentsWalter Lozano
Add missing information about internal class members in order to make the code easier to follow. Signed-off-by: Walter Lozano <walter.lozano@collabora.com> Reviewed-by: Simon Glass <sjg@chromium.org>
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>