* [PATCH 0/5] fdtput: Make it clearer how to create nodes
@ 2026-10-27 12:01 Simon Glass
2026-10-27 12:01 ` [PATCH 1/5] fdtput: Explain " Simon Glass
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Simon Glass @ 2026-10-27 12:01 UTC (permalink / raw)
To: Devicetree Compiler; +Cc: David Gibson, Simon Glass
fdtput can create nodes with -c, and -p creates any missing nodes along
the way, but this is easy to miss. A user has asked for a way to add
nodes, not realising that one exists.
The first patch explains in the help and the manual how to create
nodes. The second fixes -p for a path which starts with an alias, which
creates a stray node at the top level. The third suggests -p when a
node is missing, naming the parent which is missing. The fourth names
the property, rather than the node, when it cannot be deleted. The
fifth corrects the manual's description of -t.
Link: https://github.com/dgibson/dtc/issues/49
Simon Glass (5):
fdtput: Explain how to create nodes
fdtput: Follow an alias when creating nodes with -p
fdtput: Suggest -p when a node is missing
fdtput: Name the property when it cannot be deleted
fdtput: Correct the description of -t in the manual
Documentation/manual.txt | 38 ++++++++++++++++++++++++++++++-----
fdtput.c | 43 ++++++++++++++++++++++++++++++++++------
tests/run_tests.sh | 11 ++++++++++
3 files changed, 81 insertions(+), 11 deletions(-)
---
base-commit: 9a712e0c7fb7eec14cc83a06d7a2ff7910f49b97
branch: fdtput-nodes
--
2.43.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/5] fdtput: Explain how to create nodes
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
@ 2026-10-27 12:01 ` Simon Glass
2026-10-27 12:01 ` [PATCH 2/5] fdtput: Follow an alias when creating nodes with -p Simon Glass
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Simon Glass @ 2026-10-27 12:01 UTC (permalink / raw)
To: Devicetree Compiler; +Cc: David Gibson, Simon Glass
fdtput can create nodes, with -c and -p, but this is easy to miss. A
user has asked for a way to create nodes, not realising that one exists.
The manual also claims that -c creates nodes "if they don't already
exist" and that -r and -d delete things "if they already exist",
suggesting that these are silently skipped otherwise. In fact each of
these fails. The help for -d says the same.
Mention -p in the usage message. Correct the option descriptions in the
manual, describe when each operation fails, and add some examples
showing how to create and delete nodes and properties.
Closes: https://github.com/dgibson/dtc/issues/49
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Documentation/manual.txt | 34 +++++++++++++++++++++++++++++++---
fdtput.c | 3 ++-
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/Documentation/manual.txt b/Documentation/manual.txt
index 598c6e6..00e361b 100644
--- a/Documentation/manual.txt
+++ b/Documentation/manual.txt
@@ -755,9 +755,9 @@ Options are:
Optional modifier prefix:
hh or b=byte, h=2 byte, l=4 byte (default)
- -c, --create Create nodes if they don't already exist
- -r, --remove Delete nodes (and any subnodes) if they already exist
- -d, --delete Delete properties if they already exist
+ -c, --create Create nodes
+ -r, --remove Delete nodes (and any subnodes)
+ -d, --delete Delete properties
-p, --auto-path Automatically create nodes as needed for the node path
-t, --type <arg> Type of data
-v, --verbose Display each value decoded from command line
@@ -771,3 +771,31 @@ create/delete nodes and delete properties.
For the first usage, the command line arguments are joined together into a
single value which is written to the property. The -t option is required so
that fdtput knows how to decode its arguments.
+
+When writing a property, the node must already exist unless -p is given, in
+which case fdtput creates any missing nodes along the node path.
+
+With -c, fdtput creates each node given. This fails if the node already exists
+or its parent does not. Adding -p creates any missing parents as well, and
+does not complain about nodes which already exist.
+
+With -r, it is an error if a node does not exist. With -d, it is an error if a
+property does not exist.
+
+Examples:
+
+ # Add a node to an existing parent
+ fdtput -c test.dtb /soc/serial@1000
+
+ # Add a node, along with any missing parents
+ fdtput -cp test.dtb /soc/bus/serial@2000
+
+ # Write a string property, creating the node if needed
+ fdtput -p -ts test.dtb /soc/i2c@3000 compatible vendor,i2c
+
+ # Write a property with two cells, given in hex
+ fdtput -tx test.dtb /soc/serial@1000 reg 1000 100
+
+ # Delete a property, then a node and its subnodes
+ fdtput -d test.dtb /soc/i2c@3000 compatible
+ fdtput -r test.dtb /soc/bus
diff --git a/fdtput.c b/fdtput.c
index fdb581a..c139de1 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -403,6 +403,7 @@ static const char usage_synopsis[] =
" fdtput -d <options> <dt file> <node> [<property>...]\n"
"\n"
"The command line arguments are joined together into a single value.\n"
+ "Use -p to create any missing nodes in the node path.\n"
USAGE_TYPE_MSG;
static const char usage_short_opts[] = "crdpt:v" USAGE_COMMON_SHORT_OPTS;
static struct option const usage_long_opts[] = {
@@ -417,7 +418,7 @@ static struct option const usage_long_opts[] = {
static const char * const usage_opts_help[] = {
"Create nodes",
"Delete nodes (and any subnodes)",
- "Delete properties if they already exist",
+ "Delete properties",
"Automatically create nodes as needed for the node path",
"Type of data",
"Display each value decoded from command line",
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] fdtput: Follow an alias when creating nodes with -p
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
2026-10-27 12:01 ` [PATCH 1/5] fdtput: Explain " Simon Glass
@ 2026-10-27 12:01 ` Simon Glass
2026-10-28 1:34 ` David Gibson
2026-10-27 12:01 ` [PATCH 3/5] fdtput: Suggest -p when a node is missing Simon Glass
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Simon Glass @ 2026-10-27 12:01 UTC (permalink / raw)
To: Devicetree Compiler; +Cc: David Gibson, Simon Glass
A node path can start with an alias, such as serial0/sub, but -p does
not allow for this. It looks up each part of the path from the root, so
it creates a top-level node named after the alias:
$ fdtput -cp test.dtb serial0/sub
This creates /serial0/sub instead of adding 'sub' to the node which
serial0 points to, and reports success. When writing a property, the
stray node is left behind if the alias is the whole path, and fdtput
fails if the path continues beyond the alias.
When the path starts with an alias, create any missing nodes below the
node which the alias points to. Keep the existing behaviour for other
paths which do not start with '/', which are created from the root.
Fixes: f807af192828 ("fdtput: Add -p option to create subnodes along entire path")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Simon Glass <sjg@chromium.org>
---
fdtput.c | 18 ++++++++++++++++--
tests/run_tests.sh | 7 +++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/fdtput.c b/fdtput.c
index c139de1..4094015 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -201,8 +201,9 @@ static int store_key_value(char **blob, const char *node_name,
/**
* Create paths as needed for all components of a path
*
- * Any components of the path that do not exist are created. Errors are
- * reported.
+ * Any components of the path that do not exist are created. If the path
+ * starts with an alias, they are created below the node which the alias
+ * points to. Otherwise the path starts at the root. Errors are reported.
*
* @param blob FDT blob to write into
* @param in_path Path to process
@@ -214,6 +215,19 @@ static int create_paths(char **blob, const char *in_path)
const char *sep;
int node, offset = 0;
+ /* a path which starts with an alias is created below its node */
+ sep = strchr(path, '/');
+ if (!sep)
+ sep = path + strlen(path);
+ if (sep > path && fdt_get_alias_namelen(*blob, path, sep - path)) {
+ offset = fdt_path_offset_namelen(*blob, path, sep - path);
+ if (offset < 0) {
+ report_error(path, sep - path, offset);
+ return -1;
+ }
+ path = sep;
+ }
+
/* skip leading '/' */
while (*path == '/')
path++;
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 842b543..77f0a81 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -970,6 +970,13 @@ fdtput_tests () {
"-ts" "fine wine"
run_wrap_test $DTPUT $dtb -p /you/are/drunk/sir/winston slurp -ts twice
+ # Automatic node creation below an alias
+ run_wrap_test $DTPUT $dtb -p /aliases second -ts /blackadder/the-second
+ run_wrap_test $DTPUT $dtb -cp second/carrot
+ run_fdtput_test "orange" $dtb second/carrot colour -ts "orange"
+ run_fdtget_test "orange" $dtb /blackadder/the-second/carrot colour
+ run_wrap_error_test $DTGET $dtb -l /second
+
# Test expansion of the blob when insufficient room for a new node
run_wrap_test $DTPUT $dtb -cp "$(cat $text $text)/longish"
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/5] fdtput: Suggest -p when a node is missing
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
2026-10-27 12:01 ` [PATCH 1/5] fdtput: Explain " Simon Glass
2026-10-27 12:01 ` [PATCH 2/5] fdtput: Follow an alias when creating nodes with -p Simon Glass
@ 2026-10-27 12:01 ` Simon Glass
2026-10-28 1:39 ` David Gibson
2026-10-27 12:01 ` [PATCH 4/5] fdtput: Name the property when it cannot be deleted Simon Glass
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Simon Glass @ 2026-10-27 12:01 UTC (permalink / raw)
To: Devicetree Compiler; +Cc: David Gibson, Simon Glass
When the node being written to does not exist, fdtput just prints
FDT_ERR_NOTFOUND - nothing points to -p, which creates missing nodes, so
it is easy to conclude that fdtput cannot add nodes at all.
When creating a node with -c, the error also names the full path, even
though it is the parent which is missing.
Add a hint to use -p when a node is missing, both when writing a
property and when creating a node. Report the parent path when it is
the parent which is missing.
Add tests that writing a property or creating a node fails when a parent
node is missing and -p is not given.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Simon Glass <sjg@chromium.org>
---
fdtput.c | 20 ++++++++++++++++++--
tests/run_tests.sh | 4 ++++
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/fdtput.c b/fdtput.c
index 4094015..c9973d5 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -47,6 +47,22 @@ static void report_error(const char *name, int namelen, int err)
fdt_strerror(err));
}
+/**
+ * Report an error looking up a node which must exist before writing to it.
+ *
+ * If the node is missing, suggest -p, since it creates missing nodes.
+ *
+ * @param name Node name to report error on
+ * @param namelen Length of node name, or -1 to use entire string
+ * @param err Error number to report (-FDT_ERR_...)
+ */
+static void report_node_error(const char *name, int namelen, int err)
+{
+ report_error(name, namelen, err);
+ if (err == -FDT_ERR_NOTFOUND)
+ fprintf(stderr, "Use -p to create missing nodes\n");
+}
+
/**
* Encode a series of arguments in a property value.
*
@@ -182,7 +198,7 @@ static int store_key_value(char **blob, const char *node_name,
node = fdt_path_offset(*blob, node_name);
if (node < 0) {
- report_error(node_name, -1, node);
+ report_node_error(node_name, -1, node);
return -1;
}
@@ -284,7 +300,7 @@ static int create_node(char **blob, const char *node_name)
node = fdt_path_offset(*blob, path);
free(path);
if (node < 0) {
- report_error(node_name, -1, node);
+ report_node_error(node_name, p - node_name, node);
return -1;
}
}
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 77f0a81..7254e53 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -962,6 +962,10 @@ fdtput_tests () {
run_wrap_error_test $DTPUT $dtb -c /chosen
run_wrap_error_test $DTPUT $dtb -c /chosen/son
+ # Missing nodes are not created without -p
+ run_wrap_error_test $DTPUT $dtb -c /blackadder/the-second
+ run_wrap_error_test $DTPUT $dtb /blackadder/the-second cost -ts high
+
# Automatic node creation
run_wrap_test $DTPUT $dtb -cp /blackadder/the-second/turnip \
/blackadder/the-second/potato
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] fdtput: Name the property when it cannot be deleted
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
` (2 preceding siblings ...)
2026-10-27 12:01 ` [PATCH 3/5] fdtput: Suggest -p when a node is missing Simon Glass
@ 2026-10-27 12:01 ` Simon Glass
2026-10-28 1:43 ` David Gibson
2026-10-27 12:01 ` [PATCH 5/5] fdtput: Correct the description of -t in the manual Simon Glass
2026-10-28 1:58 ` [PATCH 0/5] fdtput: Make it clearer how to create nodes David Gibson
5 siblings, 1 reply; 11+ messages in thread
From: Simon Glass @ 2026-10-27 12:01 UTC (permalink / raw)
To: Devicetree Compiler; +Cc: David Gibson, Simon Glass
When 'fdtput -d' fails to delete a property, for example because it does
not exist, the error names the node rather than the property:
$ fdtput -d test.dtb /chosen missing
Error at '/chosen': FDT_ERR_NOTFOUND
This suggests that the node is missing, when it is the property that
is.
Report the property name instead.
Fixes: aa719618a8b7 ("fdtput: add delete node and property function")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Simon Glass <sjg@chromium.org>
---
fdtput.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fdtput.c b/fdtput.c
index c9973d5..8636d5a 100644
--- a/fdtput.c
+++ b/fdtput.c
@@ -334,7 +334,7 @@ static int delete_prop(char *blob, const char *node_name, const char *prop_name)
node = fdt_delprop(blob, node, prop_name);
if (node < 0) {
- report_error(node_name, -1, node);
+ report_error(prop_name, -1, node);
return -1;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] fdtput: Correct the description of -t in the manual
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
` (3 preceding siblings ...)
2026-10-27 12:01 ` [PATCH 4/5] fdtput: Name the property when it cannot be deleted Simon Glass
@ 2026-10-27 12:01 ` Simon Glass
2026-10-28 1:58 ` [PATCH 0/5] fdtput: Make it clearer how to create nodes David Gibson
5 siblings, 0 replies; 11+ messages in thread
From: Simon Glass @ 2026-10-27 12:01 UTC (permalink / raw)
To: Devicetree Compiler; +Cc: David Gibson, Simon Glass
The manual says that the -t option is required so that fdtput knows how
to decode its arguments. This has never been true: without -t, each
argument is taken as a decimal integer.
Correct the text.
Fixes: 4d09a83420df ("fdtput: Add documentation")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Simon Glass <sjg@chromium.org>
---
Documentation/manual.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/manual.txt b/Documentation/manual.txt
index 00e361b..d466645 100644
--- a/Documentation/manual.txt
+++ b/Documentation/manual.txt
@@ -769,8 +769,8 @@ is performed. The first usage adds or updates properties; the rest are used to
create/delete nodes and delete properties.
For the first usage, the command line arguments are joined together into a
-single value which is written to the property. The -t option is required so
-that fdtput knows how to decode its arguments.
+single value which is written to the property. The -t option tells fdtput how
+to decode its arguments. Without it, each argument is a decimal integer.
When writing a property, the node must already exist unless -p is given, in
which case fdtput creates any missing nodes along the node path.
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] fdtput: Follow an alias when creating nodes with -p
2026-10-27 12:01 ` [PATCH 2/5] fdtput: Follow an alias when creating nodes with -p Simon Glass
@ 2026-10-28 1:34 ` David Gibson
0 siblings, 0 replies; 11+ messages in thread
From: David Gibson @ 2026-10-28 1:34 UTC (permalink / raw)
To: Simon Glass; +Cc: Devicetree Compiler
[-- Attachment #1: Type: text/plain, Size: 3899 bytes --]
On Tue, Oct 27, 2026 at 06:01:16AM -0600, Simon Glass wrote:
> A node path can start with an alias, such as serial0/sub, but -p does
> not allow for this. It looks up each part of the path from the root, so
> it creates a top-level node named after the alias:
>
> $ fdtput -cp test.dtb serial0/sub
>
> This creates /serial0/sub instead of adding 'sub' to the node which
> serial0 points to, and reports success. When writing a property, the
> stray node is left behind if the alias is the whole path, and fdtput
> fails if the path continues beyond the alias.
>
> When the path starts with an alias, create any missing nodes below the
> node which the alias points to. Keep the existing behaviour for other
> paths which do not start with '/', which are created from the root.
>
> Fixes: f807af192828 ("fdtput: Add -p option to create subnodes along entire path")
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> fdtput.c | 18 ++++++++++++++++--
> tests/run_tests.sh | 7 +++++++
> 2 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/fdtput.c b/fdtput.c
> index c139de1..4094015 100644
> --- a/fdtput.c
> +++ b/fdtput.c
> @@ -201,8 +201,9 @@ static int store_key_value(char **blob, const char *node_name,
> /**
> * Create paths as needed for all components of a path
> *
> - * Any components of the path that do not exist are created. Errors are
> - * reported.
> + * Any components of the path that do not exist are created. If the path
> + * starts with an alias, they are created below the node which the alias
> + * points to. Otherwise the path starts at the root. Errors are reported.
> *
> * @param blob FDT blob to write into
> * @param in_path Path to process
> @@ -214,6 +215,19 @@ static int create_paths(char **blob, const char *in_path)
> const char *sep;
> int node, offset = 0;
>
> + /* a path which starts with an alias is created below its node */
> + sep = strchr(path, '/');
> + if (!sep)
> + sep = path + strlen(path);
> + if (sep > path && fdt_get_alias_namelen(*blob, path, sep - path)) {
> + offset = fdt_path_offset_namelen(*blob, path, sep - path);
> + if (offset < 0) {
> + report_error(path, sep - path, offset);
> + return -1;
> + }
> + path = sep;
> + }
> +
The previous behaviour was certainly buggy, but I don't think this fix
is quite correct. If 'foo' is *not* an existing alias, then
fdtput -cp test.dtb foo/bar/baz
Will still create /foo/bar/baz, which is not how dt paths generally
work.
Instead, we should look for an alias if and only if there's no leading
'/'. If there's no leading '/' but the first segment is not a valid
alias, then we should error out.
> /* skip leading '/' */
> while (*path == '/')
> path++;
> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> index 842b543..77f0a81 100755
> --- a/tests/run_tests.sh
> +++ b/tests/run_tests.sh
> @@ -970,6 +970,13 @@ fdtput_tests () {
> "-ts" "fine wine"
> run_wrap_test $DTPUT $dtb -p /you/are/drunk/sir/winston slurp -ts twice
>
> + # Automatic node creation below an alias
> + run_wrap_test $DTPUT $dtb -p /aliases second -ts /blackadder/the-second
> + run_wrap_test $DTPUT $dtb -cp second/carrot
> + run_fdtput_test "orange" $dtb second/carrot colour -ts "orange"
> + run_fdtget_test "orange" $dtb /blackadder/the-second/carrot colour
> + run_wrap_error_test $DTGET $dtb -l /second
> +
> # Test expansion of the blob when insufficient room for a new node
> run_wrap_test $DTPUT $dtb -cp "$(cat $text $text)/longish"
>
> --
> 2.43.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] fdtput: Suggest -p when a node is missing
2026-10-27 12:01 ` [PATCH 3/5] fdtput: Suggest -p when a node is missing Simon Glass
@ 2026-10-28 1:39 ` David Gibson
2026-10-28 7:39 ` Simon Glass
0 siblings, 1 reply; 11+ messages in thread
From: David Gibson @ 2026-10-28 1:39 UTC (permalink / raw)
To: Simon Glass; +Cc: Devicetree Compiler
[-- Attachment #1: Type: text/plain, Size: 3311 bytes --]
On Tue, Oct 27, 2026 at 06:01:17AM -0600, Simon Glass wrote:
> When the node being written to does not exist, fdtput just prints
> FDT_ERR_NOTFOUND - nothing points to -p, which creates missing nodes, so
> it is easy to conclude that fdtput cannot add nodes at all.
>
> When creating a node with -c, the error also names the full path, even
> though it is the parent which is missing.
>
> Add a hint to use -p when a node is missing, both when writing a
> property and when creating a node. Report the parent path when it is
> the parent which is missing.
>
> Add tests that writing a property or creating a node fails when a parent
> node is missing and -p is not given.
>
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>
> fdtput.c | 20 ++++++++++++++++++--
> tests/run_tests.sh | 4 ++++
> 2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/fdtput.c b/fdtput.c
> index 4094015..c9973d5 100644
> --- a/fdtput.c
> +++ b/fdtput.c
> @@ -47,6 +47,22 @@ static void report_error(const char *name, int namelen, int err)
> fdt_strerror(err));
> }
>
> +/**
> + * Report an error looking up a node which must exist before writing to it.
> + *
> + * If the node is missing, suggest -p, since it creates missing nodes.
> + *
> + * @param name Node name to report error on
> + * @param namelen Length of node name, or -1 to use entire string
> + * @param err Error number to report (-FDT_ERR_...)
> + */
> +static void report_node_error(const char *name, int namelen, int err)
> +{
> + report_error(name, namelen, err);
> + if (err == -FDT_ERR_NOTFOUND)
> + fprintf(stderr, "Use -p to create missing nodes\n");
> +}
> +
> /**
> * Encode a series of arguments in a property value.
> *
> @@ -182,7 +198,7 @@ static int store_key_value(char **blob, const char *node_name,
>
> node = fdt_path_offset(*blob, node_name);
> if (node < 0) {
> - report_error(node_name, -1, node);
> + report_node_error(node_name, -1, node);
> return -1;
> }
>
> @@ -284,7 +300,7 @@ static int create_node(char **blob, const char *node_name)
> node = fdt_path_offset(*blob, path);
> free(path);
> if (node < 0) {
> - report_error(node_name, -1, node);
> + report_node_error(node_name, p - node_name, node);
> return -1;
> }
> }
> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> index 77f0a81..7254e53 100755
> --- a/tests/run_tests.sh
> +++ b/tests/run_tests.sh
> @@ -962,6 +962,10 @@ fdtput_tests () {
> run_wrap_error_test $DTPUT $dtb -c /chosen
> run_wrap_error_test $DTPUT $dtb -c /chosen/son
>
> + # Missing nodes are not created without -p
> + run_wrap_error_test $DTPUT $dtb -c /blackadder/the-second
> + run_wrap_error_test $DTPUT $dtb /blackadder/the-second cost -ts high
> +
> # Automatic node creation
> run_wrap_test $DTPUT $dtb -cp /blackadder/the-second/turnip \
> /blackadder/the-second/potato
> --
> 2.43.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/5] fdtput: Name the property when it cannot be deleted
2026-10-27 12:01 ` [PATCH 4/5] fdtput: Name the property when it cannot be deleted Simon Glass
@ 2026-10-28 1:43 ` David Gibson
0 siblings, 0 replies; 11+ messages in thread
From: David Gibson @ 2026-10-28 1:43 UTC (permalink / raw)
To: Simon Glass; +Cc: Devicetree Compiler
[-- Attachment #1: Type: text/plain, Size: 1507 bytes --]
On Tue, Oct 27, 2026 at 06:01:18AM -0600, Simon Glass wrote:
> When 'fdtput -d' fails to delete a property, for example because it does
> not exist, the error names the node rather than the property:
>
> $ fdtput -d test.dtb /chosen missing
> Error at '/chosen': FDT_ERR_NOTFOUND
>
> This suggests that the node is missing, when it is the property that
> is.
>
> Report the property name instead.
>
> Fixes: aa719618a8b7 ("fdtput: add delete node and property function")
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Simon Glass <sjg@chromium.org>
I agree it would be useful to show the property name, but
Error at '<property name'
Doesn't seem very usefully descriptive to me, and the node name _also_
seems useful. I think we should print both in such cases.
> ---
>
> fdtput.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fdtput.c b/fdtput.c
> index c9973d5..8636d5a 100644
> --- a/fdtput.c
> +++ b/fdtput.c
> @@ -334,7 +334,7 @@ static int delete_prop(char *blob, const char *node_name, const char *prop_name)
>
> node = fdt_delprop(blob, node, prop_name);
> if (node < 0) {
> - report_error(node_name, -1, node);
> + report_error(prop_name, -1, node);
> return -1;
> }
>
> --
> 2.43.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/5] fdtput: Make it clearer how to create nodes
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
` (4 preceding siblings ...)
2026-10-27 12:01 ` [PATCH 5/5] fdtput: Correct the description of -t in the manual Simon Glass
@ 2026-10-28 1:58 ` David Gibson
5 siblings, 0 replies; 11+ messages in thread
From: David Gibson @ 2026-10-28 1:58 UTC (permalink / raw)
To: Simon Glass; +Cc: Devicetree Compiler
[-- Attachment #1: Type: text/plain, Size: 1709 bytes --]
On Tue, Oct 27, 2026 at 06:01:14AM -0600, Simon Glass wrote:
> fdtput can create nodes with -c, and -p creates any missing nodes along
> the way, but this is easy to miss. A user has asked for a way to add
> nodes, not realising that one exists.
>
> The first patch explains in the help and the manual how to create
> nodes. The second fixes -p for a path which starts with an alias, which
> creates a stray node at the top level. The third suggests -p when a
> node is missing, naming the parent which is missing. The fourth names
> the property, rather than the node, when it cannot be deleted. The
> fifth corrects the manual's description of -t.
>
> Link: https://github.com/dgibson/dtc/issues/49
I've merged patches 1 & 5. I think 2 & 4 need some refinement. 3
looks good to me, but I haven't merged since it may depend on 2.
>
>
> Simon Glass (5):
> fdtput: Explain how to create nodes
> fdtput: Follow an alias when creating nodes with -p
> fdtput: Suggest -p when a node is missing
> fdtput: Name the property when it cannot be deleted
> fdtput: Correct the description of -t in the manual
>
> Documentation/manual.txt | 38 ++++++++++++++++++++++++++++++-----
> fdtput.c | 43 ++++++++++++++++++++++++++++++++++------
> tests/run_tests.sh | 11 ++++++++++
> 3 files changed, 81 insertions(+), 11 deletions(-)
>
> ---
> base-commit: 9a712e0c7fb7eec14cc83a06d7a2ff7910f49b97
> branch: fdtput-nodes
>
> --
> 2.43.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] fdtput: Suggest -p when a node is missing
2026-10-28 1:39 ` David Gibson
@ 2026-10-28 7:39 ` Simon Glass
0 siblings, 0 replies; 11+ messages in thread
From: Simon Glass @ 2026-10-28 7:39 UTC (permalink / raw)
To: David Gibson; +Cc: Devicetree Compiler
Hi David,
On Wed, 28 Oct 2026 at 01:47, David Gibson <david@gibson.dropbear.id.au> wrote:
>
> On Tue, Oct 27, 2026 at 06:01:17AM -0600, Simon Glass wrote:
> > When the node being written to does not exist, fdtput just prints
> > FDT_ERR_NOTFOUND - nothing points to -p, which creates missing nodes, so
> > it is easy to conclude that fdtput cannot add nodes at all.
> >
> > When creating a node with -c, the error also names the full path, even
> > though it is the parent which is missing.
> >
> > Add a hint to use -p when a node is missing, both when writing a
> > property and when creating a node. Report the parent path when it is
> > the parent which is missing.
> >
> > Add tests that writing a property or creating a node fails when a parent
> > node is missing and -p is not given.
> >
> > Assisted-by: Claude:claude-opus-5-5
> > Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
I ended up changing this a bit so dropped your review tag on v2.
[..]
Regards,
Simon
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-10-28 7:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 12:01 [PATCH 0/5] fdtput: Make it clearer how to create nodes Simon Glass
2026-10-27 12:01 ` [PATCH 1/5] fdtput: Explain " Simon Glass
2026-10-27 12:01 ` [PATCH 2/5] fdtput: Follow an alias when creating nodes with -p Simon Glass
2026-10-28 1:34 ` David Gibson
2026-10-27 12:01 ` [PATCH 3/5] fdtput: Suggest -p when a node is missing Simon Glass
2026-10-28 1:39 ` David Gibson
2026-10-28 7:39 ` Simon Glass
2026-10-27 12:01 ` [PATCH 4/5] fdtput: Name the property when it cannot be deleted Simon Glass
2026-10-28 1:43 ` David Gibson
2026-10-27 12:01 ` [PATCH 5/5] fdtput: Correct the description of -t in the manual Simon Glass
2026-10-28 1:58 ` [PATCH 0/5] fdtput: Make it clearer how to create nodes David Gibson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.