aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-03-04tests: Allow running the testsuite on already installed binary / librariesDavid Gibson2-6/+13
Currently the test runner script always expects to be run from within the tests/ subdirectory of a dtc source tree: it looks for dtc and other binaries in the parent of the current directory and for the libfdt shared library in ../libfdt. That works great with make check and for testing a build you've just made. However, sometimes it's useful to test a dtc & libfdt which have already been installed on the system, or which for whatever reason are located somewhere else. This patch allows the test runner script to do this when TEST_BINDIR and/or TEST_LIBDIR environment variables are set. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04tests: Honour NO_YAML make variableDavid Gibson1-1/+15
Support for YAML output in dtc is optional (to cover systems that don't have libyaml). Currently the tests for yaml output test if the libyaml package is locally installed. That duplicates similar logic in the Makefile, and worse it will cause failed tests if the user explicitly disables YAML support, rather than simply not having libyaml installed. Fix this by having the test script use the NO_YAML variable exported by make. Fall back to the current test if the variable isn't set, such as when running the script manually. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04tests: Properly clean up .bak file from testsDavid Gibson2-1/+2
One of our testcases creates a .bak file from invoking sed. Fix that to be removed by make clean, and also ignore it in git to avoid clutter. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04tests: Honour $(NO_PYTHON) flag from Makefile in run_tests.shDavid Gibson1-1/+15
Currently the test script bases whether to run the Python tests on whether it can see a built Python module. That can easily be fooled if there is a stale module there. Instead, have it actually look at the NO_PYTHON variable exported from the Makefile. If the variable doesn't exist (such as if we're running the script manually) fall back on the old logic. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04Encode $(NO_PYTHON) consistently with other variablesDavid Gibson1-3/+5
We have several $(NO_*) variables used to disable optional features. $(NO_PYTHON) is encoded as empty for "include Python support" and anything else for "disable Python support". However the other variables - $(NO_YAML) and $(NO_VALGRIND) - use 0 for "include" and 1 for "disable". Change $(NO_PYTHON) to work consistently with the others. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04tests: No need to explicitly pass $PYTHON from Make to run_tests.shDavid Gibson1-3/+3
Make automatically passes its variables through the environment, so we don't need to explicitly copy this one into the test script. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04tests: Let run_tests.sh run Python tests without Makefile assistanceDavid Gibson1-0/+4
Currently run_tests.sh needs the $PYTHON environment variable set to correctly run pylibfdt tests. The Makefile does this for make check, but it breaks if the script is run manually. Add a fallback to handle that case. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04checks: Add 'dma-ranges' checkRob Herring3-10/+26
Generalize the existing 'ranges' check to also work for 'dma-ranges' which has the same parsing requirements. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20200303193931.1653-1-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-03libfdt: Use VALID_INPUT for FDT_ERR_BADSTATE checksSimon Glass2-4/+5
This error indicates a logic bug in the code calling libfdt, so VALID_DTB is not really the right check. Update it to use VALID_INPUT instead. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200302190255.51426-4-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-03libfdt: Add support for disabling internal checksSimon Glass2-2/+11
If libfdt returns -FDT_ERR_INTERNAL that generally indicates a bug in the library. Add a new assumption for these cases since it should be save to disable these checks regardless of the input. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200302190255.51426-3-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-03libfdt: Improve comments in some of the assumptionsSimon Glass1-3/+12
Add a little more detail in a few of these comments. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200302190255.51426-2-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-03libfdt: Fix a few typosSimon Glass1-3/+3
Fix 'saftey' and 'additional' typos noticed in the assumption series. Reword the ASSUME_NO_ROLLBACK slightly to improve clarity. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200302190255.51426-1-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: Allow exclusion of fdt_check_full()Simon Glass3-64/+75
This function is used to perform a full check of the device tree. Allow it to be excluded if all assumptions are enabled. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-9-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: Add support for disabling ordering check/fixupSimon Glass1-1/+2
Add a way to remove this check and the reordering code, which is unnecessary if the dtb is known to be correctly ordered. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-8-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: Add support for disabling version checksSimon Glass3-24/+32
Allow enabling FDT_ASSUME_LATEST to disable version checks. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-7-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: Add support for disabling rollback handlingSimon Glass1-3/+15
Allow enabling FDT_ASSUME_NO_ROLLBACK to disable rolling back after a failed operation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Message-Id: <20200220214557.176528-6-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: Add support for disabling sanity checksSimon Glass2-24/+48
Allow enabling ASSUME_VALID_INPUT to disable sanity checks on the device tree and the parameters to libfdt. This assumption covers that cases where the problem could be with either. Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20200220214557.176528-5-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: Add support for disabling dtb checksSimon Glass4-29/+45
Support ASSUME_VALID_DTB to disable some sanity checks If we assume that the DTB itself is valid then we can skip some checks and save code space. Add various conditions to handle this. Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20200220214557.176528-4-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24Add a way to control the level of checks in the codeSimon Glass2-1/+109
Add a new ASSUME_MASK option, which allows for some control over the checks used in libfdt. With all assumptions enabled, libfdt assumes that the input data and parameters are all correct and that internal errors cannot happen. By default no assumptions are made and all checks are enabled. Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20200220214557.176528-3-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-02-24libfdt: De-inline fdt_header_size()Simon Glass3-4/+11
There does not seem to be a strong reason to inline this function. Also we are about to add some extra code to it which will increase its size. Move it into fdt.c and use a simple declaration in libfdt.h Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20200220214557.176528-2-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-01-29Revert "yamltree: Ensure consistent bracketing of properties with phandles"Rob Herring1-21/+0
This reverts commit 18d7b2f4ee45fec422b7d82bab0b3c762ee907e4. This doesn't work for properties such as 'interrupt-map' that has phandle in the middle of an entry. It would also not work for a 0 or -1 phandle value that acts as a NULL. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20200124144657.29749-1-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-01-16Remove redundant YYLOC global declarationDirk Mueller1-1/+0
gcc 10 will default to -fno-common, which causes this error at link time: (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here This is because both dtc-lexer as well as dtc-parser define the same global symbol yyloc. Before with -fcommon those were merged into one defintion. The proper solution would be to to mark this as "extern", however that leads to: dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls] 26 | extern YYLTYPE yylloc; | ^~~~~~ In file included from dtc-lexer.l:24: dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here 127 | extern YYLTYPE yylloc; | ^~~~~~ cc1: all warnings being treated as errors which means the declaration is completely redundant and can just be dropped. Signed-off-by: Dirk Mueller <dmueller@suse.com> Message-Id: <20200114175341.2994-1-dmueller@suse.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-12-19Move -DNO_VALGRIND into CPPFLAGSDavid Gibson1-1/+1
Since -D sets preprocessor directives, it applies for the preprocessor not just the C compiler proper and so belongs in CPPFLAGS rather than CFLAGS. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-12-17Makefile: pass $(CFLAGS) also during dependency generationEd Maste1-1/+1
When Valgrind is not available NO_VALGRIND is set in CFLAGS, and this is needed during dependency generation as well as compilation. Message-Id: <20191210163033.9888-1-emaste@freefall.freebsd.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-12-04travis.yml: Run tests on the non-x86 builders, tooThomas Huth1-0/+32
Travis recently added the possibility to compile on aarch64, ppc64le and s390x hosts, so let's add this possibility to the dtc CI, too. Unfortunately, there are some weird valgrind errors when running on ppc64le (which rather look like a problem on the valgrind side to me, and not in dtc), so we can not use "checkm" on ppc64le yet. Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <20191203122020.14442-1-thuth@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-21Add .cirrus.yml for FreeBSD buildEd Maste1-0/+21
Right now this is just a build test for FreeBSD, along with a Linux build and "make check." A later change will add "gmake check" for FreeBSD. Signed-off-by: Ed Maste <emaste@freebsd.org> Message-Id: <20191120211133.69281-1-emaste@freefall.freebsd.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-21Avoid gnu_printf attribute when using ClangEd Maste1-0/+4
Clang does not support gnu_printf, so just use printf when using it to compile. Signed-off-by: Ed Maste <emaste@freebsd.org> Message-Id: <20191120210422.61327-1-emaste@freefall.freebsd.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-16tests: default to 'cc' if CC not setEd Maste1-1/+1
By default FreeBSD does not have 'gcc' in the PATH (on common platforms). As on Linux 'cc' is available as a link to the default compiler (Clang or GCC), so just use 'cc'. Signed-off-by: Ed Maste <emaste@freebsd.org> Message-Id: <20191115155108.39488-1-emaste@freefall.freebsd.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15Add test-case for trailing zeroStefan Mavrodiev1-0/+4
If there is trailing zero, fdtget adds extra chacarter to the property value. Thus comparing the expected with the actual value, an error is emitted. Signed-off-by: Stefan Mavrodiev <stefan@olimex.com> Message-Id: <20191111080444.9819-3-stefan@olimex.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15Remove trailing zero from the overlay pathStefan Mavrodiev1-1/+1
The overlay path ends with trailing zero. When adding this path as property value, this character should be removed. This is the case when the overlay adds a node with an alias. Signed-off-by: Stefan Mavrodiev <stefan@olimex.com> Message-Id: <20191111080444.9819-2-stefan@olimex.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15pylibfdt: Adjust for deprecated test methodsSimon Glass1-99/+99
Python recently deprecated some test methods in favour of others. Adjust the code to avoid warnings. Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20191113012410.62550-1-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-15tests: add extension to sed -i for GNU/BSD sed compatibilityEd Maste1-1/+1
BSD sed requires that an extension is provided to the -i (in-place edit) flag, which may immediately follow the -i or may be separated by a space - sed -i .bak and sed -i.bak are equivalent. The extension is optional with GNU sed, but if provided must immediately follow the -i. Thus, sed -i.bak behaves identically with both GNU and BSD sed. Signed-off-by: Ed Maste <emaste@freebsd.org> Message-Id: <20191114203615.2866-1-emaste@freefall.freebsd.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-08libfdt: Correct prototype for fdt_ro_probe_()David Gibson1-2/+2
This function returns an int32_t, however the prototype in libfdt_internal.h shows it returning an int. We haven't caught this before because they're the same type on nearly all platforms this gets built on. Apparently it's not the case on FreeRTOS, so someone hit this mismatch building for that platform. Reported-by: dharani kumar <dharanikumarsrvn@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-07Use correct inttypes.h format specifierDavid Gibson1-1/+2
The type here is uint32_t which should use PRIx32, not plain %x which is for an int, we've just gotten away with it so far. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-11-03support byacc in addition to bisonEthan Sommer2-1/+5
Use -b to explicitly set file prefix, so that byacc generates files with the same names as bison. Add %locations to dtc-parser.y to explicitly enable location tracking for byacc, and define YYERROR_CALL to prevent byacc from defining it to call yyerror with 2 parameters because of the locations directive, because dtc-parser.y defines yyerror to accept one parameter. Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com> Message-Id: <20191029162619.32561-1-e5ten.arch@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-27pylibfdt: Correct the type for fdt_property_stub()Simon Glass2-5/+6
This function should use a void * type, not char *. This causes an error: TypeError: in method 'fdt_property_stub', argument 3 of type 'char const *' Fix it and update the tests. Signed-off-by: Simon Glass <sjg@chromium.org> Message-Id: <20191025010226.34378-1-sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14tests: fix some python warningsMarc-André Lureau1-2/+4
Fixes: ResourceWarning: unclosed file <_io.BufferedReader name='test_tree1.dtb'> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-9-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14util: use gnu_printf format attributeMarc-André Lureau1-1/+1
dtc uses non-portable formats. Using gnu_printf attributes (for warnings) in combination with __USE_MINGW_ANSI_STDIO allows to build for win32. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-8-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14fstree: replace lstat with statMarc-André Lureau1-1/+1
Fixes mingw cross-compilation. lstat() doesn't exist on win32. It seems to me that stat() is the right function there, to return informations about the file it refers to. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-7-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14dumptrees: pass outputdir as first argumentMarc-André Lureau2-1/+11
Instead of outputing files to current directory, allow to specificy an output directory. This helps with meson build system out-of-tree support. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-4-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-14tests: allow out-of-tree test runMarc-André Lureau9-173/+185
meson runs out-of-tree, add absolute path location where necessary. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-3-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-11fdtoverlay: Return non-zero exit code if overlays can't be appliedValter Minute1-1/+0
At present the tool terminates its execution if one of the overlays passed as command-line arguments can't be successfully read or applied, but the exit code of the process is zero, making failures hard to detect inside scripts. Signed-off-by: Valter Minute <valter.minute@toradex.com> Message-Id: <20191009123256.14248-1-valter.minute@toradex.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-10-09Add .editorconfigMarc-André Lureau1-0/+30
Set code style for various editors. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20191009102025.10179-2-marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-25yamltree: Ensure consistent bracketing of properties with phandlesRob Herring1-0/+21
The dts syntax allows for '<>' around phandles and arg cells or not which it didn't matter until adding type information. However, the YAML encoding expects each phandle + args to be bracketed. If TYPE_UINT32 markers are not present before each REF_PHANDLE, fix up the markers and add the TYPE_UINT32 markers. This allows the subsequent YAML emitting code to work as-is. Adding the markers at an earlier stage doesn't work because of possible labels in dts output. We'd have to define the ordering of labels and brackets. Also, it is probably best to have dts output match the input. Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20190918183534.24205-1-robh@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-10libfdt.h: add explicit cast from void* to uint8_t* in fdt(32|64)_stLuc Michel1-2/+2
Including libfdt.h in a C++ project fails during compilation with recent version of GCC or Clang. This simple example: extern "C" { #include <libfdt.h> } int main(void) { return 0; } leads to the following errors with GCC 9.1.0: /usr/include/libfdt.h: In function ‘void fdt32_st(void*, uint32_t)’: /usr/include/libfdt.h:139:16: error: invalid conversion from ‘void*’ to ‘uint8_t*’ {aka ‘unsigned char*’} [-fpermissive] 139 | uint8_t *bp = property; | ^~~~~~~~ | | | void* /usr/include/libfdt.h: In function ‘void fdt64_st(void*, uint64_t)’: /usr/include/libfdt.h:163:16: error: invalid conversion from ‘void*’ to ‘uint8_t*’ {aka ‘unsigned char*’} [-fpermissive] 163 | uint8_t *bp = property; | ^~~~~~~~ | | | void* This commit adds an explicit cast to uint8_t* to fix this issue. Signed-off-by: Luc Michel <luc.michel@greensocs.com> Message-Id: <20190910104824.1321594-1-luc.michel@greensocs.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-09pylibfdt: use python3 shebangLuca Weiss1-1/+4
The default Python version for pylibfdt is already Python 3 but if called without specifiying an interpreter, the setup.py script gets called with Python 2. It's of course still possible to call setup.py with python2 directly. Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Message-Id: <20190907152530.25102-1-luca@z3ntu.xyz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-09-04Ignore phandle properties in /aliasesv1.5.1David Gibson1-0/+5
The 'alias_paths' check verifies that each property in /aliases is a valid path to another node. However this can cans false positives trees where the /aliases node has a phandle property, which isn't in this format but is allowed. In particular this situation can be common with trees dumped from some real OF systems (which typically generate a phandle for every node). Special case this to avoid the spurious error. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-08-29README: update for Python 3Luca Weiss1-14/+12
Convert the usage to be compatible with Python 3 and the current API. Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Message-Id: <20190817212532.15661-2-luca@z3ntu.xyz> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-08-28livetree: simplify condition in get_node_by_pathDenis Efremov1-2/+1
The "strlen && strprefixeq" check in get_node_by_path is excessive, since strlen is checked in strprefixeq macro internally. Thus, "strlen(child->name) == p-path" conjunct duplicates after macro expansion and could be removed. Signed-off-by: Denis Efremov <efremov@linux.com> Message-Id: <20190827204148.20604-1-efremov@linux.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-07-28libfdt: Allow #size-cells of 0David Gibson3-3/+17
c12b2b0c20eb "libfdt: fdt_address_cells() and fdt_size_cells()" introduced a bug as it consolidated code between the helpers for getting #address-cells and #size-cells. Specifically #size-cells is allowed to be 0, and is frequently found so in practice for /cpus. IEEE1275 only requires implementations to handle 1..4 for #address-cells, although one could make a case for #address-cells == #size-cells == 0 being used to represent a bridge with a single port. While we're there, it's not totally obvious that the existing implicit cast of a u32 to int will give the correct results according to strict C, although it does work in practice. Straighten that up to cast only after we've made our range checks. Reported-by: yonghuhaige via https://github.com/dgibson/dtc/issues/28 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>