mirror of
https://git.yoctoproject.org/git/poky
synced 2026-01-04 16:10:04 +00:00
kernel-dev: Added the host prep for kernel dev to the chapter.
(From yocto-docs rev: 7343f1108808bb3be182af58325f9e3195ff4d8e) Signed-off-by: Scott Rifenbark <srifenbark@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
d4be6ea72a
commit
ccbfdd795e
|
|
@ -3,20 +3,391 @@
|
|||
[<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
|
||||
|
||||
<chapter id='kernel-dev-common'>
|
||||
|
||||
<title>Common Tasks</title>
|
||||
|
||||
<para>
|
||||
This chapter presents several common tasks you perform when you
|
||||
work with the Yocto Project Linux kernel.
|
||||
These tasks include preparing a layer, modifying an existing recipe,
|
||||
iterative development, working with your own sources, and incorporating
|
||||
out-of-tree modules.
|
||||
<note>
|
||||
The examples presented in this chapter work with the Yocto Project
|
||||
1.2.2 Release and forward.
|
||||
</note>
|
||||
</para>
|
||||
<para>
|
||||
This chapter presents several common tasks you perform when you
|
||||
work with the Yocto Project Linux kernel.
|
||||
These tasks include preparing your host development system for
|
||||
kernel development, preparing a layer, modifying an existing recipe,
|
||||
patching the kernel, iterative development, working with your own sources,
|
||||
and incorporating out-of-tree modules.
|
||||
<note>
|
||||
The examples presented in this chapter work with the Yocto Project
|
||||
2.4 Release and forward.
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<section id='preparing-the-build-host-to-work-on-the-kernel'>
|
||||
<title>Preparing the Build Host to Work on the Kernel</title>
|
||||
|
||||
<para>
|
||||
Before you can do any kernel development, you need to be
|
||||
sure your build host is set up to use the Yocto Project.
|
||||
For information on how to get set up, see the
|
||||
"<ulink url='&YOCTO_DOCS_DEV_URL;#setting-up-the-development-host-to-use-the-yocto-project'>Setting Up to Use the Yocto Project</ulink>"
|
||||
section in the Yocto Project Development Manual.
|
||||
Part of preparing the system is creating a local Git
|
||||
repository of the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
|
||||
(<filename>poky</filename>) on your system.
|
||||
Follow the steps in the
|
||||
"<ulink url='&YOCTO_DOCS_DEV_URL;#cloning-the-poky-repository'>Cloning the <filename>poky</filename> Repository</ulink>"
|
||||
section in the Yocto Project Development Manual to set up your
|
||||
Source Directory.
|
||||
<note>
|
||||
Be sure you check out the appropriate development branch or
|
||||
by tag to get the version of Yocto Project you want.
|
||||
See the
|
||||
"<ulink url='&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky'>Checking Out by Branch in Poky</ulink>"
|
||||
and
|
||||
"<ulink url='&YOCTO_DOCS_DEV_URL;#checkout-out-by-tag-in-poky'>Checking Out by Tag in Poky</ulink>"
|
||||
sections in the Yocto Project Development Manual for more
|
||||
information.
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Kernel development is best accomplished using
|
||||
<ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename></ulink>
|
||||
and not through traditional kernel workflow methods.
|
||||
The remainder of this section provides information for both
|
||||
scenarios.
|
||||
</para>
|
||||
|
||||
<section id='getting-ready-to-develop-using-devtool'>
|
||||
<title>Getting Ready to Develop using <filename>devtool</filename></title>
|
||||
|
||||
<para>
|
||||
Follow these steps to prepare to update the kernel image using
|
||||
<filename>devtool</filename>.
|
||||
Completing this procedure leaves you with a clean kernel image
|
||||
and ready to make modifications as described in the
|
||||
"<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
|
||||
section:
|
||||
<orderedlist>
|
||||
<listitem><para>
|
||||
<emphasis>Initialize the BitBake Environment:</emphasis>
|
||||
Before building an extensible SDK, you need to
|
||||
initialize the BitBake build environment by sourcing a
|
||||
build environment script
|
||||
(i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
|
||||
or
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>):
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky
|
||||
$ source oe-init-build-env
|
||||
</literallayout>
|
||||
<note>
|
||||
The previous commands assume the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#source-repositories'>Source Repositories</ulink>
|
||||
(i.e. <filename>poky</filename>) have been cloned
|
||||
using Git and the local repository is named
|
||||
"poky".
|
||||
</note>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Prepare Your <filename>local.conf</filename> File:</emphasis>
|
||||
By default, the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
|
||||
variable is set to "qemux86", which is fine if you are
|
||||
building for the QEMU emulator in 32-bit mode.
|
||||
However, if you are not, you need to set the
|
||||
<filename>MACHINE</filename> variable appropriately in
|
||||
your <filename>conf/local.conf</filename> file found in
|
||||
the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
|
||||
(i.e. <filename>~/poky/build</filename> in this
|
||||
example).</para>
|
||||
|
||||
<para>Also, since you are preparing to work on the
|
||||
kernel image, you need to set the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
|
||||
variable to include kernel modules.</para>
|
||||
|
||||
<para>This example uses the default "qemux86" for the
|
||||
<filename>MACHINE</filename> variable but needs to
|
||||
add the "kernel-modules":
|
||||
<literallayout class='monospaced'>
|
||||
MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Create a Layer for Patches:</emphasis>
|
||||
You need to create a layer to hold patches created
|
||||
for the kernel image.
|
||||
You can use the <filename>yocto-layer</filename> command
|
||||
as follows:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky
|
||||
$ yocto-layer create my-kernel -o ../meta-my-kernel
|
||||
Please enter the layer priority you'd like to use for the layer: [default: 6]
|
||||
Would you like to have an example recipe created? (y/n) [default: n]
|
||||
Would you like to have an example bbappend file created? (y/n) [default: n]
|
||||
|
||||
New layer created in ../meta-my-kernel.
|
||||
|
||||
Don't forget to add it to your BBLAYERS (for details see ../meta-my-kernel/README).
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Inform the BitBake Build Environment About
|
||||
Your Layer:</emphasis>
|
||||
As directed when you created your layer, you need to
|
||||
add the layer to the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
|
||||
variable in the <filename>bblayers.conf</filename> file
|
||||
as follows:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky/build
|
||||
$ bitbake-layers add-layer ../../meta-my-kernel
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Build the Extensible SDK:</emphasis>
|
||||
Use BitBake to build the extensible SDK specifically for
|
||||
the Minnowboard:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky/build
|
||||
$ bitbake core-image-minimal -c populate_sdk_ext
|
||||
</literallayout>
|
||||
Once the build finishes, you can find the SDK installer
|
||||
file (i.e. <filename>*.sh</filename> file) in the
|
||||
following directory:
|
||||
<literallayout class='monospaced'>
|
||||
~/poky/build/tmp/deploy/sdk
|
||||
</literallayout>
|
||||
For this example, the installer file is named
|
||||
<filename>poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-&DISTRO;.sh</filename>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Install the Extensible SDK:</emphasis>
|
||||
Use the following command to install the SDK.
|
||||
For this example, install the SDK in the default
|
||||
<filename>~/poky_sdk</filename> directory:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky/build/tmp/deploy/sdk
|
||||
$ ./poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-&DISTRO;.sh
|
||||
Poky (Yocto Project Reference Distro) Extensible SDK installer version &DISTRO;
|
||||
============================================================================
|
||||
Enter target directory for SDK (default: ~/poky_sdk):
|
||||
You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed[Y/n]? Y
|
||||
Extracting SDK......................................done
|
||||
Setting it up...
|
||||
Extracting buildtools...
|
||||
Preparing build system...
|
||||
Parsing recipes: 100% |#################################################################| Time: 0:00:52
|
||||
Initializing tasks: 100% |############## ###############################################| Time: 0:00:04
|
||||
Checking sstate mirror object availability: 100% |######################################| Time: 0:00:00
|
||||
Parsing recipes: 100% |#################################################################| Time: 0:00:33
|
||||
Initializing tasks: 100% |##############################################################| Time: 0:00:00
|
||||
done
|
||||
SDK has been successfully set up and is ready to be used.
|
||||
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
|
||||
$ . /home/scottrif/poky_sdk/environment-setup-i586-poky-linux
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para id='setting-up-the-esdk-terminal'>
|
||||
<emphasis>Set Up a New Terminal to Work With the
|
||||
Extensible SDK:</emphasis>
|
||||
You must set up a new terminal to work with the SDK.
|
||||
You cannot use the same BitBake shell used to build the
|
||||
installer.</para>
|
||||
|
||||
<para>After opening a new shell, run the SDK environment
|
||||
setup script as directed by the output from installing
|
||||
the SDK:
|
||||
<literallayout class='monospaced'>
|
||||
$ source ~/poky_sdk/environment-setup-i586-poky-linux
|
||||
"SDK environment now set up; additionally you may now run devtool to perform development tasks.
|
||||
Run devtool --help for further details.
|
||||
</literallayout>
|
||||
<note>
|
||||
If you get a warning about attempting to use the
|
||||
extensible SDK in an environment set up to run
|
||||
BitBake, you did not use a new shell.
|
||||
</note>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Build the Clean Image:</emphasis>
|
||||
The final step in preparing to work on the kernel is to
|
||||
build an initial image using
|
||||
<filename>devtool</filename> in the new terminal you
|
||||
just set up and initialized for SDK work:
|
||||
<literallayout class='monospaced'>
|
||||
$ devtool build-image
|
||||
Parsing recipes: 100% |##########################################| Time: 0:00:05
|
||||
Parsing of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 skipped, 0 masked, 0 errors.
|
||||
WARNING: No packages to add, building image core-image-minimal unmodified
|
||||
Loading cache: 100% |############################################| Time: 0:00:00
|
||||
Loaded 1299 entries from dependency cache.
|
||||
NOTE: Resolving any missing task queue dependencies
|
||||
Initializing tasks: 100% |#######################################| Time: 0:00:07
|
||||
Checking sstate mirror object availability: 100% |###############| Time: 0:00:00
|
||||
NOTE: Executing SetScene Tasks
|
||||
NOTE: Executing RunQueue Tasks
|
||||
NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need to be rerun and all succeeded.
|
||||
NOTE: Successfully built core-image-minimal. You can find output files in /home/scottrif/poky_sdk/tmp/deploy/images/qemux86
|
||||
</literallayout>
|
||||
If you were building for actual hardware and not for
|
||||
emulation, you could flash the image to a USB stick
|
||||
on <filename>/dev/sdd</filename> and boot your device.
|
||||
For an example that uses a Minnowboard, see the
|
||||
<ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/KernelDevelopmentWithEsdk'>TipsAndTricks/KernelDevelopmentWithEsdk</ulink>
|
||||
Wiki page.
|
||||
</para></listitem>
|
||||
</orderedlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
At this point you have set up to start making modifications to
|
||||
the kernel by using the extensible SDK.
|
||||
For a continued example, see the
|
||||
"<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
|
||||
section.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id='getting-ready-for-traditional-kernel-development'>
|
||||
<title>Getting Ready for Traditional Kernel Development</title>
|
||||
|
||||
<para>
|
||||
Getting ready for traditional kernel development using the Yocto
|
||||
Project involves many of the same steps as described in the
|
||||
previous section.
|
||||
However, you need to establish a local copy of the kernel source
|
||||
since you will be editing these files.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Follow these steps to prepare to update the kernel image using
|
||||
traditional kernel development flow with the Yocto Project.
|
||||
Completing this procedure leaves you ready to make modifications
|
||||
to the kernel source as described in the
|
||||
"<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
|
||||
section:
|
||||
<orderedlist>
|
||||
<listitem><para>
|
||||
<emphasis>Initialize the BitBake Environment:</emphasis>
|
||||
Before you can do anything using BitBake, you need to
|
||||
initialize the BitBake build environment by sourcing a
|
||||
build environment script
|
||||
(i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>
|
||||
or
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>):
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky
|
||||
$ source oe-init-build-env
|
||||
</literallayout>
|
||||
<note>
|
||||
The previous commands assume the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#source-repositories'>Source Repositories</ulink>
|
||||
(i.e. <filename>poky</filename>) have been cloned
|
||||
using Git and the local repository is named
|
||||
"poky".
|
||||
</note>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Prepare Your <filename>local.conf</filename>
|
||||
File:</emphasis>
|
||||
By default, the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
|
||||
variable is set to "qemux86", which is fine if you are
|
||||
building for the QEMU emulator in 32-bit mode.
|
||||
However, if you are not, you need to set the
|
||||
<filename>MACHINE</filename> variable appropriately in
|
||||
your <filename>conf/local.conf</filename> file found
|
||||
in the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
|
||||
(i.e. <filename>~/poky/build</filename> in this
|
||||
example).</para>
|
||||
|
||||
<para>Also, since you are preparing to work on the
|
||||
kernel image, you need to set the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
|
||||
variable to include kernel modules.</para>
|
||||
|
||||
<para>This example uses the default "qemux86" for the
|
||||
<filename>MACHINE</filename> variable but needs to
|
||||
add the "kernel-modules":
|
||||
<literallayout class='monospaced'>
|
||||
MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Create a Layer for Patches:</emphasis>
|
||||
You need to create a layer to hold patches created
|
||||
for the kernel image.
|
||||
You can use the <filename>yocto-layer</filename> command
|
||||
as follows:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky
|
||||
$ yocto-layer create my-kernel -o ../meta-my-kernel
|
||||
Please enter the layer priority you'd like to use for the layer: [default: 6]
|
||||
Would you like to have an example recipe created? (y/n) [default: n]
|
||||
Would you like to have an example bbappend file created? (y/n) [default: n]
|
||||
|
||||
New layer created in ../meta-my-kernel.
|
||||
|
||||
Don't forget to add it to your BBLAYERS (for details see ../meta-my-kernel/README).
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Inform the BitBake Build Environment About
|
||||
Your Layer:</emphasis>
|
||||
As directed when you created your layer, you need to add
|
||||
the layer to the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
|
||||
variable in the <filename>bblayers.conf</filename> file
|
||||
as follows:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky/build
|
||||
$ bitbake-layers add-layer ../../meta-my-kernel
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Create a Local Copy of the Kernel Git
|
||||
Repository:</emphasis>
|
||||
You can find Git repositories of supported Yocto Project
|
||||
kernels organized under "Yocto Linux Kernel" in the
|
||||
Yocto Project Source Repositories at
|
||||
<ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For simplicity, it is recommended that you create your
|
||||
copy of the kernel Git repository outside of the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;source-directory'>Source Directory</ulink>,
|
||||
which is usually named <filename>poky</filename>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The following command shows how to create a local copy
|
||||
of the <filename>linux-yocto-4.9</filename> kernel:
|
||||
<literallayout class='monospaced'>
|
||||
$ git clone git://git.yoctoproject.org/linux-yocto-4.9 linux-yocto-4.9.git
|
||||
Cloning into 'linux-yocto-4.9.git'...
|
||||
remote: Counting objects: 5094108, done.
|
||||
remote: Compressing objects: 100% (765113/765113), done.
|
||||
remote: Total 5094108 (delta 4294009), reused 5088388 (delta 4288312)
|
||||
Receiving objects: 100% (5094108/5094108), 1.02 GiB | 7.82 MiB/s, done.
|
||||
Resolving deltas: 100% (4294009/4294009), done.
|
||||
Checking connectivity... done.
|
||||
Checking out files: 100% (56233/56233), done.
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
</orderedlist>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
At this point you have set up to start making modifications to
|
||||
the kernel using traditional kernel development steps.
|
||||
For a continued example, see the
|
||||
"<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
|
||||
section.
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section id='creating-and-preparing-a-layer'>
|
||||
<title>Creating and Preparing a Layer</title>
|
||||
|
|
@ -824,6 +1195,188 @@ NOTE: This stuff is how it would have been if a *.wic file was created
|
|||
</orderedlist>
|
||||
</section>
|
||||
|
||||
<section id="using-traditional-kernel-development-to-patch-the-kernel">
|
||||
<title>Using Traditional Kernel Development to Patch the Kernel</title>
|
||||
|
||||
<para>
|
||||
The steps in this procedure show you how you can patch the
|
||||
kernel using traditional kernel development (i.e. not using
|
||||
<filename>devtool</filename> and the extensible SDK as
|
||||
described in the
|
||||
"<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
|
||||
section).
|
||||
<note>
|
||||
Before attempting this procedure, be sure you have performed
|
||||
the steps to get ready for updating the kernel as described
|
||||
in the
|
||||
"<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
|
||||
section.
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Patching the kernel involves changing or adding configurations
|
||||
to an existing kernel, changing or adding recipes to the kernel
|
||||
that are needed to support specific hardware features, or even
|
||||
altering the source code itself.
|
||||
<note>
|
||||
You can also use the <filename>yocto-kernel</filename> script
|
||||
found in the
|
||||
<ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
|
||||
under <filename>scripts</filename> to manage kernel patches
|
||||
and configuration.
|
||||
See the "<ulink url='&YOCTO_DOCS_BSP_URL;#managing-kernel-patches-and-config-items-with-yocto-kernel'>Managing kernel Patches and Config Items with yocto-kernel</ulink>"
|
||||
section in the Yocto Project Board Support Packages (BSP)
|
||||
Developer's Guide for more information.
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This example creates a simple patch by adding some QEMU emulator
|
||||
console output at boot time through <filename>printk</filename>
|
||||
statements in the kernel's <filename>calibrate.c</filename> source
|
||||
code file.
|
||||
Applying the patch and booting the modified image causes the added
|
||||
messages to appear on the emulator's console.
|
||||
<note>
|
||||
The example is a continuation of the setup procedure found in
|
||||
the
|
||||
"<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
|
||||
Section.
|
||||
</note>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Also, for more information on patching the kernel, see the
|
||||
"<link linkend='applying-patches'>Applying Patches</link>"
|
||||
section.
|
||||
<orderedlist>
|
||||
<listitem><para>
|
||||
<emphasis>Know What Branch is Checked Out In Your Local
|
||||
Kernel Git Repository:</emphasis>
|
||||
Prior to this step, you should have used Git to create a
|
||||
local copy of the repository for your kernel.
|
||||
Assuming you created the repository as directed in the
|
||||
"<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
|
||||
section, use the following commands to check out the
|
||||
<filename>standard/base</filename> branch of the
|
||||
Linux Yocto 4.9 kernel:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/linux-yocto-4.9
|
||||
$ git checkout -b standard/base origin/standard/base
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Edit the Source Files</emphasis>
|
||||
Follow these steps to make some simple changes to the source
|
||||
files:
|
||||
<orderedlist>
|
||||
<listitem><para>
|
||||
<emphasis>Change the working directory</emphasis>:
|
||||
You need to locate the source files in the
|
||||
local copy of the kernel Git repository:
|
||||
Change to where the kernel source code is before making
|
||||
your edits to the <filename>calibrate.c</filename> file:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/linux-yocto-4.9/init
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Edit the source file</emphasis>:
|
||||
Edit the <filename>calibrate.c</filename> file to have
|
||||
the following changes:
|
||||
<literallayout class='monospaced'>
|
||||
void calibrate_delay(void)
|
||||
{
|
||||
unsigned long lpj;
|
||||
static bool printed;
|
||||
int this_cpu = smp_processor_id();
|
||||
|
||||
printk("*************************************\n");
|
||||
printk("* *\n");
|
||||
printk("* HELLO YOCTO KERNEL *\n");
|
||||
printk("* *\n");
|
||||
printk("*************************************\n");
|
||||
|
||||
if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
|
||||
.
|
||||
.
|
||||
.
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
</orderedlist>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Stage and Commit Your Changes:</emphasis>
|
||||
Use standard Git commands to stage and commit the changes
|
||||
you just made:
|
||||
<literallayout class='monospaced'>
|
||||
$ git add calibrate.c
|
||||
$ git commit -m "calibrate.c - Added some printk statements"
|
||||
</literallayout>
|
||||
If you do not stage and commit your changes, the OpenEmbedded
|
||||
Build System will not pick up the changes.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Update Your <filename>local.conf</filename> File to Point to Your Source Files:</emphasis>
|
||||
In addition to your <filename>local.conf</filename> file
|
||||
specifying to use "kernel-modules" and the "qemux86" machine,
|
||||
it must also point to the updated kernel source files.
|
||||
Add the following commands to your
|
||||
<filename>local.conf</filename>:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky/build/conf
|
||||
<replaceable>Add the following:</replaceable>
|
||||
|
||||
SRC_URI_pn-linux-yocto = "git:///$HOME/linux-yocto-4.9;protocol=file;name=machine;branch=standard/base; \
|
||||
git:///home/scottrif/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-4.9;destsuffix=${KMETA}"
|
||||
SRCREV_meta_qemux86 = "${AUTOREV}"
|
||||
SRCREV_machine_qemux86 = "${AUTOREV}"
|
||||
</literallayout>
|
||||
You must be sure to specify the correct branch and machine
|
||||
types.
|
||||
For this example, the branch is
|
||||
<filename>standard/base</filename> and the machine is
|
||||
"qemux86".
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Build the Image:</emphasis>
|
||||
With the source modified, staged, and committed, and
|
||||
the <filename>local.conf</filename> file pointing to
|
||||
the kernel files, you can now use BitBake to build the
|
||||
image:
|
||||
<literallayout class='monospaced'>
|
||||
$ cd ~/poky/build
|
||||
$ bitbake core-image-minimal
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Boot the image</emphasis>:
|
||||
Boot the modified image in the QEMU emulator
|
||||
using this command.
|
||||
When prompted to login to the QEMU console, use "root"
|
||||
with no password:
|
||||
<literallayout class='monospaced'>
|
||||
$ runqemu qemux86
|
||||
</literallayout>
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
<emphasis>Look for Your Changes:</emphasis>
|
||||
As QEMU booted, you might have seen your changes rapidly
|
||||
scroll by.
|
||||
If not, use these commands to see your changes:
|
||||
<literallayout class='monospaced'>
|
||||
# dmesg | less
|
||||
</literallayout>
|
||||
You should see the results of your
|
||||
<filename>printk</filename> statements
|
||||
as part of the output when you scroll down the
|
||||
console window.
|
||||
</para></listitem>
|
||||
</orderedlist>
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id='using-an-iterative-development-process'>
|
||||
<title>Using an Iterative Development Process</title>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user