aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-07-02Add simple .travis.ymlDavid Gibson1-0/+5
This adds the .travis.yml file allowing for dtc building and testing in the Travis Continuous Integration system. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-07-01guess output file formatAndre Przywara1-1/+10
If no output file type is specified via the -O parameter, guess the desired file type by looking at the file name extension. If that provides no useful hints, assume "dtb" as long as the input type is "dts". Any other input type will lead to "dts" being used as the guessed output type. Any explicit specification of the output type will skip this guessing. Signed-off-by: Andre Przywara <osp@andrep.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-07-01guess input file format based on file content or file nameAndre Przywara1-1/+50
Always needing to specify the input file format can be quite annoying, especially since a dtb is easily detected by its magic. Looking at the file name extension sounds useful as a hint, too. Add heuristic file type guessing of the input file format in case none has been specified on the command line. The heuristics are as follows (in that order): - Any issues with opening the file drop back to the current default behaviour. - A directory will be treated as the /proc/device-tree type. - If the first 4 bytes are the DTB magic, assume "dtb". - If no other test succeeded so far, use a file name based guessing method: if the filename ends with .dts or .DTS, device tree source text is assumed, .dtb or .DTB hint at a device tree blob. For the majority of practical use cases this gets rid of the tedious -I specification on the command line and simplifies actual typing of dtc command lines. Any explicit specification of the input type by using -I still avoids any guessing, which resembles the current behaviour. Signed-off-by: Andre Przywara <osp@andrep.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-05-25tests: convert `echo -n` to `printf`Mike Frysinger1-10/+10
The -n option is not standard in POSIX, so convert to printf which should work the same in every shell. Signed-off-by: Mike Frysinger <vapier@chromium.org>
2015-04-30Fix crash with poorly defined #size-cellsJack Miller3-1/+15
If you have a parent block with #size-cells improperly set to 0, and then subsequently try to include a regs property in the child, dtc will crash with SIGFPE while validating it. This patch fixes that crash, instead printing the same invalid length warning that was causing it. Test included. Signed-off-by: Jack Miller <jack@codezen.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-04-07Add testcases for fdt_path_offset_namelen()David Gibson1-0/+31
This extends the path_offset testcase to exercise the fdt_path_offset_namelen() function. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-04-07Extend path_offset testcase for handling of duplicated separatorsDavid Gibson1-0/+10
Paths with multiple '/' characters in a row (e.g. //somenode//somsubnode), or trailing '/' characters (e.g. '/somenode/somesubnode/') should be handled by fdt_path_offset(), and treated as equivalent to /somenode/somesubnode. Our current path_offset testcase doesn't check for these cases, so extend it so it does. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-04-07Use a helper function to clean up path_offset testcaseDavid Gibson1-35/+20
This introduces a check_path_offset() helper function into the path_offset testcase to simplify it. This will also make extending the test case with tests for path_offset_namelen() and some edge cases easier. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-04-07libfdt: Add fdt_path_offset_namelen()Peter Hurley3-8/+26
Properties may contain path names which are not NUL-terminated. For example, the 'stdout-path' property allows the form 'path:options', where the ':' character terminates the path specifier. Allow these path names to be used in-place for path descending; add fdt_path_offset_namelen(), which limits the path name to 'namelen' characters. Reimplement fdt_path_offset() as a trivial wrapper. Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
2015-03-18libfdt: Add missing functions to shared libraryJulien Grall1-0/+2
The commit 4e76ec7 "libfdt: Add fdt_next_subnode() to permit easy subnode iteration" adds new functions (fdt_{first,next}_subnode) but forgot to mark them as 'global' in the shared library. Signed-off-by: Julien Grall <julien.grall@linaro.org>
2015-02-23dtc: parser: Add label while overriding nodesNikhil Devshatwar3-0/+69
This patch changes the dtc grammar to allow following syntax i2cexp: &i2c2 { ... }; Current device tree compiler allows to define multiple labels when defining the device node the first time. Typically device nodes are defined in DTSI files. Now these nodes can be overwritten for updating some of the properties. Typically, device nodes are overridden in DTS files. When working with adapter boards, most of the time adapter board can fit to multiple base boards. But depending on which base board it is connected to, the devices on the adapter board would be children of different devices. e.g. On dra7-evm.dts, i2c2 is exported for expansion connector whereas on dra72-evm.dts, i2c5 is exported for expansion connector. This causes a problem when writing a generic device tree file for the adapter board. Because, you cannot know whether all the devices on adapter board are present on i2c or i2c5. The problem can be solved by adding a common label (e.g. i2cexp) in both of the DTS files when overriding the device nodes for i2c2 or i2c5. This way, generic adapter board file would override the i2cexp. And depending on which base board you use the adapter board, all the devices are automatically added for correct device nodes. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2015-01-27fdtput: add delete node and property functionWang Long2-3/+104
add the delete node and property function for fdtput. usage: 1) delete nodes fdtput -r <options> <dt file> [<node>...] 2) delete properties fdtput -d <options> <dt file> <node> [<property>...] Signed-off-by: Wang Long <long.wanglong@huawei.com>
2015-01-13dtc: Use va_end to match corresponding va_startColin Ian King2-0/+2
Although on some systems va_end is a no-op, it is good practice to use va_end, especially since the manual states: "Each invocation of va_start() must be matched by a corresponding invocation of va_end() in the same function." Signed-off-by: Colin Ian King <colin.king@canonical.com>
2014-11-12dtc: Bump version to 1.4.1v1.4.1David Gibson1-1/+1
Bump version number in preparation for a release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-11-12dtc: Add maintainer script for signing and upload to kernel.orgDavid Gibson2-0/+32
This patch adds scripts/kup-dtc which builds a tarball from a specified git tag, signs it and uploads to kernel.org with kup. This is useful only for dtc maintainers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-10-24Improve portabilityPhil Elwell2-3/+3
1) Remove the double parentheses around two comparisons in checks.c. The OSX LLVM-based C compiler warns about them. 2) Put an explicit "=" in the TN() macro, in accordance with c99. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
2014-09-26dtc: Delete the unused start condition INCLUDEWang Long2-2/+0
The scanners of the latest version of dtc and convert-dtsv0 are no longer use start condition "INCLUDE". so we should delete it. Signed-off-by: Wang Long <long.wanglong@huawei.com>
2014-09-11dtc: Update the usage helper messageWang Long1-2/+4
if #define DEFAULT_FDT_VERSION 17 The message Blob version to produce, defaults to %d (for dtb and asm output) should be Blob version to produce, defaults to 17 (for dtb and asm output) This patch fix it, and delete the redundant 't'. Signed-off-by: Wang Long <long.wanglong@huawei.com>
2014-08-08Properly handle embedded nul delimited string listsJack Miller4-1/+11
For example: reserved-names="res1\0res2\0res3"; Where \0 is an actual embedded NUL in the source instead of a string escape. To achieve this, use the len given by the lexer instead of strlen. Without this patch dtc will mangle the output and possibly hang on realloc.
2014-06-19Work around MSVC limitationsAndrei Errapart1-3/+3
1) No variadic macros in the form "args..."; this is a GCC extension. 2) No empty struct initializers. In any case, there is very little to win: { } vs. { 0 }. Signed-off-by: Andrei Errapart <andrei@errapartengineering.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-06-19Open binary files in binary modeAndrei Errapart3-3/+3
The "b" flag to fopen() is generally a no-op on Unix-like systems, but may be important on other systems, including Windows. Signed-off-by: Andrei Errapart <andrei@errapartengineering.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-06-19Correct write_propval_bytes() for platforms with signed char by defaultAndrei Errapart1-1/+1
Some platforms (including the Microsoft C compiler) have char defaulting to signed. write_propval_bytes() in the -O dts code will not behave correctly in this case, due to sign extension. Signed-off-by: Andrei Errapart <andrei@errapartengineering.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-06-18Fix an off-by-2 error in the source output codeDavid Gibson3-1/+19
This has been there for ages, but the assertion makes no sense in the context of the test immediately preceding it. This caused an abort() when in -I dts -O dts mode with the right sort of internal labels in a string property value. Add a testcase for this and another candidate edge case (though this one we already get right). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-06-18Add a basic test for fdtdumpSimon Glass5-1/+99
We can test fdtdump by comparing its output with the source file that was compiled by dtc. Add a simple test that should at least catch regressions in basic functionality. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-06-18Tweak code to display cell valuesSimon Glass1-3/+3
Move the division out of the loop; this seems slightly cleaner. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-06-18Correct output from memreserve in fdtdumpSimon Glass1-1/+1
This currently displays a hex value without the 0x prefix. Add the prefix as dtc requires it. Signed-off-by: Simon Glass <sjg@chromium.org>
2014-05-12libfdt: Add helpers to read #address-cells and #size-cellsDavid Gibson8-2/+243
This patch makes a small start on libfdt functions which actually help to parse the contents of device trees, rather than purely manipulating the tree's structure. We add simple helpers to read and sanity check the #address-cells and #size-cells values for a given node. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-05-09Fix bug with references to root nodeDavid Gibson8-2/+48
At present, the lexer token for references to a path doesn't permit a reference to the root node &{/}. Fixing the lexer exposes another bug handling this case. This patch fixes both bugs and adds testcases. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-03-03Update source code location for dtc in manual.txtHeinrich Schuchardt1-12/+10
The information about the location of the source code of the device tree compiler was inaccurate. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-03-03Remove duplicate assignmentHeinrich Schuchardt1-1/+0
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2014-03-03Consistently use xrealloc instead of reallocHeinrich Schuchardt1-6/+1
fdtput.c: Replace the remaining call to realloc by xrealloc. Some redundant lines in encode_value can be saved. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2014-03-02Remove dead code in util.cHeinrich Schuchardt1-4/+0
xrealloc never returns null Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2014-02-15Remove references to unused DT_BASE tokenDavid Gibson1-2/+0
Also remove the cbase bison union member that was only used for it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-02-12Add a README file for dtc and libfdtGrant Likely1-0/+20
Add a README file to document the location of the mailing list, the home page and state who the maintainers are. Signed-off-by: Grant Likely <grant.likely@linaro.org>
2014-02-04Makefile: add a make "dist" targetFlorian Fainelli1-0/+5
make dist can be used to produce tarballs directly from the git repository, which can be useful to automate the release process as well as shipping custom releases. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-02-01dtc: fix some more -Wshadow warningsFlorian Fainelli4-17/+17
Building on a RHEL6 system produced the following -Wshadow warnings in fstree.c, util.c and checks.c: cc1: warnings being treated as errors checks.c: In function 'parse_checks_option': checks.c:709: error: declaration of 'optarg' shadows a global declaration /usr/include/getopt.h:59: error: shadowed declaration is here make[1]: *** [checks.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: *** Waiting for unfinished jobs.... cc1: warnings being treated as errors fstree.c: In function 'read_fstree': fstree.c:40: error: declaration of 'tmpnam' shadows a global declaration /usr/include/stdio.h:208: error: shadowed declaration is here make[1]: *** [fstree.o] Error 1 cc1: warnings being treated as errors util.c: In function 'xstrdup': util.c:42: error: declaration of 'dup' shadows a global declaration /usr/include/unistd.h:528: error: shadowed declaration is here Fix all of these -Wshadow warnings by using slightly different variable names which won't collide with anything else. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-25Makefile: enable -Wshadow by defaultFlorian Fainelli1-1/+1
Now that all -Wshadow build warnings/errors are fixed, turn on -Wshadow by default to make sure we would catch new potential shadow warnings. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-25libfdt: avoid shadowing "err" in FDT_RW_CHECK_HEADERFlorian Fainelli1-3/+3
FDT_RW_CHECK_HEADER declares an internal variable named "err" which is far too generic and will produce the following -Wshadow warnings: libfdt/fdt_rw.c: In function 'fdt_add_mem_rsv': libfdt/fdt_rw.c:177:2: error: declaration of 'err' shadows a previous local [-Werror=shadow] libfdt/fdt_rw.c:175:6: error: shadowed declaration is here [-Werror=shadow] libfdt/fdt_rw.c: In function 'fdt_del_mem_rsv': libfdt/fdt_rw.c:194:2: error: declaration of 'err' shadows a previous local [-Werror=shadow] libfdt/fdt_rw.c:192:6: error: shadowed declaration is here [-Werror=shadow] libfdt/fdt_rw.c: In function 'fdt_set_name': ... Since this variable is only used internally in the macro, rename to __err which should be prefixed enough not to cause new shadow warnings. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-25libfdt: avoid shadowing "err" in FDT_CHECK_HEADERFlorian Fainelli1-3/+3
FDT_CHECK_HEADER declares an internal variable named "err" whose name is far too generic and will produce the following -Wshadow warnings: libfdt/fdt_ro.c: In function 'fdt_node_offset_by_compatible': libfdt/fdt_ro.c:555:2: error: declaration of 'err' shadows a previous local [-Werror=shadow] libfdt/fdt_ro.c:553:14: error: shadowed declaration is here [-Werror=shadow] cc1: all warnings being treated as errors Since this variable is only used internally in the macro, rename to __err which should be prefixed enough not to cause new shadow warnings. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-25dtc: avoid shadowing dirname()Florian Fainelli1-2/+2
dirname() is declared as a function, and later on try_open() another variable dirname is used, which shadows the dirname() function declaration and will produce the following warnings/errors with -Wshadow turned on: srcpos.c: In function 'try_open': srcpos.c:71:35: error: declaration of 'dirname' shadows a global declaration [-Werror=shadow] srcpos.c:37:14: error: shadowed declaration is here [-Werror=shadow] srcpos.c: In function 'srcfile_add_search_path': srcpos.c:183:42: error: declaration of 'dirname' shadows a global declaration [-Werror=shadow] srcpos.c:37:14: error: shadowed declaration is here [-Werror=shadow] cc1: all warnings being treated as errors Fix this by renaming the function dirname() to get_dirname(). Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
2014-01-04Clean up parser error messagesDavid Gibson1-26/+18
Generally edit parser error messages for brevity and clarity. Replace the print_error() function with a a new macro for brevity and clarity in the source. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-04Correct locations in parser error messaesDavid Gibson1-14/+12
The print_error() function used in several places in the parser uses the location information in yylloc to describe the location of the error. This is not correct in most cases. yylloc gives the location of the lookahead token, whereas the error is generally associated with one of the already parsed non-terminals. This patch corrects this, adding a location parameter to print_error() and supplying it with the appropriate bison @N symbols. This probably breaks yacc compatiblity, but too bad - accurate error messages are more important. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-04Die on failed /incbin/ seeksDavid Gibson1-4/+3
Failing to open an input file, with /include/ or /incbin/ is treated as immediately fatal inside srcfile_relative_open(). However, filing to seek() to the requested offset in an /incbin/ is not. This is a bit oddly inconsistent, and leaves us with a strange case that's awkward to deal with down the line. So, get rid of it and have failed seeks on an /incbin/ be immediately fatal. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-04Move character literal processing to the lexerDavid Gibson2-36/+18
To match the processing of integer literals, character literals are passed as a string from lexer to parser then interpreted there. This is just as awkward as it was for integer literals, without the excuse that we used to need the information about the dts version to process them correctly. So, move character literal processing back to the lexer as well, cleaning things up. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-03Move integer literal processing back to the lexerDavid Gibson2-34/+38
At the moment integer literals are passed from the lexer to the parser as a string, where it's evaluated into an integer by eval_literal(). That strange approach happened because we needed to know whether we were processing dts-v0 or dts-v1 - only known at the parser level - to know how to interpret the literal properly. dts-v0 support has been gone for some time now, and the base and bits parameters to eval_literal() are essentially useless. So, clean things up by moving the literal interpretation back to the lexer. This also introduces a new lexical_error() function to report malformed literals and set the treesource_error flag so that they'll cause a parse failure at the top level. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-01Make srcpos_{v,}error() more widely usefulDavid Gibson3-11/+13
Allow them to take a prefix argument giving the general type of error, which will be useful in future. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-01Fix memory leak in srcpos_verror()David Gibson1-1/+3
Since dtc runs are short, we don't care that much about memory leaks. Still, leaking the source position string every time we print an error messages is pretty nasty. Fix it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-01Fix indentation of srcpos_verror()David Gibson1-5/+5
Somehow this function ended up with a 7 space indent, instead of the usual 8 space (1 tab) indent. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-01Fix typo in type of srcpos_verror() et al.David Gibson2-4/+4
The srcpos_verror() and srcpos_error() functions declare the format string as 'char const *' instead of 'const char *'. Fix it. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2014-01-01Remove unused srcpos_warn() functionDavid Gibson2-19/+0
This function has no users, and we can replace it more generally later. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>