Re: lua loader

From: Kyle Evans <kevans_at_freebsd.org>
Date: Sun, 31 Jul 2022 04:12:18 UTC
On Fri, Jul 29, 2022 at 6:06 PM Obsto Clades <obsto.clades@zohomail.com> wrote:
>
> On 7/29/22 14:26, Christopher Bowman wrote:
> > I’ve been looking through the lua code in /boot/loader/lua I can’t really say I understand how the FDT gets loaded or even find the code that does but I am able to load a DTB using:
> >
> > load -t dtb /boot/dtb/foo.dtb
> >
> > It doesn’t see that overlays are supported (at least in the lua loader).  I have a fdt_overlay=“overlay.dtb” statement in my loader.conf but I don’t see it being honored.
> > Am I correct in understanding that?
> >
> > If I’m not correct could someone point me at the code that does the overlay loading so I could look at it?
> > Thanks
> > Christopher
>
>
> I am also interesting in learning more about the lua loader.  So, if
> anybody replies to Christopher's question, could you please include me
> in your replies.
>

Hey,

I ended up reaching out to Christopher out-of-band (IRC) after
identifying them from a question they had asked a couple days ago. The
answer to this particular question is that fdt_overlays doesn't
require any real interpreter support -- it's all implemented in C
(see: stand/fdt/fdt_loader_cmd.c; I had gotten the path wrong both in
IRC and another e-mail I sent not too long ago. D'oh!). The
interpreted scripts will read loader.conf and stuff (most) of the
contents into the loader environment, which is how the C part
understands that it needs to apply some overlay(s). A couple of
different actions will trigger overlay application; it should happen
automatically at or maybe a little after loadelf (lualoader's term for
it) but before jumping to the kernel, or you can drop to the loader
prompt and trigger it manually by trying to inspect the loaded FDT
with the fdt command.

Thanks,

Kyle Evans