Add fdtget utility to read property values from a device tree
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>
2012-01-21 19:14:47 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
. ./tests.sh
|
|
|
|
|
2012-02-03 06:12:04 +01:00
|
|
|
LOG=tmp.log.$$
|
|
|
|
EXPECT=tmp.expect.$$
|
|
|
|
rm -f $LOG $EXPECT
|
|
|
|
trap "rm -f $LOG $EXPECT" 0
|
Add fdtget utility to read property values from a device tree
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>
2012-01-21 19:14:47 +01:00
|
|
|
|
|
|
|
expect="$1"
|
|
|
|
echo "$expect" >$EXPECT
|
|
|
|
shift
|
|
|
|
|
|
|
|
verbose_run_log "$LOG" $VALGRIND "$DTGET" "$@"
|
|
|
|
ret="$?"
|
|
|
|
|
|
|
|
if [ "$ret" -ne 0 -a "$expect" = "ERR" ]; then
|
|
|
|
PASS
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ret" -gt 127 ]; then
|
|
|
|
signame=$(kill -l $[ret - 128])
|
|
|
|
FAIL "Killed by SIG$signame"
|
|
|
|
fi
|
|
|
|
|
|
|
|
diff $EXPECT $LOG
|
|
|
|
ret="$?"
|
|
|
|
|
|
|
|
if [ "$ret" -eq 0 ]; then
|
|
|
|
PASS
|
|
|
|
else
|
|
|
|
FAIL
|
|
|
|
fi
|