1

I have a Linux kernel for NXP i.MX6. There are some capture kernel modules in /driver/media/platform/mxc/capture.

One of the files called mxc_v4l2_capture.c. I had to change this file for using it with my own new kernel driver.

I created a repository with my driver and the sources for mxc_v4l2_capture. Then I made a new Yocto recipe in my layer recipies-kernel -> kernel-modules->my-kernel-module.bb

Yocto can build these two kernel modules (my-kernel-module.ko and mxc_v4l2_capture.ko).

Okay, now there is a problem because the kernel recipe already builds the mxc_v4l2_capture module. Therefore I want to manipulate the Makefile for the original kernel modules and exclude the make of mxc_v4l2_capture.

I have created the patch but I don't know how to use the patch with Yocto. Where to place it and how can I call it?

Normally I put a patch into a .bbappend file and finish but I don't know the name of the recipe that build the kernel modules.

It would be great if there is a way without manipulating this Makefile.

Is there a way to solve this with my kernel module recipe?

Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95
Michael
  • 43
  • 5

2 Answers2

1

mxc_v4l2_capture.c is in-tree kernel driver. If you want to change the in-tree driver code and compile, it's highly recommended to patch the kernel and compile the kernel with usual recipe.

Having additional bitbake recipe for the in-tree kernel module is not necessary. To patch the kernel and compile, you can use .bbappend or .bb itself. For example,

if you have recipes-kernel/linux/linux-stable_4.19.75.bb in your Yocto BSP layer, you can add the patch to SRC_URI as below.

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
SRC_URI += "file://mxc_v4l2_capture.patch"

Now, you create recipes-kernel/linux/linux-stable-4.19.75/ and copy the mxc_v4l2_capture.patch file inside.

Or if you don't have permission or not possible to modify the Kernel recipe in BSP layer, you can create .bbappend in your custom layer. For the above example, you can create linux-stable_4.19.75.bbappend (specific version) or linux-stable_%.bbappend (any version). Then place the same content as mentioned above.

Yocto supports various patch formats, refer here for more details.

Parthiban
  • 2,130
  • 2
  • 14
  • 27
0

Look at this answer I wrote some days ago. The steps are basically the same. Using

devtool modify virtual/kernel

will create a working copy in build/workspace where you can do the work you want. Commiting those changes to the local branch and running

devtool finish linux-mainline <path-to-your-layer> 

will create a .bbappend file with the patches already created and put to the correct location for you.

If you want to learn how to do it manually follow the advice @Parthiban gave.

Stanislav
  • 155
  • 2
  • 9