[PATCH] cmd: fdt: Add support for reading stringlist property values
Marek Vasut
marex at denx.de
Tue Jul 12 13:47:03 CEST 2022
On 7/12/22 12:58, Simon Glass wrote:
> Hi Marek,
>
> On Fri, 8 Jul 2022 at 15:50, Marek Vasut <marex at denx.de> wrote:
>>
>> The fdt command currently handles stringlists as strings in 'fdt get value'
>> subcommand. Since strings in FDT stringlists are separated by '\0', only
>> the first value gets inserted into the environment variable passed to the
>> 'fdt get value' command.
>>
>> Example, consider the following DT snippet:
>>
>> / { compatible = "foo", "bar" };
>>
>> The following command only reports the first string in stringlist:
>> => fdt get value var / compatible ; print var
>> foo
>>
>> It is not possible to assign list of null-terminated strings into U-Boot
>> environment variable. Add optional 'index' parameter to the subcommand
>> 'fdt get value <var> <path> <prop> [<index>]' which lets user specify which
>> string within the stringlist should be assigned into the 'var' variable.
>> The default value of 'index' is 0 in case it is not present. This way the
>> 'fdt' command API does not change and existing scripts are not broken.
>>
>> The following command now reports the Nth string in stringlist, counting
>> from zero:
>> => fdt get value var / compatible 1 ; print var
>> bar
>>
>> Signed-off-by: Marek Vasut <marex at denx.de>
>> Cc: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
>> Cc: Simon Glass <sjg at chromium.org>
>> Cc: Tom Rini <trini at konsulko.com>
>> ---
>> cmd/fdt.c | 34 ++++++++++++++++++++++++++++------
>> 1 file changed, 28 insertions(+), 6 deletions(-)
>
> Can you please add docs and a test?
I was expecting this kind of question ... there is no test for the FDT
command.
> I am happy to do a starting point for a test if you like.
You can implement the test for this while at it.
More information about the U-Boot
mailing list