From: Rob Herring <robh+dt@kernel.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Frank Rowand <frowand.list@gmail.com>,
Viresh Kumar <viresh.kumar@linaro.org>,
Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
devicetree@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Bill Mills <bill.mills@linaro.org>,
Anmar Oueja <anmar.oueja@linaro.org>,
Masahiro Yamada <masahiroy@kernel.org>
Subject: Re: [PATCH V4 0/3] scripts: dtc: Build fdtoverlay
Date: Thu, 4 Feb 2021 08:25:23 -0600 [thread overview]
Message-ID: <CAL_JsqJjR7EknfnbA7RKckUtYVu9jmjf7L_DC=LmF=jMGfThgQ@mail.gmail.com> (raw)
In-Reply-To: <20210201040748.GB2251@yekko.fritz.box>
On Sun, Jan 31, 2021 at 10:39 PM David Gibson
<david@gibson.dropbear.id.au> wrote:
>
> On Mon, Jan 25, 2021 at 09:42:21PM -0600, Frank Rowand wrote:
> > Hi David,
> >
> > On 1/22/21 12:34 AM, David Gibson wrote:
> > > On Wed, Jan 20, 2021 at 10:47:40AM +0530, Viresh Kumar wrote:
> > >> +David.
> > >>
> > >> On 19-01-21, 11:12, Frank Rowand wrote:
> > >>> On 1/12/21 2:28 AM, Viresh Kumar wrote:
> > >>>> We will start building overlays for platforms soon in the kernel and
> > >>>> would need fdtoverlay tool going forward. Lets start fetching and
> > >>>> building it.
> > >>>>
> > >>>> While at it, also remove fdtdump.c file, which isn't used by the kernel.
> > >>>>
> > >>>> V4:
> > >>>> - Don't fetch and build fdtdump.c
> > >>>> - Remove fdtdump.c
> > >>>>
> > >>>> Viresh Kumar (3):
> > >>>> scripts: dtc: Add fdtoverlay.c to DTC_SOURCE
> > >>>> scripts: dtc: Build fdtoverlay tool
> > >>>> scripts: dtc: Remove the unused fdtdump.c file
> > >>>>
> > >>>> scripts/dtc/Makefile | 6 +-
> > >>>> scripts/dtc/fdtdump.c | 163 -------------------------------
> > >>>> scripts/dtc/update-dtc-source.sh | 6 +-
> > >>>> 3 files changed, 8 insertions(+), 167 deletions(-)
> > >>>> delete mode 100644 scripts/dtc/fdtdump.c
> > >>>>
> > >>>
> > >>> My first inclination was to accept fdtoverlay, as is, from the upstream
> > >>> project.
> > >>>
> > >>> But my experiences debugging use of fdtoverlay against the existing
> > >>> unittest overlay files has me very wary of accepting fdtoverlay in
> > >>> it's current form.
> > >>>
> > >>> As an exmple, adding an overlay that fails to reply results in the
> > >>> following build messages:
> > >>>
> > >>> linux--5.11-rc> make zImage
> > >>> make[1]: Entering directory '/local/frowand_nobackup/src/git_linus/build/dragon_linus_5.11-rc'
> > >>> GEN Makefile
> > >>> CALL /local/frowand_nobackup/src/git_linus/linux--5.11-rc/scripts/checksyscalls.sh
> > >>> CALL /local/frowand_nobackup/src/git_linus/linux--5.11-rc/scripts/atomic/check-atomics.sh
> > >>> CHK include/generated/compile.h
> > >>> FDTOVERLAY drivers/of/unittest-data/static_test.dtb
> > >>>
> > >>> Failed to apply 'drivers/of/unittest-data/overlay.dtb': FDT_ERR_NOTFOUND
> > >>> make[4]: *** [/local/frowand_nobackup/src/git_linus/linux--5.11-rc/drivers/of/unittest-data/Makefile:96: drivers/of/unittest-data/static_test.dtb] Error 1
> > >>> make[3]: *** [/local/frowand_nobackup/src/git_linus/linux--5.11-rc/scripts/Makefile.build:496: drivers/of/unittest-data] Error 2
> > >>> make[2]: *** [/local/frowand_nobackup/src/git_linus/linux--5.11-rc/scripts/Makefile.build:496: drivers/of] Error 2
> > >>> make[1]: *** [/local/frowand_nobackup/src/git_linus/linux--5.11-rc/Makefile:1805: drivers] Error 2
> > >>> make[1]: Leaving directory '/local/frowand_nobackup/src/git_linus/build/dragon_linus_5.11-rc'
> > >>> make: *** [Makefile:185: __sub-make] Error 2
> > >>>
> > >>>
> > >>> The specific error message (copied from above) is:
> > >>>
> > >>> Failed to apply 'drivers/of/unittest-data/overlay.dtb': FDT_ERR_NOTFOUND
> > >>>
> > >>> which is cryptic and does not even point to the location in the overlay that
> > >>> is problematic. If you look at the source of fdtoverlay / libfdt, you will
> > >>> find that FDT_ERR_NOTFOUND may be generated in one of many places.
> > >>>
> > >>> I do _not_ want to do a full review of fdtoverlay, but I think that it is
> > >>> reasonable to request enhancing fdtoverlay in the parent project to generate
> > >>> usable error messages before enabling fdtoverlay in the Linux kernel tree.
> > >
> >
> > > That's... actually much harder than it sounds. fdtoverlay is
> > > basically a trivial wrapper around the fdt_overlay_apply() function in
> > > libfdt. Matching the conventions of the rest of the library, really
> > > it's only way to report errors is a single error code.
> > >
> > > Returning richer errors is not an easy problem in a C library,
> > > especially one designed to be usable in embedded systems, without an
> > > allocator or much else available.
> > >
> > > Of course it would be possible to write a friendly command line tool
> > > specifically for applying overlays, which could give better errors.
> > > fdtoverlay as it stands isn't really that - it was pretty much written
> > > just to invoke fdt_overlay_apply() in testcases.
> >
> > Thank you for providing that context.
> >
> > I do not know if there is a way to enable the code that is currently in libfdt
> > to both be useful as an embedded library (for example, U-boot seems to often
> > have a need to keep memory usage very small) and also be part of a tool with
> > effective warning and error messages.
>
> Yeah, I don't know either.
>
> > Before having looked at libfdt only at a cursory level while debugging the proposed
> > use of fdtoverlay in Linux, my first thought was that maybe it would be possible
> > to add warning and error messages within "#ifdef" blocks, or other ways that
> > cause the error code to _not_ be compiled as part of library version of libfdt,
> > but only be compiled as part of fdtoverlay _when built in the Linux kernel_
> > (noting that the proposed Linux patch builds the libfdt files as part of
> > the fdtoverlay compile instead of as a discrete library). After looking at
> > the libfdt source a tiny bit more carefully, I would probably shoot down this
> > suggestion, as it makes the source code uglier and harder to understand and
> > maintain for the primary purpose of being an embedded library.
>
> Oof. That sounds really ugly, but maybe it could be pulled off.
>
> > Do you have any thoughts on how warning and error messages could be added,
> > or if it is even possible? Or maybe your suggestion of writing a "friendly
> > command line tool specifically for applying overlays" is the path that
> > Viresh should pursue?
>
> I think at this stage it's a matter of trying a few approaches and
> seeing what works out.
Another way would be applying overlays to dtc's live tree. This could
apply overlays from dts in addition to dtb. It could be a plug-in if
we ever get that finished up.
The downside of this is not testing libfdt's code and possible
differences between 2 implementations.
Rob
next prev parent reply other threads:[~2021-02-04 14:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 8:28 [PATCH V4 0/3] scripts: dtc: Build fdtoverlay Viresh Kumar
2021-01-12 8:29 ` [PATCH V4 1/3] scripts: dtc: Add fdtoverlay.c to DTC_SOURCE Viresh Kumar
2021-01-19 16:32 ` Frank Rowand
2021-01-12 8:29 ` [PATCH V4 2/3] scripts: dtc: Build fdtoverlay tool Viresh Kumar
2021-01-19 16:37 ` Frank Rowand
2021-01-20 15:47 ` Rob Herring
2021-01-12 8:29 ` [PATCH V4 3/3] scripts: dtc: Remove the unused fdtdump.c file Viresh Kumar
2021-01-19 17:12 ` [PATCH V4 0/3] scripts: dtc: Build fdtoverlay Frank Rowand
2021-01-20 5:17 ` Viresh Kumar
2021-01-22 6:34 ` David Gibson
2021-01-26 3:42 ` Frank Rowand
2021-02-01 4:07 ` David Gibson
2021-02-03 9:51 ` Viresh Kumar
2021-02-04 14:25 ` Rob Herring [this message]
2021-02-22 6:17 ` David Gibson
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='CAL_JsqJjR7EknfnbA7RKckUtYVu9jmjf7L_DC=LmF=jMGfThgQ@mail.gmail.com' \
--to=robh+dt@kernel.org \
--cc=anmar.oueja@linaro.org \
--cc=bill.mills@linaro.org \
--cc=david@gibson.dropbear.id.au \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=pantelis.antoniou@konsulko.com \
--cc=vincent.guittot@linaro.org \
--cc=viresh.kumar@linaro.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).