Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Last active January 24, 2023 05:20
Show Gist options
  • Save matthewjberger/9c00806cae4605cc91f9159aed8e2b42 to your computer and use it in GitHub Desktop.
Save matthewjberger/9c00806cae4605cc91f9159aed8e2b42 to your computer and use it in GitHub Desktop.

How to patch the device tree for a custom RPI CM4 board

Locating the kernel source

Run devtool modify linux-raspberrypi from the same shell you run bitbake my-image from. The kernel source tree will be copied to build/workspace/sources/linux-raspberrypi.

Make edits to the device tree at build/workspace/sources/linux-raspberrypi/arch/arm/boot/dts/bcm2711-rpi-cm4.dts and then run git diff > 0001-my-patch-description.patch.

Getting the name of the kernel recipe

To know the name of the kernel source recipe to override, we can ask bitbake.

# In bitbake, view the selected kernel recipe name
oe-pkgdata-util lookup-recipe kernel

For the RPI4 this should show linux-raspberrypi.

Directory structure for kernel patch

  • meta-mylayer
    • recipes-mylayer
    • recipes-kernel
      • linux
        • files
          • 0001-my-patch-description.patch (this is the diff from the kernel source tree we sourced)
      • linux-raspberrypi_%.bbappend

The content of linux-raspberrypi_%.bbappend is the following:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://0001-my-patch-description.patch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment