devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fdt_setprop comma-separated cells
@ 2022-09-22  0:35 Radha Mohan Chintakuntla
       [not found] ` <CA+Nonppng=cKrpwqz6YxiVLikvgZGeuYBfdEn3jH8fW49070Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Radha Mohan Chintakuntla @ 2022-09-22  0:35 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

Hi,
Not sure if this right forum to discuss this issue.
I have a requirement where I have to update the device tree property
with comma-separated values. If I use fdt_setprop() and pass a
2-dimensional array then it is not creating the property with comma
separation. Instead I get all the values in same cell separated by
space.

Is there any other way this should be done?
I have referred to some uboot code that used libfdt and does same way
as me but even that has the same problem.

Any suggestions please?

regards,
RC

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fdt_setprop comma-separated cells
       [not found] ` <CA+Nonppng=cKrpwqz6YxiVLikvgZGeuYBfdEn3jH8fW49070Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2022-09-26 16:49   ` Rob Herring
  2022-09-28  5:35   ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2022-09-26 16:49 UTC (permalink / raw)
  To: Radha Mohan Chintakuntla; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

On Wed, Sep 21, 2022 at 7:35 PM Radha Mohan Chintakuntla
<radhamohan.cta-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> Hi,
> Not sure if this right forum to discuss this issue.
> I have a requirement where I have to update the device tree property
> with comma-separated values. If I use fdt_setprop() and pass a
> 2-dimensional array then it is not creating the property with comma
> separation. Instead I get all the values in same cell separated by
> space.

'cell' in DT terms means a uint32 value, but I gather here you mean
values within '<>' brackets. The brackets are part of dts syntax and
are irrelevant for dtb. Values in a dtb are just a byte array. dtc
will do some guessing of types (e.g. divisible by 4 or ascii), but
that's it.

> Is there any other way this should be done?
> I have referred to some uboot code that used libfdt and does same way
> as me but even that has the same problem.
>
> Any suggestions please?

The only way to get from a dtb to some output format with decoded
types without guessing is by knowing the type of every possible
property. dtc doesn't have this information. Fortunately, with
dtschema[1] we do and it can decode dtb files assuming it has a schema
for every property. dts as an output format is not supported though.
Only dumping the internal python representation is supported ATM.
dtb2py does this.

Rob

[1] https://github.com/devicetree-org/dt-schema/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fdt_setprop comma-separated cells
       [not found] ` <CA+Nonppng=cKrpwqz6YxiVLikvgZGeuYBfdEn3jH8fW49070Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2022-09-26 16:49   ` Rob Herring
@ 2022-09-28  5:35   ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2022-09-28  5:35 UTC (permalink / raw)
  To: Radha Mohan Chintakuntla; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]

On Wed, Sep 21, 2022 at 05:35:19PM -0700, Radha Mohan Chintakuntla wrote:
> Hi,
> Not sure if this right forum to discuss this issue.
> I have a requirement where I have to update the device tree property
> with comma-separated values. If I use fdt_setprop() and pass a
> 2-dimensional array then it is not creating the property with comma
> separation. Instead I get all the values in same cell separated by
> space.
> 
> Is there any other way this should be done?
> I have referred to some uboot code that used libfdt and does same way
> as me but even that has the same problem.
> 
> Any suggestions please?

I'm afraid it looks like you have a miunderstanding about the
flattened tree format (a very common one, alas).

In the dtb, properties are simply bytestrings, there is no type
information.  You can only separate them into typed values by knowing
the binding which describes the format.  In other words, in the dtb
there is no such thing as "comma separation".  Commas in dts are
simply a way to notate concatenating bytestrings which can be
generated from integers, strings or whatever.

When using dtc in dtb -> dts mode, it applies some heuristics to guess
the right format to display things in.  However it does not - and
cannot - get this right all the time.

-- 
David Gibson			| 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] 3+ messages in thread

end of thread, other threads:[~2022-09-28  5:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22  0:35 fdt_setprop comma-separated cells Radha Mohan Chintakuntla
     [not found] ` <CA+Nonppng=cKrpwqz6YxiVLikvgZGeuYBfdEn3jH8fW49070Xw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-09-26 16:49   ` Rob Herring
2022-09-28  5:35   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).