Re: path for overlays

From: Mark Millard <marklmi_at_yahoo.com>
Date: Tue, 12 Jul 2022 05:16:44 UTC
Nick Kostyria <nick_at_i11.co> wrote on
Date: Tue, 12 Jul 2022 03:27:25 UTC :

> On Mon, 11 Jul 2022 00:18:59 -0300
> "Dr. Rolf Jansen" <freebsd-rj@cyclaero.com> wrote:
> 
> 
> > 
> > Anyway, for enabling I2C5 (we may choose from I2C3, I2C4, I2C5 and I2C6) on a Raspberry Pi 4, we do:
> > 
> > # fetch https://github.com/raspberrypi/linux/blob/rpi-5.15.y/arch/arm/boot/dts/overlays/i2c5-overlay.dts
> > # dtc -I dts -O dtb -b0 -@ -o /boot/msdos/overlays/i2c5.dtbo i2c5-overlay.dts
> > 
> > Then we add the following 2 lines to /boot/msdos/config.txt:
> > 
> >   gpio=12,13=a5
> >   dtoverlay=i2c5,pins_12_13
> > 
> 
> Hello.
> 
> I see you use /boot/msdos/overlays/ for overlays.
> I have a question for a long time and I can't find an answer.
> 
> What is the difference between /boot/msdos/overlays/ and /boot/dtb/overlays/ (fdt_overlays in /boot/loader.conf).

[I've written these notes to presume a RPi* context based on
U-Boot, not EDK2 UEFI/ACPI or the like, and  not for other
platforms.]

Some of this is just convention, and these notes are from memory,
but:

A) If the partitioning is MBR, /boot/msdos is a mount point where
   the msdosfs is mounted by FreeBSD. The RPi* firmware has access
   to the msdosfs (MS-DOS  file system). The FreeBSD loader gets a
   copy in the msdosfs (that is started by U-Boot, which in turn is
   started by the RPi* firmware) but the rest of FreeBSD does not
   go in the msdosfs.

B) If the partitioning is GPT /boot/efi is a mount point where
   the msdosfs is mounted by FreeBSD. The RPi* firmware has access
   to the msdosfs (MS-DOS  file system). The FreeBSD loader gets a
   copy in the msdosfs (that is started by U-Boot, which in turn is
   started by the RPi* firmware) but the rest of FreeBSD does not
   go in the msdosfs.

C) /boot/dtb is not used as such a mount point. It is part of the
   UFS (or ZFS) file system. The RPi* firmware and U-Boot do not
   have access into the UFS or ZFS file systems. This is a reason
   why a copy of an appropriate FreeBSD loader is put on the
   msdosfs. The FreeBSD loader, in turn, can access UFS or ZFS.

(A)/(B) are used for the dtb files so that the RPi* firmware loads
and sets up the dtb material to be in the DeviceTree, well before
FreeBSD is involved. The RPi* firmware and U-Boot hand over a
version of that DeviceTree to the FreeBSD loader and, from there
the FreeBSD kernel sees it.

(C) would be for only the FreeBSD kernel seeing/using the dtb.

FreeBSD does not have full control of the RPi* and some types
of overlays have to be processed by the RPi* firmware, if I
understand right. For RPi*'s /boot/dtb/ use is likely rare.

Do not presume all the content of these notes apply to other
types of FreeBSD platforms.

> What is more correct?
> What should be used?
> 
> /boot/msdos/overlays/ or /boot/dtb/overlays/
> /boot/msdos/config.txt or /boot/loader.conf

config.txt is for the RPi* firmware use, not FreeBSD's
direct use. loader.conf is for FreeBSD's direct use, not RPi*
firmware use (nor U-Boot). Nothing says that the notations
used in the two files would be compatible. Moving text correct
for one file to the other (but unchanged) is not likely to
work.

In this case, the config.txt text "dtoverlay=i2c5" is tied to
the file placement (as seen via FreeBSD's /boot/msdos mount
point):

/boot/msdos/overlays/i2c5.dtbo

and "pins_12_13" is a configuration parameter of some sort.
The "gpio=12,13=a5" is also defined for and handled by the
RPi* firmware, not directly by FreeBSD.

The lack of a /boot/msdosfs/ prefix (or, possibly, /boot/efi/
prefix) is a clue that loader.conf is just for FreeBSD's use.


I'll note that the RPi* firmware accesses the msdosfs long
before FreeBSD starts. The FreeBSD mount point use (for
access to the msdosfs from FreeBSD) happens later.

===
Mark Millard
marklmi at yahoo.com