mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <trent.piepho@igorinstitute.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] kbuild: dtc: Allow adding device tree fragments via config
Date: Mon, 20 Sep 2021 13:43:52 -0700	[thread overview]
Message-ID: <CAMHeXxPZ9on3rZu92H1EeNQj79rUFBRbs5Qre=AS3U7_y=UueQ@mail.gmail.com> (raw)
In-Reply-To: <a2ed83cd-102d-a3f1-1b28-89199d8f2a06@pengutronix.de>

On Mon, Sep 20, 2021 at 2:02 AM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> >>> Preprocessing the dts file gains another layer, where a generated dts
> >>> source consisting of an include directive for the original dts source is
> >>> followed by more includes for each fragment.  This is piped to the
> >>> existing preprocessor call on stdin to avoid another temporary file.
> >>> cpp/dtc will correctly identify errors in the source files they occur
> >>> in.  The -MT option is used so the cpp auto-dependencies reference the
> >>> original dts source and not the generated code passed on stdin.
> >>
> >> If you go this route wouldn't you want to apply device tree overlays?
> >
> > Can the Barebox apply overlays to the *Barebox dtb* when it starts?
>
> I meant overlay application at compile time. I have no experience with
> that and was interested to hear your opinion on it.

This could be done, but I think overall it is worse.  Additional
fragments can be made into dtbo files and then fdtoverlay from dtc
package can apply them to the main dtb at compile time.  But there are
drawbacks:
dtb must be compiled with symbols, which makes it larger.  And
non-fragment users get a different dtb than before for no reason.
One can not use the preprocessor to control overlays per board.  Such
as changing a node name from <&nand> to <&emmc> based on board or
enabling/disable the entire fragment.
The overlay can not delete nodes or properties, i.e. /delete-property/
and /delete-node/ are not useful.

A possible benefit of overlays is if an overlay is used in many
different images, then it could be compiled only once.  But dtc is not
any slower to compile a dts fragment append to the main dts than
fdoverlay is to apply an already compiled dtbo to the main dtb, so
there is not even a build time improvement here.

So, I can see only disadvantages and not advantages for compile time overlays.

Maybe one could ship a firmware update with a pool of overlays, then
firmware update installation could construct a final dtb from hardware
variant appropriate overlays.  That would be a way to make use of
non-dynamic overlays.  Otherwise I think there is no advantage to
non-runtime applied overlays over appended dts fragments.

>
> There is an easy way out, define the (sanitized) board name as a macro
> and let users worry about it.

Ok, I can add that.  I think the same identifier as constructed for
the C symbol of the compiled in dtb bytes will work.


> >
> > That is the use case here. So I can use rauc with just the standard
> > Barebox source without needing to patch it.
>
> I see the utility when using e.g. evaluation kits barebox already
> supports. Could be useful for DistroKit if RAUC support were to
> be added.

I used this originally for a devkit.  But it is Variscite's DART-6UL,
which is not supported in Barebox.  So I added support.  But not just
support for the one thing my FW does, support as a proper Barebox
devkit target.

Now I want to change the flash partitions for my specific FW design
and also want RAUC and barebox-state.  Should I include this in my
Barebox devkit support?  No one else wants it, at least not as I have
implemented it.   Should other users submit patches to Barebox to
change the partitions to what they want?  Of course not.

My answer is I should not have to patch Barebox to do this.  I do not
patch Barebox to change the defconfig I'm building with.  I do not
patch RAUC to configure it.  I do not patch wic to change my SD card
partitions.

Now we have made a custom board for the next phase and I have added a
new board to Barebox for this.  But still I use external dts fragments
despite having my FW specific Barebox git repo.  Because I do not want
FW system configuration to be done inside the bootloader codebase.  It
is much better if it is part of my FW git repo that configures
everything else in the system too.

In the old days, we had to patch a header in U-Boot to change *any*
bootloader configuration. Yuck! Then we had Barebox and it used the
kernel config system and we could have an external defconfig.  So much
better!  And Linux had board code with compiled in driver
configuration data, but then we got OF device trees and it was much
better.

So I want external dts files with Barebox.  Complete external dts is
really hard to do with the way Barebox images work.  But really, I
never write a complete dts from scatch. It is always a modification of
a base dts.  This patch to Barebox is not very complex and it lets me
do anything I have ever wanted to do with external Linux dts files in
Barebox.

>
> > If I was building two different
> > boards under yocto, I would have a machine specific override in my
> > barebox bbappend to add the only dts fragment for board I was building
> > for.  Yocto builds a different copy of barebox for each
> > target/machine.  I do not need barebox to use the preprocessor to turn
> > off the fragment I am not using.  I would not have yocto give it the
> > unused fragment in the first place.
>
> I usually avoid Yocto MACHINEs for board variants. Build same rootfs
> for both variants, ship two device trees and reference them either
> from FIT configurations or bootloader specs and let the bootloader worry
> about selecting the correct DT to boot.

When I have done one FW for multiple boards, I've always been able to
use the same bootloader and have it, or a preloader, determine board,
usually by resistor strapping on a GPIO or ADC, so it is easy to use
without drivers and to keep consistent on each board variant.  But if
one simply could not do that, then I see that multiple images from a
single Barebox machine target would be useful.  Also useful for
Buildroot, which is not as sophisticated as Yocto when it comes to
building a package in different ways.  One gets one target or one
host.  Not target-arm, target-arm-machineA, target-arm-machineB, etc.
like Yocto.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-09-20 20:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-08 18:59 Trent Piepho
2021-09-15 11:42 ` Ahmad Fatoum
2021-09-19 21:51   ` Trent Piepho
2021-09-20  9:02     ` Ahmad Fatoum
2021-09-20 20:43       ` Trent Piepho [this message]
2021-09-22  8:54         ` Ahmad Fatoum

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='CAMHeXxPZ9on3rZu92H1EeNQj79rUFBRbs5Qre=AS3U7_y=UueQ@mail.gmail.com' \
    --to=trent.piepho@igorinstitute.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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