fdtgrep: Add option to reserve free space in the output FDT
PATCH 1/1 fdtgrep: Add option to reserve free space in the output FDT
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after fdt_pack(), so it is not reclaimed when -r is used.
---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)
tools/binman/btool/fdtgrep.py +2 -1
@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb) -Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grep
tools/fdtgrep.c +30 -1
@@ -64,6 +64,7 @@ struct display_info {int types_exc;/* Mask of types that we exclude (FDT_IS...) */ int invert;/* Invert polarity of match */ int props_up;/* Imply properties up to supernodes */ +int pad;/* Free bytes to append after the strings section */ struct value_node *value_head;/* List of values to match */ const char *output_fname;/* Output filename */ FILE *fout;/* File to write dts/dtb output */
@@ -913,6 +914,27 @@ static int do_fdtgrep(struct display_info *disp, const char *filename) size =fdt_totalsize (fdt); } +if (disp->pad) { +int new_size =fdt_totalsize (fdt) + disp->pad; +void *new_fdt =realloc (fdt, new_size); + +if (!new_fdt) { +fprintf (stderr,"Out_of_memory\n" ); + ret =-1 ; + goto err; + } + fdt = new_fdt; + ret =fdt_open_into (fdt, fdt, new_size); +if (ret <0 ) { +fprintf (stderr, +"Failed to expand FDT: %s\n" , +fdt_strerror (ret)); + goto err; + } +memset ((char *)fdt + size,'\0' , new_size - size); + size = new_size; + } +if ((size_t )size !=fwrite (fdt,1 , size, disp->fout)) {fprintf (stderr,"Write failure, %d bytes\n" , size);free (fdt);
@@ -965,11 +987,12 @@ static const char usage_synopsis[] =case '?' :usage ("unknown option" );static const char usage_short_opts[] = -"haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTuv" +"haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTuv" USAGE_COMMON_SHORT_OPTS ;static const struct option usage_long_opts[] = { {"show-address" , no_argument,NULL ,'a' }, {"colour" , no_argument,NULL ,'A' }, + {"pad" , a_argument,NULL ,'B' }, {"include-node-with-prop" , a_argument,NULL ,'b' }, {"include-compat" , a_argument,NULL ,'c' }, {"exclude-compat" , a_argument,NULL ,'C' },
@@ -1002,6 +1025,7 @@ static const struct option usage_long_opts[] = {static const char *const usage_opts_help[] = {"Display address" ,"Show all nodes/tags, colour those that match" , +"Append free space to the output FDT, for later growth" ,"Include contains containing property" ,"Compatible nodes to include in grep" ,"Compatible nodes to exclude in grep" ,
@@ -1132,6 +1156,11 @@ static void scan_args(struct display_info *disp, int argc, char *argv[])case 'A' : disp->all =1 ;break ; +case 'B' : + disp->pad =atoi (optarg); +if (disp->pad <0 ) +usage ("Padding must be non-negative" ); +break ;case 'b' : type =FDT_NODE_HAS_PROP ;break ;
---
base-commit: 052988aa29bfd506d7ce207fbb3f5374a5dbecbb
branch: fdtgrep
Signature · 1 line
2.43.0
Quoted 22 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0
tools/binman/btool/fdtgrep.py Output formats are: · line 22
Quoted 8 lines
tools/binman/btool/fdtgrep.py +2
-1@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb) -Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth
Shouldn't the parameter at least match the dtc -p parameter ? -p is not taken yet.
Hi Marek,
Quoted 27 lines · Marek Vasut
Quoted 25 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb)
Quoted 7 lines
tools/binman/btool/fdtgrep.py Output formats are: · line 22
Quoted 5 lines
tools/binman/btool/fdtgrep.py +2
-1-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growthShouldn't the parameter at least match the dtc -p parameter ? -p is not taken yet.
We have:
-p, --include-prop <arg> Property to include in grep
Regards,
Simon
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
Quoted 19 lines
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically)
tools/binman/btool/fdtgrep.py Output formats are: · line 25
Quoted 10 lines
tools/binman/btool/fdtgrep.py +2
-1bin - device tree fragment (may not be a valid .dtb) -Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grep
I'm tempted to remove this and just tell people to look at the documentation in tools/fdtgrep.c. Especially since we don't actually allow the user to pass any of those parameters themselves via the bintool, so it isn't actually useful.
Quoted 13 lines
tools/fdtgrep.c +1
-0@@ -64,6 +64,7 @@ struct display_info {int types_exc;/* Mask of types that we exclude (FDT_IS...) */ int invert;/* Invert polarity of match */ int props_up;/* Imply properties up to supernodes */ +int pad;/* Free bytes to append after the strings section */ struct value_node *value_head;/* List of values to match */ const char *output_fname;/* Output filename */ FILE *fout;/* File to write dts/dtb output */
tools/fdtgrep.c static int do_fdtgrep(struct display_info *disp, const char *filename) · line 922
Quoted 9 lines
tools/fdtgrep.c +6
-0@@ -913,6 +914,27 @@ static int do_fdtgrep(struct display_info *disp, const char *filename) size =fdt_totalsize (fdt); } +if (disp->pad) { +int new_size =fdt_totalsize (fdt) + disp->pad; +void *new_fdt =realloc (fdt, new_size); + +if (!new_fdt) { +fprintf (stderr,"Out_of_memory\n" );
Should we free fdt here?
man realloc says
If there is not enough available memory, realloc() shall return a null pointer and set errno to [ENOMEM]. If realloc() returns a null pointer and errno has been set to [ENOMEM], the memory referenced by ptr shall not be changed.
though it also says
The realloc() function shall deallocate the old object pointed to by ptr and return a pointer to a new object that has the size specified by size.
so if it happens in that order, it's freed before being reallocated (but I would guess this to be racey since you want to copy the content of the old object into the new object and if you free the space and it can be claimed and used by something else).
Cheers,
Quentin
Quoted 9 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
This is needed to prevent fdtgrep from inhibiting this and stripping the pad bytes again:
scripts/Makefile.dts:DTC_FLAGS += -p $(CONFIG_SYS_DTC_PAD_BYTES)
That ^ is used by early U-Boot stages in place of 'fdt resize' , it provides enough space to add basic modifications to the DT at those stages.
Hi Marek,
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Quoted 6 lines
Quoted 1 line
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
This is needed to prevent fdtgrep from inhibiting this and stripping the pad bytes again:
scripts/Makefile.dts:DTC_FLAGS += -p $(CONFIG_SYS_DTC_PAD_BYTES)
That ^ is used by early U-Boot stages in place of 'fdt resize' , it provides enough space to add basic modifications to the DT at those stages.
It'd have been soooo nice to explain what CONFIG_SYS_DTC_PAD_BYTES is useful for. The default for arm64 is 4096 but it doesn't explain where it came from and if we can have more, or less and what's the impact on the system.
But ok, the commit log should be updated to add this additional piece of information (and also in the same series have whatever's going to use this new option). Something like "This is the counterpart to DTC_FLAGS += -p $(CONFIG_SYS_DTC_PAD_BYTES) in scripts/Makefile.dts because xPL device trees are passed through fdtgrep which packs the DTB after stripping nodes and properties and therefore do not respect this for now. In the next commit(s), we'll make use of that new property such that xPL devices also respect that."
Now I'm wondering if we want the same value for xPL DTB padding as some systems are heavily size-constrained (and next stages may not allow enough space for storing the new DTB with that much padding; TF-A on Rockchip for example was notorious for only allowing very small DTBs).
Cheers,
Quentin
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Quoted 5 lines
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
I'm going to leave this question to Marek :-)
Quoted 22 lines
Quoted 22 lines
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb)
Quoted 13 lines
tools/binman/btool/fdtgrep.py Output formats are: · line 25
Quoted 8 lines
tools/binman/btool/fdtgrep.py +2
-1-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grepI'm tempted to remove this and just tell people to look at the documentation in
tools/fdtgrep.c. Especially since we don't actually allow the user to pass any of those parameters themselves via the bintool, so it isn't actually useful.
I would like fdtgrep to give useful help, though. It is a tool which can stand alone.
Quoted 35 lines
Quoted 14 lines
tools/fdtgrep.c +1
-0@@ -64,6 +64,7 @@ struct display_info {int types_exc;/* Mask of types that we exclude (FDT_IS...) */ int invert;/* Invert polarity of match */ int props_up;/* Imply properties up to supernodes */ +int pad;/* Free bytes to append after the strings section */ struct value_node *value_head;/* List of values to match */ const char *output_fname;/* Output filename */ FILE *fout;/* File to write dts/dtb output */ tools/fdtgrep.c static int do_fdtgrep(struct display_info *disp, const char *filename) · line 922
Quoted 9 lines
tools/fdtgrep.c +6
-0@@ -913,6 +914,27 @@ static int do_fdtgrep(struct display_info *disp, const char *filename) size =fdt_totalsize (fdt); } +if (disp->pad) { +int new_size =fdt_totalsize (fdt) + disp->pad; +void *new_fdt =realloc (fdt, new_size); + +if (!new_fdt) { +fprintf (stderr,"Out_of_memory\n" );Should we free fdt here?
man realloc says
If there is not enough available memory,
realloc()shall return a null pointer and set errno to [ENOMEM]. Ifrealloc()returns a null pointer and errno has been set to [ENOMEM], the memory referenced by ptr shall not be changed.though it also says
Quoted 8 lines
The
realloc()function shall deallocate the old object pointed to by ptr and return a pointer to a new object that has the size specified by size.so if it happens in that order, it's freed before being reallocated (but I would guess this to be racey since you want to copy the content of the old object into the new object and if you free the space and it can be claimed and used by something else).
My understanding is that it does not touch fdt on failure, so we need free() as you say.
I'll hold off on v2 until you and Marek have figured out the other questions / issues, since they are bigger than fdtgrep itself.
Regards,
Simon
Hi Simon,
Quoted 56 lines · Simon Glass
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Quoted 5 lines
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
I'm going to leave this question to Marek :-)
Quoted 22 lines
Quoted 22 lines
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb)Quoted 13 lines
tools/binman/btool/fdtgrep.py Output formats are: · line 25
Quoted 8 lines
tools/binman/btool/fdtgrep.py +2
-1-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grepI'm tempted to remove this and just tell people to look at the documentation in
tools/fdtgrep.c. Especially since we don't actually allow the user to pass any of those parameters themselves via the bintool, so it isn't actually useful.
Quoted 3 lines
I would like fdtgrep to give useful help, though. It is a tool which can stand alone.
Yes, but this here is docstring for the fdtgrep *Bintool* module which actually doesn't support most of the arguments specified here. So I would say it's more confusing to have it there than not have anything. For sure we want to keep documentation of fdtgrep, the tool as in tools/fdtgrep.c, complete and up-to-date!
Cheers,
Quentin
Hi Quentin,
Quoted 64 lines · Quentin Schulz
Hi Simon,
Quoted 56 lines · Simon Glass
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Quoted 5 lines
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
I'm going to leave this question to Marek :-)
Quoted 22 lines
Quoted 22 lines
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb)Quoted 13 lines
tools/binman/btool/fdtgrep.py Output formats are: · line 25
Quoted 8 lines
tools/binman/btool/fdtgrep.py +2
-1-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grepI'm tempted to remove this and just tell people to look at the documentation in
tools/fdtgrep.c. Especially since we don't actually allow the user to pass any of those parameters themselves via the bintool, so it isn't actually useful.Quoted 3 lines
I would like fdtgrep to give useful help, though. It is a tool which can stand alone.
Quoted 5 lines
Yes, but this here is docstring for the fdtgrep *Bintool* module which actually doesn't support most of the arguments specified here. So I would say it's more confusing to have it there than not have anything. For sure we want to keep documentation of fdtgrep, the tool as in
tools/fdtgrep.c, complete and up-to-date!
Ah yes, I just generated it directly from fdtgrep. So perhaps we should have no argument docs here and just mention what the bintool actually supports / uses?
Regards,
Simon
Quoted 73 lines · Simon Glass
Hi Quentin,
Quoted 64 lines · Quentin Schulz
Hi Simon,
Quoted 56 lines · Simon Glass
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Quoted 5 lines
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
I'm going to leave this question to Marek :-)
Quoted 22 lines
Quoted 22 lines
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb)Quoted 13 lines
tools/binman/btool/fdtgrep.py Output formats are: · line 25
Quoted 8 lines
tools/binman/btool/fdtgrep.py +2
-1-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grepI'm tempted to remove this and just tell people to look at the documentation in
tools/fdtgrep.c. Especially since we don't actually allow the user to pass any of those parameters themselves via the bintool, so it isn't actually useful.Quoted 3 lines
I would like fdtgrep to give useful help, though. It is a tool which can stand alone.
Quoted 5 lines
Yes, but this here is docstring for the fdtgrep *Bintool* module which actually doesn't support most of the arguments specified here. So I would say it's more confusing to have it there than not have anything. For sure we want to keep documentation of fdtgrep, the tool as in
tools/fdtgrep.c, complete and up-to-date!
Quoted 4 lines
Ah yes, I just generated it directly from fdtgrep. So perhaps we should have no argument docs here and just mention what the bintool actually supports / uses?
It only matters what the bintool exposes as API, create_for_phase() is one for example. I'm assuming you *could* call run_cmd() on the bintool and provide a list of arguments yourself but then there's no point documenting this in the bintool as it'll only be a thin wrapper around fdtgrep itself? See what we have for mkimage bintool for example?
Cheers,
Quentin
Hi Quentin,
Quoted 80 lines · Quentin Schulz
Quoted 73 lines · Simon Glass
Hi Quentin,
Quoted 64 lines · Quentin Schulz
Hi Simon,
Quoted 56 lines · Simon Glass
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Simon, Marek,
Quoted 4 lines · Simon Glass
When producing a DTB from fdtgrep, there is no way to reserve extra space so that more nodes/properties can be added at runtime without growing totalsize first.
Quoted 5 lines
Ok but why is that an issue? What is the actual usecase? What I'm afraid of is that you pad enough and you hit random bugs because you forget that adding enough properties can now hit the size limit and you forgot to add the logic to resize/grow the fdt when it's too small to fit new properties.
I'm going to leave this question to Marek :-)
Quoted 22 lines
Quoted 22 lines
Add a -B/--pad option that appends a caller-specified number of free bytes after the strings section and grows totalsize accordingly. The padding is applied after
fdt_pack(), so it is not reclaimed when -r is used.Suggested-by Marek Vasut <[email protected]>Signed-off-by Simon Glass <[email protected]>---
tools/binman/btool/fdtgrep.py | 3 ++- tools/fdtgrep.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-)tools/binman/btool/fdtgrep.py +0
-0@@ -16,9 +16,10 @@ Output formats are: dtb - device tree blob (sets -Hmt automatically) bin - device tree fragment (may not be a valid .dtb)Quoted 13 lines
tools/binman/btool/fdtgrep.py Output formats are: · line 25
Quoted 8 lines
tools/binman/btool/fdtgrep.py +2
-1-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] +Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV] -a, --show-address Display address -A, --colour Show all nodes/tags, colour those that match + -B, --pad <arg> Append free space to the output FDT, for later growth -b, --include-node-with-prop <arg> Include contains containing property -c, --include-compat <arg> Compatible nodes to include in grep -C, --exclude-compat <arg> Compatible nodes to exclude in grepI'm tempted to remove this and just tell people to look at the documentation in
tools/fdtgrep.c. Especially since we don't actually allow the user to pass any of those parameters themselves via the bintool, so it isn't actually useful.Quoted 3 lines
I would like fdtgrep to give useful help, though. It is a tool which can stand alone.
Quoted 5 lines
Yes, but this here is docstring for the fdtgrep *Bintool* module which actually doesn't support most of the arguments specified here. So I would say it's more confusing to have it there than not have anything. For sure we want to keep documentation of fdtgrep, the tool as in
tools/fdtgrep.c, complete and up-to-date!Quoted 4 lines
Ah yes, I just generated it directly from fdtgrep. So perhaps we should have no argument docs here and just mention what the bintool actually supports / uses?
Quoted 5 lines
It only matters what the bintool exposes as API,
create_for_phase()is one for example. I'm assuming you *could* callrun_cmd()on the bintool and provide a list of arguments yourself but then there's no point documenting this in the bintool as it'll only be a thin wrapper around fdtgrep itself? See what we have for mkimage bintool for example?
i.e. very little :-) Yes that seems fine.
I'll keep an eye on this thread and send v2 when you and Marek have resolved the other questions.
Regards,
Simon