Using populate_sdk to include kernel headers

How to include Linux kernel headers as part of the Yocto SDK?

I am using Yocto 1.8 (fido) in an embedded project and want to do kernel module development outside the tree. Currently, I can create kernel modules (except for the bitback) by pointing my $KERNEL_PATH to the poky/build/tmp/work-shared/<machine>/kernel-source/ when make is run. I do not want to do this in the long run, however, since others need to easily create modules without installing and creating a complete image from the beatbox.

I can generate the SDK using bitbake myimage -c populate_sdk . However, this does not include kernel headers (all I have ever seen is sysroots/<mach>/usr/include/linux ). How to make kernel headers be included in the SDK? Also, I do not want the kernel headers to appear as part of my target image.

[edit] My recipe image is as follows:

 EXTRA_IMAGE_FEATURES_append = " eclipse-debug debug-tweaks" TOOLCHAIN_HOST_TASK_append = " nativesdk-cmake" IMAGE_INSTALL = "packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL} util-linux kernel-modules netbase busybox base-passwd base-files sysvinit initscripts bash gdbserver strace sysfsutils dtc gawk ethtool grep sed wget iptables oprofile net-tools dropbear rsync stress-ng rt-tests i2c-tools" inherit core-image 

The kernel I use is linux-altera-ltsi-rt in the meta-altera layer.

+6
source share
1 answer

In the fido release, kernel assembly handling has been changed. In previous releases, you can usually just skip to the use case below.

In fido , if you want the src core and build system to be available in the SDK, you must add

 TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc" 

to your image recipe. This ensures that the new kernel-devsrc is installed in your toolchain.

The procedure below is intended only to ensure that the rest of the workflow is fully understood (although this is not strictly part of the original question).

Usage example

Let's assume the Makefile module is as follows:

 obj-m += hello-1.o all: make -C $(KERNEL_SRC M=$(PWD) modules clean: make -C $(KERNEL_SRC) M=$(PWD) clean 

Example taken from the Linux kernel module programming guide (note that there must be a tab character for indentation for actual commands).

Then you need to define KERNEL_SRC as sysroots/<mach>/usr/src/kernel/ , either in the Makefile or from your call request. (Using a variable of type KERNEL_SRC ensures that your module recipe automatically selects the right place when creating using the beatbox).

To manually create a kernel module:

  • Extract the environment file - * for your SDK.
  • Go to the modules directory.
  • KERNEL_SRC=<sdk-install-path>/sysroots/<mach>/usr/src/kernel LDFLAGS="" make However, this will fail because fixdep cannot be found. We will fix it manually.
  • cd <sdk-install-path>/sysroots/<mach>/usr/src/kernel
  • make silentoldconfig scripts

    If you need to run this using sudo, be sure to send the environment file to the sudo environment: sudo bash -c "source <sdk-install-path>/environment-setup-<mach> && make silentoldconfig sripts"

  • Return to your modules directory.
  • KERNEL_SRC=<sdk-install-path>/sysroots/<mach>/usr/src/kernel LDFLAGS="" make

Now it will allow you to create your own modules.

If you do not have a kernel source under ysroots/<mach>/usr/src/kernel/ , we will need to study this.

+10
source

All Articles