Commit 4038fd9005 ("dtc: add ability to make nodes conditional on them
being referenced") added the new /omit-if-no-ref/ directive to mark
nodes as eligible to be discarded if not referenced. The mechanism to
process this happens before the symbol generation phase. This means even
if symbol generation is requested and the node has a label, it will be
discarded if there are no references to it within the same file.
This is probably not what people expect. When using symbol generation to
compile base device trees for applying overlays, nodes with labels could
be referenced by the overlays, and therefore should be preserved.
Check if the node has a label and symbol generation was requested before
dropping the node.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Message-Id: <20190327035352.24036-1-wens@csie.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Yet again, we've added several functions to libfdt that were supposed
to be exported, but forgotten to add them to the versio.lds script.
This adds them.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
The new fdt_generate_phandle() function can be used to generate a new,
unused phandle given a specific device tree blob. The implementation is
somewhat naive in that it simply walks the entire device tree to find
the highest phandle value and then returns a phandle value one higher
than that. A more clever implementation might try to find holes in the
current set of phandle values and fill them. But this implementation is
relatively simple and works reliably.
Also add a test that validates that phandles generated by this new API
are indeed unique.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Message-Id: <20190320151003.28941-1-thierry.reding@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Should be "endpoint" rather than "endpont"
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Message-Id: <6fcb6e160163467b706c312ffe307ee8a5d9255d.1552328099.git.leonard.crestez@nxp.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
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>
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>
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>
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>
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>
The actual error is FDT_ERR_NOTFOUND, not FDT_ERR_NOT_FOUND.
Fixes: d29126c90a ("libfdt: Add iterator over properties")
Fixes: 902d0f0953 ("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>
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>
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>
Commit 3616b9a811 ("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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This reverts commit baa1d2cf78.
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>
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>
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>
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>
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
f3da2d1b00?branch=master
originally.
Signed-off-by: Dan Horák <dan@danny.cz>
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: 8c59a97ce0 ("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>
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>
Commit 8c59a97ce0 ("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: 8c59a97ce0 ("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>
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>
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>
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>
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>
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>
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>