From 65cf76cc1c3fde42104249cccb197f079df45aec Mon Sep 17 00:00:00 2001 From: Scott Rifenbark Date: Tue, 3 Jun 2014 10:51:09 +0300 Subject: kernel-dev: Added new "Building Out-of-Tree Modules on the Target" section. Fixes [YOCTO #3729] I have made an attempt at understanding this and creating a section that describes the steps the user needs to take in order to build out-of-tree modules on the target device when running an SDK image. I created a new section called "Building Out-of-Tree Modules on the Target". Basically, the user needs to be on the target and change to a directory and then create some scripts before attempting to build these types of modules on the target. (From yocto-docs rev: e0754ae6dbc5dc07fb6707fe4b71ecd95c8180dc) Signed-off-by: Scott Rifenbark Signed-off-by: Richard Purdie --- documentation/kernel-dev/kernel-dev-common.xml | 247 +++++++++++++++---------- 1 file changed, 147 insertions(+), 100 deletions(-) diff --git a/documentation/kernel-dev/kernel-dev-common.xml b/documentation/kernel-dev/kernel-dev-common.xml index 3adc648098..b3f4c438d7 100644 --- a/documentation/kernel-dev/kernel-dev-common.xml +++ b/documentation/kernel-dev/kernel-dev-common.xml @@ -625,55 +625,100 @@ -
- Incorporating Out-of-Tree Modules +
+ Working with Out-of-Tree Modules - 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 section describes steps you need to take to be able + to build out-of-tree modules on your target and how to + incorporate out-of-tree modules in the build. - - 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 - - +
+ Building Out-of-Tree Modules on the Target - - 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 - - - + + If you want to be able to build out-of-tree modules on + the target, there are some steps you need to take + on the target that has your SDK image running. + Briefly, the kernel-dev package + is installed by default on all + *.sdk images. + However, you need to create some scripts prior to + attempting to build the out-of-tree modules on the target + that is running that image. + - - 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: - + + Prior to attempting to build the out-of-tree modules, + you need to be on the target as root and change to the + /usr/src/kernel directory and + then make the scripts: + + # cd /usr/src/kernel + # make scripts + + Because all SDK image recipes include + dev-pkgs the + kernel-dev packages will be installed + as part of the SDK image. + The SDK uses the scripts when building out-of-tree + modules. + Once you have switched to that directory and created the + scripts, you should be able to build your out-of-tree modules + on the target. + +
+ +
+ Incorporating Out-of-Tree Modules + + + 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) @@ -684,68 +729,70 @@ modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install ... - - - - - The important point to note here is the - KERNEL_SRC - variable. - The class 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 configuration 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: - + + The important point to note here is the + KERNEL_SRC + variable. + The class 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 configuration 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-". - + + 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. - + + 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. + +
+
Inspecting Changes and Commits -- cgit v1.2.3-54-g00ecf