All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] Fix fdt set command to conform to dts spec
Date: Tue, 01 Apr 2008 10:06:07 -0400	[thread overview]
Message-ID: <47F2414F.9070001@ge.com> (raw)
In-Reply-To: <1207014356-1663-1-git-send-email-afleming@freescale.com>

Andy Fleming wrote:
> The fdt set command was treating properties specified as <00> and <0011>
> as byte streams, rather than as an array of cells.  As we already have
> syntax for expressing the desire for a stream of bytes ([ xx xx ...]),
> we should use the <> syntax to describe arrays of cells, which are always
> 32-bits per element.  If we imagine this likely (IMHO) scenario:
> 
>> fdt set /ethernet-phy at 1 reg <1>
> 
> With the old code, this would create a bad fdt, since the reg cell would be
> made to be one byte in length.  But the cell must be 4 bytes, so this would
> break mysteriously.
> 
> Also, the dts spec calls for constants inside the angle brackets (<>)
> to conform to C constant standards as they pertain to base.
> Take this scenario:
> 
>> fdt set /ethernet at f00 reg <0xe250000\ 0x1000>
> 
> The old fdt command would complain that it couldn't parse that.  Or, if you
> wanted to specify that a certain clock ran at 33 MHz, you'd be required to
> do this:
> 
>> fdt set /mydev clock <1f78a40>
> 
> Whereas the new code will accept decimal numbers.
> 
> While I was in there, I extended the fdt command parser to handle property
> strings which are split across multiple arguments:
> 
>> fdt set /ethernet at f00 interrupts < 33 2 34 2 36 2 >
>> fdt p /ethernet at f00
> ethernet at f00 {
> 	interrupts = <0x21 0x2 0x22 0x2 0x24 0x2>;
> };
> 
> Lastly, the fdt print code was rearranged slightly to print arrays of cells
> if the length of the property is a multiple of 4 bytes, and to not print
> leading zeros.
> 
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> ---

Hi Andy,

This looks like a very good improvement, fix some of my mistakes and 
misassumptions.

What I wrote originally was prior to dtc v1.0... at that time, all 
constants were hex.  Bringing our parsing/printing forward to the 
C-syntax age (dtc v1.0++) is good.

The parsing and print format that I did, I did to make the device tree 
printout reversible: I compiled source with dtc, loaded it, and printed 
it out.  I adapted the print heuristics so that the fdt print command 
matched (exactly in almost all cases) the example dtc source.  Your 
point about <> values being 32 bit cells bothers me... either I didn't 
understand the particulars of the <> notation (quite possible) or 
something has changed.  I would like to understand the genesis of this 
error/misunderstanding.

I have not had time yet to apply the patch to the u-boot-fdt tree and 
try it, I'll do that pronto.

Best regards,
gvb

  reply	other threads:[~2008-04-01 14:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-01  1:45 [U-Boot-Users] [PATCH] Fix fdt set command to conform to dts spec Andy Fleming
2008-04-01 14:06 ` Jerry Van Baren [this message]
2008-04-02 15:29 ` Jerry Van Baren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47F2414F.9070001@ge.com \
    --to=gerald.vanbaren@ge.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.