summaryrefslogtreecommitdiff
path: root/tools/dtoc
AgeCommit message (Collapse)AuthorFilesLines
2023-01-19dtoc: Add a way to read a phandle with paramsSimon Glass4-0/+43
Add a function to read a phandle and associated name and offset. This is useful for binman. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13dtoc: Drop sys.exit() in test_fdtSimon Glass1-1/+0
This breaks using pytest to run the tests. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Correct remaining pylint problems in test_fdtSimon Glass1-113/+141
Fix various camel-case and other naming problems. Update the pylint base file to avoid regressions. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09test_fdt: Convert to use argparseSimon Glass1-19/+20
Drop the deprecated OptionParser. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Move main program into its own functionSimon Glass1-20/+24
Use a function for the main program so everything there doesn't look like a global variable to pylint. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Fix fdt test coverageSimon Glass1-1/+1
Fix a bug that the --processes option was ignored, thus resulting in no test coverage information being generated. Signed-off-by: Simon Glass <sjg@chromium.org> Fixes: 42ae363ddd9 ("dtoc: Update fdt tests to use test_util")
2022-08-09dtoc: Tidy up fdt_tests RunTests()Simon Glass1-6/+9
Pass the options args in rather than using the global variables. Use snake case, fix up comments and use a ternary operator to make pylint happy. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-09dtoc: Tidy up fdt_tests RunTestCoverage() argsSimon Glass1-4/+8
Pass the options args in rather than using the global various. Use snake case and fix up comments to make pylint happy. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Support accessing core tagsSimon Glass1-0/+4
At present tag numbers are only allocated for non-core data, meaning that the 'core' data, like priv and plat, are accessed through dedicated functions. For debugging and consistency it is convenient to use tags for this 'core' data too. Add support for this, with new tag numbers and functions to access the pointer and size for each. Update one of the test drivers so that the uclass-private data can be tested here. There is some code duplication with functions like device_alloc_priv() but this is not addressed for now. At some point, some rationalisation may help to reduce code size, but more thought it needed on that. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28dm: core: Switch the testbus driver to use a new structSimon Glass1-1/+1
At present this driver uses 'priv' struct to hold 'plat' data, which is confusing. The contents of the strct don't matter, since only dtoc is using it. Create a new struct with the correct name. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-28patman: test_util: Use unittest text runner to print test resultsAlper Nebi Yasak2-9/+8
The python tools' test utilities handle printing test results, but the output is quite bare compared to an ordinary unittest run. Delegate printing the results to a unittest text runner, which gives us niceties like clear separation between each test's result and how long it took to run the test suite. Unfortunately it does not print info for skipped tests by default, but this can be handled later by a custom test result subclass. It also does not print the tool name; manually print a heading that includes the toolname so that the outputs of each tool's tests are distinguishable in the CI output. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-28dtoc: Update fdt tests to use test_utilSimon Glass1-17/+10
Use the common functions to run tests and report results. Ensure that the result code indicates success or failure. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-06-14dtoc: Update test_src_scan.py for new tegra compatiblesTom Rini1-0/+1
This test was written to match up with the list of compatibles in drivers/i2c/tegra_i2c.c so adding another one requires the test to be updated to match. Fixes: 0d2105ae5e32 ("arm: tegra: Update some DT compatibles") Signed-off-by: Tom Rini <trini@konsulko.com>
2022-03-19dtoc: Tidy up implementation of AddStringList()Simon Glass3-3/+13
Refactor this to avoid a loop. Also add a test for an empty string. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-19dtoc: Make GetArgs() more flexibleSimon Glass3-3/+13
At present it is not possible to have arguments which include spaces. Update the function to only split the args if the property is a single string. This is a bit inconsistent, but might still be useful. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-02dtoc: Correct pylint errorsSimon Glass2-6/+6
Fix pylint errors in this directory. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support reading a list of argumentsSimon Glass3-0/+28
It is helpful to support a string or stringlist containing a list of space-separated arguments, for example: args = "-n fred", "-a", "123"; This resolves to the list: -n fred -a 123 which can be passed to a program as arguments. Add a helper to do the required processing. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Allow deleting nodes and adding them in the same syncSimon Glass2-0/+13
This does not work at present, since the current algorithm assumes that either there are no nodes or all nodes have an offset. If a node is new, but an old node is still in the tree, then syncing fails due to this assumption. Fix it and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support deleting a nodeSimon Glass2-0/+26
Add a function to delete a node. This is synced to the tree when requested. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support adding a string list to a device treeSimon Glass2-0/+26
Add a new function to add a string list. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in test_util.pySimon Glass2-4/+4
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in command.pySimon Glass1-2/+2
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tools.pySimon Glass5-66/+66
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Update test_util to run doc testsSimon Glass1-1/+1
At present this function does not run the doctests. Allow the caller to pass these modules in as strings. Update patman to use this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25tools: Add init files for Python toolsSimon Glass1-0/+0
Add some empty __init__ files for binman, buildman and dtoc so that pylint is able to recognise these as Python modules and produce more useful pylint output. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25dtoc: Fix up a code comment that confuses pylintSimon Glass1-1/+1
This produces a pylint error at present. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-05dtoc: Add support for reading string-list propertiesSimon Glass2-0/+30
Add a function to read a list of strings from the devicetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02dtoc: Add support for reading fixed-length bytes propertiesSimon Glass2-0/+37
Add functions to read a sequence of bytes from the devicetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02dtoc: Add support for reading 64-bit intsSimon Glass4-3/+56
Add functions to read a 64-bit integer property from the devicetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02dtoc: Bring in the libfdt module automaticallySimon Glass1-0/+6
Use the same technique as with binman to load this module from the U-Boot tree if available. This allows running tests without having to specify the PYTHONPATH variable. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-09-25irq: Tidy up of-platdata irq supportSimon Glass1-0/+1
This function is available but not exported. More generally it does not really work as intended. Reimplement it and add a sandbox test too. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-08dtoc: Correct the intarray-widening test caseSimon Glass1-1/+1
This case was intended to check that widening an int array with an int does nothing. Fix it. Reported-by: Walter Lozano <walter.lozano@collabora.com> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-08-01dtoc: Support widening a bool valueSimon Glass4-2/+33
At present if we see 'ranges' property (with no value) we assume it is a boolean, as per the devicetree spec. But another node may define 'ranges' with a value, forcing us to widen it to an int array. At present this is not supported and causes an error. Fix this and add some test cases. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com>
2021-08-01dtoc: Fix widening an int array to an intSimon Glass3-11/+21
An int array can hold a single int so we should not need to do anything in the widening operation. However due to a quirk in the code, an int[3] widened with an int produced an int[4]. Fix this and add a test. Fix a comment typo while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com>
2021-08-01dtoc: Rename is_wider_than() to reduce confusionSimon Glass1-6/+9
The current name is confusing because the logic is actually backwards from what you might expect. Rename it to needs_widening() and update the comments. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Detect drivers which do not parse correctlySimon Glass2-1/+44
At present if a driver is missing a uclass or compatible stirng, this is silently ignored. This makes sense in most cases, particularly for the compatible string, since it is not required except when the driver is used with of-platdata. But it is also not very helpful. When there is some sort of problem with a driver, the missing compatible string (for example) may be the cause. Add a warning in this case, showing it only for drivers which are used by the build. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Detect unexpected suffix on .of_matchSimon Glass2-3/+101
Some rockchip drivers use a suffix on the of_match line which is not strictly valid. At present this causes the parsing to fail. Fix this and offer a warning. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Add a stdout check in test_normalized_name()Simon Glass1-2/+1
This test captures output but does not always check it. Add the missing code and drop the old comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Correct the re_compat regular expressionSimon Glass1-2/+2
This expects a . before the field name (.e.g '.compatible = ...) but presently accepts anything at all. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Allow multiple warnings for a driverSimon Glass1-4/+20
At present we show when a driver is missing but this is not always that useful. There are various reasons why a driver may appear to be missing, such as a parse error in the source code or a missing field in the driver declaration. Update the implementation to record all warnings for each driver, showing only those which relate to drivers that are actually used. This avoids spamming the user with warnings related to a driver for a different board. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Convert to use ArgumentParserSimon Glass1-24/+27
Use this parser instead of OptionParser, which is deprecated. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Avoid using subscripts on match objectsSimon Glass1-1/+1
These are not supported before Python 3.6 so avoid them. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-15dtoc: Check that a parent is not missingSimon Glass3-0/+51
With of-platdata-inst we want to set up a reference to each devices' parent device, if there is one. If we find that the device has a parent (i.e. is not a root node) but it is not in the list of devices being written, then we cannot create the reference. Report an error in this case, since it indicates that the parent node is either missing a compatible string, is disabled, or perhaps does not have any properties because it was not tagged for SPL. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29dtoc: Correct dtoc output when testingSimon Glass2-53/+22
At present each invocation of run_steps() updates OUTPUT_FILES_COMMON, since it does not make a copy of the dict. This is fine for a single invocation, but for tests, run_steps() is invoked many times. As a result it may include unwanted items from the previous run, if it happens that a test runs twice on the same CPU. The problem has not been noticied previously, as there are few enough tests and enough CPUs that is is rare for the 'wrong' combination of tests to run together. Fix this by making a copy of the dict, before updating it. Update the tests to suit, taking account of the files that are no-longer generated. With this fix, we no-longer generate files which are not needed for a particular state of OF_PLATDATA_INST, so the check_instantiate() function is not needed anymore. It has become dead code and so fails the code-coverage test (dtoc -T). Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-06dtoc: Improve handling of reg propertiesSimon Glass4-3/+73
This existing code assumes that a reg property is larger than one cell, but this is not always the case. Fix this assumption. Also if a node's parent is missing the #address-cells and #size-cells properties we use 2 as a default for each. But this should not happen in practice. More likely the properties were removed for SPL due to there being no 'u-boot,dm-pre-reloc' property, or similar. Add a warning for this as the failure can be very confusing. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-06dtoc: Adjust detection of 64-bit propertiesSimon Glass2-6/+6
At present an empty size is considered to be a 64-bit value. This does not seem useful and wastes space. Limit the 64-bit detection to where one or both of the addr/size is two cells or more. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-06dtoc: Show driver warnings once at the endSimon Glass4-28/+33
At present warnings are shown as soon as they are discovered in the source scannner. But the function that detects them may be called multiple times. Collect all the warnings and show them at the end. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Add new check that offsets are correctSimon Glass2-3/+40
Add a few more internal checks to make sure offsets are correct, before updating the dtb. To make this easier, update the functions which add a property to return that property,. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Support adding subnodes alongside existing onesSimon Glass2-9/+51
So far we have only needed to add subnodes to empty notds, so have not had to deal with ordering. However this feature is needed for binman's expanded nodes, since there may be another node in the same section. While libfdt adds new properties after existing properties, it adds new subnodes before existing subnodes. This means that we must reorder the nodes in the cached version, so that the ordering remains consistent. Update the sync implementation to sync existing subnodes first, then add new ones, then tidy up the ordering in the cached version. Update the test to cover this behaviour. Also improve the comment about property syncing while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27dtoc: Add a subnode test for multiple nodesSimon Glass2-12/+34
Add a new test that adds a subnode alongside an existing one, as well as adding properties to a subnode. This will expand to adding multiple subnodes in future patches. Put a node after the one we are adding to so we can check that things sync correctly. The testAddNode() test should be in the TestNode class since it is a node test, so move it. Signed-off-by: Simon Glass <sjg@chromium.org>