devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: Pantelis Antoniou
	<pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
Cc: Frank Rowand
	<frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	Tom Rini <trini-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
	Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Franklin S Cooper Jr <fcooper-l0cyMroinI0@public.gmane.org>,
	Matt Porter <mporter-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>,
	Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Phil Elwell
	<philip.j.elwell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Geert Uytterhoeven
	<geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>,
	Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>,
	Devicetree Compiler
	<devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [RFC] Introducing yamldt, a yaml to dtb compiler
Date: Mon, 31 Jul 2017 15:40:10 +1000	[thread overview]
Message-ID: <20170731054010.GF2652@umbus.fritz.box> (raw)
In-Reply-To: <1501174151.1055.8.camel@hp800z>

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

On Thu, Jul 27, 2017 at 07:49:11PM +0300, Pantelis Antoniou wrote:
> Hi all,
> 
> This is a project I've been working on lately and it's finally in a
> usuable form.
> 
> I'm introducing yamldt.
> 
> A YAML to DT blob generator/compiler, utilizing a YAML schema that is
> functionaly equivalent to DTS and supports all DTS features.
> 
> yamldl parses a device tree description (source) file in YAML format and
> outputs a (bit-exact if the -C option is used) device tree blob.
> 
> A DT aware YAML schema is a good fit as a DTS syntax alternative.
> 
> YAML is a human-readable data serialization language, and is expressive
> enough to cover all DTS source features.
> 
> Simple YAML files are just key value pairs that are very easy to parse,
> even without using a formal YAML parser. For instance YAML in restricted
> environments may simple be appending a few lines of text in a given YAML
> file.
> 
> The parsers of YAML are very mature, as it has been released in 2001. It
> is in wide-spread use and schema validation tools are available. YAML
> support is available for every major programming language.
> 
> Data in YAML can easily be converted to/form other format that a
> particular tool that we may use in the future understands.
> 
> More importantly YAML offers (an optional) type information for each
> data, which is IMHO crucial for thorough validation and checking against
> device tree bindings (when they will be converted to a machine readable
> format, preferably YAML).
> 
> For more take a look here.
> 
> https://github.com/pantoniou/yamldt
> 
> I am eagerly awaiting for your comments.

Ok, technical comments here only; I addressthe procedural questions
brought up in the thread elsewhere.

First, there's a lot to like about YAML - if it had been as well known
when I wrote dtc, maybe we'd already be using it.  It was also the
frontrunner for a schema language in the various inconclusive threads
there have been on the topic.  It's been a little while since I read
up on YAML, so I may have forgotten some things about it.

I do have some doubts about this approach.

(1)

dts has its semantic model built closely around what dtb can
represent.  YAML (and JSON) have a different semantic model - in many
ways a better one than dtb (and IEEE1275), but that's not really the
point.  I wonder if having a source language which suggests the
possibility of things that can't actually be done in dtb will be
confusing.  The most obvious example is that any explicit type tags
will be stripped, of course, but there are others: nested list
structure can't be preserved in dtb, nor even what basic scalars are
in a list.  i.e. dtb couldn't tell the difference between:
	foo: [0, "\0\0\0\0"];
and
	foo: ["\0\0\0\0", 0];
	
There's also the fact that using YAML implicitly puts nodes and
properties into the namespace, which isn't the case in the dtb model.
Obviously you can simply ban having a property and subnode with the
same name (since that's good practice anyway), but it could be an
issue for decompiling or manipulating existing trees. I know there
have been device trees in the wild which had a property and subnode
with the same name in the same place (some old PowerPC based
Macintoshes, I think).

(2)

In the other direction there are several features of the dts format
I don't think you'll get for free with YAML - and it's not clear how
you would represent them there.  Obviously you *can* represent them -
it's a key value tree, so it can represent anything; whether it's
natural and readable is a different question.

YAML might have an equivalent of /incbin/, I'm not sure.  I'm pretty
sure it doesn't have integer expression evaluation, which is quite
useful in dts when combined with includes.  Likewise, how would you
tell a YAML based compiler what size to use when encoding a list of
integers - the equivalent of dtc's /bits/ directive.

(3)

It's not clear to me that preserving type information helps all that
much with validation.  You still have to validate against something,
so you need a schema.  And if you have a schema, you can get type and
structure information from there which will let you interpret the
untyped dt information.  That has the additional advantage that you
can also validate dtbs, which is a nice debugging feature when working
with some dtb that you've got from firmware or somewhere without any
dts/yaml/whatever.

-- 
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 --]

  parent reply	other threads:[~2017-07-31  5:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-27 16:49 [RFC] Introducing yamldt, a yaml to dtb compiler Pantelis Antoniou
2017-07-27 18:09 ` Rob Herring
2017-07-27 18:58   ` Pantelis Antoniou
2017-07-27 20:22     ` Frank Rowand
     [not found]       ` <597A4B80.7000106-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-27 21:46         ` Pantelis Antoniou
2017-07-27 23:00           ` Rob Herring
     [not found]             ` <CAL_Jsq+NBEXyOmRx3Ar0OTpyaLeT0hEKw45R0PrVEdmOcd9czw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-28  0:51               ` Tom Rini
2017-07-28  2:12                 ` Rob Herring
     [not found]                   ` <CAL_Jsq+eJNG66D22bNButg6=jj9WQ7Nw4PpxLsPBmGxN9KBnaw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-28 11:23                     ` Tom Rini
2017-07-28 12:23                     ` Pantelis Antoniou
2017-07-28 15:07                       ` Rob Herring
     [not found]                         ` <CAL_JsqLRDy_uG1eeNsjbhs29L5DF-4z2Oa_npGrYVgoMiR=YpQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-28 16:11                           ` Pantelis Antoniou
2017-07-28 21:16                             ` Rob Herring
2017-07-31 13:11                           ` David Gibson
     [not found]                             ` <20170731131118.GJ2652-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-07-31 17:15                               ` Rob Herring
     [not found]                                 ` <CAL_Jsq+HjOpaLcVJzS-mskzHLTS+J=WHdqCVmpc_qJ7da2faHw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-02 14:30                                   ` David Gibson
     [not found]                                     ` <20170802143025.GD394-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-03 22:53                                       ` Rob Herring
2017-07-31  5:53                     ` David Gibson
     [not found]                       ` <20170731055316.GG2652-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-07-31  8:38                         ` Oliver
2017-08-02 15:09                 ` David Gibson
     [not found]                   ` <20170802150933.GG394-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-02 22:04                     ` Grant Likely
     [not found]                       ` <CACxGe6um3TC3URKa8NWbbQT-gc=AV5jgTxbQ3pYnSp4Xmu_Mfg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-03  5:49                         ` David Gibson
     [not found]                           ` <20170803054914.GL394-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-10 14:21                             ` Grant Likely
     [not found]                               ` <CACxGe6s3-1rK1NMm0B8fKP+XfxphcHj+pBU7=FxpSexXMWyeFQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-10 22:05                                 ` Pantelis Antoniou
2017-08-11 14:45                                 ` Pantelis Antoniou
2017-08-14 13:41                                 ` David Gibson
     [not found]                                   ` <20170814134150.GL3452-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-10-22 18:48                                     ` Grant Likely
2017-07-28 11:26               ` Pantelis Antoniou
2017-07-31  6:52                 ` David Gibson
2017-07-27 23:13           ` Frank Rowand
2017-08-03  6:13           ` David Gibson
2017-07-28  1:00         ` Tom Rini
2017-07-31  5:40 ` David Gibson [this message]
     [not found]   ` <20170731054010.GF2652-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-07-31 20:36     ` Pantelis Antoniou
2017-08-02 14:53       ` David Gibson
     [not found]         ` <20170802145312.GF394-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-02 15:17           ` Pantelis Antoniou
2017-08-02 16:11             ` David Gibson
     [not found]               ` <20170802161113.GH394-K0bRW+63XPQe6aEkudXLsA@public.gmane.org>
2017-08-02 17:05                 ` Pantelis Antoniou

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=20170731054010.GF2652@umbus.fritz.box \
    --to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=fcooper-l0cyMroinI0@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=marex-ynQEQJNshbs@public.gmane.org \
    --cc=mporter-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=philip.j.elwell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=trini-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    /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 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).