[yocto] [bitbake] Conditional Linux Kernel compilation according to Yocto Variables

Fabien Lahoudere fabien.lahoudere at collabora.co.uk
Fri Jun 9 03:18:11 PDT 2017


On Thu, 2017-06-08 at 07:32 +0000, Karim ATIKI wrote:
> I'm using Yocto (Poky Dora is mandatory for our project) to create a Linux image for an ARM base
> board.
> Currently, we're working on an evaluation board.
> We have a dedicated layer (meta-docking) with all the stuff.
> We have dedicated recipes that installs a specific version of the Linux Kernel and some specific
> patch as well.
> As we create the image:
> 
> bitbake -k docking-image
> 
> Now, we're moving toward the final board to be used in production. It differs from the evaluation
> board as some connectors are added (lighting etc.).
> Therefore, the Linux Kernel being installed is slightly different, some source files need to be
> replaced/patched/modified consequently.
> 
> My colleague, firstly chose to create another copy of the layer (i.e. meta-docking-prod).
> This option does not satisfy us, I'm sure Yocto provides mechanisms to apply taks according to the
> target.
> 
> My question is, for example, how to apply different patches on a Linux kernel (or any yocto
> resource file) according to user's variable ? or according to the target machine ?
> Without having to duplicate layers.

1. Take a look at OVERRIDES. You can probably use the followings for different machines:

SRC_URI_append_<machine1> = " file://patchformachine1.patch"

SRC_URI_append_<machine2> = " file://patchformachine2.patch"

2. To enable patch according to variable, take a look at how bb.utils.contains works.

SRC_URI = "... \
	  ${@bb.utils.contains('YOURVARIABLE', 'tagtomatch', 'file://feature.patch', '', d)} \
	... "

and set YOURVARIABLE in your local.conf for example.


You have a lot of examples on how to use such mechanism in all available metas.


> 
> Thanks.
> 
> K.



More information about the yocto mailing list