How to Add Custom SPI Overlay (with 4 Chip Selects) to Yocto Built Image (tdx-reference-multimedia-image)?

I’m using the Apalis iMX8QM on an Ixora V1.3A carrier board. I have built a custom image using Yocto (tdx-reference-multimedia-image).

I need to enable SPI1 with 4 chip selects, and for this, I manually modified the device tree overlay file:

apalis-imx8_spi1_spidev_overlay.dts

I updated it to support 4 chip selects, compiled it to a .dtbo using dtc, and manually copied the resulting apalis-imx8_spi_spidev_overlay.dtbo to:

/boot/overlays/

This works as expected.

Now, I want to integrate this overlay directly via Yocto, so it’s included in the image during the build. Can you please guide me on how to:

  1. Properly modify or add this overlay in my custom Yocto layer?
  2. Ensure it is compiled and installed to /boot/overlays as part of the build?
  3. Optionally enable the overlay automatically via u-boot or /boot/overlays.txt?

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your detailed description. Here’s how you can properly integrate your custom SPI1 overlay into your Yocto-based image for the Apalis iMX8QM, ensuring it’s built and deployed automatically:


1. Add/Modify the Overlay in Your Custom Yocto Layer

First, place your overlay source file (apalis-imx8_spi1_spidev_overlay.dts) in a dedicated directory in your custom layer, such as:

meta-yourlayer/recipes-kernel/linux/device-tree-overlays/

For best practice, create a recipe for your overlay or use a bbappend to extend the existing overlays recipe.

Example:

  • Create:
    meta-yourlayer/recipes-kernel/linux/device-tree-overlays_git.bbappend
    
  • Inside this file, append your overlay:
    SRC_URI += "file://apalis-imx8_spi1_spidev_overlay.dts"
    

For more detail, see:


2. Ensure Compilation and Installation

The main overlays recipe is:

meta-toradex-nxp/recipes-kernel/linux/device-tree-overlays_git.bb

If your overlay .dts is added properly and referenced in the recipe, Yocto will automatically compile it to .dtbo and install it to /boot/overlays/.

  • Ensure that your overlay is included in the OVERLAY_FILES variable within the recipe or in your bbappend.

Example:

OVERLAY_FILES += "apalis-imx8_spi1_spidev_overlay.dts"
  • Check that the compiled .dtbo appears under /boot/overlays/ after you build and flash your image.

Details:


3. Enable the Overlay Automatically

To load the overlay at boot:

  • Add your overlay to /boot/overlays.txt by customizing the overlays.txt file in your Yocto layer or via a rootfs overlay.
  • The line should look like:
    fdt_overlays=apalis-imx8_spi1_spidev_overlay.dtbo
    
    You can include multiple overlays, separated by spaces.

To do this in Yocto:

  • Use a bbappend or a custom recipe to install the default overlays.txt file to ${D}${bootdir}/.

Example:

do_install_append() {
    echo "fdt_overlays=apalis-imx8_spi1_spidev_overlay.dtbo" > ${D}${bootdir}/overlays.txt
}
  • Or, you can edit the file post-deployment once for testing.

After any change, always synchronize and reboot:

sync
reboot

Reference:


Summary

  1. Add .dts to your Yocto layer and reference it in a bbappend.
  2. Yocto will compile and install the .dtbo if it’s listed in the recipe’s overlays.
  3. Add your overlay to overlays.txt for automatic boot application.

If you need concrete examples or have a specific layer structure, feel free to ask for more details!

Best regards,
Toradex AI Assistant.

Hey, @subhash-vijigi,

Take a look into our documentation on device tree overlays, this section gives instructions on how to compile and apply them automatically using Yocto. You can also look into this example on github, showing the complete Yocto layer to enable a device tree overlay.

Let me know if you manage to deploy the overlay or if you find any issues.

Best regards,