aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-03-06Bump version to v1.5.0v1.5.0David Gibson1-2/+2
We've accumulated several new features as well as a number of bugfixes, so prepare for another release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt:tests: Extend the way how to find a Python moduleLumir Balhar1-1/+1
Python 3 C extensions have suffix containing platform, Python version and another details in the name so the condition has to be extended. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-5-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: Change how passing tests are recognizedLumir Balhar1-1/+1
When some warning appears in test result, "ok" is still at the end of the line but without three dots. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-4-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: Test fdt.setprop take bytes on Python 3, add error handlingPetr Viktorin2-5/+11
Signed-off-by: Petr Viktorin <pviktori@redhat.com> Message-Id: <20190218164856.23861-3-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: check_err accepts only integer as a first argument.Lumir Balhar1-1/+1
A list passed as an argument to check_err() means that there is no error code to check and therefore it should be returned back. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-2-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-02-19pylibfdt: Proper handling of bytes/unicode strings and octal literalsLumir Balhar2-13/+21
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-1-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-01-02Use PRIxPTR for printing uintptr_t valuesAndreas Schwab1-3/+3
Fixes: 49903aed77 ("use ptrdiff_t modifier for printing pointer differences") Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
2018-12-23libfdt: Fix FDT_ERR_NOTFOUND typos in documentationGeert Uytterhoeven1-2/+2
The actual error is FDT_ERR_NOTFOUND, not FDT_ERR_NOT_FOUND. Fixes: d29126c90acb0d70 ("libfdt: Add iterator over properties") Fixes: 902d0f0953d0074b ("libfdt: Add a subnodes iterator macro") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-12-22libfdt: Fix fdt_getprop_by_offset() parameter name in documentationGeert Uytterhoeven1-1/+1
The second parameter of fdt_getprop_by_offset() is called "offset", not "ffset". Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-12-15checks: Add unit address check if node is enabledKumar Gala1-2/+39
There are various SoCs that have 2 different peripheral blocks at the same register offset. However, we might have one block marked as status = "disabled" and the other status = "ok". In such cases we shouldn't warn about duplicate unit-address. Here's a cut down example that we would warning about before: /dts-v1/; / { #address-cells = <0x01>; #size-cells = <0x01>; soc { #address-cells = <0x01>; #size-cells = <0x01>; compatible = "simple-bus"; ranges; i2c0: i2c@40003000 { compatible = "nordic,nrf-i2c"; reg = <0x40003000 0x1000>; status = "ok"; }; spi0: spi@40003000 { compatible = "nordic,nrf-spi"; reg = <0x40003000 0x1000>; status = "disabled"; }; }; }; We introduce 'unique_unit_address_if_enabled' check that is disabled by default. Signed-off-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-28checks: Fix crash with multiple source annotationsRob Herring1-1/+1
Commit 3616b9a811b6 ("checks: Use source position information for check failures") causes crashes when there's a check message with multiple source annotations. Drop the errant addition to the str pointer left over from the previous version. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25checks: Use source position information for check failuresRob Herring1-3/+32
Now that we retain source position information of nodes and properties, make that the preferred file name (and position) to print out in check failures. This will greatly simplify finding and fixing check errors because most errors are in included source .dtsi files and they get duplicated every time the source file is included. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25checks: Make each message output atomicRob Herring1-6/+11
Printing to stderr as we build up the check message results in interleaving of messages when multiple instances of dtc are running. Change the message output to use an intermediate buffer for constructing the message and then output the message to stderr with a single fputs. While perhaps there is no guarantee that fputs will be atomic, this gets rid of any interleaved output that previously occurred on Linux. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-25util: Add xa{v}sprintf_append functionsRob Herring2-21/+41
Add variadic and va_list functions, xa{v}sprintf, which appends a formatted string to an existing string and re-allocate the string buffer if necessary. xasprintf becomes just a special case of xasprintf_append with a NULL starting string. Rather than looping to get a big enough buffer, simply the implementation by assuming we have a C99 compliant vsnprintf implementation to return the necessary size. A side effect is glibc 2.0 support is dropped which seems unnecessary. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-24libfdt: Add a test for fdt_getprop_by_offset()Simon Glass6-1/+94
This function does not have its own test at present. Add one. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23PEP8 / Flake8 cleanups for setup.pyDavid Gibson1-6/+7
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Remove broken objdir / srcdir supportDavid Gibson3-21/+19
The dtc makefiles have support for building into a separate directory from the sources... except that it's broken and probably always has been. Remove the pretense. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23pylibfdt: Use common PREFIX variableDavid Gibson1-1/+1
For no particularly good reason, the install target for the Python library uses a different PREFIX variable to give the installation destination to the rest of dtc & libfdt. Make it use the same one. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Refine make tests_clean targetDavid Gibson2-4/+4
Remove some redundancy, and also clean up *.test.dt.yaml files generated during the tests. Also add the latter to gitignore. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Refine pylibfdt_clean targetDavid Gibson2-5/+8
Move it to the subdir Makefile, generalize some of the patterns, remove the 'build' directory made by setup.py and __pycache__ directory made by Python3. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23Refine libfdt_clean targetDavid Gibson2-5/+4
Move it to the libfdt Makefile piece, use neater make syntax, and remove redundant command (already included in STD_CLEANFILES). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23tests: Use modern octal literals for PythonDavid Gibson1-2/+2
Python3 removes support for C-style octal literals, using 0oXXXX instead. Python2 also supports this form, so move to the new style. Reported-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-23pylibfdt: Allow switch to Python 3 via environment variable PYTHONLumir Balhar4-7/+8
Python 2 is still the default but it can be changed by setting environment variable PYTHON before build/test. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-22libfdt: Don't use memcpy to handle unaligned reads on ARMDavid Gibson1-7/+15
6dcb8ba4 "libfdt: Add helpers for accessing unaligned words" introduced the fdt32_ld() and fdt64_ld() helpers for loading values from the FDT blob which might not be naturally aligned. This matters for ARM, where attempting a plain unaligned load will often cause an exception. However, it seems the memcpy() we used here was surprisingly expensive, making libfdt nearly 6x slower on at least some ARM platforms. This patch takes an alternative approach, using a bunch of 1-byte loads and shifts to implement the helpers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-22checks: Restructure check_msg to decrease indentationRob Herring1-14/+14
The entire check_msg function is under the if condition except for va_start/va_end. Move these and invert the if condition saving a level of indentation. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-19annotations: add the annotation functionalityJulia Lawall5-10/+170
Provide the new command-line option: --annotate (abbreviated -T) --annotate provides one or more filenames and line numbers indicating the origin of a given line. The filename is expressed relative the the filename provided on the command line. Nothing is printed for overlays, etc. -T can be repeated giving more verbose annotations. These consist of one or more tuples of: filename, starting line, starting column, ending line ending column. The full path is given for the file name. Overlays, etc are annotated with <no-file>:<no-line>. The verbose annotations may be too verbose for normal use. There are numerous changes in srcpos.c to provide the relative filenames (variables initial_path, initial_pathlen and initial_cpp, new functions set_initial_path and shorten_to_initial_path, and changes in srcfile_push and srcpos_set_line). The change in srcpos_set_line takes care of the case where cpp is used as a preprocessor. In that case the initial file name is not the one provided on the command line but the one found at the beginnning of the cpp output. shorten_to_initial_path only returns a string if it has some shortening to do. Otherwise it returns NULL and relies on the caller to use the initial string. This simplifies memory management, by making clear to the caller whether a new string is allocated. The new functions srcpos_string_comment, srcpos_string_first, and srcpos_string_last print the annotations. srcpos_string_comment is recursive to print a list of source file positions. Various changes are sprinkled throughout treesource.c to print the annotations. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-19annotations: add positionsJulia Lawall7-23/+68
Extend the parser to record positions, in build_node, build_node_delete, and build_property. srcpos structures are added to the property and node types, and to the parameter lists of the above functions that construct these types. Nodes and properties that are created by the compiler rather than from parsing source code have NULL as the srcpos value. merge_nodes, defined in livetree.c, uses srcpos_extend to combine multiple positions, resulting in a list of positions. srcpos_extend is defined in srcpos.c. New elements are added at the end. This requires the srcpos type, define in srcpos.h, to be a list structure with a next field. This next field is initialized to NULL in srcpos.h, in the macro YYLLOC_DEFAULT invoked implicitly by the generated parser code. Another change to srcpos.c is to make srcpos_copy always do a full copy, including a copy of the file substructure. This is required because when dtc is used on the output of cpp, the successive detected file names overwrite the file name in the file structure. The next field does not need to be deep copied, because it is always NULL when srcpos_copy is called; an assert checks for this. File names are only updated in uncopied position structures. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14tests: Don't lose errors from make checkmDavid Gibson1-1/+1
For unclear reasons we had some code to copy a transcript of "make checkm" runs to a vglog.XXX file. It's not really clear why this was there, and it had the nasty side effect of discarding errors from run_tests.sh, meaning that an error on the valgrind run wouldn't show up clearly in Travis CI builds. Remove that logic so that we see errors more clearly. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14tests: Property count valgrind errors in wrapped testsDavid Gibson1-0/+3
The logic in wrap_test() was effectively squashing valgrind errors into the "FAIL" bucket rather than their own bucket as intended. Correct it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14srcpos: Remove srcpos_emptyDavid Gibson2-19/+0
Nothing was actually using it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14Revert "annotations: add positions"David Gibson7-67/+23
This reverts commit baa1d2cf7894a32bf2f640ef40ebce561b2df565. Turns out this introduced memory badness. valgrind picks it up on x86, but it straight out SEGVs on x86. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-14checks: Update SPI bus check for 'spi-slave'Kumar Gala1-1/+7
If the SPI bus controller is being used for 'spi-slave' mode some of the checks we have need to change: In 'spi-slave' mode #address-cells should be 0, as any children don't have a reg property. Signed-off-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-13annotations: add positionsJulia Lawall7-23/+67
Extend the parser to record positions, in build_node, build_node_delete, and build_property. srcpos structures are added to the property and node types, and to the parameter lists of the above functions that construct these types. Nodes and properties that are created by the compiler rather than from parsing source code have NULL as the srcpos value. merge_nodes, defined in livetree.c, uses srcpos_extend to combine multiple positions, resulting in a list of positions. srcpos_extend is defined in srcpos.c. New elements are added at the end. The srcpos type, define in srcpos.h, is now a list structure with a next field. Another change to srcpos.c is to make srcpos_copy always do a full copy, including a copy of the file substructure. This is required because when dtc is used on the output of cpp, the successive detected file names overwrite the file name in the file structure. The next field does not need to be deep copied, because it is only updated in newly copied positions and the positions to which it points have also been copied. File names are only updated in uncopied position structures. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-11-07Merge remote-tracking branch 'origin/pr/18'David Gibson1-5/+5
2018-11-07libfdt: return correct value if #size-cells property is not presentJohn Clarke4-6/+16
According to the device tree specification, the default value for #size-cells is 1, but fdt_size_cells() was returning 2 if this property was not present. This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned. Signed-off-by: John Clarke <johnc@kirriwa.net>
2018-10-23use ptrdiff_t modifier for printing pointer differencesDan Horák1-5/+5
Use ptrdiff_t modifier (%tx) for printing a difference between 2 pointers. Currently %zx (size_t) is used, but it fails on platforms where size_t and ptrdiff_t are defined differently (like s390). Comes from https://src.fedoraproject.org/rpms/dtc/c/f3da2d1b00d01d83fef7001d5767baa3d5a6df87?branch=master originally. Signed-off-by: Dan Horák <dan@danny.cz>
2018-10-12treesource: Fix dts output for phandles in middle of a sequence of intsRob Herring1-3/+3
If we have a phandle in the middle of a sequence of numbers and it is not bracketed (e.g. <0x1234 &phandle 0x5678>), the dts output will be corrupted due to missing a space between the phandle value and the following number. Fixes: 8c59a97ce096 ("Fix missing labels when emitting dts format") Cc: Grant Likely <grant.likely@arm.com> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-10-04tests: Wrap check_align() calls with base_run_test()Lubomir Rintel1-2/+2
Otherwise the FAIL results won't be accounted for in the summary. Easily testable by artifically causing them to fail: - if [ $(($size % $align)) -eq 0 ] ;then + if [ $(($size % $align)) -eq 666 ] ;then Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-09-27Fix dts output with a REF_PATH markerRob Herring3-1/+11
Commit 8c59a97ce096 ("Fix missing labels when emitting dts format") fixed label output, but broke output when there is a REF_PATH marker. The problem is a REF_PATH marker causes a zero length string to be emitted. The write_propval_string() function requires a length of at least 1 (including the terminating '\0'), but that was not being checked. For the integer output, a length of 0 is valid as it is possible to have labels inside the starting '<': int-prop = < start: 0x1234>; REF_PHANDLE is another marker that we don't explicitly handle, but it doesn't cause a problem as it is fundamentally just an int. Fixes: 8c59a97ce096 ("Fix missing labels when emitting dts format") Reported-by: Kumar Gala <kumar.gala@linaro.org> Cc: Grant Likely <grant.likely@arm.com> Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-09-26Added test cases for target referencesFredrik Markstrom2-0/+34
This commit adds test cases for commits "Correct overlay syntactic sugar for generating target-path fragments" and "Merge nodes with local target label references". It verifies that target path references are not resolved locally and that target label references that can be resolved locally are. Signed-off-by: Fredrik Markstrom <fredrik.markstrom@gmail.com> [dwg: Fixed some whitespace problems] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-09-25Merge nodes with local target label referencesFredrik Markstrom2-10/+33
This change makes sure that nodes with target label references doesn't create additional fragments if the label can been resolved locally. Target path references are not resolved locally and will generate a fragment. Previously the dts below would generate two fragments: /dts-v1/; /plugin/; &x { a: a@0 {};}; &a { b {}; }; This commit essentially reverts part of the commit "Correct overlay syntactic sugar for generating target-path fragments". The main reason we want to do this is that it breaks consumers of dtbo:s that can't resolve references between fragments in the same dtbo (like the linux 4.1 kernel). In addition creating a fragment for each label reference substantially increases the size of the resulting dtbo for some use cases. Signed-off-by: Fredrik Markstrom <fredrik.markstrom@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2018-09-25pylibfdt: Don't have setup.py depend on where it's invoked fromDavid Gibson3-8/+11
Currently setup.py depends on being invoked from the right directory (specifically it needs to be run from the root of the project). That's a bit confusing. This updates setup.py to no longer depend on the invoking directory by instead having it change directory to the location of the script itself, then using internal paths relative to that. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Eliminate run_setup make functionDavid Gibson1-7/+3
This function no longer does anything useful, so get rid of it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Improved version extractionDavid Gibson2-73/+8
Currently setup.py expects the library version in a VERSION environment variable, or it exctracts the version from the Makefile. The latter is for the case where the script is run standalone, rather than from make. But parsing the Makefile is ugly and fragile, and won't always get the same version we put into the C code. This changes to instead extracting the version from the trivial .h file we already generate to put the version into C code. It's still slightly ugly, but it's simpler and since we can control the precise format of that .h, not as fragile. This lets us remove the remains of the makefile parsing code from setup.py. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Don't silence setup.py when V=1David Gibson1-1/+6
At the moment we unconditionally pass --quiet to setup.py. Change that to get more debugging output from it when V=1 is passed to make. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Make SETUP make variableDavid Gibson1-2/+4
This points to the Python setup script, since we reference it in a couple of places. While we're there correct two small problems: 1) setup.py is part of the checked in sources and so lives in $(PYLIBFDT_srcdir) not $(PYLIBFDT_objdir) [this only worked because those are the same by default] 2) The module itself should depend on the setup script so it is rebuilt if the script is changed Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Simpler CFLAGS handlingDavid Gibson2-8/+5
At the moment we have some fiddly code to either pass in make's CPPFLAGS to setup.py, or have setup.py extract them from the Makefile. But really the only thing we need from here is the include paths. We already know what include paths we need (libfdt/) so we can just set that directly in setup.py. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Link extension module with libfdt rather than rebuildingDavid Gibson2-19/+12
Currently we build the Python extension module from all the libfdt source files as well as the swig wrapper file. This is a bit silly, since we've already compiled libfdt itself. This changes the build to instead build the extension module from just the swig wrapper, linking it against the libfdt.a we've already build. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: Correctly set build output directoryDavid Gibson2-12/+5
Our Makefile currently passes PYLIBFDT_objdir into setup.py in an attempt to set the correct place to put the Python extension module output. But that gets passed in the 'package_dir' map in distutils. But that's basically not what package_dir controls. What actually makes us find the module in the right place is the --inplace passed to setup.py (causing the module to go into the current directory), and the following 'mv' in the Makefile to move it into the right final location. We can simplify setup.py by dropping the useless objdir stuff, and get the module put in the right place straight way by instead using the --build-lib setup.py option. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-25pylibfdt: We don't need include files from the base directoryDavid Gibson1-7/+3
pylibfdt/setup.py currently adds include flags to the extension module build to allow include files in the base dtc directory. But pylibfdt doesn't rely on any headers there, only on headers in libfdt/ - it also shouldn't rely on dtc headers at any future time. So, remove that from the include list, allowing some simplifications to setup.py. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Simon Glass <sjg@chromium.org>