ANDROID: Merge upstream c2ccf8a77d
(v1.6.1)
Bug: 238913758 Test: - Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Change-Id: I43c4e721d5778e5b214c70c6084026a4bb4933b8
This commit is contained in:
commit
354123a2d1
11 changed files with 235 additions and 125 deletions
79
CONTRIBUTING.md
Normal file
79
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,79 @@
|
|||
# Contributing to dtc or libfdt
|
||||
|
||||
There are two ways to submit changes for dtc or libfdt:
|
||||
|
||||
* Post patches directly to the the
|
||||
[devicetree-compiler](mailto:devicetree-compiler@vger.kernel.org)
|
||||
mailing list.
|
||||
* Submit pull requests via
|
||||
[Github](https://github.com/dgibson/dtc/pulls)
|
||||
|
||||
## Adding a new function to libfdt.h
|
||||
|
||||
The shared library uses `libfdt/version.lds` to list the exported
|
||||
functions, so add your new function there. Check that your function
|
||||
works with pylibfdt. If it cannot be supported, put the declaration in
|
||||
`libfdt.h` behind `#ifndef SWIG` so that swig ignores it.
|
||||
|
||||
## Tests
|
||||
|
||||
Test files are kept in the `tests/` directory. Use `make check` to build and run
|
||||
all tests.
|
||||
|
||||
If you want to adjust a test file, be aware that `tree_tree1.dts` is compiled
|
||||
and checked against a binary tree from assembler macros in `trees.S`. So
|
||||
if you change that file you must change `tree.S` also.
|
||||
|
||||
## Developer's Certificate of Origin
|
||||
|
||||
Like many other projects, dtc and libfdt have adopted the "Developer's
|
||||
Certificate of Origin" (Signed-off-by) process created by the Linux
|
||||
kernel community to improve tracking of who did what. Here's how it
|
||||
works (this is a very slight modification of the description from
|
||||
`Documentation/process/submitting-patches.rst` in the kernel tree):
|
||||
|
||||
The sign-off is a simple line at the end of the explanation for the
|
||||
patch, which certifies that you wrote it or otherwise have the right
|
||||
to pass it on as an open-source patch. The rules are pretty simple:
|
||||
if you can certify the below:
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
then you just add a line saying::
|
||||
|
||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||
|
||||
using your real name (sorry, no pseudonyms or anonymous
|
||||
contributions.) This will be done for you automatically if you use
|
||||
`git commit -s`. Reverts should also include "Signed-off-by". `git
|
||||
revert -s` does that for you.
|
||||
|
||||
Any further SoBs (Signed-off-by:'s) following the author's SoB are
|
||||
from people handling and transporting the patch, but were not involved
|
||||
in its development. SoB chains should reflect the **real** route a
|
||||
patch took as it was propagated to the maintainers, with the first SoB
|
||||
entry signalling primary authorship of a single author.
|
13
Makefile
13
Makefile
|
@ -198,6 +198,13 @@ LIBFDT_lib = $(LIBFDT_dir)/$(LIBFDT_LIB)
|
|||
LIBFDT_include = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_INCLUDES))
|
||||
LIBFDT_version = $(addprefix $(LIBFDT_dir)/,$(LIBFDT_VERSION))
|
||||
|
||||
ifeq ($(STATIC_BUILD),1)
|
||||
CFLAGS += -static
|
||||
LIBFDT_dep = $(LIBFDT_archive)
|
||||
else
|
||||
LIBFDT_dep = $(LIBFDT_lib)
|
||||
endif
|
||||
|
||||
include $(LIBFDT_dir)/Makefile.libfdt
|
||||
|
||||
.PHONY: libfdt
|
||||
|
@ -261,11 +268,11 @@ convert-dtsv0: $(CONVERT_OBJS)
|
|||
|
||||
fdtdump: $(FDTDUMP_OBJS)
|
||||
|
||||
fdtget: $(FDTGET_OBJS) $(LIBFDT_lib)
|
||||
fdtget: $(FDTGET_OBJS) $(LIBFDT_dep)
|
||||
|
||||
fdtput: $(FDTPUT_OBJS) $(LIBFDT_lib)
|
||||
fdtput: $(FDTPUT_OBJS) $(LIBFDT_dep)
|
||||
|
||||
fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_lib)
|
||||
fdtoverlay: $(FDTOVERLAY_OBJS) $(LIBFDT_dep)
|
||||
|
||||
dist:
|
||||
git archive --format=tar --prefix=dtc-$(dtc_version)/ HEAD \
|
||||
|
|
106
README
106
README
|
@ -1,106 +0,0 @@
|
|||
The source tree contains the Device Tree Compiler (dtc) toolchain for
|
||||
working with device tree source and binary files and also libfdt, a
|
||||
utility library for reading and manipulating the binary format.
|
||||
|
||||
DTC and LIBFDT are maintained by:
|
||||
|
||||
David Gibson <david@gibson.dropbear.id.au>
|
||||
Jon Loeliger <loeliger@gmail.com>
|
||||
|
||||
|
||||
Python library
|
||||
--------------
|
||||
|
||||
A Python library is also available. To build this you will need to install
|
||||
swig and Python development files. On Debian distributions:
|
||||
|
||||
sudo apt-get install swig python3-dev
|
||||
|
||||
The library provides an Fdt class which you can use like this:
|
||||
|
||||
$ PYTHONPATH=../pylibfdt python3
|
||||
>>> import libfdt
|
||||
>>> fdt = libfdt.Fdt(open('test_tree1.dtb', mode='rb').read())
|
||||
>>> node = fdt.path_offset('/subnode@1')
|
||||
>>> print(node)
|
||||
124
|
||||
>>> prop_offset = fdt.first_property_offset(node)
|
||||
>>> prop = fdt.get_property_by_offset(prop_offset)
|
||||
>>> print('%s=%s' % (prop.name, prop.as_str()))
|
||||
compatible=subnode1
|
||||
>>> node2 = fdt.path_offset('/')
|
||||
>>> print(fdt.getprop(node2, 'compatible').as_str())
|
||||
test_tree1
|
||||
|
||||
You will find tests in tests/pylibfdt_tests.py showing how to use each
|
||||
method. Help is available using the Python help command, e.g.:
|
||||
|
||||
$ cd pylibfdt
|
||||
$ python3 -c "import libfdt; help(libfdt)"
|
||||
|
||||
If you add new features, please check code coverage:
|
||||
|
||||
$ sudo apt-get install python3-coverage
|
||||
$ cd tests
|
||||
# It's just 'coverage' on most other distributions
|
||||
$ python3-coverage run pylibfdt_tests.py
|
||||
$ python3-coverage html
|
||||
# Open 'htmlcov/index.html' in your browser
|
||||
|
||||
|
||||
The library can be installed with pip from a local source tree:
|
||||
|
||||
pip install . [--user|--prefix=/path/to/install_dir]
|
||||
|
||||
Or directly from a remote git repo:
|
||||
|
||||
pip install git+git://git.kernel.org/pub/scm/utils/dtc/dtc.git@main
|
||||
|
||||
The install depends on libfdt shared library being installed on the host system
|
||||
first. Generally, using --user or --prefix is not necessary and pip will use the
|
||||
default location for the Python installation which varies if the user is root or
|
||||
not.
|
||||
|
||||
You can also install everything via make if you like, but pip is recommended.
|
||||
|
||||
To install both libfdt and pylibfdt you can use:
|
||||
|
||||
make install [PREFIX=/path/to/install_dir]
|
||||
|
||||
To disable building the python library, even if swig and Python are available,
|
||||
use:
|
||||
|
||||
make NO_PYTHON=1
|
||||
|
||||
|
||||
More work remains to support all of libfdt, including access to numeric
|
||||
values.
|
||||
|
||||
|
||||
Adding a new function to libfdt.h
|
||||
---------------------------------
|
||||
|
||||
The shared library uses libfdt/version.lds to list the exported functions, so
|
||||
add your new function there. Check that your function works with pylibfdt. If
|
||||
it cannot be supported, put the declaration in libfdt.h behind #ifndef SWIG so
|
||||
that swig ignores it.
|
||||
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
Test files are kept in the tests/ directory. Use 'make check' to build and run
|
||||
all tests.
|
||||
|
||||
If you want to adjust a test file, be aware that tree_tree1.dts is compiled
|
||||
and checked against a binary tree from assembler macros in trees.S. So
|
||||
if you change that file you must change tree.S also.
|
||||
|
||||
|
||||
Mailing list
|
||||
------------
|
||||
The following list is for discussion about dtc and libfdt implementation
|
||||
mailto:devicetree-compiler@vger.kernel.org
|
||||
|
||||
Core device tree bindings are discussed on the devicetree-spec list:
|
||||
mailto:devicetree-spec@vger.kernel.org
|
100
README.md
Normal file
100
README.md
Normal file
|
@ -0,0 +1,100 @@
|
|||
# Device Tree Compiler and libfdt
|
||||
|
||||
The source tree contains the Device Tree Compiler (dtc) toolchain for
|
||||
working with device tree source and binary files and also libfdt, a
|
||||
utility library for reading and manipulating the binary format.
|
||||
|
||||
dtc and libfdt are maintained by:
|
||||
|
||||
* [David Gibson `<david@gibson.dropbear.id.au>`](mailto:david@gibson.dropbear.id.au)
|
||||
|
||||
## Python library
|
||||
|
||||
A Python library wrapping libfdt is also available. To build this you
|
||||
will need to install `swig` and Python development files. On Debian
|
||||
distributions:
|
||||
|
||||
```
|
||||
$ sudo apt-get install swig python3-dev
|
||||
```
|
||||
|
||||
The library provides an `Fdt` class which you can use like this:
|
||||
|
||||
```
|
||||
$ PYTHONPATH=../pylibfdt python3
|
||||
>>> import libfdt
|
||||
>>> fdt = libfdt.Fdt(open('test_tree1.dtb', mode='rb').read())
|
||||
>>> node = fdt.path_offset('/subnode@1')
|
||||
>>> print(node)
|
||||
124
|
||||
>>> prop_offset = fdt.first_property_offset(node)
|
||||
>>> prop = fdt.get_property_by_offset(prop_offset)
|
||||
>>> print('%s=%s' % (prop.name, prop.as_str()))
|
||||
compatible=subnode1
|
||||
>>> node2 = fdt.path_offset('/')
|
||||
>>> print(fdt.getprop(node2, 'compatible').as_str())
|
||||
test_tree1
|
||||
```
|
||||
|
||||
You will find tests in `tests/pylibfdt_tests.py` showing how to use each
|
||||
method. Help is available using the Python help command, e.g.:
|
||||
|
||||
```
|
||||
$ cd pylibfdt
|
||||
$ python3 -c "import libfdt; help(libfdt)"
|
||||
```
|
||||
|
||||
If you add new features, please check code coverage:
|
||||
|
||||
```
|
||||
$ sudo apt-get install python3-coverage
|
||||
$ cd tests
|
||||
# It's just 'coverage' on most other distributions
|
||||
$ python3-coverage run pylibfdt_tests.py
|
||||
$ python3-coverage html
|
||||
# Open 'htmlcov/index.html' in your browser
|
||||
```
|
||||
|
||||
The library can be installed with pip from a local source tree:
|
||||
|
||||
```
|
||||
$ pip install . [--user|--prefix=/path/to/install_dir]
|
||||
```
|
||||
|
||||
Or directly from a remote git repo:
|
||||
|
||||
```
|
||||
$ pip install git+git://git.kernel.org/pub/scm/utils/dtc/dtc.git@main
|
||||
```
|
||||
|
||||
The install depends on libfdt shared library being installed on the
|
||||
host system first. Generally, using `--user` or `--prefix` is not
|
||||
necessary and pip will use the default location for the Python
|
||||
installation which varies if the user is root or not.
|
||||
|
||||
You can also install everything via make if you like, but pip is
|
||||
recommended.
|
||||
|
||||
To install both libfdt and pylibfdt you can use:
|
||||
|
||||
```
|
||||
$ make install [PREFIX=/path/to/install_dir]
|
||||
```
|
||||
|
||||
To disable building the python library, even if swig and Python are available,
|
||||
use:
|
||||
|
||||
```
|
||||
$ make NO_PYTHON=1
|
||||
```
|
||||
|
||||
More work remains to support all of libfdt, including access to numeric
|
||||
values.
|
||||
|
||||
## Mailing lists
|
||||
|
||||
* The [devicetree-compiler](mailto:devicetree-compiler@vger.kernel.org)
|
||||
list is for discussion about dtc and libfdt implementation.
|
||||
* Core device tree bindings are discussed on the
|
||||
[devicetree-spec](mailto:devicetree-spec@vger.kernel.org) list.
|
||||
|
|
@ -66,7 +66,7 @@ int fdt_check_full(const void *fdt, size_t bufsize)
|
|||
int len;
|
||||
|
||||
name = fdt_get_name(fdt, offset, &len);
|
||||
if (*name || len)
|
||||
if (!name || *name || len)
|
||||
return -FDT_ERR_BADSTRUCTURE;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -31,9 +31,15 @@ libfdt_a = static_library(
|
|||
|
||||
libfdt_inc = include_directories('.')
|
||||
|
||||
if static_build
|
||||
link_with = libfdt_a
|
||||
else
|
||||
link_with = libfdt
|
||||
endif
|
||||
|
||||
libfdt_dep = declare_dependency(
|
||||
include_directories: libfdt_inc,
|
||||
link_with: libfdt,
|
||||
link_with: link_with,
|
||||
)
|
||||
|
||||
install_headers(
|
||||
|
|
14
meson.build
14
meson.build
|
@ -31,8 +31,16 @@ add_project_arguments(
|
|||
language: 'c'
|
||||
)
|
||||
|
||||
if get_option('static-build')
|
||||
static_build = true
|
||||
extra_link_args = ['-static']
|
||||
else
|
||||
static_build = false
|
||||
extra_link_args = []
|
||||
endif
|
||||
|
||||
yamltree = 'yamltree.c'
|
||||
yaml = dependency('yaml-0.1', required: get_option('yaml'))
|
||||
yaml = dependency('yaml-0.1', required: get_option('yaml'), static: static_build)
|
||||
if not yaml.found()
|
||||
add_project_arguments('-DNO_YAML', language: 'c')
|
||||
yamltree = []
|
||||
|
@ -85,6 +93,7 @@ if get_option('tools')
|
|||
],
|
||||
dependencies: util_dep,
|
||||
install: true,
|
||||
link_args: extra_link_args,
|
||||
)
|
||||
endif
|
||||
|
||||
|
@ -105,10 +114,11 @@ if get_option('tools')
|
|||
],
|
||||
dependencies: [util_dep, yaml],
|
||||
install: true,
|
||||
link_args: extra_link_args,
|
||||
)
|
||||
|
||||
foreach e: ['fdtdump', 'fdtget', 'fdtput', 'fdtoverlay']
|
||||
executable(e, files(e + '.c'), dependencies: util_dep, install: true)
|
||||
executable(e, files(e + '.c'), dependencies: util_dep, install: true, link_args: extra_link_args)
|
||||
endforeach
|
||||
|
||||
install_data(
|
||||
|
|
|
@ -8,3 +8,5 @@ option('valgrind', type: 'feature', value: 'auto',
|
|||
description: 'Valgrind support')
|
||||
option('python', type: 'feature', value: 'auto',
|
||||
description: 'Build pylibfdt Python library')
|
||||
option('static-build', type: 'boolean', value: false,
|
||||
description: 'Build static binaries')
|
||||
|
|
|
@ -37,8 +37,10 @@ LIBTREE_TESTS_L = truncated_property truncated_string truncated_memrsv \
|
|||
|
||||
LIBTREE_TESTS = $(LIBTREE_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
|
||||
DL_LIB_TESTS_L = asm_tree_dump value-labels
|
||||
DL_LIB_TESTS = $(DL_LIB_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
ifneq ($(STATIC_BUILD),1)
|
||||
DL_LIB_TESTS_L = asm_tree_dump value-labels
|
||||
DL_LIB_TESTS = $(DL_LIB_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
endif
|
||||
|
||||
TESTS = $(LIB_TESTS) $(LIBTREE_TESTS) $(DL_LIB_TESTS)
|
||||
|
||||
|
@ -60,17 +62,17 @@ TESTS_CLEANDIRS = $(TESTS_CLEANDIRS_L:%=$(TESTS_PREFIX)%)
|
|||
.PHONY: tests
|
||||
tests: $(TESTS) $(TESTS_TREES)
|
||||
|
||||
$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib)
|
||||
$(LIB_TESTS): %: $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep)
|
||||
|
||||
# Not necessary on all platforms; allow -ldl to be excluded instead of forcing
|
||||
# other platforms to patch it out.
|
||||
LIBDL = -ldl
|
||||
$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_lib)
|
||||
$(DL_LIB_TESTS): %: %.o $(TESTS_PREFIX)testutils.o util.o $(LIBFDT_dep)
|
||||
@$(VECHO) LD [libdl] $@
|
||||
$(LINK.c) -o $@ $^ $(LIBDL)
|
||||
|
||||
$(LIBTREE_TESTS): %: $(TESTS_PREFIX)testutils.o $(TESTS_PREFIX)trees.o \
|
||||
util.o $(LIBFDT_lib)
|
||||
util.o $(LIBFDT_dep)
|
||||
|
||||
$(TESTS_PREFIX)dumptrees: $(TESTS_PREFIX)trees.o
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ tests = [
|
|||
'property_iterate',
|
||||
'propname_escapes',
|
||||
'references',
|
||||
'relref_merge',
|
||||
'root_node',
|
||||
'rw_oom',
|
||||
'rw_tree1',
|
||||
|
@ -95,15 +96,20 @@ tests += [
|
|||
]
|
||||
|
||||
dl = cc.find_library('dl', required: false)
|
||||
if dl.found()
|
||||
if dl.found() and not static_build
|
||||
tests += [
|
||||
'asm_tree_dump',
|
||||
'value-labels',
|
||||
]
|
||||
endif
|
||||
|
||||
test_deps = [testutil_dep, util_dep, libfdt_dep]
|
||||
if not static_build
|
||||
test_deps += [dl]
|
||||
endif
|
||||
|
||||
foreach t: tests
|
||||
executable(t, files(t + '.c'), dependencies: [testutil_dep, util_dep, libfdt_dep, dl])
|
||||
executable(t, files(t + '.c'), dependencies: test_deps, link_args: extra_link_args)
|
||||
endforeach
|
||||
|
||||
run_tests = find_program('run_tests.sh')
|
||||
|
|
|
@ -195,7 +195,7 @@ asm_to_so_test () {
|
|||
run_fdtget_test () {
|
||||
expect="$1"
|
||||
shift
|
||||
printf "fdtget-runtest.sh %s $*: " "$(echo $expect)"
|
||||
printf "fdtget-runtest.sh \"%s\" $*: " "$expect"
|
||||
base_run_test sh "$SRCDIR/fdtget-runtest.sh" "$expect" "$@"
|
||||
}
|
||||
|
||||
|
@ -607,11 +607,15 @@ dtc_tests () {
|
|||
run_dtc_test -I dts -O asm -o oasm_$tree.test.s "$SRCDIR/$tree"
|
||||
asm_to_so_test oasm_$tree
|
||||
run_dtc_test -I dts -O dtb -o $tree.test.dtb "$SRCDIR/$tree"
|
||||
run_test asm_tree_dump ./oasm_$tree.test.so oasm_$tree.test.dtb
|
||||
run_wrap_test cmp oasm_$tree.test.dtb $tree.test.dtb
|
||||
if [ -x ./asm_tree_dump ]; then
|
||||
run_test asm_tree_dump ./oasm_$tree.test.so oasm_$tree.test.dtb
|
||||
run_wrap_test cmp oasm_$tree.test.dtb $tree.test.dtb
|
||||
fi
|
||||
done
|
||||
|
||||
run_test value-labels ./oasm_value-labels.dts.test.so
|
||||
if [ -x ./value-labels ]; then
|
||||
run_test value-labels ./oasm_value-labels.dts.test.so
|
||||
fi
|
||||
|
||||
# Check -Odts mode preserve all dtb information
|
||||
for tree in test_tree1.dtb dtc_tree1.test.dtb dtc_escapes.test.dtb \
|
||||
|
@ -862,7 +866,7 @@ fdtget_tests () {
|
|||
run_fdtget_test "61 62 63 0" -tbx $dtb /randomnode tricky1
|
||||
run_fdtget_test "a b c d de ea ad be ef" -tbx $dtb /randomnode blob
|
||||
run_fdtget_test "MyBoardName\0MyBoardFamilyName\0" -tr $dtb / compatible
|
||||
run_fdtget_test "\x0a\x0b\x0c\x0d\xde\xea\xad\xbe\xef" -tr $dtb /randomnode blob
|
||||
run_fdtget_test "\012\013\014\015\336\352\255\276\357" -tr $dtb /randomnode blob
|
||||
|
||||
# Here the property size is not a multiple of 4 bytes, so it should fail
|
||||
run_wrap_error_test $DTGET -tlx $dtb /randomnode mixed
|
||||
|
|
Loading…
Reference in a new issue