From 9a5376be500c1127fa6bce39dc206b278b85427a Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Wed, 19 Dec 2012 13:47:00 -0600 Subject: kernel-dev: Re-write of "Incorporating Out-of-Tree Modules" section. (From yocto-docs rev: 1abc8be7a2862d51165615f49c8c9cfab319564b) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- documentation/kernel-dev/kernel-dev-common.xml | 115 ++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) (limited to 'documentation/kernel-dev') diff --git a/documentation/kernel-dev/kernel-dev-common.xml b/documentation/kernel-dev/kernel-dev-common.xml index 506a45ee11..d76580dd02 100644 --- a/documentation/kernel-dev/kernel-dev-common.xml +++ b/documentation/kernel-dev/kernel-dev-common.xml @@ -783,7 +783,119 @@ details. Incorporating Out-of-Tree Modules - While it is always preferable to work with sources integrated into the Linux + While it is always preferable to work with sources integrated + into the Linux kernel sources, if you need an external kernel + module, the hello-mod.bb recipe is available + as a template from which you can create your own out-of-tree + Linux kernel module recipe. + + + + This template recipe is located in the + poky Git repository of the + Yocto Project Source Repository + at: + + poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb + + + + + To get started, copy this recipe to your layer and give it a + meaningful name (e.g. mymodule_1.0.bb). + In the same directory, create a directory named + files where you can store any source files, + patches, or other files necessary for building + the module that do not come with the sources. + Finally, update the recipe as appropriate for the module. + Typically you will need to set the following variables: + + DESCRIPTION + + LICENSE* + + SRC_URI + + PV + + + + + + Depending on the build system used by the module sources, you might + need to make some adjustments. + For example, a typical module Makefile looks + much like the one provided with the hello-mod + template: + + obj-m := hello.o + + SRC := $(shell pwd) + + all: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) + + modules_install: + $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install + ... + + + + + The important point to note here is the + KERNEL_SRC variable. + The module bbclass sets this variable, + as well as the KERNEL_PATH variable + to ${STAGING_KERNEL_DIR} with the + necessary Linux kernel build information to build modules. + If your module Makefile uses a different + variable, you might want to override the + do_compile() step, or create a patch to + the Makefile to work with the more typical + KERNEL_SRC or KERNEL_PATH + variables. + + + + After you have prepared your recipe, you will likely want to + include the module in your images. + To do this, see the documentation for the following variables in + the Yocto Project Reference Manual and set one of them as + appropriate in your machine config file: + + MACHINE_ESSENTIAL_EXTRA_RDEPENDS + + MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS + + MACHINE_EXTRA_RDEPENDS + + MACHINE_EXTRA_RRECOMMENDS + + + + + + modules are often not required for boot and can be excluded from + certain build configurations. + The following allows for the most flexibility: + + MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule" + + Where the value is derived by appending the module filename without + the .ko extension to the string + "kernel-module-". + + + + Because the variable is RRECOMMENDS and not + a RDEPENDS variable, the build will not fail + if this module is not available to include in the image. + + + + Original Text: + +While it is always preferable to work with sources integrated into the Linux kernel sources, if you have need of an external kernel module, the hello-mod recipe is available as a template to create your own out-of-tree Linux kernel module recipe. It is available in the poky repository at: @@ -844,6 +956,7 @@ extension to the string "kernel-module-". As it is an RRECOMMENDS (and not an RDEPENDS) variable, the build will not fail if this module is not available to include in the image. + -- cgit v1.2.3-54-g00ecf