0

I built the yocto image for my board . Now I need to apply this patch

First, how do I figure out which recipe the patch goes to? Second, how do I apply this patch?

(I checked similar question but its patching yocto system itself, I don't want that)

I can list all my recipes with this command I found

bitbake-layers show-recipes

But I still don't know which of these recipes builds the file drivers/rpmsg/virtio_rpmsg_bus.c, the file I need to patch.

I also found three directories that have this c file:

find . -name virtio_rpmsg_bus.c
./build_wayland/tmp/work-shared/imx8mm-var-dart/kernel-source/drivers/rpmsg/virtio_rpmsg_bus.c
./build_wayland/tmp/work/aarch64-fslc-linux/linux-libc-headers/5.4-r0/linux-5.4/drivers/rpmsg/virtio_rpmsg_bus.c
./build_wayland/tmp/work/aarch64-mx8mm-fslc-linux/linux-imx-headers/5.4-r0/git/drivers/rpmsg/virtio_rpmsg_bus.c

These recipe folders have recipes-kernel/linux directory

sources/meta-freescale-3rdparty/recipes-kernel
sources/meta-freescale/recipes-kernel
sources/poky/meta-skeleton/recipes-kernel
sources/poky/meta/recipes-kernel
sources/poky/meta-yocto-bsp/recipes-kernel
sources/meta-virtualization/recipes-kernel
sources/meta-variscite-fslc/recipes-kernel
sources/meta-openembedded/meta-gnome/recipes-kernel
sources/meta-openembedded/meta-initramfs/recipes-kernel
sources/meta-openembedded/meta-networking/recipes-kernel
sources/meta-openembedded/meta-oe/recipes-kernel

I don't know which of these recipes might be building my c file virtio_rpmsg_bus.c

rosewater
  • 604
  • 2
  • 8
  • 22

1 Answers1

0

So I haven't done the build myself but here is what I could gather (this is a bit of a long shot on certain points... hope everything works, I'm open to discussion if that's not the case).

Finding the recipe to patch: In my opinion this might be often tricky to find what recipe does what in Yocto. If I'm not mistaken (which is very much a possibility) you should have a layer called meta-xilinx-bsp. Wihtin this layer there should be recipes-kernel/linux/linux_xlnx_[version].bb. This should be the recipe the patch should go to.

Applying the patch: To apply the patch the simplest way is to append the recipe.

  • Create the folder structure: In your own layer you need to reproduce the structure where the recipe is in the original layer. Here: meta-myLayer/recipes-kernel/linux/. In this folder create linux-xlnx_%.bbappend.
  • Create a .bbappend file: With this structure and name yocto will know this is an append to the original linux-xlnx_[verion_number].bb recipe. The % is put here instead of a version number. This is a wildcard and will append any version of the linux-xlnx recipe. Should you want to append only a specific version you can replace % by a version number.
  • Add the patch file to your directory: To do so create a folder called linux-xlnx next to you recipe. And within this folder create your patch file by copying the content you have in something like my-xlnx-patch.patch
  • Reference the patch file in the .bbappend: Indicate the file path in your linux-xlnx_%.bbappend as follow:
    FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
    SRC_URI_append = " \
         file://my-xlnx-patch.patch \
         "
    

I'm not 100% sure you need the first line but this will tell yocto that you have a patch file for this recipe and if I'm not mistaken yocto will take care of applying it.

LNiederha
  • 911
  • 4
  • 18
  • Thanks, this is very helpful. I don't have any meta-xilinx-bsp, but I ran "find sources/ -name recipes-kernel" and got a bunch of directories, and most have the linux subdirectory. I updated the original post with more information from this. – rosewater Oct 06 '21 at 15:37
  • Oh ok! Are compiling a kernel that is not xilinx and want to apply this patch from xilinx? I did not understand that at first but it would make sense – LNiederha Oct 06 '21 at 15:45
  • I looked up the Makefile that builds virtio_rpmsg_bus.c and I am guessing, the target is called vmlinux something, by going up the folders to the top level and looking at Makefile. After that I ran this command to find the recipe that builds vmlinux target: "oe-pkgdata-util find-path *vmlinux*" which led me to the recipe kernel-vmlinux: /boot/vmlinux-5.4.85+ge6d7d211f484 – rosewater Oct 06 '21 at 17:16
  • Then doing "grep -nr kernel-vmlinux *" led me to poky/meta/recipes-kernel/linux/linux-dummy.bb - So I think this is the recipe that builds the c file I want to patch – rosewater Oct 06 '21 at 17:18
  • Hum it might be this one... my guess is it is on of the recipe in poky/meta/recipe-kernel/linux/linux-[somthing].bb . If I remember correctly there should not be a lot of recipe like this. Maybe try appending them all to see if it works and if it does you could try to narrow down to the correct recipe. Imo it would be a little wired for your image to be built with a recipe called "dummy" – LNiederha Oct 07 '21 at 09:09
  • I found this webpage that worked for me https://variwiki.com/index.php?title=Yocto_Customizing_the_Linux_kernel – rosewater Oct 07 '21 at 18:22
  • Ok good job glad it work – LNiederha Oct 08 '21 at 11:25