kernel-dev: Edits to "Working with Out-of-Tree Modules"

Fixes [YOCTO #3729]

I made an editing pass through this section.  Found some minor
corrections.

(From yocto-docs rev: 314ec3a066de7328b6c6893ce33cc0e5faa8700a)

Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Scott Rifenbark 2014-06-17 10:09:06 +03:00 committed by Richard Purdie
parent 5112dbd23d
commit 45a1c42e7e
1 changed files with 33 additions and 31 deletions

View File

@ -261,7 +261,7 @@
<!-- <!--
<para> <para>
<emphasis>AR - Darrren Hart:</emphasis> This section <emphasis>AR - Darren Hart:</emphasis> This section
originated from the old Yocto Project Kernel Architecture originated from the old Yocto Project Kernel Architecture
and Use Manual. and Use Manual.
It was decided we need to put it in this section here. It was decided we need to put it in this section here.
@ -635,9 +635,9 @@
<title>Working with Out-of-Tree Modules</title> <title>Working with Out-of-Tree Modules</title>
<para> <para>
This section describes steps you need to take to be able This section describes steps to build out-of-tree modules on
to build out-of-tree modules on your target and how to your target and describes how to incorporate out-of-tree modules
incorporate out-of-tree modules in the build. in the build.
</para> </para>
<section id='building-out-of-tree-modules-on-the-target'> <section id='building-out-of-tree-modules-on-the-target'>
@ -646,7 +646,7 @@
<para> <para>
If you want to be able to build out-of-tree modules on If you want to be able to build out-of-tree modules on
the target, there are some steps you need to take the target, there are some steps you need to take
on the target that has your SDK image running. on the target that is running your SDK image.
Briefly, the <filename>kernel-dev</filename> package Briefly, the <filename>kernel-dev</filename> package
is installed by default on all is installed by default on all
<filename>*.sdk</filename> images. <filename>*.sdk</filename> images.
@ -657,15 +657,15 @@
<para> <para>
Prior to attempting to build the out-of-tree modules, Prior to attempting to build the out-of-tree modules,
you need to be on the target as root and change to the you need to be on the target as root and you need to
<filename>/usr/src/kernel</filename> directory and change to the <filename>/usr/src/kernel</filename> directory.
then <filename>make</filename> the scripts: Next, <filename>make</filename> the scripts:
<literallayout class='monospaced'> <literallayout class='monospaced'>
# cd /usr/src/kernel # cd /usr/src/kernel
# make scripts # make scripts
</literallayout> </literallayout>
Because all SDK image recipes include Because all SDK image recipes include
<filename>dev-pkgs</filename> the <filename>dev-pkgs</filename>, the
<filename>kernel-dev</filename> packages will be installed <filename>kernel-dev</filename> packages will be installed
as part of the SDK image. as part of the SDK image.
The SDK uses the scripts when building out-of-tree The SDK uses the scripts when building out-of-tree
@ -682,9 +682,9 @@
<para> <para>
While it is always preferable to work with sources integrated While it is always preferable to work with sources integrated
into the Linux kernel sources, if you need an external kernel into the Linux kernel sources, if you need an external kernel
module, the <filename>hello-mod.bb</filename> recipe is available module, the <filename>hello-mod.bb</filename> recipe is
as a template from which you can create your own out-of-tree available as a template from which you can create your
Linux kernel module recipe. own out-of-tree Linux kernel module recipe.
</para> </para>
<para> <para>
@ -700,12 +700,12 @@
<para> <para>
To get started, copy this recipe to your layer and give it a To get started, copy this recipe to your layer and give it a
meaningful name (e.g. <filename>mymodule_1.0.bb</filename>). meaningful name (e.g. <filename>mymodule_1.0.bb</filename>).
In the same directory, create a directory named In the same directory, create a new directory named
<filename>files</filename> where you can store any source files, <filename>files</filename> where you can store any source files,
patches, or other files necessary for building patches, or other files necessary for building
the module that do not come with the sources. the module that do not come with the sources.
Finally, update the recipe as appropriate for the module. Finally, update the recipe as needed for the module.
Typically you will need to set the following variables: Typically, you will need to set the following variables:
<itemizedlist> <itemizedlist>
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink> <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
</para></listitem> </para></listitem>
@ -719,11 +719,11 @@
</para> </para>
<para> <para>
Depending on the build system used by the module sources, you might Depending on the build system used by the module sources,
need to make some adjustments. you might need to make some adjustments.
For example, a typical module <filename>Makefile</filename> looks For example, a typical module <filename>Makefile</filename>
much like the one provided with the <filename>hello-mod</filename> looks much like the one provided with the
template: <filename>hello-mod</filename> template:
<literallayout class='monospaced'> <literallayout class='monospaced'>
obj-m := hello.o obj-m := hello.o
@ -742,27 +742,29 @@
The important point to note here is the The important point to note here is the
<ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_SRC'><filename>KERNEL_SRC</filename></ulink> <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_SRC'><filename>KERNEL_SRC</filename></ulink>
variable. variable.
The class <filename>module.bbclass</filename> sets this variable, The
as well as the <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-module'><filename>module</filename></ulink>
class sets this variable and the
<ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_PATH'><filename>KERNEL_PATH</filename></ulink> <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_PATH'><filename>KERNEL_PATH</filename></ulink>
variable to variable to
<filename>${<ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>}</filename> <filename>${<ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>}</filename>
with the necessary Linux kernel build information to build modules. with the necessary Linux kernel build information to build
modules.
If your module <filename>Makefile</filename> uses a different If your module <filename>Makefile</filename> uses a different
variable, you might want to override the variable, you might want to override the
<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile()</filename></ulink> <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile()</filename></ulink>
step, or create a patch to step, or create a patch to
the <filename>Makefile</filename> to work with the more typical the <filename>Makefile</filename> to work with the more typical
<filename>KERNEL_SRC</filename> or <filename>KERNEL_PATH</filename> <filename>KERNEL_SRC</filename> or
variables. <filename>KERNEL_PATH</filename> variables.
</para> </para>
<para> <para>
After you have prepared your recipe, you will likely want to After you have prepared your recipe, you will likely want to
include the module in your images. include the module in your images.
To do this, see the documentation for the following variables in To do this, see the documentation for the following variables in
the Yocto Project Reference Manual and set one of them as the Yocto Project Reference Manual and set one of them
appropriate in your machine configuration file: appropriately for your machine configuration file:
<itemizedlist> <itemizedlist>
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RDEPENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RDEPENDS</filename></ulink> <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RDEPENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RDEPENDS</filename></ulink>
</para></listitem> </para></listitem>
@ -776,13 +778,13 @@
</para> </para>
<para> <para>
modules are often not required for boot and can be excluded from Modules are often not required for boot and can be excluded from
certain build configurations. certain build configurations.
The following allows for the most flexibility: The following allows for the most flexibility:
<literallayout class='monospaced'> <literallayout class='monospaced'>
MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule" MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule"
</literallayout> </literallayout>
Where the value is derived by appending the module filename without The value is derived by appending the module filename without
the <filename>.ko</filename> extension to the string the <filename>.ko</filename> extension to the string
"kernel-module-". "kernel-module-".
</para> </para>
@ -792,8 +794,8 @@
<ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink> <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
and not a and not a
<ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
variable, the build will not fail if this module is not available variable, the build will not fail if this module is not
to include in the image. available to include in the image.
</para> </para>
</section> </section>
</section> </section>