Sometimes the requested node or property is not present in the device
tree. This option provides a way of reporting a default value in this
case, rather than halting with an error.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
There is a rather unfortunate bug in fdtget in that if multiple argument
sets are provided, it just repeats displaying the first set ones for
each set.
Fix this bug and add a test for it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Currently run_tests.sh generates several files of text test data. The
procedure it uses for this is somewhat torturous and has several problems:
* Since the test data is derived from a dts file, a cursory glance at the
test output suggests something is wrong with the processing of that dts.
This is misleading since in fact it's just being used as an arbirary
string.
* Since the base input has linefeeds removed, the head and sort commands
used later have no effect.
* Although an attempt is made to get rid of characters which the shell
will mangle, it's not thorough enough. Specifically it leaves in \ which
means that some string escapes found in the input data can get expanded
somewhere along the line in some shells.
This patch, therefore, replaces this generation of test data with a
pre-canned "Lorem ipsum" of approximately 2k. On my system, where /bin/sh
is dash, this fixes a test failure due to the aforementioned string
escapes being evaluated on one but not the other of the two comparison
paths (I haven't tracked down exactly where the expansion is happening).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch cleans up how the fdtget and fdtput tests are invoked.
Specifically we no longer hide the full command lines with a wrapper
function - this makes it possible to distinguish fdtget from similar
fdtput tests and makes it easier to work out how to manually invoke an
individual failing test.
In addition, we remove the testing for errors from the
fdt{get,put}-runtest.sh script, instead using an internal wrapper
analagous to run_wrap_test which can test for any program invocation
that's expected to return an error.
For a couple of the fdtput tests this would result in printing out
ludicrously large command lines. Therefore we introduce a new
mechanism to cut those down to something reasonable.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
The patches introducing fdtget and fdtput inserted a peculiar bashism to
run_tests.sh using non-portable assignment within an (( )) expression.
This patch fixes it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This simple utility allows writing of values into a device tree from the
command line. It aimes to be the opposite of fdtget.
What is it for:
- Updating fdt values when a binary blob already exists
(even though source may be available it might be easier to use this
utility rather than sed, etc.)
- Writing machine-specific fdt values within a build system
To use it, specify the fdt binary file on command line followed by the node
and property to set. Then, provide a list of values to put into that
property. Often there will be just one, but fdtput also supports arrays and
string lists.
fdtput does not try to guess the type of the property based on looking at
the arguments. Instead it always assumes that an integer is provided. To
indicate that you want to write a string, use -ts. You can also provide
hex values with -tx.
The command line arguments are joined together into a single value. For
strings, a nul terminator is placed between each string when it is packed
into the property. To avoid this, pass the string as a single argument.
Usage:
fdtput <options> <dt file> <<node> <property> [<value>...]
Options:
-t <type> Type of data
-v Verbose: display each value decoded from command line
-h Print this help
<type> s=string, i=int, u=unsigned, x=hex
Optional modifier prefix:
hh or b=byte, h=2 byte, l=4 byte (default)
To read from stdin and write to stdout, use - as the file. So you can do:
cat somefile.dtb | fdtput -ts - /node prop "My string value" > newfile.dtb
This commit also adds basic tests to verify the major features.
Signed-off-by: Simon Glass <sjg@chromium.org>
This simply utility makes it easy for scripts to read values from the device
tree. It is written in C and uses the same libfdt as the rest of the dtc
package.
What is it for:
- Reading fdt values from scripts
- Extracting fdt information within build systems
- Looking at particular values without having to dump the entire tree
To use it, specify the fdt binary file on command line followed by a list of
node, property pairs. The utility then looks up each node, finds the property
and displays the value.
Each value is printed on a new line.
fdtget tries to guess the type of each property based on its contents. This
is not always reliable, so you can use the -t option to force fdtget to decode
the value as a string, or byte, etc.
To read from stdin, use - as the file.
Usage:
fdtget <options> <dt file> [<node> <property>]...
Options:
-t <type> Type of data
-h Print this help
<type> s=string, i=int, u=unsigned, x=hex
Optional modifier prefix:
hh or b=byte, h=2 byte, l=4 byte (default)
Signed-off-by: Simon Glass <sjg@chromium.org>
This will allow callers to rebuild .dtb files when any of the /include/d
.dtsi files are modified, not just the top-level .dts file.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Commit a31e3ef83b introduced new libfdt
functions to append to existing properties. It also included a test case
for this, but neglected to update the Makefile and run_tests.sh script
to actually build and execute this testcase.
This patch corrects the oversight.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Elements of size 8, 16, 32, and 64 bits are supported. The new
/bits/ syntax was selected so as to not pollute the reserved
keyword space with uint8/uint16/... type names.
With this patch the following property assignment:
property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>;
is equivalent to:
property = <0x12345678 0x0000ffff>;
It is now also possible to directly specify a 64 bit literal in a
cell list, also known as an array using:
property = /bits/ 64 <0xdeadbeef00000000>;
It is an error to attempt to store a literal into an element that is
too small to hold the literal, and the compiler will generate an
error when it detects this. For instance:
property = /bits/ 8 <256>;
Will fail to compile. It is also an error to attempt to place a
reference in a non 32-bit element.
The documentation has been changed to reflect that the cell list
is now an array of elements that can be of sizes other than the
default 32-bit cell size.
The sized_cells test tests the creation and access of 8, 16, 32,
and 64-bit sized elements. It also tests that the creation of two
properties, one with 16 bit elements and one with 32 bit elements
result in the same property contents.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
This adds higher-level libfdt operations for reading/writing an fdt
blob from/to a file, as well as a function to decode a data type string
as will be used by fdtget, fdtput.
This also adds a few tests for the simple type argument supported by
utilfdt_decode_type.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
With this patch the following property assignment:
property = <0x12345678 'a' '\r' 100>;
is equivalent to:
property = <0x12345678 0x00000061 0x0000000D 0x00000064>
Signed-off-by: Anton Staaf <robotboy@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds a "dtdiff" script to do a useful form diff of two
device trees. This automatically converts the tree to dts form (if
it's not already) and uses a new "-s" option in dtc to "sort" the
tree. That is, it sorts the reserve entries, it sorts the properties
within each node by name, and it sorts nodes by name within their
parent.
This gives a pretty sensible diff between the trees, which will ignore
semantically null internal rearrangements (directly diffing the dts
files can give a lot of noise due to the order changes).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
When nodes are modified by merging device trees, nodes to be updated/merged can
be specified by a label. Specifying nodes by full path (instead of label)
doesn't quite work. This patch fixes that.
Signed-off-by: John Bonesio <bones@secretlab.ca>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Current we check for various error codes with [ $x == "NN" ]. However
'==' is not actually a correct operator for the [ (test) command. It
should be either '=' for string comparison or '-eq' for integer
comparison. It appears that the bash builtin version of test
implements '==' though, so we were getting away with it, as long as
/bin/sh was bash - or the testsuite generated no errors.
This patch fixes the usage of test so that it should work on non-bash
shells.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
The dtbs_equal_ordered test program is used to implement a number of
testcases. However, the test program itself has never been
particularly well tested. In addition there are testcases coming in
future for which it would be useful to have a corresponding
"dtbs_equal_unordered" which checks for equality of device trees, not
considering the internal ordering of elements. Finally, for some
tests we may want it would be useful to check trees for equality with
the PASS case being when they are *not* equal.
This patch addresses all of the above. A dtbs_equal_unordered is
added, and both it and the existing dtbs_equal_ordered program now
take a -n option to make the PASS case be where the trees are not
equal. A number of example trees with slight modifications from
test_tree1 are used to verify that both these programs correctly
identify when the tree is altered, and a dtb_reverse program is used
to verify that the unordered version does not depend on internal
ordering. These new testcases for the equality testing programs are
split out into a new test group in run_tests.sh.
dtbs_equal_unordered uses the new property iteration functions, and so
this also acts as further testing for those functions.
dtbs_equal_unordered will be useful for further testing the recently
added tree-merging code and its upcoming extensions.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch allows the following construct:
/ {
property-a = "old";
property-b = "does not change";
};
/ {
property-a = "changed";
property-c = "new";
node-a {
};
};
Where the later device tree overrides the properties found in the
earlier tree. This is useful for laying down a template device tree
in an include file and modifying it for a specific board without having
to clone the entire tree.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
At present, both the grammar and our internal data structures mean
that there can be only one label on a node or property. This is a
fairly arbitrary constraint, given that any number of value labels can
appear at the same point, and that in C you can have any number of
labels on the same statement.
This is pretty much a non-issue now, but it may become important with
some of the extensions that Grant and I have in mind. It's not that
hard to change, so this patch does so, allowing an arbitrary number of
labels on any given node or property. As usual a testcase is added
too.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
The only purpose of the dtc_references_dts0 testcase was to check
handling of references in the old dts v0 syntax. Since we no longer
support the old syntax, and the references_dts0.dts has been converted
to the new format, it's entirely redundant. This patch removes it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Currently, nothing will stop you from re-using the same label string
multiple times in a dts, e.g.:
/ {
samelabel: prop1 = "foo";
samelabel: prop2 = "bar";
};
or
/ {
samelabel: prop1 = "foo";
samelabel: subnode {
};
};
When using node references by label, this could lead to confusing
results (with no warning), and in -Oasm mode will result in output
which the assembler will complain about (since it too will have
duplicate labels).
This patch, therefore, adds code to checks.c to give errors if you
attempt to re-use the same label. It treats all labels (node,
property, and value) as residing in the same namespace, since the
assembler will treat them so for -Oasm mode.
Testcases for the new code are also added.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Currently, when in -Idts -Odtb or -Ifs -Odtb modes, dtc always
defaults to using 0 as the value for the boot_cpuid_phys header field.
That's correct quite often, but there are some systems where there is
no CPU with hardware ID of 0, or where we don't want to use the CPU
with hardware ID 0 at all (e.g. for AMP-style partitioning). The only
way to override this default currently, is with the -b command line
option.
This patch improves dtc to instead base the default boot_cpuid_phys
value on the reg property of the first listed subnode of /cpus. This
means that dtc will get boot_cpuid_phys correct by default in a
greater proportion of cases (since the boot cpu is usually listed
first, and this way at least the boot_cpuid_phys default will match
some existing cpu node). If the node doesn't exist or has an invalid
'reg' property (missing or not 4 bytes in length), then
boot_cpuid_phys is set to 0.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Currently, the Linux kernel, libfdt and dtc, when using flattened
device trees encode a node's phandle into a property named
"linux,phandle". The ePAPR specification, however - aiming as it is
to not be a Linux specific spec - requires that phandles be encoded in
a property named simply "phandle".
This patch adds support for this newer approach to dtc and libfdt.
Specifically:
- fdt_get_phandle() will now return the correct phandle if it
is supplied in either of these properties
- fdt_node_offset_by_phandle() will correctly find a node with
the given phandle encoded in either property.
- By default, when auto-generating phandles, dtc will encode
it into both properties for maximum compatibility. A new -H
option allows either only old-style or only new-style
properties to be generated.
- If phandle properties are explicitly supplied in the dts
file, dtc will not auto-generate ones in the alternate format.
- If both properties are supplied, dtc will check that they
have the same value.
- Some existing testcases are updated to use a mix of old and
new-style phandles, partially testing the changes.
- A new phandle_format test further tests the libfdt support,
and the -H option.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
I've just tested building dtc as an x86_64 binary on a 32-bit i386
host by using:
make CC="gcc -m64"
This patch fixes a handful of minor bugs thus discovered:
* There is a printf() type mismatch on 64-bit in value-labels.c
* For the tests which use libdl, we were using the GNU make feature
where it will find libdl.so given a dependency in the form '-ldl'.
But this built-in make logic doesn't know we're compiling 64-bit so
finds the 32-bit version of the library. We avoid using this and
instead explicitly pass -ldl to CC, which being the 64-bit version
does know where to look.
* To process dtc's asm output into .so files, run_tests.sh was
directly invoking the (default instance of) the assembler and linker.
Instead invoke these via the CC driver, and allow that to be overriden
from the make environment.
* The x86_64 assembler doesn't 0 fill with the .balign directive
(presumably it is NOP filling). That doesn't produce strictly
incorrect trees, but it is confusing and confounds are testcases which
do byte-by-byte comparison of the trees produced by asm output with
direct dtb output (which does 0 pad where necessary, of course). This
patch uses the optional second argument to .balign to force gas to
zero-fill instead.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
In one section, the run_tests script attempts to use the -e (interpret
escapes) option to echo. This option is not portable - for example
the echo built into dash, now the default /bin/sh on several
distributions does not support it and will just echo "-e" literally.
Since we don't actually use any of the escapes that -e enables, this
patch simply removes it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
When in -Odts mode, dtc will not produce correct output for
string-like properties which have more than one \0 character at the
end of the property's bytestring. In fact, it generates output which
is not syntactically correct. This patch fixes the bug, and adds a
testcase for future regressions here.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds a testcase using asm output mode to check that labels
within property values are correctly processed.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds some testcases for dtc's -Oasm mode. Specifically it
checks that building the asm will result in the same device tree blob
in memory as -Odtb mode would produce, for a variety of trees. This
test uncovered two difficulties with our current -Oasm output, both of
which are addressed in this patch as well.
First, -Oasm output would only be correct if assembled for a
big-endian target. Usually that would be the case, when building
device trees into a firmware or similar. However this makes life
inconvenient for testing on a little-endian target, and one can think
up use cases where a program running on a little endian host might
want to embed a device tree for a big-endian target. This patch
therefore changes -Oasm output to use .byte directives instead of
.long throughout in order to generate byte-for-byte identical trees
regardless of the endianness of the assembler target.
Second, -Oasm output emitted several #define statements which were
then used in the innards of the output - i.e. it assumed the output
would be processed by cpp before being assembled. That may not be
convenient in all build environments, and in any case doesn't work
well with the above fix. So, -Oasm output no longer needs to be
preprocessed before assembling.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Currently, dtc will generate phandles for nodes which are referenced
elsewhere in the tree. phandles can also be explicitly assigned by
defining the linux,phandle property. However, there is no way,
currently to tell dtc to generate a phandle for a node if it is not
referenced elsewhere. This is inconvenient when it's expected that
later processing on the flat tree might add nodes which _will_
the node in question.
One way one might attempt to do this is with the construct:
mynode: mynode {
linux,phandle = <&mynode>;
/* ... */
};
Though it's a trifle odd, there's really only one sensible meaning
which can be assigned to this construct: allocate a unique phandle to
"mynode" and put that in its linux,phandle property (as always).
Currently, however, dtc will choke on this self-reference. This patch
corrects this, making the construct above give the expected results.
It also ensures a more meaningful error message is given if you
attempt to process the nonsensical construct:
mynode: mynode {
linux,phandle = <&someothernode>;
/* ... */
};
The 'references' testcase is extended to cover this case, as well.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Now that all in-kernel-tree DTS files are properly /dts-v1/,
remove direct support for the older, un-numbered DTS
source file format.
Convert existing tests to /dts-v1/ and remove support
for the conversion tests themselves.
For now, though, the conversion tool still exists.
Signed-off-by: Jon Loeliger <jdl@freescale.com>
Kumar has already added alias expansion to fdt_path_offset().
However, in some circumstances it may be convenient for the user of
libfdt to explicitly get the string expansion of an alias. This patch
adds a function to do this, fdt_get_alias(), and uses it to implement
fdt_path_offset().
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
If the path doesn't start with '/' check to see if it matches some alias
under "/aliases" and substitute the matching alias value in the path
and retry the lookup.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
This patch adjusts the testsuite to run most of the tests for the tree
checking code on input in dtb form as well as dts form. Some checks
which only make sense for dts input (like reference handling) are
excluded, as are those which currently take dtb input because they
rely on things which cannot be lexically constructed in a dts file.
This shows up two small bugs in dtc, which are also corrected.
First, the name_properties test which was is supposed to remove
correctly formed 'name' properties (because they can be reconstructed
from tne node name) was instead removing 'name' properties even if
they weren't correct.
Secondly, when using dtb or fs input, the runtime tree in dtc did not
have the parent pointer initialized propertly because.built
internally. The appropriate initialization is added to the
add_child() function.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
I've recently worked with a FreeBSD developer, getting dtc and libfdt
working on FreeBSD. This showed up a number of portability problems
in the dtc package which this patch addresses. Changes are as
follows:
- the parent_offset and supernode_atdepth_offset testcases
used the glibc extension functions strchrnul() and strndupa(). Those
are removed, using slightly longer coding with standard C functions
instead.
- some other testcases had a #define _GNU_SOURCE for no
particular reason. This is removed.
- run_tests.sh has bash specific constructs removed, and the
interpreter changed to /bin/sh. This apparently now runs fine on
FreeBSD's /bin/sh, and I've also tested it with both ash and dash.
- convert-dtsv0-lexer.l has some extra #includes added. These
must have been included indirectly with Linux and glibc, but aren't on
FreeBSD.
- the endian handling functions in libfdt_env.h, based on
endian.h and byteswap.h are replaced with some portable open-coded
versions. Unfortunately, these result in fairly crappy code when
compiled, but as far as I can determine there doesn't seem to be any
POSIX, SUS or de facto standard way of determining endianness at
compile time, nor standard names for byteswapping functions.
- some more endian handling, from testdata.h using the
problematic endian.h is simply removed, since it wasn't actually being
used anyway.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds a testcase for the /include/ directive. It assembles
a sample dts file with many /include/ directives at a variety of
different lexical / grammatical contexts.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
On Wed, Jun 04, 2008 at 09:26:23AM -0500, Jon Loeliger wrote:
> David Gibson wrote:
>
>> But as I said that can be dealt with in the future without breaking
>> compatibility. Objection withdrawn.
>>
>
> And on that note, I officially implore Scott to
> re-submit his binary include patch!
Scott's original patch does still have some implementation details I
didn't like. So in the interests of saving time, I've addressed some
of those, added a testcase, and and now resubmitting my revised
version of Scott's patch.
dtc: Add support for binary includes.
A property's data can be populated with a file's contents
as follows:
node {
prop = /incbin/("path/to/data");
};
A subset of a file can be included by passing start and size parameters.
For example, to include bytes 8 through 23:
node {
prop = /incbin/("path/to/data", 8, 16);
};
As with /include/, non-absolute paths are looked for in the directory
of the source file that includes them.
Implementation revised, and a testcase added by David Gibson
Signed-off-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Scott Wood <scottwood@freescale.com>
This patch adds an extra testcase to dtc to ensure that the
"reg_format" and "ranges_format" checks trigger as they should if a
'reg' or 'ranges' property appears in the root node.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds a new utility program, convert-dtsv0, to the dtc
sources. This program will convert dts files from v0 to v1,
preserving comments and spacing. It also includes some heuristics to
guess an appropriate base to use in the v1 output (so it will use hex
for the contents of reg properties and decimal for clock-frequency
properties, for example). They're limited and imperfect, but not
terrible.
The guts of the converter program is a modified version of the lexer
from dtc itself.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Currently, dtc will put the nonsense value 0xfeedbeef into the
boot_cpuid_phys field of an output blob, unless explicitly given
another value with the -b command line option. As well as being a
totally unuseful default value, this also means that dtc won't
properly preserve the boot_cpuid_phys field in -I dtb -O dtb mode.
This patch reworks things to improve the boot_cpuid handling. The new
semantics are that the output's boot_cpuid_phys value is:
the value given on the command line if -b is used
otherwise
the value from the input, if in -I dtb mode
otherwise
0
Implementation-wise we do the following:
- boot_cpuid_phys is added to struct boot_info, so that
structure now contains all of the blob's semantic information.
- dt_to_blob() and dt_to_asm() output the cpuid given in
boot_info
- dt_from_blob() fills in boot_info based on the input blob
- The other dt_from_*() functions just record 0, but we can
change this easily if e.g. we invent a way of specifying the boot cpu
in the source format.
- main() overrides the cpuid in the boot_info between input
and output if -b is given
We add some testcases to check this new behaviour.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds some testcases checking corner cases of dtc's input
file handling. Specifically it checks that dtc works correctly when
given input via stdin, and it checks that dtc fails gracefully if
given a nonexistent input file (or directory, in the case of -Ifs
mode).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch makes several small improvements to the test harness.
* An altered way of invoking shell script testcases from run_tests.sh
means scripts no longer need to me marked executable in the
repository to work properly.
* dtc.sh never did anything that was really dtc specific - with the
exception of messages, it would work equally well for any binary
that returns 0 in the successful case. Therefore, generalise dtc.sh
and fold it into run_tests.sh so we don't need a separate script any
more.
* Tweak various things so that the valgrind options are properly
propagated down to invoke dtc under valgrind when called via wrapper
scripts.
* Tweak the valgrind suppressions to work properly on a wider range of
systems (this was necessary on my machine running Ubuntu Hardy).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds testcases which test dtc when used to convert between
different dtb versions. These tests uncovered a couple of bugs
handling old dtb versions, which are also fixed.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds checks to the checking framework to verify that node
and property names contain only legal characters, and in the case of
node names there is at most one '@'.
At present when coming from dts input, this is mostly already ensured
by the grammer, however putting the check later means its easier to
generate helpful error messages rather than just "syntax error". For
dtb input, these checks replace the older similar check built into
flattree.c.
Testcases for the checks are also implemented.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
In light of the recently discovered bug with NOP handling, this adds
some more testcases for NOP handling. Specifically, it adds a helper
program which will add a NOP tag after every existing tag in a dtb,
and runs the standard battery of tests over trees mangled in this way.
For now, this does not add a NOP at the very beginning of the
structure block. This causes problems for libfdt at present, because
we assume in many places that the root node's BEGIN_NODE tag is at
offset 0. I'm still contemplating what to do about this (with one
option being simply to declare such dtbs invalid).
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
For ages dtc has included a sample dts, comment-test.dts, for checking
various lexical corner cases in comment processing. In fact, it
predates the automated testsuite, and has never been integrated into
it. This patch addresses this oversight, folding the comment handling
test in with the rest of the testsuite.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
fdt_add_subnode_namelen() has a bug if asked to add a subnode to a
node which has NOP tags interspersed with its properties. In this
case fdt_add_subnode_namelen() will put the new subnode before the
first NOP tag, even if there are properties after it, which will
result in an invalid blob.
This patch fixes the bug, and adds a testcase for it.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch adds an fdt_set_name() function to libfdt, mirroring
fdt_get_name(). This is a r/w function which alters the name of a
given device tree node.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This converts the test for the obsolete "interrupt-controller"
property in /chosen to the new framework. That was the only thing
left in the old-style check_chosen() function, so that function is
removed, too.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This patch converts checks related to #address-cells and #size-cells
to the new framework. Specifically, it reimplements the check that
"reg" properties have a valid size based on the relevant
#address-cells and #size-cells values. The new implementation uses
the correct default value, unlike the old-style check which assumed
the values were inherited by default.
It also implements a new, similar test for "ranges" properties.
Finally, since relying on the default values of these variables is
considered not-good-practice these days, it implements a "style" check
which will give a warning if the tree ever relies on the default
values (that is if any node with either "reg" or "ranges" appears
under a parent which has no #address-cells or #size-cells property).
This patch converts to the new tree checking framework those checks
which verify that certain properties (device_type, model) have a
string value, when present.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>