You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
924 B

# Common functions for shell testcases
PASS () {
echo "PASS"
exit 0
}
FAIL () {
echo "FAIL" "$@"
exit 2
}
FAIL_IF_SIGNAL () {
ret="$1"
if [ "$ret" -gt 127 ]; then
signame=$(kill -l $((ret - 128)))
FAIL "Killed by SIG$signame"
fi
}
DTC=../dtc
DTGET=../fdtget
Add fdtput utility to write property values to a device tree This simple utility allows writing of values into a device tree from the command line. It aimes to be the opposite of fdtget. What is it for: - Updating fdt values when a binary blob already exists (even though source may be available it might be easier to use this utility rather than sed, etc.) - Writing machine-specific fdt values within a build system To use it, specify the fdt binary file on command line followed by the node and property to set. Then, provide a list of values to put into that property. Often there will be just one, but fdtput also supports arrays and string lists. fdtput does not try to guess the type of the property based on looking at the arguments. Instead it always assumes that an integer is provided. To indicate that you want to write a string, use -ts. You can also provide hex values with -tx. The command line arguments are joined together into a single value. For strings, a nul terminator is placed between each string when it is packed into the property. To avoid this, pass the string as a single argument. Usage: fdtput <options> <dt file> <<node> <property> [<value>...] Options: -t <type> Type of data -v Verbose: display each value decoded from command line -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) To read from stdin and write to stdout, use - as the file. So you can do: cat somefile.dtb | fdtput -ts - /node prop "My string value" > newfile.dtb This commit also adds basic tests to verify the major features. Signed-off-by: Simon Glass <sjg@chromium.org>
13 years ago
DTPUT=../fdtput
FDTDUMP=../fdtdump
FDTOVERLAY=../fdtoverlay
verbose_run () {
if [ -z "$QUIET_TEST" ]; then
"$@"
else
"$@" > /dev/null 2> /dev/null
fi
}
verbose_run_check () {
verbose_run "$@"
ret="$?"
FAIL_IF_SIGNAL $ret
if [ $ret != 0 ]; then
FAIL "Returned error code $ret"
fi
}
verbose_run_log () {
LOG="$1"
shift
"$@" > "$LOG" 2>&1
ret=$?
if [ -z "$QUIET_TEST" ]; then
cat "$LOG" >&2
fi
return $ret
}
verbose_run_log_check () {
verbose_run_log "$@"
ret="$?"
FAIL_IF_SIGNAL $ret
if [ $ret != 0 ]; then
FAIL "Returned error code $ret"
fi
}