aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-05-04Add METADATA to dtc: LGPL+GPL=RESTRICTED am: d0d4dc4b82Bob Badour
Change-Id: I87bb85b03484086644d4898c641b3b2a459fad29
2020-04-28Add METADATA to dtc: LGPL+GPL=RESTRICTEDBob Badour
Bug: 68860345 Bug: 69058154 Bug: 151953481 Test: no code changes Change-Id: Iad5c32087e0680d82d6d98461155660b1f8d70b6
2020-04-14Fix some potential unaligned accesses in dtcDavid Gibson
Because of the convention of packed representations in property layouts, it's not uncommon to have integer values in properties which aren't naturally aligned. Thus, there are several places in the dtc code where we cast a potentially unaligned byte pointer into an integer pointer and load it directly. On a number of architectures (including sparc64 and arm) this won't work and will cause a fault. In some cases it may be trapped and emulated by the kernel, but not always. Therefore, replace such direct unaligned reads with a helper which will handle unaligned data reads (a variant on the fdtXX_ld() functions already used in libfdt). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-10check: Inform about missing rangesArkadiusz Drabczyk
In check_unit_address_vs_reg() warning message already says 'reg _or_ ranges' when reg or ranges are present but unit name is missing. Add this message for compatibility to say "reg _or_ ranges" when unit name is present but neither reg nor ranges are present. Signed-off-by: Arkadiusz Drabczyk <arkadiusz@drabczyk.org> Message-Id: <20200308165643.19281-1-arkadiusz@drabczyk.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-06libfdt: fix undefined behaviour in fdt_splice_()Jan Beulich
libfdt: fix undefined behaviour in fdt_splice_() Along the lines of commit d0b3ab0a0f46 ("libfdt: Fix undefined behaviour in fdt_offset_ptr()"), fdt_splice_() similarly may not use pointer arithmetic to do overflow checks. (The left side of the checks added by d4c7c25c9ed1 ["libfdt: check for potential overrun in _fdt_splice()"] doesn't really lend itself to similar replacement though.) Signed-off-by: Jan Beulich <jbeulich@suse.com> Message-Id: <f2d09e81-7cb8-c5cc-9699-1ac05b0626ff@suse.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04Bump version to v1.6.0David Gibson
We've accumulated some new features and a bunch of fixes. Also the versioning on v1.5.1 was messed up :(. Prepare for another release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04Execute tests on FreeBSD with Cirrus CIDavid Gibson
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2020-03-04tests: Allow running the testsuite on already installed binary / librariesDavid Gibson
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 Gibson
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 Gibson
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 Gibson
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 Gibson
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 Gibson
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 Gibson
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 Herring
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Glass
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 Herring
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 Mueller
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 Gibson
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 Maste
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 Huth
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 Maste
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 Maste
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 Maste
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 Mavrodiev
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 Mavrodiev
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 Glass
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 Maste
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 Gibson
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 Gibson
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 Sommer
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 Glass
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é Lureau
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é Lureau
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é Lureau
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é Lureau
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é Lureau
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 Minute
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é Lureau
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>