Skip to contentSkip to conversation

Adding Device Tree Overlays for MIPI-CSI2 Camera and libcamera to u-boot in a buildroot or Yocto Build

DISCUSSION [email protected] 3 participants 3 messages May 7, 2025 – May 8, 2025

lore
Share & tools
lore
#0 lore raw

Hi,

Does anyone have any advice on how to add DTOs needed by libcamera to a u-boot in a buildroot or Yocto build or on whether it's more appropriate to add them as part of u-boot or as another part of the build?

We'd like to add Kieran's DTOs

https://git.uk.ideasonboard.com/camera/dt-overlays/src/branch/main/arch/arm64/boot/dts/freescale

to the buildroot default configuration for Debix Model A SBC

https://github.com/buildroot/buildroot/blob/master/configs/polyhex_debix_model_a_defconfig

Ideally we'd also like to add the overlays for the Sony IMX 708 Image Sensor used in the RPi V3 camera but these aren't mainline:

https://github.com/raspberrypi/linux/blob/rpi-6.12.y/arch/arm/boot/dts/overlays/imx708-overlay.dts
https://github.com/raspberrypi/linux/blob/rpi-6.12.y/arch/arm/boot/dts/overlays/imx708.dtsi

We're planning to use the Debix Model A SBC or Debix SoM A with SoM A I/O board to prototype a new open source wildlife camera for our work in conservation of tree dwelling endangered dormice

https://new-homes-for-old-friends.cairnwater.com/

then after field studies with the prototype design a custom board for an NXP i.MX 8M Plus SoM.

The analysis for the new open source wildlife camera is here:

https://github.com/William-Robert-Robertson/WildCamera

Will

#1 lore raw

Hi Will,

Quoted 8 lines · On 5/7/25 6:30 PM, [email protected] wrote:

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Hi,

Does anyone have any advice on how to add DTOs needed by libcamera to a u-boot in a buildroot or Yocto build or on whether it's more appropriate to add them as part of u-boot or as another part of the build?

If we're talking solely about cameras, I'm not sure it's important to have the overlay applied for use within U-Boot so I would suggest to focus on generating a FIT image for the kernel which has the base device tree and one or more device tree overlays that will automatically be applied by U-Boot based on the fdt property in a configuration node.

This however means that the DTB used in U-Boot will be different from the one by the kernel. There's some effort for some architectures/vendors to pass the DTB along stages (multiple U-Boot stages, TF-A, OP-TEE, followed by the kernel) instead of loading different ones. I believe this would be bloblist or the upcoming (?) passage standard. I have no experience with those as all my boards use a different DTB in U-Boot stages and kernel.

Quoted 6 lines

We'd like to add Kieran's DTOs

https://eur02.safelinks.protection.outlook.com/? url=https%3A%2F%2Fgit.uk.ideasonboard.com%2Fcamera%2Fdt- overlays%2Fsrc%2Fbranch%2Fmain%2Farch%2Farm64%2Fboot%2Fdts%2Ffreescale&data=05%7C02%7Cquentin.schulz%40cherry.de%7Ca8e0b5c29f524a517d7f08dd8d8d899e%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638822361226841805%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=8OQ%2BjZjI9Fi1qd9qTwDRiD1wvX6llMGZINDL%2BiPm%2B6o%3D&reserved=0

to the buildroot default configuration for Debix Model A SBC

The easiest is to upstream those to the Linux kernel or have a forked kernel with those in-tree and then use BR2_LINUX_KERNEL_INTREE_DTSO_NAMES to specify which device tree overlays to build and add.

Buildroot also seems to have support for out-of-tree DTSO but those likely need to be within the Buildroot main tree to be discoverable?

I have no clue how to generate a FIT image for the kernel with Buildroot though.

Don't forget to select BR2_LINUX_KERNEL_INTREE_DTSO_NAMES otherwise you won't be able to apply the overlay on top of the base dtb as symbols would be missing.

Quoted 5 lines

https://eur02.safelinks.protection.outlook.com/? url=https%3A%2F%2Fgithub.com%2Fbuildroot%2Fbuildroot%2Fblob%2Fmaster%2Fconfigs%2Fpolyhex_debix_model_a_defconfig&data=05%7C02%7Cquentin.schulz%40cherry.de%7Ca8e0b5c29f524a517d7f08dd8d8d899e%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C638822361226862151%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=UTJeVWJcHnslwSkLjGFVyXIwGnGJuf%2FinrOD%2F%2F1RV5s%3D&reserved=0

Ideally we'd also like to add the overlays for the Sony IMX 708 Image Sensor used in the RPi V3 camera but these aren't mainline:

Then upstream them or use a forked kernel.

[...]

For Yocto, I believe you could have a recipe only for the overlays for the debix model a hosted on Kieran's gitea which would inherit the kernel-devicetree.bbclass (or is it devicetree.bbclass?)? How to make those out-of-tree device tree overlays part of the kernel FIT image, no clue. Probably kernel-fitimage.bbclass inherit in a recipe and some custom callbacks? I seem to recall Yocto isn't fully ready for overlays right now so there may be additional work required.

Another option could be to use extlinux.conf with FDTOVERLAYS. This is available in uboot-extlinux-config.bbclass, but only since Walnascar (5.2) released 3 hours ago. I tested it myself back when I contributed it, so it should reasonably work :) Don't forget to compile your in-tree kernel base dtb with -@ (for symbols).

I'm not sure the u-boot mailing list is the appropriate place to discuss those though as there doesn't seem to be much required in U-Boot aside from the usual (FIT and/or extlinux.conf support), Buildroot and Yocto mailing lists could probably be better places.

Cheers,
Quentin

#2 lore raw
In reply to [email protected]
Quoted 25 lines · On 07-05-2025 18:30, [email protected] wrote:

Hi,

Does anyone have any advice on how to add DTOs needed by libcamera to a u-boot in a buildroot or Yocto build or on whether it's more appropriate to add them as part of u-boot or as another part of the build?

We'd like to add Kieran's DTOs

https://git.uk.ideasonboard.com/camera/dt-overlays/src/branch/main/arch/arm64/boot/dts/freescale

to the buildroot default configuration for Debix Model A SBC

https://github.com/buildroot/buildroot/blob/master/configs/polyhex_debix_model_a_defconfig

Ideally we'd also like to add the overlays for the Sony IMX 708 Image Sensor used in the RPi V3 camera but these aren't mainline:

https://github.com/raspberrypi/linux/blob/rpi-6.12.y/arch/arm/boot/dts/overlays/imx708-overlay.dts

https://github.com/raspberrypi/linux/blob/rpi-6.12.y/arch/arm/boot/dts/overlays/imx708.dtsi

We're planning to use the Debix Model A SBC or Debix SoM A with SoM A I/O board to prototype a new open source wildlife camera for our work in conservation of tree dwelling endangered dormice

https://new-homes-for-old-friends.cairnwater.com/

Quoted 7 lines

then after field studies with the prototype design a custom board for an NXP i.MX 8M Plus SoM.

The analysis for the new open source wildlife camera is here:

https://github.com/William-Robert-Robertson/WildCamera

Will

You can enable device-tree overlay loading in the kernel and do it all there.

U-boot can also do it for you, example bootscript that detects the panel to use and then loads the appropriate overlay (this runs on a RPi4 board):

fdt addr ${fdt_addr}
setenv panel fancy-display-panel

[Magic I2C stuff to detect hardware and set "panel"]

fdt resize 8192
fatload mmc 0:1 ${kernel_addr_r} /overlays/${panel}.dtbo fdt apply ${kernel_addr_r}

[load and boot your kernel]

Example recipe to create the overlay, e.g. "device-tree-fancy.bb":

SUMMARY = "Devicetree overlay for FANCY board"

SRC_URI = "\
    file://fancy-display-panel.dts \
    file://fancier-display-panel.dts \
    "

inherit devicetree

# Override to NOT have a devicetree subdir
FILES:${PN} = "/boot/overlays"

devicetree_do_install() {
    for DTB_FILE in ls *.dtb *.dtbo; do
        install -Dm 0644 ${B}/${DTB_FILE} ${D}/boot/overlays/${DTB_FILE} done
}

do_deploy() {
    for DTB_FILE in ls *.dtb *.dtbo; do
        install -Dm 0644 ${B}/${DTB_FILE} ${DEPLOYDIR}/${DTB_FILE} done
}

Signature · 10 lines
Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: [email protected]
W: www.topic.nl