mirror of
https://git.yoctoproject.org/poky
synced 2026-09-13 09:49:32 +02:00
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 <scott.m.rifenbark@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
3cb04638b4
commit
65cf76cc1c
@@ -625,55 +625,100 @@
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id='incorporating-out-of-tree-modules'>
|
<section id='working-with-out-of-tree-modules'>
|
||||||
<title>Incorporating Out-of-Tree Modules</title>
|
<title>Working with Out-of-Tree Modules</title>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
While it is always preferable to work with sources integrated
|
This section describes steps you need to take to be able
|
||||||
into the Linux kernel sources, if you need an external kernel
|
to build out-of-tree modules on your target and how to
|
||||||
module, the <filename>hello-mod.bb</filename> recipe is available
|
incorporate out-of-tree modules in the build.
|
||||||
as a template from which you can create your own out-of-tree
|
|
||||||
Linux kernel module recipe.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<section id='building-out-of-tree-modules-on-the-target'>
|
||||||
This template recipe is located in the
|
<title>Building Out-of-Tree Modules on the Target</title>
|
||||||
<filename>poky</filename> Git repository of the
|
|
||||||
Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink>
|
<para>
|
||||||
at:
|
If you want to be able to build out-of-tree modules on
|
||||||
<literallayout class="monospaced">
|
the target, there are some steps you need to take
|
||||||
|
on the target that has your SDK image running.
|
||||||
|
Briefly, the <filename>kernel-dev</filename> package
|
||||||
|
is installed by default on all
|
||||||
|
<filename>*.sdk</filename> 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.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Prior to attempting to build the out-of-tree modules,
|
||||||
|
you need to be on the target as root and change to the
|
||||||
|
<filename>/usr/src/kernel</filename> directory and
|
||||||
|
then <filename>make</filename> the scripts:
|
||||||
|
<literallayout class='monospaced'>
|
||||||
|
# cd /usr/src/kernel
|
||||||
|
# make scripts
|
||||||
|
</literallayout>
|
||||||
|
Because all SDK image recipes include
|
||||||
|
<filename>dev-pkgs</filename> the
|
||||||
|
<filename>kernel-dev</filename> 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.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id='incorporating-out-of-tree-modules'>
|
||||||
|
<title>Incorporating Out-of-Tree Modules</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
While it is always preferable to work with sources integrated
|
||||||
|
into the Linux kernel sources, if you need an external kernel
|
||||||
|
module, the <filename>hello-mod.bb</filename> recipe is available
|
||||||
|
as a template from which you can create your own out-of-tree
|
||||||
|
Linux kernel module recipe.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This template recipe is located in the
|
||||||
|
<filename>poky</filename> Git repository of the
|
||||||
|
Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink>
|
||||||
|
at:
|
||||||
|
<literallayout class="monospaced">
|
||||||
poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
|
poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
|
||||||
</literallayout>
|
</literallayout>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<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 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 appropriate 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>
|
||||||
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE*</filename></ulink>
|
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE*</filename></ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
|
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
|
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</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, you might
|
||||||
need to make some adjustments.
|
need to make some adjustments.
|
||||||
For example, a typical module <filename>Makefile</filename> looks
|
For example, a typical module <filename>Makefile</filename> looks
|
||||||
much like the one provided with the <filename>hello-mod</filename>
|
much like the one provided with the <filename>hello-mod</filename>
|
||||||
template:
|
template:
|
||||||
<literallayout class='monospaced'>
|
<literallayout class='monospaced'>
|
||||||
obj-m := hello.o
|
obj-m := hello.o
|
||||||
|
|
||||||
SRC := $(shell pwd)
|
SRC := $(shell pwd)
|
||||||
@@ -684,68 +729,70 @@
|
|||||||
modules_install:
|
modules_install:
|
||||||
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
|
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
|
||||||
...
|
...
|
||||||
</literallayout>
|
</literallayout>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
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 class <filename>module.bbclass</filename> sets this variable,
|
||||||
as well as the
|
as well as 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 <filename>KERNEL_PATH</filename>
|
||||||
variables.
|
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 as
|
||||||
appropriate in your machine configuration file:
|
appropriate in 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>
|
||||||
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
|
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RDEPENDS'><filename>MACHINE_EXTRA_RDEPENDS</filename></ulink>
|
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RDEPENDS'><filename>MACHINE_EXTRA_RDEPENDS</filename></ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RRECOMMENDS'><filename>MACHINE_EXTRA_RRECOMMENDS</filename></ulink>
|
<listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RRECOMMENDS'><filename>MACHINE_EXTRA_RRECOMMENDS</filename></ulink>
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</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
|
Where 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>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Because the variable is
|
Because the variable is
|
||||||
<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 available
|
||||||
to include in the image.
|
to include in the image.
|
||||||
</para>
|
</para>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<section id='inspecting-changes-and-commits'>
|
<section id='inspecting-changes-and-commits'>
|
||||||
<title>Inspecting Changes and Commits</title>
|
<title>Inspecting Changes and Commits</title>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user