[yocto] Custom kernel headers and SDK

Longchamp, Valentin Valentin.Longchamp at keymile.com
Thu Dec 10 01:46:46 PST 2015


Hi Martin,

Thanks a lot for the suggestion. I had in the meantime come to a simliar solution: define a linux-XXX-headers recipe in our own meta layer where I install the missing kernel headers and then I add this linux-XXX-headers-dev package to our SDK's sysroot thanks to TARGET_TOOLCHAIN_TASK.
Your implementation looks fine and I am going to pick some ideas from it.

However, I have stumbled upon another problem with this approach: it works well if you add new files to the kernel headers. We unforntunately have at least one uapi file (i2c.h to name it) that is present in the standard kernel headers where we have our own version with some additions/extensions. If I install our version from ou linux-XXX-headers recipe, bitbake (correctly) complains that this file is provided by 2 packages (linux-libc-headers and linux-XXX-headers). And here I really don't know how to solve this issue. Any ideas/suggestions ?

Thanks

Valentin
________________________________________
From: Vuille, Martin (Martin) [vmartin at avaya.com]
Sent: Wednesday, December 09, 2015 5:40 PM
To: Longchamp, Valentin; yocto at yoctoproject.org
Cc: Brunck, Holger
Subject: RE: Custom kernel headers and SDK

Hi Valentin,

Not sure whether this the “canonical” Yocto way, but here’s how we solved
the same issue.

First, let me say that we use a BSP from our technology partner, and have
our own meta-XXX layer for customization.


-          Created a .bbappend in our layer for the kernel recipe

-          In the .bbappend

o   add a do_install_append task that creates directory ${D}${includedir}/XXX
and installs the required headers from kernel source into that
directory

o   add a new package: PACKAGES += “ XXX-kernel-headers”

o   specify the files for that package: FILES_XXX-kernel-headers = “${includedir}/XXX/*”

-          In the recipe for the SDK, include the package XXX-kernel-headers

MV

From: yocto-bounces at yoctoproject.org [mailto:yocto-bounces at yoctoproject.org] On Behalf Of Longchamp, Valentin
Sent: December 08, 2015 4:06 PM
To: yocto at yoctoproject.org
Cc: Brunck, Holger
Subject: [yocto] Custom kernel headers and SDK


Hello,

We are currently migrating our Embedded Linux software and the corresponding
small in house distribution to Yocto. We are small Linux team and we provide and
maintain the toolchain, kernel and base distribution for a broader team of
software developers that build the applications for our hardware.

So far, we have been able to use Yocto to build our whole software (kernel,
minimal distribution and application software) by adding our minimal meta-layer
and defining stuff there and it works great.

Since the application devs are "not interested" in our distro nor in the
compiler, we want to make them available for them thanks to the SDK which is a
great fit for this use case. So far it works very well and we are currently
working on adapting the build system to the SDK.

And here comes my question. We have however our own kernel sources that extend
the headers for a few "in-house" drivers. From the warning in linux-libc-headers
(http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc<https://urldefense.proofpoint.com/v2/url?u=http-3A__git.yoctoproject.org_cgit_cgit.cgi_poky_tree_meta_recipes-2Dkernel_linux-2Dlibc-2Dheaders_linux-2Dlibc-2Dheaders.inc&d=BQQGaQ&c=BFpWQw8bsuKpl1SgiZH64Q&r=SbT_XjBLTrjzWy1iRhblzG3bKRhcodBp7tD_mnp1dpg&m=aecjOhK90BxgIsO0Z0SxTTAYA24E0E2rNHYdLiaPdEM&s=NsNJ4rNpfxO5fD-mwfYiZL8m1FwdIcozCxbta8sS7lA&e=>),
I understand that it should be avoided to recreate a recipe for the kernel
headers to avoid having the libc "machinified". From yocto, I could get the
custom headers thanks to STAGING_KERNEL_DIR. However, we need these custom
headers from "outside" of yocto, when using the SDK.

I have found 2 ways to install them into the sysroot and thus SDK:
- either by adding the kernel-devsrc to the SDK that installs them into
/usr/src/kernel by default.
- or by adding something similar to what is proposed in this mailing-list
discussion to our kernel recipe:
https://lists.yoctoproject.org/pipermail/linux-yocto/2014-April/002178.html<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.yoctoproject.org_pipermail_linux-2Dyocto_2014-2DApril_002178.html&d=BQQGaQ&c=BFpWQw8bsuKpl1SgiZH64Q&r=SbT_XjBLTrjzWy1iRhblzG3bKRhcodBp7tD_mnp1dpg&m=aecjOhK90BxgIsO0Z0SxTTAYA24E0E2rNHYdLiaPdEM&s=utjVbEgHLBYm4zWbGYyBQ0jFBfRz43KePurEZ1meevs&e=>

The problem with these 2 solutions is that sysroot contains:
1) the sanitized kernel headers at in sysroot/usr/include/linux
2) our custom headers at sysroot/usr/src/kernel/include/linux

and when I add a -I option in the CFLAGS for 2), I get conflicts since the SDK
automatically looks first in sysroot/usr/include.

Here is an example of the current errors I get with 1) and 2) in both the -I path:

>                  from plat/icndrv/hdlc/mpc8xxx_scc/src/libhdlc-km.c:2:
> /opt/work/ppc-toolchain/sysroots/powerpc-oe-linux/usr/src/kernel/include/linux/types.h:14:26: error: conflicting types for 'fd_set'
>  typedef __kernel_fd_set  fd_set;
>                           ^
> In file included from /opt/work/ppc-toolchain/sysroots/powerpc-oe-linux/usr/include/sys/types.h:219:0,
>                  from /opt/work/ppc-toolchain/sysroots/powerpc-oe-linux/usr/include/sys/uio.h:23,
>                  from /opt/work/ppc-toolchain/sysroots/powerpc-oe-linux/usr/include/sys/socket.h:26,
>                  from plat/icndrv/hdlc/mpc8xxx_scc/src/libhdlc-km.c:1:
> /opt/work/ppc-toolchain/sysroots/powerpc-oe-linux/usr/include/sys/select.h:75:5: note: previous declaration of 'fd_set' was here
>    } fd_set;

What would be the correct "yocto" way of solving our current problem with our
custom headers to be added to the SDK ?

Thanks

Valentin




More information about the yocto mailing list