linuxsdkkernelyoctotoolchain

Yocto: How to add custom header files to sdk sysroot


I created a custom header file named soc-v4l2-controls.h inside the kernel source, and it is located in the include/uapi/linux folder.

What I want to achieve is to include this header file in the SDK sysroot. I build the SDK using the following command, but I cannot find the custom header file inside the sysroot, especially in the directory /opt/.../sysroots/cortexa53-poky-linux/usr/include/linux/.

bitbake core-image-soc -c populate_sdk

I have two questions regarding this issue:

  1. Is it normal that custom header files in the kernel source are not included in the sysroot, even though I set the PREFERRED_PROVIDER for the virtual kernel to my kernel recipe? In the core-image-soc.bb file, I have specified the following line:
PREFERRED_PROVIDER_virtual/kernel = "linux-soc"
  1. The Yocto documentation (https://docs.yoctoproject.org/5.0.5/sdk-manual/appendix-customizing-standard.html#adding-individual-packages-to-the-standard-sdk) mentions that the variable TOOLCHAIN_TARGET_TASK can be used to include libraries or headers in the SDK. However, there are no concrete examples on how to properly use this variable. How can I use TOOLCHAIN_TARGET_TASK in my case to include my custom header?

Thank you for your help!


Solution

  • If your soc-v4l2-controls.h correctly added to the kernel source of the Linux recipe, it will be deployed together with the full kernel sources in sysroot if you start to use kernel-devsrc in your installed Yocto recipe list.

    If you like to provide soc-v4l2-controls.h in usr/include/... for any user-space stuff, you have to make a manual install task for it in a custom .bbappend recipes files.