mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] RPi3b+ boot sequence with DistroKit (barebox)
@ 2019-09-01  2:35 Jon Ringle
  2019-09-03 13:53 ` Roland Hieber
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Ringle @ 2019-09-01  2:35 UTC (permalink / raw)
  To: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 1881 bytes --]

I am a little confused about the boot sequence and where each boot stage
gets configuration from. Here's my current understanding, which I am sure
is flawed:

1. On power on or reset, the GPU executes the 1st stage bootloader from ROM
2. 1st stage bootloader reads the file bootcode.bin from the 1st partition
(fat) on SDCard and loads it to L2 cache and executes this as the 2nd stage
bootloader.
3. The 2nd stage bootloader initializes and enables SDRAM and reads the
file start.elf to ram as the 3rd stage bootloader.
4. The 3rd stage bootloader reads the config.txt.
[This is the part that confuses me with regards to how other RPi distros
work vs DistroKit with barebox...]
I thought that this stage would also load the DTB and any dtoverlay before
loading the "4th stage bootloader" (by default is the file kernel.img, but
barebox changes this by having `kernel=barebox.img` in config.txt).
However, it seems like barebox is also handling the loading and
manipulating of the DTB that will then be used by the Linux kernel when
barebox boots to it...

5. The 3rd stage bootloader read the "4th stage" and releases the CPU to
execute it.
With DistroKit, the config.txt and the GPU bootloader images, and
barebox.img are on /dev/disk0.0 (available in barebox at /boot/), but the
DTB is on /dev/disk0.1 (available in /mnt/disk0.1/boot/). There is neither
a /boot/overlays/ nor a /mnt/disk0.1/boot/overlays/ directory. (Which is
why I'm confused with my comments on 4 above.)

A) Can I create an overlays/ directory in order to affect the DTB that gets
sent to the Linux kernel as described by the RPi docs:
https://www.raspberrypi.org/documentation/configuration/device-tree.md and
https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README ?

B) If so, where should the overlays/ directory live...?
C) Or does barebox handle this in a different way?

Thanks,
-Jon

[-- Attachment #1.2: Type: text/html, Size: 2365 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] RPi3b+ boot sequence with DistroKit (barebox)
  2019-09-01  2:35 [ptxdist] RPi3b+ boot sequence with DistroKit (barebox) Jon Ringle
@ 2019-09-03 13:53 ` Roland Hieber
  2019-09-07  5:42   ` Jon Ringle
  0 siblings, 1 reply; 6+ messages in thread
From: Roland Hieber @ 2019-09-03 13:53 UTC (permalink / raw)
  To: Jon Ringle; +Cc: ptxdist

On Sat, Aug 31, 2019 at 10:35:05PM -0400, Jon Ringle wrote:
> I am a little confused about the boot sequence and where each boot stage
> gets configuration from. Here's my current understanding, which I am sure
> is flawed:
> 
> 1. On power on or reset, the GPU executes the 1st stage bootloader from ROM
> 2. 1st stage bootloader reads the file bootcode.bin from the 1st partition
> (fat) on SDCard and loads it to L2 cache and executes this as the 2nd stage
> bootloader.
> 3. The 2nd stage bootloader initializes and enables SDRAM and reads the
> file start.elf to ram as the 3rd stage bootloader.

I cannot tell anything before this point, this is totally opaque to me.

> 4. The 3rd stage bootloader reads the config.txt.
> [This is the part that confuses me with regards to how other RPi distros
> work vs DistroKit with barebox...]

Why? config.txt is the standard way to configure the ROM loader, and it
is even present on a standard Raspbian image:
https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md

> I thought that this stage would also load the DTB and any dtoverlay before
> loading the "4th stage bootloader" (by default is the file kernel.img, but
> barebox changes this by having `kernel=barebox.img` in config.txt).
> However, it seems like barebox is also handling the loading and
> manipulating of the DTB that will then be used by the Linux kernel when
> barebox boots to it...

That's correct, DistroKit currently does not install any DTB overlays to
the boot partition, because barebox could not do anything with them in
the past. As far as I understand, barebox uses its compiled-in device
tree (which is mostly the upstream kernel device tree), and passes it to
the kernel on boot.

> 5. The 3rd stage bootloader read the "4th stage" and releases the CPU to
> execute it.
> With DistroKit, the config.txt and the GPU bootloader images, and
> barebox.img are on /dev/disk0.0 (available in barebox at /boot/), but the
> DTB is on /dev/disk0.1 (available in /mnt/disk0.1/boot/). There is neither
> a /boot/overlays/ nor a /mnt/disk0.1/boot/overlays/ directory. (Which is
> why I'm confused with my comments on 4 above.)
> 
> A) Can I create an overlays/ directory in order to affect the DTB that gets
> sent to the Linux kernel as described by the RPi docs:
> https://www.raspberrypi.org/documentation/configuration/device-tree.md and
> https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README ?

I don't know if barebox can handle DTBOs in the meantime, there were
some patches posted to the mailing list, but I don't know what exactly
needs to be done here. This seems like a question for the barebox
mailing list...
http://lists.infradead.org/mailman/listinfo/barebox

> B) If so, where should the overlays/ directory live...?

If you put the DTBOs into configs/platform-v7a/rpi-firmware/overlays/,
you can change configs/platform-v7a/rules/image-rpi3.make to pick them
up when you add the files to IMAGE_RPI3_DATA (this works by passing the
variable contents to genimage by replacing @FIRMWARE_RPI3@ in
configs/platform-v7a/config/images/rpi3.config) (and accordingly for
s/rpi3/rpi2/).

 - Roland

> C) Or does barebox handle this in a different way?
> 
> Thanks,
> -Jon

> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de


-- 
Roland Hieber                     | r.hieber@pengutronix.de     |
Pengutronix e.K.                  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] RPi3b+ boot sequence with DistroKit (barebox)
  2019-09-03 13:53 ` Roland Hieber
@ 2019-09-07  5:42   ` Jon Ringle
  2019-09-07 20:06     ` Jon Ringle
  0 siblings, 1 reply; 6+ messages in thread
From: Jon Ringle @ 2019-09-07  5:42 UTC (permalink / raw)
  To: Roland Hieber; +Cc: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 812 bytes --]

On Tue, Sep 3, 2019 at 9:53 AM Roland Hieber <rhi@pengutronix.de> wrote:

> On Sat, Aug 31, 2019 at 10:35:05PM -0400, Jon Ringle wrote:
> > B) If so, where should the overlays/ directory live...?
>
> If you put the DTBOs into configs/platform-v7a/rpi-firmware/overlays/,
> you can change configs/platform-v7a/rules/image-rpi3.make to pick them
> up when you add the files to IMAGE_RPI3_DATA (this works by passing the
> variable contents to genimage by replacing @FIRMWARE_RPI3@ in
> configs/platform-v7a/config/images/rpi3.config) (and accordingly for
> s/rpi3/rpi2/).
>
>
The problem I am having is that there doesn't seem to be a way to tell
genimage to create files in a subdirectory.
In the image there needs to be a subdir `overlays/`, but genimage is
putting all files in the root dir of the image.

-Jon

[-- Attachment #1.2: Type: text/html, Size: 1218 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] RPi3b+ boot sequence with DistroKit (barebox)
  2019-09-07  5:42   ` Jon Ringle
@ 2019-09-07 20:06     ` Jon Ringle
  2019-09-09  6:15       ` Michael Olbrich
  2019-09-09 10:59       ` Roland Hieber
  0 siblings, 2 replies; 6+ messages in thread
From: Jon Ringle @ 2019-09-07 20:06 UTC (permalink / raw)
  To: Roland Hieber; +Cc: ptxdist


[-- Attachment #1.1: Type: text/plain, Size: 2076 bytes --]

On Sat, Sep 7, 2019 at 1:42 AM Jon Ringle <jonringle@gmail.com> wrote:

>
> On Tue, Sep 3, 2019 at 9:53 AM Roland Hieber <rhi@pengutronix.de> wrote:
>
>> On Sat, Aug 31, 2019 at 10:35:05PM -0400, Jon Ringle wrote:
>> > B) If so, where should the overlays/ directory live...?
>>
>> If you put the DTBOs into configs/platform-v7a/rpi-firmware/overlays/,
>> you can change configs/platform-v7a/rules/image-rpi3.make to pick them
>> up when you add the files to IMAGE_RPI3_DATA (this works by passing the
>> variable contents to genimage by replacing @FIRMWARE_RPI3@ in
>> configs/platform-v7a/config/images/rpi3.config) (and accordingly for
>> s/rpi3/rpi2/).
>>
>>
> The problem I am having is that there doesn't seem to be a way to tell
> genimage to create files in a subdirectory.
> In the image there needs to be a subdir `overlays/`, but genimage is
> putting all files in the root dir of the image.
>
>
It was a pain in the ass to figure out how to get genimage to cooperate
with putting the *.dtbo in the overlays/ dir in the image.
This is what I came up with:

IMAGE_RPI3_DATA := \
    $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.bin) \
    $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.elf) \
    $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.dat) \
    $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.dtb) \
    $(wildcard $(IMAGE_RPI3_DATA_DIR)/config.txt)
IMAGE_RPI3_OVERLAYS_DATA := \
    $(wildcard $(IMAGE_RPI3_DATA_DIR)/overlays/*.dtbo)


#
----------------------------------------------------------------------------
# Image
#
----------------------------------------------------------------------------

define squote
$(addsuffix $(ptx/def/squote),$(addprefix $(ptx/def/squote),$(1)))
endef

define squote_and_comma
$(subst $(ptx/def/space),$(comma) ,$(call squote, $(1)))
endef

define filespec
$(patsubst %,file $(call squote,$(1)/$(notdir $(2))) { image=$(call squote,
$(2)) },$(2))
endef

IMAGE_RPI3_ENV := \
        FIRMWARE_RPI3="$(call squote_and_comma,$(IMAGE_RPI3_DATA))" \
        FIRMWARE_RPI3_OVERLAYS="$(foreach
file,$(IMAGE_RPI3_OVERLAYS_DATA),$(call filespec,overlays,$(file)))"

-Jon

[-- Attachment #1.2: Type: text/html, Size: 2929 bytes --]

[-- Attachment #2: Type: text/plain, Size: 92 bytes --]

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] RPi3b+ boot sequence with DistroKit (barebox)
  2019-09-07 20:06     ` Jon Ringle
@ 2019-09-09  6:15       ` Michael Olbrich
  2019-09-09 10:59       ` Roland Hieber
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Olbrich @ 2019-09-09  6:15 UTC (permalink / raw)
  To: ptxdist

On Sat, Sep 07, 2019 at 04:06:24PM -0400, Jon Ringle wrote:
> On Sat, Sep 7, 2019 at 1:42 AM Jon Ringle <jonringle@gmail.com> wrote:
> > On Tue, Sep 3, 2019 at 9:53 AM Roland Hieber <rhi@pengutronix.de> wrote:
> >
> >> On Sat, Aug 31, 2019 at 10:35:05PM -0400, Jon Ringle wrote:
> >> > B) If so, where should the overlays/ directory live...?
> >>
> >> If you put the DTBOs into configs/platform-v7a/rpi-firmware/overlays/,
> >> you can change configs/platform-v7a/rules/image-rpi3.make to pick them
> >> up when you add the files to IMAGE_RPI3_DATA (this works by passing the
> >> variable contents to genimage by replacing @FIRMWARE_RPI3@ in
> >> configs/platform-v7a/config/images/rpi3.config) (and accordingly for
> >> s/rpi3/rpi2/).
> >>
> >>
> > The problem I am having is that there doesn't seem to be a way to tell
> > genimage to create files in a subdirectory.
> > In the image there needs to be a subdir `overlays/`, but genimage is
> > putting all files in the root dir of the image.
> >
> >
> It was a pain in the ass to figure out how to get genimage to cooperate
> with putting the *.dtbo in the overlays/ dir in the image.

The file / files syntax is really only meant for very simple stuff. The
vfat image type supports the rootdir  just like other filesystem types. So
maybe it would be easier to use that instead.

Michael

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ptxdist] RPi3b+ boot sequence with DistroKit (barebox)
  2019-09-07 20:06     ` Jon Ringle
  2019-09-09  6:15       ` Michael Olbrich
@ 2019-09-09 10:59       ` Roland Hieber
  1 sibling, 0 replies; 6+ messages in thread
From: Roland Hieber @ 2019-09-09 10:59 UTC (permalink / raw)
  To: jon; +Cc: ptxdist

On Sat, Sep 07, 2019 at 04:06:24PM -0400, Jon Ringle wrote:
> On Sat, Sep 7, 2019 at 1:42 AM Jon Ringle <jonringle@gmail.com> wrote:
> 
> >
> > On Tue, Sep 3, 2019 at 9:53 AM Roland Hieber <rhi@pengutronix.de> wrote:
> >
> >> On Sat, Aug 31, 2019 at 10:35:05PM -0400, Jon Ringle wrote:
> >> > B) If so, where should the overlays/ directory live...?
> >>
> >> If you put the DTBOs into configs/platform-v7a/rpi-firmware/overlays/,
> >> you can change configs/platform-v7a/rules/image-rpi3.make to pick them
> >> up when you add the files to IMAGE_RPI3_DATA (this works by passing the
> >> variable contents to genimage by replacing @FIRMWARE_RPI3@ in
> >> configs/platform-v7a/config/images/rpi3.config) (and accordingly for
> >> s/rpi3/rpi2/).
> >>
> >>
> > The problem I am having is that there doesn't seem to be a way to tell
> > genimage to create files in a subdirectory.
> > In the image there needs to be a subdir `overlays/`, but genimage is
> > putting all files in the root dir of the image.
> >
> >
> It was a pain in the ass to figure out how to get genimage to cooperate
> with putting the *.dtbo in the overlays/ dir in the image.
> This is what I came up with:
> 
> IMAGE_RPI3_DATA := \
>     $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.bin) \
>     $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.elf) \
>     $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.dat) \
>     $(wildcard $(IMAGE_RPI3_DATA_DIR)/*.dtb) \
>     $(wildcard $(IMAGE_RPI3_DATA_DIR)/config.txt)
> IMAGE_RPI3_OVERLAYS_DATA := \
>     $(wildcard $(IMAGE_RPI3_DATA_DIR)/overlays/*.dtbo)
> 
> 
> #
> ----------------------------------------------------------------------------
> # Image
> #
> ----------------------------------------------------------------------------
> 
> define squote
> $(addsuffix $(ptx/def/squote),$(addprefix $(ptx/def/squote),$(1)))
> endef
> 
> define squote_and_comma
> $(subst $(ptx/def/space),$(comma) ,$(call squote, $(1)))
> endef
> 
> define filespec
> $(patsubst %,file $(call squote,$(1)/$(notdir $(2))) { image=$(call squote,
> $(2)) },$(2))
> endef
> 
> IMAGE_RPI3_ENV := \
>         FIRMWARE_RPI3="$(call squote_and_comma,$(IMAGE_RPI3_DATA))" \
>         FIRMWARE_RPI3_OVERLAYS="$(foreach
> file,$(IMAGE_RPI3_OVERLAYS_DATA),$(call filespec,overlays,$(file)))"

Ah yes, that's one solution. I remember I was running into the same
problem a few months back. My solution was rather to pack all firmware
files into a new tar.gz, let genimage create a new image for the RPi
boot partition from that tar.gz, and let genimage pick up that image in
the rpi[123].config. Sadly I didn't yet get around to integrating this
fully into the rest of DistroKit, so this one branch [1] is still lying
around in need of a feather duster...

[1]: https://git.pengutronix.de/cgit/rhi/DistroKit/log/?h=rhi/rpi-firmware-package

 - Roland

-- 
Roland Hieber                     | r.hieber@pengutronix.de     |
Pengutronix e.K.                  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-09 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-01  2:35 [ptxdist] RPi3b+ boot sequence with DistroKit (barebox) Jon Ringle
2019-09-03 13:53 ` Roland Hieber
2019-09-07  5:42   ` Jon Ringle
2019-09-07 20:06     ` Jon Ringle
2019-09-09  6:15       ` Michael Olbrich
2019-09-09 10:59       ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox