* [U-Boot] [PATCH v3] cmd, fdt: add subcommand "get" to fdt header
@ 2018-11-21 6:45 Jonas Mark
2018-11-29 17:42 ` sjg at google.com
0 siblings, 1 reply; 4+ messages in thread
From: Jonas Mark @ 2018-11-21 6:45 UTC (permalink / raw)
To: u-boot
Hi Heiko,
> store fdt header member with name <member> in U-Boot
> Environment variable with name <var>.
>
> for example to get the total length of the fdt and store
> it in filesize, call:
>
> fdt header get filesize totalsize
>
> For membernames look into fdt header definition at
> scripts/dtc/libfdt/libfdt.h
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>
> Changes in v3:
> - add comments from Marek
> simplify for loop, use fdtp[i] -> drop ftdip++
>
> Changes in v2:
> - add obviously missing "static const char *"
>
> cmd/fdt.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
The patch was
Tested-by: Leo Ruan <tingquan.ruan@cn.bosch.com>
and works fine.
Greetings,
Mark
Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn | GERMANY | www.boschsecurity.com
Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Tanja Rückert, Andreas Bartz, Thomas Quante, Bernhard Schuster
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v3] cmd, fdt: add subcommand "get" to fdt header
2018-11-21 6:45 [U-Boot] [PATCH v3] cmd, fdt: add subcommand "get" to fdt header Jonas Mark
@ 2018-11-29 17:42 ` sjg at google.com
0 siblings, 0 replies; 4+ messages in thread
From: sjg at google.com @ 2018-11-29 17:42 UTC (permalink / raw)
To: u-boot
Hi Heiko,
> store fdt header member with name <member> in U-Boot
> Environment variable with name <var>.
>
> for example to get the total length of the fdt and store
> it in filesize, call:
>
> fdt header get filesize totalsize
>
> For membernames look into fdt header definition at
> scripts/dtc/libfdt/libfdt.h
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>
> Changes in v3:
> - add comments from Marek
> simplify for loop, use fdtp[i] -> drop ftdip++
>
> Changes in v2:
> - add obviously missing "static const char *"
>
> cmd/fdt.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
The patch was
Tested-by: Leo Ruan <tingquan.ruan@cn.bosch.com>
and works fine.
Greetings,
Mark
Building Technologies, Panel Software Fire (BT-FIR/ENG1)
Bosch Sicherheitssysteme GmbH | Postfach 11 11 | 85626 Grasbrunn |
GERMANY | www.boschsecurity.com
Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart HRB 23118
Aufsichtsratsvorsitzender: Stefan Hartung; Geschäftsführung: Tanja
Rückert, Andreas Bartz, Thomas Quante, Bernhard Schuster
Applied to u-boot-dm/master, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v3] cmd, fdt: add subcommand "get" to fdt header
@ 2018-11-15 5:06 Heiko Schocher
2018-11-16 0:07 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Heiko Schocher @ 2018-11-15 5:06 UTC (permalink / raw)
To: u-boot
store fdt header member with name <member> in U-Boot
Environment variable with name <var>.
for example to get the total length of the fdt and store
it in filesize, call:
fdt header get filesize totalsize
For membernames look into fdt header definition at
scripts/dtc/libfdt/libfdt.h
Signed-off-by: Heiko Schocher <hs@denx.de>
---
Changes in v3:
- add comments from Marek
simplify for loop, use fdtp[i] -> drop ftdip++
Changes in v2:
- add obviously missing "static const char *"
cmd/fdt.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 8a19a3fdbf..8bfa731a9e 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -73,6 +73,40 @@ static int fdt_value_env_set(const void *nodep, int len, const char *var)
return 0;
}
+static const char * const fdt_member_table[] = {
+ "magic",
+ "totalsize",
+ "off_dt_struct",
+ "off_dt_strings",
+ "off_mem_rsvmap",
+ "version",
+ "last_comp_version",
+ "boot_cpuid_phys",
+ "size_dt_strings",
+ "size_dt_struct",
+};
+
+static int fdt_get_header_value(int argc, char * const argv[])
+{
+ fdt32_t *fdtp = (fdt32_t *)working_fdt;
+ ulong val;
+ int i;
+
+ if (argv[2][0] != 'g')
+ return CMD_RET_FAILURE;
+
+ for (i = 0; i < ARRAY_SIZE(fdt_member_table); i++) {
+ if (strcmp(fdt_member_table[i], argv[4]))
+ continue;
+
+ val = fdt32_to_cpu(fdtp[i]);
+ env_set_hex(argv[3], val);
+ return CMD_RET_SUCCESS;
+ }
+
+ return CMD_RET_FAILURE;
+}
+
/*
* Flattened Device Tree command, see the help for parameter definitions.
*/
@@ -491,6 +525,9 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* Display header info
*/
} else if (argv[1][0] == 'h') {
+ if (argc == 5)
+ return fdt_get_header_value(argc, argv);
+
u32 version = fdt_version(working_fdt);
printf("magic:\t\t\t0x%x\n", fdt_magic(working_fdt));
printf("totalsize:\t\t0x%x (%d)\n", fdt_totalsize(working_fdt),
@@ -1090,7 +1127,8 @@ static char fdt_help_text[] =
"fdt set <path> <prop> [<val>] - Set <property> [to <val>]\n"
"fdt mknode <path> <node> - Create a new node after <path>\n"
"fdt rm <path> [<prop>] - Delete the node or <property>\n"
- "fdt header - Display header info\n"
+ "fdt header [get <var> <member>] - Display header info\n"
+ " get - get header member <member> and store it in <var>\n"
"fdt bootcpu <id> - Set boot cpuid\n"
"fdt memory <addr> <size> - Add/Update memory node\n"
"fdt rsvmem print - Show current mem reserves\n"
--
2.17.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [U-Boot] [PATCH v3] cmd, fdt: add subcommand "get" to fdt header
2018-11-15 5:06 Heiko Schocher
@ 2018-11-16 0:07 ` Simon Glass
0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2018-11-16 0:07 UTC (permalink / raw)
To: u-boot
On 14 November 2018 at 21:06, Heiko Schocher <hs@denx.de> wrote:
> store fdt header member with name <member> in U-Boot
> Environment variable with name <var>.
>
> for example to get the total length of the fdt and store
> it in filesize, call:
>
> fdt header get filesize totalsize
>
> For membernames look into fdt header definition at
> scripts/dtc/libfdt/libfdt.h
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>
> Changes in v3:
> - add comments from Marek
> simplify for loop, use fdtp[i] -> drop ftdip++
>
> Changes in v2:
> - add obviously missing "static const char *"
>
> cmd/fdt.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
Should we have a test case for this?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-29 17:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21 6:45 [U-Boot] [PATCH v3] cmd, fdt: add subcommand "get" to fdt header Jonas Mark
2018-11-29 17:42 ` sjg at google.com
-- strict thread matches above, loose matches on Subject: below --
2018-11-15 5:06 Heiko Schocher
2018-11-16 0:07 ` Simon Glass
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.