How to specify which kernel to build with bitbake/yocto
Like E-rich wrote, the build system does only see my-kernel and linux-dummy as available providers for virtual/kernel. Thus, I'd guess that you'd actually want to build one of them?
The reason that linux-yocto isn't available is likely that your machine isn't in the COMPATIBLE_MACHINE regexp in linux-yocto_3.14.bb. Thus, if you want to use linux-yocto, you should bbappend that recipe in your own layer, and add your machine to COMPATIBLE_MACHINE. (You will also likely need to supply some more parameters, SRCREV, KBRANCH, etc.)
Kernel selection using yocto
Select which kernel to build in your machine configuration, see BSP manual and for example stackoverflow question
Basically, for selecting kernel you can add
PREFERRED_PROVIDER_virtual/kernel = "my-kernel-recipe"
To your mymachine.conf
.
How to build in tree Linux kernel module in Yocto
If you want to add a kernel module in tree, you need to understand the Kbuild system
,
Each kernel module is a component/feature and it is called a symbol
Kbuild is based on four components:
- Configuration symbols (
CONFIG_EXAMPLE
) - Symbols container (
Kconfig
) Makefile
(s)- The kernel main configuration file (
.config
)
So, if you want to add your module to the kernel tree you need to:
Copy the driver source file to the right location (You need to locate it based on your driver type (net, i2c, ...)).
Add a symbol entry for the driver in the Kconfig/Makefile files of the same driver source code directory.
Create a patch.
Activate the driver symbol in the main Kernel configuration file (menuconfig / config fragement)
Example:
- Get the workding directory of your kernel recipe:
bitbake -e virtual/kernel | grep ^WORKDIR=
Inside that directory you will find
git
which contains the kernel source, make your modifications there.Add the driver source file:
cp /home/xxx/custom_lkm.c drivers/gpu/drm/panel
- Add entry to Kconfig (
drivers/gpu/panel/Kconfig
)
...
config CUSTOM_LKM
tristate "Example driver"
depends on <YOU NEED TO FIND OUT WHAT IT DEPENDS ON>
depends on DRM <-------( This is just an example of a panel driver )
help
Say Y if you want to enable support for Example driver.
...
- Add entry to Makefile (
drivers/gpu/panel/Makefile
)
...
obj-$(CONFIG_CUSTOM_LKM) += custom_lkm.o
^ ^
| |
Driver symbol | |
in Kconfig---------- |
|
Driver source file name -------------
...
- Create a patch:
<workdir>/git$ git add drivers/gpu/panel/custom_lkm.c
<workdir>/git$ git add drivers/gpu/panel/Makefile
<workdir>/git$ git add drivers/gpu/panel/Kconfig
<workdir>/git$ git commit -m "Add the driver xxx in tree"
<workdir>/git$ git format-patch -1 -o /path/to/your/meta/recipes-kernel/linux/files
(This will create a patch: `add-the-driver-xxx-in-tree.patch`)
If your kernel is fetched from a local compressed file (no git), you then:
6.1 Init the kernel workdir as a git folder (git init)
6.2 Add and commit all the kernel (git add . && git commit -m "first init")
6.3 Add the driver files
6.4 Git add and commit and create the patch
Now, you got a patch that adds your driver in tree.
- Add the patch to the
SRC_URI
. If you have abbappend
for the kernel you use just :
SRC_URI_append = " file://add-the-driver-xxx-in-tree.patch"
You need just to create a configuration fragment to activate it.
- Run
bitbake virtual/kernel -c menuconfig
- Activate your module
- Create a configuration fragment
bitbake virtual/kernel -c diffconfig
This will generate a path to a fragment.cfg
file. Just copy it along side the patch, and add it to SRC_URI
.
IMPORTANT NOTES:
- Make sure that your kernel can handle the
.cfg
files. - If you have a custom kernel hosted in custom git (that you have access to) you just commit the driver changes to it and just update
SRCREV
and keep only the fragment part.
How to compile linux-raspberrypi kernel in yocto?
Remove IMAGE_INSTALL_append = " linux-raspberrypi"
and try adding to local.conf (or machine.conf) PREFERRED_PROVIDER_virtual/kernel = "linux-raspberrypi"
.
Related Topics
Sqlite Data File on Linux and Os X Incompatible
Cmakelist File to Generate Llvm Bitcode File from C Source File
Logging Memory Access Footprint
Stty: Standard Input: Inappropriate Ioctl for Device
How to Identify Padding Scheme Used in Rsa Signature of a Certificate, Using Openssl
How to Attach Domain Name to My Server
I Need a Binary Comparison Tool for Win/Linux
How to Use Sysfs Inside Kernel Module
Set Cron Job for 1St Working Day of Every Month in Shell Scripting
Correct Way to Export Multiple Ld_Library_Paths
Mono and Unmanaged Code in Ubuntu
How to Have Postgresql Not Collapse Punctuation and Spaces When Collating Using a Language
How to Enable Hocr Font Info in Tesseract 4
How to Add More Algorithm in Cryptoapi in Linux