summaryrefslogtreecommitdiffstats
path: root/documentation/kernel-dev/kernel-dev-common.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/kernel-dev/kernel-dev-common.rst')
-rw-r--r--documentation/kernel-dev/kernel-dev-common.rst1017
1 files changed, 683 insertions, 334 deletions
diff --git a/documentation/kernel-dev/kernel-dev-common.rst b/documentation/kernel-dev/kernel-dev-common.rst
index ef3a9f710a..d4b60a9dc9 100644
--- a/documentation/kernel-dev/kernel-dev-common.rst
+++ b/documentation/kernel-dev/kernel-dev-common.rst
@@ -21,13 +21,11 @@ Preparing the Build Host to Work on the Kernel
21 21
22Before you can do any kernel development, you need to be sure your build 22Before you can do any kernel development, you need to be sure your build
23host is set up to use the Yocto Project. For information on how to get 23host is set up to use the Yocto Project. For information on how to get
24set up, see the "`Preparing the Build 24set up, see the ":doc:`../dev-manual/dev-manual-start`" section in
25Host <&YOCTO_DOCS_DEV_URL;#dev-preparing-the-build-host>`__" section in
26the Yocto Project Development Tasks Manual. Part of preparing the system 25the Yocto Project Development Tasks Manual. Part of preparing the system
27is creating a local Git repository of the 26is creating a local Git repository of the
28:term:`Source Directory` (``poky``) on your 27:term:`Source Directory` (``poky``) on your system. Follow the steps in the
29system. Follow the steps in the "`Cloning the ``poky`` 28":ref:`dev-manual/dev-manual-start:cloning the \`\`poky\`\` repository`"
30Repository <&YOCTO_DOCS_DEV_URL;#cloning-the-poky-repository>`__"
31section in the Yocto Project Development Tasks Manual to set up your 29section in the Yocto Project Development Tasks Manual to set up your
32Source Directory. 30Source Directory.
33 31
@@ -43,7 +41,7 @@ Source Directory.
43 information. 41 information.
44 42
45Kernel development is best accomplished using 43Kernel development is best accomplished using
46```devtool`` <&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow>`__ 44:ref:`devtool <sdk-manual/sdk-extensible:using \`\`devtool\`\` in your sdk workflow>`
47and not through traditional kernel workflow methods. The remainder of 45and not through traditional kernel workflow methods. The remainder of
48this section provides information for both scenarios. 46this section provides information for both scenarios.
49 47
@@ -52,15 +50,17 @@ Getting Ready to Develop Using ``devtool``
52 50
53Follow these steps to prepare to update the kernel image using 51Follow these steps to prepare to update the kernel image using
54``devtool``. Completing this procedure leaves you with a clean kernel 52``devtool``. Completing this procedure leaves you with a clean kernel
55image and ready to make modifications as described in the "`Using 53image and ready to make modifications as described in the "
56``devtool`` to Patch the Kernel <#using-devtool-to-patch-the-kernel>`__" 54:ref:`kernel-dev/kernel-dev-common:using \`\`devtool\`\` to patch the kernel`"
57section: 55section:
58 56
591. *Initialize the BitBake Environment:* Before building an extensible 571. *Initialize the BitBake Environment:* Before building an extensible
60 SDK, you need to initialize the BitBake build environment by sourcing 58 SDK, you need to initialize the BitBake build environment by sourcing
61 the build environment script (i.e. 59 the build environment script (i.e. :ref:`structure-core-script`):
62 ```oe-init-build-env`` <&YOCTO_DOCS_REF_URL;#structure-core-script>`__): 60 ::
63 $ cd ~/poky $ source oe-init-build-env 61
62 $ cd ~/poky
63 $ source oe-init-build-env
64 64
65 .. note:: 65 .. note::
66 66
@@ -71,7 +71,7 @@ section:
71 ) have been cloned using Git and the local repository is named 71 ) have been cloned using Git and the local repository is named
72 "poky". 72 "poky".
73 73
742. *Prepare Your ``local.conf`` File:* By default, the 742. *Prepare Your local.conf File:* By default, the
75 :term:`MACHINE` variable is set to 75 :term:`MACHINE` variable is set to
76 "qemux86-64", which is fine if you are building for the QEMU emulator 76 "qemux86-64", which is fine if you are building for the QEMU emulator
77 in 64-bit mode. However, if you are not, you need to set the 77 in 64-bit mode. However, if you are not, you need to set the
@@ -87,15 +87,22 @@ section:
87 87
88 In this example we wish to build for qemux86 so we must set the 88 In this example we wish to build for qemux86 so we must set the
89 ``MACHINE`` variable to "qemux86" and also add the "kernel-modules". 89 ``MACHINE`` variable to "qemux86" and also add the "kernel-modules".
90 As described we do this by appending to ``conf/local.conf``: MACHINE 90 As described we do this by appending to ``conf/local.conf``:
91 = "qemux86" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules" 91 ::
92
93 MACHINE = "qemux86"
94 MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
92 95
933. *Create a Layer for Patches:* You need to create a layer to hold 963. *Create a Layer for Patches:* You need to create a layer to hold
94 patches created for the kernel image. You can use the 97 patches created for the kernel image. You can use the
95 ``bitbake-layers create-layer`` command as follows: $ cd ~/poky/build 98 ``bitbake-layers create-layer`` command as follows:
96 $ bitbake-layers create-layer ../../meta-mylayer NOTE: Starting 99 ::
97 bitbake server... Add your new layer with 'bitbake-layers add-layer 100
98 ../../meta-mylayer' $ 101 $ cd ~/poky/build
102 $ bitbake-layers create-layer ../../meta-mylayer
103 NOTE: Starting bitbake server...
104 Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer'
105 $
99 106
100 .. note:: 107 .. note::
101 108
@@ -116,12 +123,22 @@ section:
1164. *Inform the BitBake Build Environment About Your Layer:* As directed 1234. *Inform the BitBake Build Environment About Your Layer:* As directed
117 when you created your layer, you need to add the layer to the 124 when you created your layer, you need to add the layer to the
118 :term:`BBLAYERS` variable in the 125 :term:`BBLAYERS` variable in the
119 ``bblayers.conf`` file as follows: $ cd ~/poky/build $ bitbake-layers 126 ``bblayers.conf`` file as follows:
120 add-layer ../../meta-mylayer NOTE: Starting bitbake server... $ 127 ::
128
129 $ cd ~/poky/build
130 $ bitbake-layers add-layer ../../meta-mylayer
131 NOTE: Starting bitbake server...
132 $
121 133
1225. *Build the Extensible SDK:* Use BitBake to build the extensible SDK 1345. *Build the Extensible SDK:* Use BitBake to build the extensible SDK
123 specifically for use with images to be run using QEMU: $ cd 135 specifically for use with images to be run using QEMU:
124 ~/poky/build $ bitbake core-image-minimal -c populate_sdk_ext Once 136 ::
137
138 $ cd ~/poky/build
139 $ bitbake core-image-minimal -c populate_sdk_ext
140
141 Once
125 the build finishes, you can find the SDK installer file (i.e. 142 the build finishes, you can find the SDK installer file (i.e.
126 ``*.sh`` file) in the following directory: 143 ``*.sh`` file) in the following directory:
127 ~/poky/build/tmp/deploy/sdk For this example, the installer file is 144 ~/poky/build/tmp/deploy/sdk For this example, the installer file is
@@ -130,39 +147,41 @@ section:
130 147
1316. *Install the Extensible SDK:* Use the following command to install 1486. *Install the Extensible SDK:* Use the following command to install
132 the SDK. For this example, install the SDK in the default 149 the SDK. For this example, install the SDK in the default
133 ``~/poky_sdk`` directory: $ cd ~/poky/build/tmp/deploy/sdk $ 150 ``~/poky_sdk`` directory:
134 ./poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-DISTRO.sh 151 ::
135 Poky (Yocto Project Reference Distro) Extensible SDK installer 152
136 version DISTRO 153 $ cd ~/poky/build/tmp/deploy/sdk
137 ============================================================================ 154 $ ./poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-3.1.2.sh
138 Enter target directory for SDK (default: ~/poky_sdk): You are about 155 Poky (Yocto Project Reference Distro) Extensible SDK installer version 3.1.2
139 to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y 156 ============================================================================
140 Extracting SDK......................................done Setting it 157 Enter target directory for SDK (default: ~/poky_sdk):
141 up... Extracting buildtools... Preparing build system... Parsing 158 You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y
142 recipes: 100% 159 Extracting SDK......................................done
143 \|#################################################################\| 160 Setting it up...
144 Time: 0:00:52 Initializing tasks: 100% \|############## 161 Extracting buildtools...
145 ###############################################\| Time: 0:00:04 162 Preparing build system...
146 Checking sstate mirror object availability: 100% 163 Parsing recipes: 100% |#################################################################| Time: 0:00:52
147 \|######################################\| Time: 0:00:00 Parsing 164 Initializing tasks: 100% |############## ###############################################| Time: 0:00:04
148 recipes: 100% 165 Checking sstate mirror object availability: 100% |######################################| Time: 0:00:00
149 \|#################################################################\| 166 Parsing recipes: 100% |#################################################################| Time: 0:00:33
150 Time: 0:00:33 Initializing tasks: 100% 167 Initializing tasks: 100% |##############################################################| Time: 0:00:00
151 \|##############################################################\| 168 done
152 Time: 0:00:00 done SDK has been successfully set up and is ready to 169 SDK has been successfully set up and is ready to be used.
153 be used. Each time you wish to use the SDK in a new shell session, 170 Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
154 you need to source the environment setup script e.g. $ . 171 $ . /home/scottrif/poky_sdk/environment-setup-i586-poky-linux
155 /home/scottrif/poky_sdk/environment-setup-i586-poky-linux 172
156 173
1577. *Set Up a New Terminal to Work With the Extensible SDK:* You must set 1747. *Set Up a New Terminal to Work With the Extensible SDK:* You must set
158 up a new terminal to work with the SDK. You cannot use the same 175 up a new terminal to work with the SDK. You cannot use the same
159 BitBake shell used to build the installer. 176 BitBake shell used to build the installer.
160 177
161 After opening a new shell, run the SDK environment setup script as 178 After opening a new shell, run the SDK environment setup script as
162 directed by the output from installing the SDK: $ source 179 directed by the output from installing the SDK:
163 ~/poky_sdk/environment-setup-i586-poky-linux "SDK environment now set 180 ::
164 up; additionally you may now run devtool to perform development 181
165 tasks. Run devtool --help for further details. 182 $ source ~/poky_sdk/environment-setup-i586-poky-linux
183 "SDK environment now set up; additionally you may now run devtool to perform development tasks.
184 Run devtool --help for further details.
166 185
167 .. note:: 186 .. note::
168 187
@@ -171,22 +190,24 @@ section:
171 190
1728. *Build the Clean Image:* The final step in preparing to work on the 1918. *Build the Clean Image:* The final step in preparing to work on the
173 kernel is to build an initial image using ``devtool`` in the new 192 kernel is to build an initial image using ``devtool`` in the new
174 terminal you just set up and initialized for SDK work: $ devtool 193 terminal you just set up and initialized for SDK work:
175 build-image Parsing recipes: 100% 194 ::
176 \|##########################################\| Time: 0:00:05 Parsing 195
177 of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 196 $ devtool build-image
178 skipped, 0 masked, 0 errors. WARNING: No packages to add, building 197 Parsing recipes: 100% |##########################################| Time: 0:00:05
179 image core-image-minimal unmodified Loading cache: 100% 198 Parsing of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 skipped, 0 masked, 0 errors.
180 \|############################################\| Time: 0:00:00 Loaded 199 WARNING: No packages to add, building image core-image-minimal unmodified
181 1299 entries from dependency cache. NOTE: Resolving any missing task 200 Loading cache: 100% |############################################| Time: 0:00:00
182 queue dependencies Initializing tasks: 100% 201 Loaded 1299 entries from dependency cache.
183 \|#######################################\| Time: 0:00:07 Checking 202 NOTE: Resolving any missing task queue dependencies
184 sstate mirror object availability: 100% \|###############\| Time: 203 Initializing tasks: 100% |#######################################| Time: 0:00:07
185 0:00:00 NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks 204 Checking sstate mirror object availability: 100% |###############| Time: 0:00:00
186 NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need 205 NOTE: Executing SetScene Tasks
187 to be rerun and all succeeded. NOTE: Successfully built 206 NOTE: Executing RunQueue Tasks
188 core-image-minimal. You can find output files in 207 NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need to be rerun and all succeeded.
189 /home/scottrif/poky_sdk/tmp/deploy/images/qemux86 If you were 208 NOTE: Successfully built core-image-minimal. You can find output files in /home/scottrif/poky_sdk/tmp/deploy/images/qemux86
209
210 If you were
190 building for actual hardware and not for emulation, you could flash 211 building for actual hardware and not for emulation, you could flash
191 the image to a USB stick on ``/dev/sdd`` and boot your device. For an 212 the image to a USB stick on ``/dev/sdd`` and boot your device. For an
192 example that uses a Minnowboard, see the 213 example that uses a Minnowboard, see the
@@ -195,8 +216,8 @@ section:
195 216
196At this point you have set up to start making modifications to the 217At this point you have set up to start making modifications to the
197kernel by using the extensible SDK. For a continued example, see the 218kernel by using the extensible SDK. For a continued example, see the
198"`Using ``devtool`` to Patch the 219":ref:`kernel-dev/kernel-dev-common:using \`\`devtool\`\` to patch the kernel`"
199Kernel <#using-devtool-to-patch-the-kernel>`__" section. 220section.
200 221
201Getting Ready for Traditional Kernel Development 222Getting Ready for Traditional Kernel Development
202------------------------------------------------ 223------------------------------------------------
@@ -209,22 +230,25 @@ you will be editing these files.
209Follow these steps to prepare to update the kernel image using 230Follow these steps to prepare to update the kernel image using
210traditional kernel development flow with the Yocto Project. Completing 231traditional kernel development flow with the Yocto Project. Completing
211this procedure leaves you ready to make modifications to the kernel 232this procedure leaves you ready to make modifications to the kernel
212source as described in the "`Using Traditional Kernel Development to 233source as described in the ":ref:`kernel-dev/kernel-dev-common:using traditional kernel development to patch the kernel`"
213Patch the
214Kernel <#using-traditional-kernel-development-to-patch-the-kernel>`__"
215section: 234section:
216 235
2171. *Initialize the BitBake Environment:* Before you can do anything 2361. *Initialize the BitBake Environment:* Before you can do anything
218 using BitBake, you need to initialize the BitBake build environment 237 using BitBake, you need to initialize the BitBake build environment
219 by sourcing the build environment script (i.e. 238 by sourcing the build environment script (i.e.
220 ```oe-init-build-env`` <&YOCTO_DOCS_REF_URL;#structure-core-script>`__). 239 :ref:`structure-core-script`).
221 Also, for this example, be sure that the local branch you have 240 Also, for this example, be sure that the local branch you have
222 checked out for ``poky`` is the Yocto Project DISTRO_NAME branch. If 241 checked out for ``poky`` is the Yocto Project &DISTRO_NAME; branch. If
223 you need to checkout out the DISTRO_NAME branch, see the "`Checking 242 you need to checkout out the &DISTRO_NAME; branch, see the
224 out by Branch in 243 ":ref:`dev-manual/dev-manual-start:checking out by branch in poky`"
225 Poky <&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky>`__" 244 section in the Yocto Project Development Tasks Manual.
226 section in the Yocto Project Development Tasks Manual. $ cd ~/poky $ 245 ::
227 git branch master \* DISTRO_NAME $ source oe-init-build-env 246
247 $ cd ~/poky
248 $ git branch
249 master
250 * &DISTRO_NAME;
251 $ source oe-init-build-env
228 252
229 .. note:: 253 .. note::
230 254
@@ -235,7 +259,7 @@ section:
235 ) have been cloned using Git and the local repository is named 259 ) have been cloned using Git and the local repository is named
236 "poky". 260 "poky".
237 261
2382. *Prepare Your ``local.conf`` File:* By default, the 2622. *Prepare Your local.conf File:* By default, the
239 :term:`MACHINE` variable is set to 263 :term:`MACHINE` variable is set to
240 "qemux86-64", which is fine if you are building for the QEMU emulator 264 "qemux86-64", which is fine if you are building for the QEMU emulator
241 in 64-bit mode. However, if you are not, you need to set the 265 in 64-bit mode. However, if you are not, you need to set the
@@ -251,15 +275,21 @@ section:
251 275
252 In this example we wish to build for qemux86 so we must set the 276 In this example we wish to build for qemux86 so we must set the
253 ``MACHINE`` variable to "qemux86" and also add the "kernel-modules". 277 ``MACHINE`` variable to "qemux86" and also add the "kernel-modules".
254 As described we do this by appending to ``conf/local.conf``: MACHINE 278 As described we do this by appending to ``conf/local.conf``:
255 = "qemux86" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules" 279 ::
280
281 MACHINE = "qemux86"
282 MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
256 283
2573. *Create a Layer for Patches:* You need to create a layer to hold 2843. *Create a Layer for Patches:* You need to create a layer to hold
258 patches created for the kernel image. You can use the 285 patches created for the kernel image. You can use the
259 ``bitbake-layers create-layer`` command as follows: $ cd ~/poky/build 286 ``bitbake-layers create-layer`` command as follows:
260 $ bitbake-layers create-layer ../../meta-mylayer NOTE: Starting 287 ::
261 bitbake server... Add your new layer with 'bitbake-layers add-layer 288
262 ../../meta-mylayer' 289 $ cd ~/poky/build
290 $ bitbake-layers create-layer ../../meta-mylayer
291 NOTE: Starting bitbake server...
292 Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer'
263 293
264 .. note:: 294 .. note::
265 295
@@ -280,8 +310,13 @@ section:
2804. *Inform the BitBake Build Environment About Your Layer:* As directed 3104. *Inform the BitBake Build Environment About Your Layer:* As directed
281 when you created your layer, you need to add the layer to the 311 when you created your layer, you need to add the layer to the
282 :term:`BBLAYERS` variable in the 312 :term:`BBLAYERS` variable in the
283 ``bblayers.conf`` file as follows: $ cd ~/poky/build $ bitbake-layers 313 ``bblayers.conf`` file as follows:
284 add-layer ../../meta-mylayer NOTE: Starting bitbake server ... $ 314 ::
315
316 $ cd ~/poky/build
317 $ bitbake-layers add-layer ../../meta-mylayer
318 NOTE: Starting bitbake server ...
319 $
285 320
2865. *Create a Local Copy of the Kernel Git Repository:* You can find Git 3215. *Create a Local Copy of the Kernel Git Repository:* You can find Git
287 repositories of supported Yocto Project kernels organized under 322 repositories of supported Yocto Project kernels organized under
@@ -306,14 +341,17 @@ section:
306 linux-yocto-4.12 341 linux-yocto-4.12
307 kernel with releases prior to Yocto Project 2.4: 342 kernel with releases prior to Yocto Project 2.4:
308 343
309 $ cd ~ $ git clone git://git.yoctoproject.org/linux-yocto-4.12 344 ::
310 --branch standard/base Cloning into 'linux-yocto-4.12'... remote: 345
311 Counting objects: 6097195, done. remote: Compressing objects: 100% 346 $ cd ~
312 (901026/901026), done. remote: Total 6097195 (delta 5152604), reused 347 $ git clone git://git.yoctoproject.org/linux-yocto-4.12 --branch standard/base
313 6096847 (delta 5152256) Receiving objects: 100% (6097195/6097195), 348 Cloning into 'linux-yocto-4.12'...
314 1.24 GiB \| 7.81 MiB/s, done. Resolving deltas: 100% 349 remote: Counting objects: 6097195, done.
315 (5152604/5152604), done. Checking connectivity... done. Checking out 350 remote: Compressing objects: 100% (901026/901026), done.
316 files: 100% (59846/59846), done. 351 remote: Total 6097195 (delta 5152604), reused 6096847 (delta 5152256)
352 Receiving objects: 100% (6097195/6097195), 1.24 GiB | 7.81 MiB/s, done.
353 Resolving deltas: 100% (5152604/5152604), done. Checking connectivity... done.
354 Checking out files: 100% (59846/59846), done.
317 355
3186. *Create a Local Copy of the Kernel Cache Git Repository:* For 3566. *Create a Local Copy of the Kernel Cache Git Repository:* For
319 simplicity, it is recommended that you create your copy of the kernel 357 simplicity, it is recommended that you create your copy of the kernel
@@ -323,14 +361,18 @@ section:
323 the ``yocto-4.12`` branch. 361 the ``yocto-4.12`` branch.
324 362
325 The following commands show how to create a local copy of the 363 The following commands show how to create a local copy of the
326 ``yocto-kernel-cache`` and be in the ``yocto-4.12`` branch: $ cd ~ $ 364 ``yocto-kernel-cache`` and be in the ``yocto-4.12`` branch:
327 git clone git://git.yoctoproject.org/yocto-kernel-cache --branch 365 ::
328 yocto-4.12 Cloning into 'yocto-kernel-cache'... remote: Counting 366
329 objects: 22639, done. remote: Compressing objects: 100% (9761/9761), 367 $ cd ~
330 done. remote: Total 22639 (delta 12400), reused 22586 (delta 12347) 368 $ git clone git://git.yoctoproject.org/yocto-kernel-cache --branch yocto-4.12
331 Receiving objects: 100% (22639/22639), 22.34 MiB \| 6.27 MiB/s, done. 369 Cloning into 'yocto-kernel-cache'...
332 Resolving deltas: 100% (12400/12400), done. Checking connectivity... 370 remote: Counting objects: 22639, done.
333 done. 371 remote: Compressing objects: 100% (9761/9761), done.
372 remote: Total 22639 (delta 12400), reused 22586 (delta 12347)
373 Receiving objects: 100% (22639/22639), 22.34 MiB | 6.27 MiB/s, done.
374 Resolving deltas: 100% (12400/12400), done.
375 Checking connectivity... done.
334 376
335At this point, you are ready to start making modifications to the kernel 377At this point, you are ready to start making modifications to the kernel
336using traditional kernel development steps. For a continued example, see 378using traditional kernel development steps. For a continued example, see
@@ -347,8 +389,7 @@ layer contains its own :term:`BitBake`
347append files (``.bbappend``) and provides a convenient mechanism to 389append files (``.bbappend``) and provides a convenient mechanism to
348create your own recipe files (``.bb``) as well as store and use kernel 390create your own recipe files (``.bb``) as well as store and use kernel
349patch files. For background information on working with layers, see the 391patch files. For background information on working with layers, see the
350"`Understanding and Creating 392":ref:`dev-manual/dev-manual-common-tasks:understanding and creating layers`"
351Layers <&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers>`__"
352section in the Yocto Project Development Tasks Manual. 393section in the Yocto Project Development Tasks Manual.
353 394
354.. note:: 395.. note::
@@ -368,37 +409,56 @@ following section describes how to create a layer without the aid of
368tools. These steps assume creation of a layer named ``mylayer`` in your 409tools. These steps assume creation of a layer named ``mylayer`` in your
369home directory: 410home directory:
370 411
3711. *Create Structure*: Create the layer's structure: $ cd $HOME $ mkdir 4121. *Create Structure*: Create the layer's structure:
372 meta-mylayer $ mkdir meta-mylayer/conf $ mkdir 413 ::
373 meta-mylayer/recipes-kernel $ mkdir meta-mylayer/recipes-kernel/linux 414
374 $ mkdir meta-mylayer/recipes-kernel/linux/linux-yocto The ``conf`` 415 $ cd $HOME
375 directory holds your configuration files, while the 416 $ mkdir meta-mylayer
417 $ mkdir meta-mylayer/conf
418 $ mkdir meta-mylayer/recipes-kernel
419 $ mkdir meta-mylayer/recipes-kernel/linux
420 $ mkdir meta-mylayer/recipes-kernel/linux/linux-yocto
421
422 The ``conf`` directory holds your configuration files, while the
376 ``recipes-kernel`` directory holds your append file and eventual 423 ``recipes-kernel`` directory holds your append file and eventual
377 patch files. 424 patch files.
378 425
3792. *Create the Layer Configuration File*: Move to the 4262. *Create the Layer Configuration File*: Move to the
380 ``meta-mylayer/conf`` directory and create the ``layer.conf`` file as 427 ``meta-mylayer/conf`` directory and create the ``layer.conf`` file as
381 follows: # We have a conf and classes directory, add to BBPATH BBPATH 428 follows:
382 .= ":${LAYERDIR}" # We have recipes-\* directories, add to BBFILES 429 ::
383 BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \\ 430
384 ${LAYERDIR}/recipes-*/*/*.bbappend" BBFILE_COLLECTIONS += "mylayer" 431 # We have a conf and classes directory, add to BBPATH
385 BBFILE_PATTERN_mylayer = "^${LAYERDIR}/" BBFILE_PRIORITY_mylayer = 432 BBPATH .= ":${LAYERDIR}"
386 "5" Notice ``mylayer`` as part of the last three statements. 433
434 # We have recipes-* directories, add to BBFILES
435 BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
436 ${LAYERDIR}/recipes-*/*/*.bbappend"
437
438 BBFILE_COLLECTIONS += "mylayer"
439 BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"
440 BBFILE_PRIORITY_mylayer = "5"
441
442 Notice ``mylayer`` as part of the last three statements.
387 443
3883. *Create the Kernel Recipe Append File*: Move to the 4443. *Create the Kernel Recipe Append File*: Move to the
389 ``meta-mylayer/recipes-kernel/linux`` directory and create the 445 ``meta-mylayer/recipes-kernel/linux`` directory and create the
390 kernel's append file. This example uses the ``linux-yocto-4.12`` 446 kernel's append file. This example uses the ``linux-yocto-4.12``
391 kernel. Thus, the name of the append file is 447 kernel. Thus, the name of the append file is
392 ``linux-yocto_4.12.bbappend``: FILESEXTRAPATHS_prepend := 448 ``linux-yocto_4.12.bbappend``:
393 "${THISDIR}/${PN}:" SRC_URI_append = " file://patch-file-one" 449 ::
394 SRC_URI_append = " file://patch-file-two" SRC_URI_append = " 450
395 file://patch-file-three" The 451 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
396 :term:`FILESEXTRAPATHS` 452
397 and :term:`SRC_URI` statements 453 SRC_URI_append = " file://patch-file-one"
454 SRC_URI_append = " file://patch-file-two"
455 SRC_URI_append = " file://patch-file-three"
456
457 The :term:`FILESEXTRAPATHS` and :term:`SRC_URI` statements
398 enable the OpenEmbedded build system to find patch files. For more 458 enable the OpenEmbedded build system to find patch files. For more
399 information on using append files, see the "`Using .bbappend Files in 459 information on using append files, see the
400 Your Layer <&YOCTO_DOCS_DEV_URL;#using-bbappend-files>`__" section in 460 ":ref:`dev-manual/dev-manual-common-tasks:using .bbappend files in your layer`"
401 the Yocto Project Development Tasks Manual. 461 section in the Yocto Project Development Tasks Manual.
402 462
403Modifying an Existing Recipe 463Modifying an Existing Recipe
404============================ 464============================
@@ -429,19 +489,28 @@ You create this file in your custom layer. You also name it accordingly
429based on the linux-yocto recipe you are using. For example, if you are 489based on the linux-yocto recipe you are using. For example, if you are
430modifying the ``meta/recipes-kernel/linux/linux-yocto_4.12.bb`` recipe, 490modifying the ``meta/recipes-kernel/linux/linux-yocto_4.12.bb`` recipe,
431the append file will typically be located as follows within your custom 491the append file will typically be located as follows within your custom
432layer: your-layer/recipes-kernel/linux/linux-yocto_4.12.bbappend The 492layer:
433append file should initially extend the 493::
494
495 your-layer/recipes-kernel/linux/linux-yocto_4.12.bbappend
496
497The append file should initially extend the
434:term:`FILESPATH` search path by 498:term:`FILESPATH` search path by
435prepending the directory that contains your files to the 499prepending the directory that contains your files to the
436:term:`FILESEXTRAPATHS` 500:term:`FILESEXTRAPATHS`
437variable as follows: FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" The 501variable as follows:
438path 502::
439``${``\ :term:`THISDIR`\ ``}/${``\ :term:`PN`\ ``}`` 503
504 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
505
506The path ``${``\ :term:`THISDIR`\ ``}/${``\ :term:`PN`\ ``}``
440expands to "linux-yocto" in the current directory for this example. If 507expands to "linux-yocto" in the current directory for this example. If
441you add any new files that modify the kernel recipe and you have 508you add any new files that modify the kernel recipe and you have
442extended ``FILESPATH`` as described above, you must place the files in 509extended ``FILESPATH`` as described above, you must place the files in
443your layer in the following area: 510your layer in the following area:
444your-layer/recipes-kernel/linux/linux-yocto/ 511::
512
513 your-layer/recipes-kernel/linux/linux-yocto/
445 514
446.. note:: 515.. note::
447 516
@@ -452,24 +521,40 @@ your-layer/recipes-kernel/linux/linux-yocto/
452 521
453As an example, consider the following append file used by the BSPs in 522As an example, consider the following append file used by the BSPs in
454``meta-yocto-bsp``: 523``meta-yocto-bsp``:
455meta-yocto-bsp/recipes-kernel/linux/linux-yocto_4.12.bbappend The 524::
456following listing shows the file. Be aware that the actual commit ID 525
526 meta-yocto-bsp/recipes-kernel/linux/linux-yocto_4.12.bbappend
527
528The following listing shows the file. Be aware that the actual commit ID
457strings in this example listing might be different than the actual 529strings in this example listing might be different than the actual
458strings in the file from the ``meta-yocto-bsp`` layer upstream. 530strings in the file from the ``meta-yocto-bsp`` layer upstream.
459KBRANCH_genericx86 = "standard/base" KBRANCH_genericx86-64 = 531::
460"standard/base" KMACHINE_genericx86 ?= "common-pc" 532
461KMACHINE_genericx86-64 ?= "common-pc-64" KBRANCH_edgerouter = 533 KBRANCH_genericx86 = "standard/base"
462"standard/edgerouter" KBRANCH_beaglebone = "standard/beaglebone" 534 KBRANCH_genericx86-64 = "standard/base"
463SRCREV_machine_genericx86 ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19" 535
464SRCREV_machine_genericx86-64 ?= 536 KMACHINE_genericx86 ?= "common-pc"
465"d09f2ce584d60ecb7890550c22a80c48b83c2e19" SRCREV_machine_edgerouter ?= 537 KMACHINE_genericx86-64 ?= "common-pc-64"
466"b5c8cfda2dfe296410d51e131289fb09c69e1e7d" SRCREV_machine_beaglebone ?= 538 KBRANCH_edgerouter = "standard/edgerouter"
467"b5c8cfda2dfe296410d51e131289fb09c69e1e7d" COMPATIBLE_MACHINE_genericx86 539 KBRANCH_beaglebone = "standard/beaglebone"
468= "genericx86" COMPATIBLE_MACHINE_genericx86-64 = "genericx86-64" 540
469COMPATIBLE_MACHINE_edgerouter = "edgerouter" 541 SRCREV_machine_genericx86 ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19"
470COMPATIBLE_MACHINE_beaglebone = "beaglebone" LINUX_VERSION_genericx86 = 542 SRCREV_machine_genericx86-64 ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19"
471"4.12.7" LINUX_VERSION_genericx86-64 = "4.12.7" LINUX_VERSION_edgerouter 543 SRCREV_machine_edgerouter ?= "b5c8cfda2dfe296410d51e131289fb09c69e1e7d"
472= "4.12.10" LINUX_VERSION_beaglebone = "4.12.10" This append file 544 SRCREV_machine_beaglebone ?= "b5c8cfda2dfe296410d51e131289fb09c69e1e7d"
545
546
547 COMPATIBLE_MACHINE_genericx86 = "genericx86"
548 COMPATIBLE_MACHINE_genericx86-64 = "genericx86-64"
549 COMPATIBLE_MACHINE_edgerouter = "edgerouter"
550 COMPATIBLE_MACHINE_beaglebone = "beaglebone"
551
552 LINUX_VERSION_genericx86 = "4.12.7"
553 LINUX_VERSION_genericx86-64 = "4.12.7"
554 LINUX_VERSION_edgerouter = "4.12.10"
555 LINUX_VERSION_beaglebone = "4.12.10"
556
557This append file
473contains statements used to support several BSPs that ship with the 558contains statements used to support several BSPs that ship with the
474Yocto Project. The file defines machines using the 559Yocto Project. The file defines machines using the
475:term:`COMPATIBLE_MACHINE` 560:term:`COMPATIBLE_MACHINE`
@@ -504,15 +589,21 @@ For example, suppose you had some configuration options in a file called
504``network_configs.cfg``. You can place that file inside a directory 589``network_configs.cfg``. You can place that file inside a directory
505named ``linux-yocto`` and then add a ``SRC_URI`` statement such as the 590named ``linux-yocto`` and then add a ``SRC_URI`` statement such as the
506following to the append file. When the OpenEmbedded build system builds 591following to the append file. When the OpenEmbedded build system builds
507the kernel, the configuration options are picked up and applied. SRC_URI 592the kernel, the configuration options are picked up and applied.
508+= "file://network_configs.cfg" 593::
594
595 SRC_URI += "file://network_configs.cfg"
509 596
510To group related configurations into multiple files, you perform a 597To group related configurations into multiple files, you perform a
511similar procedure. Here is an example that groups separate 598similar procedure. Here is an example that groups separate
512configurations specifically for Ethernet and graphics into their own 599configurations specifically for Ethernet and graphics into their own
513files and adds the configurations by using a ``SRC_URI`` statement like 600files and adds the configurations by using a ``SRC_URI`` statement like
514the following in your append file: SRC_URI += "file://myconfig.cfg \\ 601the following in your append file:
515file://eth.cfg \\ file://gfx.cfg" 602::
603
604 SRC_URI += "file://myconfig.cfg \
605 file://eth.cfg \
606 file://gfx.cfg"
516 607
517Another variable you can use in your kernel recipe append file is the 608Another variable you can use in your kernel recipe append file is the
518:term:`FILESEXTRAPATHS` 609:term:`FILESEXTRAPATHS`
@@ -552,18 +643,22 @@ reference them in :term:`SRC_URI`
552statements. 643statements.
553 644
554For example, you can apply a three-patch series by adding the following 645For example, you can apply a three-patch series by adding the following
555lines to your linux-yocto ``.bbappend`` file in your layer: SRC_URI += 646lines to your linux-yocto ``.bbappend`` file in your layer:
556"file://0001-first-change.patch" SRC_URI += 647::
557"file://0002-second-change.patch" SRC_URI += 648
558"file://0003-third-change.patch" The next time you run BitBake to build 649 SRC_URI += "file://0001-first-change.patch"
650 SRC_URI += "file://0002-second-change.patch"
651 SRC_URI += "file://0003-third-change.patch"
652
653The next time you run BitBake to build
559the Linux kernel, BitBake detects the change in the recipe and fetches 654the Linux kernel, BitBake detects the change in the recipe and fetches
560and applies the patches before building the kernel. 655and applies the patches before building the kernel.
561 656
562For a detailed example showing how to patch the kernel using 657For a detailed example showing how to patch the kernel using
563``devtool``, see the "`Using ``devtool`` to Patch the 658``devtool``, see the
564Kernel <#using-devtool-to-patch-the-kernel>`__" and "`Using Traditional 659":ref:`kernel-dev/kernel-dev-common:using \`\`devtool\`\` to patch the kernel`"
565Kernel Development to Patch the 660and
566Kernel <#using-traditional-kernel-development-to-patch-the-kernel>`__" 661":ref:`kernel-dev/kernel-dev-common:using traditional kernel development to patch the kernel`"
567sections. 662sections.
568 663
569Changing the Configuration 664Changing the Configuration
@@ -580,8 +675,12 @@ to use for the configuration, as before, copy that file to the
580appropriate ``${PN}`` directory in your layer's ``recipes-kernel/linux`` 675appropriate ``${PN}`` directory in your layer's ``recipes-kernel/linux``
581directory, and rename the copied file to "defconfig". Then, add the 676directory, and rename the copied file to "defconfig". Then, add the
582following lines to the linux-yocto ``.bbappend`` file in your layer: 677following lines to the linux-yocto ``.bbappend`` file in your layer:
583FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += 678::
584"file://defconfig" The ``SRC_URI`` tells the build system how to search 679
680 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
681 SRC_URI += "file://defconfig"
682
683The ``SRC_URI`` tells the build system how to search
585for the file, while the 684for the file, while the
586:term:`FILESEXTRAPATHS` 685:term:`FILESEXTRAPATHS`
587extends the :term:`FILESPATH` 686extends the :term:`FILESPATH`
@@ -606,13 +705,26 @@ Generally speaking, the preferred approach is to determine the
606incremental change you want to make and add that as a configuration 705incremental change you want to make and add that as a configuration
607fragment. For example, if you want to add support for a basic serial 706fragment. For example, if you want to add support for a basic serial
608console, create a file named ``8250.cfg`` in the ``${PN}`` directory 707console, create a file named ``8250.cfg`` in the ``${PN}`` directory
609with the following content (without indentation): CONFIG_SERIAL_8250=y 708with the following content (without indentation):
610CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_PCI=y 709::
611CONFIG_SERIAL_8250_NR_UARTS=4 CONFIG_SERIAL_8250_RUNTIME_UARTS=4 710
612CONFIG_SERIAL_CORE=y CONFIG_SERIAL_CORE_CONSOLE=y Next, include this 711 CONFIG_SERIAL_8250=y
712 CONFIG_SERIAL_8250_CONSOLE=y
713 CONFIG_SERIAL_8250_PCI=y
714 CONFIG_SERIAL_8250_NR_UARTS=4
715 CONFIG_SERIAL_8250_RUNTIME_UARTS=4
716 CONFIG_SERIAL_CORE=y
717 CONFIG_SERIAL_CORE_CONSOLE=y
718
719Next, include this
613configuration fragment and extend the ``FILESPATH`` variable in your 720configuration fragment and extend the ``FILESPATH`` variable in your
614``.bbappend`` file: FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 721``.bbappend`` file:
615SRC_URI += "file://8250.cfg" The next time you run BitBake to build the 722::
723
724 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
725 SRC_URI += "file://8250.cfg"
726
727The next time you run BitBake to build the
616Linux kernel, BitBake detects the change in the recipe and fetches and 728Linux kernel, BitBake detects the change in the recipe and fetches and
617applies the new configuration before building the kernel. 729applies the new configuration before building the kernel.
618 730
@@ -626,8 +738,12 @@ It might be desirable to have kernel configuration fragment support
626through a ``defconfig`` file that is pulled from the kernel source tree 738through a ``defconfig`` file that is pulled from the kernel source tree
627for the configured machine. By default, the OpenEmbedded build system 739for the configured machine. By default, the OpenEmbedded build system
628looks for ``defconfig`` files in the layer used for Metadata, which is 740looks for ``defconfig`` files in the layer used for Metadata, which is
629"out-of-tree", and then configures them using the following: SRC_URI += 741"out-of-tree", and then configures them using the following:
630"file://defconfig" If you do not want to maintain copies of 742::
743
744 SRC_URI += "file://defconfig"
745
746If you do not want to maintain copies of
631``defconfig`` files in your layer but would rather allow users to use 747``defconfig`` files in your layer but would rather allow users to use
632the default configuration from the kernel tree and still be able to add 748the default configuration from the kernel tree and still be able to add
633configuration fragments to the 749configuration fragments to the
@@ -636,11 +752,18 @@ append files, you can direct the OpenEmbedded build system to use a
636``defconfig`` file that is "in-tree". 752``defconfig`` file that is "in-tree".
637 753
638To specify an "in-tree" ``defconfig`` file, use the following statement 754To specify an "in-tree" ``defconfig`` file, use the following statement
639form: KBUILD_DEFCONFIG_KMACHINE ?= defconfig_file Here is an example 755form:
756::
757
758 KBUILD_DEFCONFIG_KMACHINE ?= defconfig_file
759
760Here is an example
640that assigns the ``KBUILD_DEFCONFIG`` variable based on "raspberrypi2" 761that assigns the ``KBUILD_DEFCONFIG`` variable based on "raspberrypi2"
641and provides the path to the "in-tree" ``defconfig`` file to be used for 762and provides the path to the "in-tree" ``defconfig`` file to be used for
642a Raspberry Pi 2, which is based on the Broadcom 2708/2709 chipset: 763a Raspberry Pi 2, which is based on the Broadcom 2708/2709 chipset:
643KBUILD_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig" 764::
765
766 KBUILD_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig"
644 767
645Aside from modifying your kernel recipe and providing your own 768Aside from modifying your kernel recipe and providing your own
646``defconfig`` file, you need to be sure no files or statements set 769``defconfig`` file, you need to be sure no files or statements set
@@ -678,8 +801,7 @@ output at boot time through ``printk`` statements in the kernel's
678``calibrate.c`` source code file. Applying the patch and booting the 801``calibrate.c`` source code file. Applying the patch and booting the
679modified image causes the added messages to appear on the emulator's 802modified image causes the added messages to appear on the emulator's
680console. The example is a continuation of the setup procedure found in 803console. The example is a continuation of the setup procedure found in
681the "`Getting Ready to Develop Using 804the ":ref:`kernel-dev/kernel-dev-common:getting ready to develop using \`\`devtool\`\``" Section.
682``devtool`` <#getting-ready-to-develop-using-devtool>`__" Section.
683 805
6841. *Check Out the Kernel Source Files:* First you must use ``devtool`` 8061. *Check Out the Kernel Source Files:* First you must use ``devtool``
685 to checkout the kernel source code in its workspace. Be sure you are 807 to checkout the kernel source code in its workspace. Be sure you are
@@ -694,8 +816,10 @@ the "`Getting Ready to Develop Using
694 devtool 816 devtool
695 " section for more information. 817 " section for more information.
696 818
697 Use the following ``devtool`` command to check out the code: $ 819 Use the following ``devtool`` command to check out the code:
698 devtool modify linux-yocto 820 ::
821
822 $ devtool modify linux-yocto
699 823
700 .. note:: 824 .. note::
701 825
@@ -706,7 +830,7 @@ the "`Getting Ready to Develop Using
706 ERROR: Taskhash mismatch 2c793438c2d9f8c3681fd5f7bc819efa versus 830 ERROR: Taskhash mismatch 2c793438c2d9f8c3681fd5f7bc819efa versus
707 be3a89ce7c47178880ba7bf6293d7404 for 831 be3a89ce7c47178880ba7bf6293d7404 for
708 /path/to/esdk/layers/poky/meta/recipes-kernel/linux/linux-yocto_4.10.bb.do_unpack 832 /path/to/esdk/layers/poky/meta/recipes-kernel/linux/linux-yocto_4.10.bb.do_unpack
709 833
710 834
711 You can safely ignore these messages. The source code is correctly 835 You can safely ignore these messages. The source code is correctly
712 checked out. 836 checked out.
@@ -718,19 +842,37 @@ the "`Getting Ready to Develop Using
718 noted where you can find the source files (e.g. 842 noted where you can find the source files (e.g.
719 ``~/poky_sdk/workspace/sources/linux-yocto``). Change to where the 843 ``~/poky_sdk/workspace/sources/linux-yocto``). Change to where the
720 kernel source code is before making your edits to the 844 kernel source code is before making your edits to the
721 ``calibrate.c`` file: $ cd 845 ``calibrate.c`` file:
722 ~/poky_sdk/workspace/sources/linux-yocto 846 ::
847
848 $ cd ~/poky_sdk/workspace/sources/linux-yocto
723 849
724 2. *Edit the source file*: Edit the ``init/calibrate.c`` file to have 850 2. *Edit the source file*: Edit the ``init/calibrate.c`` file to have
725 the following changes: void calibrate_delay(void) { unsigned long 851 the following changes:
726 lpj; static bool printed; int this_cpu = smp_processor_id(); 852 ::
727 printk("*************************************\n"); printk("\* 853
728 \*\n"); printk("\* HELLO YOCTO KERNEL \*\n"); printk("\* \*\n"); 854 void calibrate_delay(void)
729 printk("*************************************\n"); if 855 {
730 (per_cpu(cpu_loops_per_jiffy, this_cpu)) { . . . 856 unsigned long lpj;
857 static bool printed;
858 int this_cpu = smp_processor_id();
859
860 printk("*************************************\n");
861 printk("* *\n");
862 printk("* HELLO YOCTO KERNEL *\n");
863 printk("* *\n");
864 printk("*************************************\n");
865
866 if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
867 .
868 .
869 .
731 870
7323. *Build the Updated Kernel Source:* To build the updated kernel 8713. *Build the Updated Kernel Source:* To build the updated kernel
733 source, use ``devtool``: $ devtool build linux-yocto 872 source, use ``devtool``:
873 ::
874
875 $ devtool build linux-yocto
734 876
7354. *Create the Image With the New Kernel:* Use the 8774. *Create the Image With the New Kernel:* Use the
736 ``devtool build-image`` command to create a new image that has the 878 ``devtool build-image`` command to create a new image that has the
@@ -744,25 +886,40 @@ the "`Getting Ready to Develop Using
744 TipsAndTricks/KernelDevelopmentWithEsdk 886 TipsAndTricks/KernelDevelopmentWithEsdk
745 Wiki Page. 887 Wiki Page.
746 888
747 $ cd ~ $ devtool build-image core-image-minimal 889 ::
890
891 $ cd ~
892 $ devtool build-image core-image-minimal
748 893
7495. *Test the New Image:* For this example, you can run the new image 8945. *Test the New Image:* For this example, you can run the new image
750 using QEMU to verify your changes: 895 using QEMU to verify your changes:
751 896
752 1. *Boot the image*: Boot the modified image in the QEMU emulator 897 1. *Boot the image*: Boot the modified image in the QEMU emulator
753 using this command: $ runqemu qemux86 898 using this command:
899 ::
900
901 $ runqemu qemux86
754 902
755 2. *Verify the changes*: Log into the machine using ``root`` with no 903 2. *Verify the changes*: Log into the machine using ``root`` with no
756 password and then use the following shell command to scroll 904 password and then use the following shell command to scroll
757 through the console's boot output. # dmesg \| less You should see 905 through the console's boot output.
906 ::
907
908 # dmesg | less
909
910 You should see
758 the results of your ``printk`` statements as part of the output 911 the results of your ``printk`` statements as part of the output
759 when you scroll down the console window. 912 when you scroll down the console window.
760 913
7616. *Stage and commit your changes*: Within your eSDK terminal, change 9146. *Stage and commit your changes*: Within your eSDK terminal, change
762 your working directory to where you modified the ``calibrate.c`` file 915 your working directory to where you modified the ``calibrate.c`` file
763 and use these Git commands to stage and commit your changes: $ cd 916 and use these Git commands to stage and commit your changes:
764 ~/poky_sdk/workspace/sources/linux-yocto $ git status $ git add 917 ::
765 init/calibrate.c $ git commit -m "calibrate: Add printk example" 918
919 $ cd ~/poky_sdk/workspace/sources/linux-yocto
920 $ git status
921 $ git add init/calibrate.c
922 $ git commit -m "calibrate: Add printk example"
766 923
7677. *Export the Patches and Create an Append File:* To export your 9247. *Export the Patches and Create an Append File:* To export your
768 commits as patches and create a ``.bbappend`` file, use the following 925 commits as patches and create a ``.bbappend`` file, use the following
@@ -775,7 +932,9 @@ the "`Getting Ready to Develop Using
775 Getting Ready to Develop Using devtool 932 Getting Ready to Develop Using devtool
776 " section for information on setting up this layer. 933 " section for information on setting up this layer.
777 934
778 $ devtool finish linux-yocto ~/meta-mylayer Once the command 935 $ devtool finish linux-yocto ~/meta-mylayer
936
937 Once the command
779 finishes, the patches and the ``.bbappend`` file are located in the 938 finishes, the patches and the ``.bbappend`` file are located in the
780 ``~/meta-mylayer/recipes-kernel/linux`` directory. 939 ``~/meta-mylayer/recipes-kernel/linux`` directory.
781 940
@@ -783,15 +942,20 @@ the "`Getting Ready to Develop Using
783 image that includes your kernel patches. Execute the following 942 image that includes your kernel patches. Execute the following
784 command from your 943 command from your
785 :term:`Build Directory` in the terminal 944 :term:`Build Directory` in the terminal
786 set up to run BitBake: $ cd ~/poky/build $ bitbake core-image-minimal 945 set up to run BitBake:
946 ::
947
948 $ cd ~/poky/build
949 $ bitbake core-image-minimal
787 950
788Using Traditional Kernel Development to Patch the Kernel 951Using Traditional Kernel Development to Patch the Kernel
789======================================================== 952========================================================
790 953
791The steps in this procedure show you how you can patch the kernel using 954The steps in this procedure show you how you can patch the kernel using
792traditional kernel development (i.e. not using ``devtool`` and the 955traditional kernel development (i.e. not using ``devtool`` and the
793extensible SDK as described in the "`Using ``devtool`` to Patch the 956extensible SDK as described in the
794Kernel <#using-devtool-to-patch-the-kernel>`__" section). 957":ref:`kernel-dev/kernel-dev-common:using \`\`devtool\`\` to patch the kernel`"
958section).
795 959
796.. note:: 960.. note::
797 961
@@ -824,35 +988,61 @@ Section.
824 1. *Change the working directory*: You need to locate the source 988 1. *Change the working directory*: You need to locate the source
825 files in the local copy of the kernel Git repository: Change to 989 files in the local copy of the kernel Git repository: Change to
826 where the kernel source code is before making your edits to the 990 where the kernel source code is before making your edits to the
827 ``calibrate.c`` file: $ cd ~/linux-yocto-4.12/init 991 ``calibrate.c`` file:
992 ::
993
994 $ cd ~/linux-yocto-4.12/init
828 995
829 2. *Edit the source file*: Edit the ``calibrate.c`` file to have the 996 2. *Edit the source file*: Edit the ``calibrate.c`` file to have the
830 following changes: void calibrate_delay(void) { unsigned long lpj; 997 following changes:
831 static bool printed; int this_cpu = smp_processor_id(); 998 ::
832 printk("*************************************\n"); printk("\* 999
833 \*\n"); printk("\* HELLO YOCTO KERNEL \*\n"); printk("\* \*\n"); 1000 void calibrate_delay(void)
834 printk("*************************************\n"); if 1001 {
835 (per_cpu(cpu_loops_per_jiffy, this_cpu)) { . . . 1002 unsigned long lpj;
1003 static bool printed;
1004 int this_cpu = smp_processor_id();
1005
1006 printk("*************************************\n");
1007 printk("* *\n");
1008 printk("* HELLO YOCTO KERNEL *\n");
1009 printk("* *\n");
1010 printk("*************************************\n");
1011
1012 if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
1013 .
1014 .
1015 .
836 1016
8372. *Stage and Commit Your Changes:* Use standard Git commands to stage 10172. *Stage and Commit Your Changes:* Use standard Git commands to stage
838 and commit the changes you just made: $ git add calibrate.c $ git 1018 and commit the changes you just made:
839 commit -m "calibrate.c - Added some printk statements" If you do not 1019 ::
1020
1021 $ git add calibrate.c
1022 $ git commit -m "calibrate.c - Added some printk statements"
1023
1024 If you do not
840 stage and commit your changes, the OpenEmbedded Build System will not 1025 stage and commit your changes, the OpenEmbedded Build System will not
841 pick up the changes. 1026 pick up the changes.
842 1027
8433. *Update Your ``local.conf`` File to Point to Your Source Files:* In 10283. *Update Your local.conf File to Point to Your Source Files:* In
844 addition to your ``local.conf`` file specifying to use 1029 addition to your ``local.conf`` file specifying to use
845 "kernel-modules" and the "qemux86" machine, it must also point to the 1030 "kernel-modules" and the "qemux86" machine, it must also point to the
846 updated kernel source files. Add 1031 updated kernel source files. Add
847 :term:`SRC_URI` and 1032 :term:`SRC_URI` and
848 :term:`SRCREV` statements similar 1033 :term:`SRCREV` statements similar
849 to the following to your ``local.conf``: $ cd ~/poky/build/conf Add 1034 to the following to your ``local.conf``:
850 the following to the ``local.conf``: SRC_URI_pn-linux-yocto = 1035 ::
851 "git:///path-to/linux-yocto-4.12;protocol=file;name=machine;branch=standard/base; 1036
852 \\ 1037 $ cd ~/poky/build/conf
853 git:///path-to/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}" 1038
854 SRCREV_meta_qemux86 = "${AUTOREV}" SRCREV_machine_qemux86 = 1039 Add the following to the ``local.conf``:
855 "${AUTOREV}" 1040 ::
1041
1042 SRC_URI_pn-linux-yocto = "git:///path-to/linux-yocto-4.12;protocol=file;name=machine;branch=standard/base; \
1043 git:///path-to/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}"
1044 SRCREV_meta_qemux86 = "${AUTOREV}"
1045 SRCREV_machine_qemux86 = "${AUTOREV}"
856 1046
857 .. note:: 1047 .. note::
858 1048
@@ -866,23 +1056,39 @@ Section.
866 1056
8674. *Build the Image:* With the source modified, your changes staged and 10574. *Build the Image:* With the source modified, your changes staged and
868 committed, and the ``local.conf`` file pointing to the kernel files, 1058 committed, and the ``local.conf`` file pointing to the kernel files,
869 you can now use BitBake to build the image: $ cd ~/poky/build $ 1059 you can now use BitBake to build the image:
870 bitbake core-image-minimal 1060 ::
1061
1062 $ cd ~/poky/build
1063 $ bitbake core-image-minimal
871 1064
8725. *Boot the image*: Boot the modified image in the QEMU emulator using 10655. *Boot the image*: Boot the modified image in the QEMU emulator using
873 this command. When prompted to login to the QEMU console, use "root" 1066 this command. When prompted to login to the QEMU console, use "root"
874 with no password: $ cd ~/poky/build $ runqemu qemux86 1067 with no password:
1068 ::
1069
1070 $ cd ~/poky/build
1071 $ runqemu qemux86
875 1072
8766. *Look for Your Changes:* As QEMU booted, you might have seen your 10736. *Look for Your Changes:* As QEMU booted, you might have seen your
877 changes rapidly scroll by. If not, use these commands to see your 1074 changes rapidly scroll by. If not, use these commands to see your
878 changes: # dmesg \| less You should see the results of your 1075 changes:
1076 ::
1077
1078 # dmesg | less
1079
1080 You should see the results of your
879 ``printk`` statements as part of the output when you scroll down the 1081 ``printk`` statements as part of the output when you scroll down the
880 console window. 1082 console window.
881 1083
8827. *Generate the Patch File:* Once you are sure that your patch works 10847. *Generate the Patch File:* Once you are sure that your patch works
883 correctly, you can generate a ``*.patch`` file in the kernel source 1085 correctly, you can generate a ``*.patch`` file in the kernel source
884 repository: $ cd ~/linux-yocto-4.12/init $ git format-patch -1 1086 repository:
885 0001-calibrate.c-Added-some-printk-statements.patch 1087 ::
1088
1089 $ cd ~/linux-yocto-4.12/init
1090 $ git format-patch -1
1091 0001-calibrate.c-Added-some-printk-statements.patch
886 1092
8878. *Move the Patch File to Your Layer:* In order for subsequent builds 10938. *Move the Patch File to Your Layer:* In order for subsequent builds
888 to pick up patches, you need to move the patch file you created in 1094 to pick up patches, you need to move the patch file you created in
@@ -891,32 +1097,40 @@ Section.
891 ``meta-mylayer``. When the layer was created using the 1097 ``meta-mylayer``. When the layer was created using the
892 ``yocto-create`` script, no additional hierarchy was created to 1098 ``yocto-create`` script, no additional hierarchy was created to
893 support patches. Before moving the patch file, you need to add 1099 support patches. Before moving the patch file, you need to add
894 additional structure to your layer using the following commands: $ cd 1100 additional structure to your layer using the following commands:
895 ~/meta-mylayer $ mkdir recipes-kernel $ mkdir recipes-kernel/linux $ 1101 ::
896 mkdir recipes-kernel/linux/linux-yocto Once you have created this 1102
1103 $ cd ~/meta-mylayer
1104 $ mkdir recipes-kernel
1105 $ mkdir recipes-kernel/linux
1106 $ mkdir recipes-kernel/linux/linux-yocto
1107
1108 Once you have created this
897 hierarchy in your layer, you can move the patch file using the 1109 hierarchy in your layer, you can move the patch file using the
898 following command: $ mv 1110 following command:
899 ~/linux-yocto-4.12/init/0001-calibrate.c-Added-some-printk-statements.patch 1111 ::
900 ~/meta-mylayer/recipes-kernel/linux/linux-yocto 1112
1113 $ mv ~/linux-yocto-4.12/init/0001-calibrate.c-Added-some-printk-statements.patch ~/meta-mylayer/recipes-kernel/linux/linux-yocto
901 1114
9029. *Create the Append File:* Finally, you need to create the 11159. *Create the Append File:* Finally, you need to create the
903 ``linux-yocto_4.12.bbappend`` file and insert statements that allow 1116 ``linux-yocto_4.12.bbappend`` file and insert statements that allow
904 the OpenEmbedded build system to find the patch. The append file 1117 the OpenEmbedded build system to find the patch. The append file
905 needs to be in your layer's ``recipes-kernel/linux`` directory and it 1118 needs to be in your layer's ``recipes-kernel/linux`` directory and it
906 must be named ``linux-yocto_4.12.bbappend`` and have the following 1119 must be named ``linux-yocto_4.12.bbappend`` and have the following
907 contents: FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 1120 contents:
908 SRC_URI_append = " 1121 ::
909 file://0001-calibrate.c-Added-some-printk-statements.patch" The 1122
910 :term:`FILESEXTRAPATHS` 1123 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
911 and :term:`SRC_URI` statements 1124 SRC_URI_append = "file://0001-calibrate.c-Added-some-printk-statements.patch"
1125
1126 The :term:`FILESEXTRAPATHS` and :term:`SRC_URI` statements
912 enable the OpenEmbedded build system to find the patch file. 1127 enable the OpenEmbedded build system to find the patch file.
913 1128
914 For more information on append files and patches, see the "`Creating 1129 For more information on append files and patches, see the "`Creating
915 the Append File <#creating-the-append-file>`__" and "`Applying 1130 the Append File <#creating-the-append-file>`__" and "`Applying
916 Patches <#applying-patches>`__" sections. You can also see the 1131 Patches <#applying-patches>`__" sections. You can also see the
917 "`Using .bbappend Files in Your 1132 ":ref:`dev-manual/dev-manual-common-tasks:using .bbappend files in your layer`"
918 Layer" <&YOCTO_DOCS_DEV_URL;#using-bbappend-files>`__" section in the 1133 section in the Yocto Project Development Tasks Manual.
919 Yocto Project Development Tasks Manual.
920 1134
921 .. note:: 1135 .. note::
922 1136
@@ -934,7 +1148,7 @@ Section.
934 $ bitbake core-image-minimal -c cleanall 1148 $ bitbake core-image-minimal -c cleanall
935 $ bitbake core-image-minimal 1149 $ bitbake core-image-minimal
936 $ runqemu qemux86 1150 $ runqemu qemux86
937 1151
938 1152
939Configuring the Kernel 1153Configuring the Kernel
940====================== 1154======================
@@ -967,21 +1181,30 @@ environment, you must do the following:
967 1181
968- Because you launch ``menuconfig`` using BitBake, you must be sure to 1182- Because you launch ``menuconfig`` using BitBake, you must be sure to
969 set up your environment by running the 1183 set up your environment by running the
970 ````` <&YOCTO_DOCS_REF_URL;#structure-core-script>`__ script found in 1184 :ref:`structure-core-script` script found in
971 the :term:`Build Directory`. 1185 the :term:`Build Directory`.
972 1186
973- You must be sure of the state of your build's configuration in the 1187- You must be sure of the state of your build's configuration in the
974 :term:`Source Directory`. 1188 :term:`Source Directory`.
975 1189
976- Your build host must have the following two packages installed: 1190- Your build host must have the following two packages installed:
977 libncurses5-dev libtinfo-dev 1191 ::
1192
1193 libncurses5-dev
1194 libtinfo-dev
978 1195
979The following commands initialize the BitBake environment, run the 1196The following commands initialize the BitBake environment, run the
980:ref:`ref-tasks-kernel_configme` 1197:ref:`ref-tasks-kernel_configme`
981task, and launch ``menuconfig``. These commands assume the Source 1198task, and launch ``menuconfig``. These commands assume the Source
982Directory's top-level folder is ``~/poky``: $ cd poky $ source 1199Directory's top-level folder is ``~/poky``:
983oe-init-build-env $ bitbake linux-yocto -c kernel_configme -f $ bitbake 1200::
984linux-yocto -c menuconfig Once ``menuconfig`` comes up, its standard 1201
1202 $ cd poky
1203 $ source oe-init-build-env
1204 $ bitbake linux-yocto -c kernel_configme -f
1205 $ bitbake linux-yocto -c menuconfig
1206
1207Once ``menuconfig`` comes up, its standard
985interface allows you to interactively examine and configure all the 1208interface allows you to interactively examine and configure all the
986kernel configuration parameters. After making your changes, simply exit 1209kernel configuration parameters. After making your changes, simply exit
987the tool and save your changes to create an updated version of the 1210the tool and save your changes to create an updated version of the
@@ -1036,8 +1259,10 @@ area where the specific kernel is built. For example, if you were
1036building a Linux Yocto kernel based on the ``linux-yocto-4.12`` kernel 1259building a Linux Yocto kernel based on the ``linux-yocto-4.12`` kernel
1037and you were building a QEMU image targeted for ``x86`` architecture, 1260and you were building a QEMU image targeted for ``x86`` architecture,
1038the ``.config`` file would be: 1261the ``.config`` file would be:
1039poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18... 1262::
1040...967-r0/linux-qemux86-standard-build/.config 1263
1264 poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18...
1265 ...967-r0/linux-qemux86-standard-build/.config
1041 1266
1042.. note:: 1267.. note::
1043 1268
@@ -1048,7 +1273,10 @@ poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18...
1048 1273
1049Within the ``.config`` file, you can see the kernel settings. For 1274Within the ``.config`` file, you can see the kernel settings. For
1050example, the following entry shows that symmetric multi-processor 1275example, the following entry shows that symmetric multi-processor
1051support is not set: # CONFIG_SMP is not set 1276support is not set:
1277::
1278
1279 # CONFIG_SMP is not set
1052 1280
1053A good method to isolate changed configurations is to use a combination 1281A good method to isolate changed configurations is to use a combination
1054of the ``menuconfig`` tool and simple shell commands. Before changing 1282of the ``menuconfig`` tool and simple shell commands. Before changing
@@ -1094,12 +1322,14 @@ your layer's ``recipes-kernel/linux`` directory, and rename the copied
1094file to "defconfig" (e.g. 1322file to "defconfig" (e.g.
1095``~/meta-mylayer/recipes-kernel/linux/linux-yocto/defconfig``). Then, 1323``~/meta-mylayer/recipes-kernel/linux/linux-yocto/defconfig``). Then,
1096add the following lines to the linux-yocto ``.bbappend`` file in your 1324add the following lines to the linux-yocto ``.bbappend`` file in your
1097layer: FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += 1325layer:
1098"file://defconfig" The 1326::
1099:term:`SRC_URI` tells the build 1327
1100system how to search for the file, while the 1328 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
1101:term:`FILESEXTRAPATHS` 1329 SRC_URI += "file://defconfig"
1102extends the :term:`FILESPATH` 1330
1331The :term:`SRC_URI` tells the build system how to search for the file, while the
1332:term:`FILESEXTRAPATHS` extends the :term:`FILESPATH`
1103variable (search directories) to include the ``${PN}`` directory you 1333variable (search directories) to include the ``${PN}`` directory you
1104created to hold the configuration changes. 1334created to hold the configuration changes.
1105 1335
@@ -1140,16 +1370,17 @@ appear in the ``.config`` file, which is in the :term:`Build Directory`.
1140 1370
1141 For more information about where the 1371 For more information about where the
1142 .config 1372 .config
1143 file is located, see the example in the " 1373 file is located, see the example in the
1144 Using 1374 ":ref:`kernel-dev/kernel-dev-common:using \`\`menuconfig\`\``"
1145 menuconfig 1375 section.
1146 " section.
1147 1376
1148It is simple to create a configuration fragment. One method is to use 1377It is simple to create a configuration fragment. One method is to use
1149shell commands. For example, issuing the following from the shell 1378shell commands. For example, issuing the following from the shell
1150creates a configuration fragment file named ``my_smp.cfg`` that enables 1379creates a configuration fragment file named ``my_smp.cfg`` that enables
1151multi-processor support within the kernel: $ echo "CONFIG_SMP=y" >> 1380multi-processor support within the kernel:
1152my_smp.cfg 1381::
1382
1383 $ echo "CONFIG_SMP=y" >> my_smp.cfg
1153 1384
1154.. note:: 1385.. note::
1155 1386
@@ -1166,20 +1397,29 @@ To create a configuration fragment using this method, follow these
1166steps: 1397steps:
1167 1398
11681. *Complete a Build Through Kernel Configuration:* Complete a build at 13991. *Complete a Build Through Kernel Configuration:* Complete a build at
1169 least through the kernel configuration task as follows: $ bitbake 1400 least through the kernel configuration task as follows:
1170 linux-yocto -c kernel_configme -f This step ensures that you create a 1401 ::
1402
1403 $ bitbake linux-yocto -c kernel_configme -f
1404
1405 This step ensures that you create a
1171 ``.config`` file from a known state. Because situations exist where 1406 ``.config`` file from a known state. Because situations exist where
1172 your build state might become unknown, it is best to run this task 1407 your build state might become unknown, it is best to run this task
1173 prior to starting ``menuconfig``. 1408 prior to starting ``menuconfig``.
1174 1409
11752. *Launch ``menuconfig``:* Run the ``menuconfig`` command: $ bitbake 14102. *Launch menuconfig:* Run the ``menuconfig`` command:
1176 linux-yocto -c menuconfig 1411 ::
1412
1413 $ bitbake linux-yocto -c menuconfig
1177 1414
11783. *Create the Configuration Fragment:* Run the ``diffconfig`` command 14153. *Create the Configuration Fragment:* Run the ``diffconfig`` command
1179 to prepare a configuration fragment. The resulting file 1416 to prepare a configuration fragment. The resulting file
1180 ``fragment.cfg`` is placed in the 1417 ``fragment.cfg`` is placed in the
1181 ``${``\ :term:`WORKDIR`\ ``}`` 1418 ``${``\ :term:`WORKDIR`\ ``}``
1182 directory: $ bitbake linux-yocto -c diffconfig 1419 directory:
1420 ::
1421
1422 $ bitbake linux-yocto -c diffconfig
1183 1423
1184The ``diffconfig`` command creates a file that is a list of Linux kernel 1424The ``diffconfig`` command creates a file that is a list of Linux kernel
1185``CONFIG_`` assignments. See the "`Changing the 1425``CONFIG_`` assignments. See the "`Changing the
@@ -1204,59 +1444,94 @@ directory named ``linux-yocto`` that resides in the same directory as
1204the kernel's append file within your layer and then add the following 1444the kernel's append file within your layer and then add the following
1205statements to the kernel's append file, those configuration options will 1445statements to the kernel's append file, those configuration options will
1206be picked up and applied when the kernel is built: 1446be picked up and applied when the kernel is built:
1207FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += 1447::
1208"file://myconfig.cfg" 1448
1449 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
1450 SRC_URI += "file://myconfig.cfg"
1209 1451
1210As mentioned earlier, you can group related configurations into multiple 1452As mentioned earlier, you can group related configurations into multiple
1211files and name them all in the ``SRC_URI`` statement as well. For 1453files and name them all in the ``SRC_URI`` statement as well. For
1212example, you could group separate configurations specifically for 1454example, you could group separate configurations specifically for
1213Ethernet and graphics into their own files and add those by using a 1455Ethernet and graphics into their own files and add those by using a
1214``SRC_URI`` statement like the following in your append file: SRC_URI += 1456``SRC_URI`` statement like the following in your append file:
1215"file://myconfig.cfg \\ file://eth.cfg \\ file://gfx.cfg" 1457::
1458
1459 SRC_URI += "file://myconfig.cfg \
1460 file://eth.cfg \
1461 file://gfx.cfg"
1216 1462
1217Validating Configuration 1463Validating Configuration
1218------------------------ 1464------------------------
1219 1465
1220You can use the 1466You can use the
1221:ref:`ref-tasks-kernel_configcheck` 1467:ref:`ref-tasks-kernel_configcheck`
1222task to provide configuration validation: $ bitbake linux-yocto -c 1468task to provide configuration validation:
1223kernel_configcheck -f Running this task produces warnings for when a 1469::
1470
1471 $ bitbake linux-yocto -c kernel_configcheck -f
1472
1473Running this task produces warnings for when a
1224requested configuration does not appear in the final ``.config`` file or 1474requested configuration does not appear in the final ``.config`` file or
1225when you override a policy configuration in a hardware configuration 1475when you override a policy configuration in a hardware configuration
1226fragment. 1476fragment.
1227 1477
1228In order to run this task, you must have an existing ``.config`` file. 1478In order to run this task, you must have an existing ``.config`` file.
1229See the "`Using ``menuconfig`` <#using-menuconfig>`__" section for 1479See the ":ref:`kernel-dev/kernel-dev-common:using \`\`menuconfig\`\``" section for
1230information on how to create a configuration file. 1480information on how to create a configuration file.
1231 1481
1232Following is sample output from the ``do_kernel_configcheck`` task: 1482Following is sample output from the ``do_kernel_configcheck`` task:
1233Loading cache: 100% 1483::
1234\|########################################################\| Time: 1484
12350:00:00 Loaded 1275 entries from dependency cache. NOTE: Resolving any 1485 Loading cache: 100% |########################################################| Time: 0:00:00
1236missing task queue dependencies Build Configuration: . . . NOTE: 1486 Loaded 1275 entries from dependency cache.
1237Executing SetScene Tasks NOTE: Executing RunQueue Tasks WARNING: 1487 NOTE: Resolving any missing task queue dependencies
1238linux-yocto-4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0 1488
1239do_kernel_configcheck: [kernel config]: specified values did not make it 1489 Build Configuration:
1240into the kernel's final configuration: ---------- CONFIG_X86_TSC 1490 .
1241----------------- Config: CONFIG_X86_TSC From: 1491 .
1242/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc-cpu.cfg 1492 .
1243Requested value: CONFIG_X86_TSC=y Actual value: ---------- 1493
1244CONFIG_X86_BIGSMP ----------------- Config: CONFIG_X86_BIGSMP From: 1494 NOTE: Executing SetScene Tasks
1245/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg 1495 NOTE: Executing RunQueue Tasks
1246/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig 1496 WARNING: linux-yocto-4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0 do_kernel_configcheck:
1247Requested value: # CONFIG_X86_BIGSMP is not set Actual value: ---------- 1497 [kernel config]: specified values did not make it into the kernel's final configuration:
1248CONFIG_NR_CPUS ----------------- Config: CONFIG_NR_CPUS From: 1498
1249/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg 1499 ---------- CONFIG_X86_TSC -----------------
1250/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc.cfg 1500 Config: CONFIG_X86_TSC
1251/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig 1501 From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc-cpu.cfg
1252Requested value: CONFIG_NR_CPUS=8 Actual value: CONFIG_NR_CPUS=1 1502 Requested value: CONFIG_X86_TSC=y
1253---------- CONFIG_SCHED_SMT ----------------- Config: CONFIG_SCHED_SMT 1503 Actual value:
1254From: 1504
1255/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg 1505
1256/home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig 1506 ---------- CONFIG_X86_BIGSMP -----------------
1257Requested value: CONFIG_SCHED_SMT=y Actual value: NOTE: Tasks Summary: 1507 Config: CONFIG_X86_BIGSMP
1258Attempted 288 tasks of which 285 didn't need to be rerun and all 1508 From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg
1259succeeded. Summary: There were 3 WARNING messages shown. 1509 /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig
1510 Requested value: # CONFIG_X86_BIGSMP is not set
1511 Actual value:
1512
1513
1514 ---------- CONFIG_NR_CPUS -----------------
1515 Config: CONFIG_NR_CPUS
1516 From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg
1517 /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc.cfg
1518 /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig
1519 Requested value: CONFIG_NR_CPUS=8
1520 Actual value: CONFIG_NR_CPUS=1
1521
1522
1523 ---------- CONFIG_SCHED_SMT -----------------
1524 Config: CONFIG_SCHED_SMT
1525 From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg
1526 /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig
1527 Requested value: CONFIG_SCHED_SMT=y
1528 Actual value:
1529
1530
1531
1532 NOTE: Tasks Summary: Attempted 288 tasks of which 285 didn't need to be rerun and all succeeded.
1533
1534 Summary: There were 3 WARNING messages shown.
1260 1535
1261.. note:: 1536.. note::
1262 1537
@@ -1273,7 +1548,7 @@ and
1273tasks until they produce no warnings. 1548tasks until they produce no warnings.
1274 1549
1275For more information on how to use the ``menuconfig`` tool, see the 1550For more information on how to use the ``menuconfig`` tool, see the
1276"`Using ``menuconfig`` <#using-menuconfig>`__" section. 1551:ref:`kernel-dev/kernel-dev-common:using \`\`menuconfig\`\`` section.
1277 1552
1278Fine-Tuning the Kernel Configuration File 1553Fine-Tuning the Kernel Configuration File
1279----------------------------------------- 1554-----------------------------------------
@@ -1319,9 +1594,11 @@ To streamline the configuration, do the following:
1319 successfully. Use this configuration file as your baseline. 1594 successfully. Use this configuration file as your baseline.
1320 1595
13212. *Run Configure and Check Tasks:* Separately run the 15962. *Run Configure and Check Tasks:* Separately run the
1322 ``do_kernel_configme`` and ``do_kernel_configcheck`` tasks: $ bitbake 1597 ``do_kernel_configme`` and ``do_kernel_configcheck`` tasks:
1323 linux-yocto -c kernel_configme -f $ bitbake linux-yocto -c 1598 ::
1324 kernel_configcheck -f 1599
1600 $ bitbake linux-yocto -c kernel_configme -f
1601 $ bitbake linux-yocto -c kernel_configcheck -f
1325 1602
13263. *Process the Results:* Take the resulting list of files from the 16033. *Process the Results:* Take the resulting list of files from the
1327 ``do_kernel_configcheck`` task warnings and do the following: 1604 ``do_kernel_configcheck`` task warnings and do the following:
@@ -1352,8 +1629,12 @@ Expanding Variables
1352Sometimes it is helpful to determine what a variable expands to during a 1629Sometimes it is helpful to determine what a variable expands to during a
1353build. You can do examine the values of variables by examining the 1630build. You can do examine the values of variables by examining the
1354output of the ``bitbake -e`` command. The output is long and is more 1631output of the ``bitbake -e`` command. The output is long and is more
1355easily managed in a text file, which allows for easy searches: $ bitbake 1632easily managed in a text file, which allows for easy searches:
1356-e virtual/kernel > some_text_file Within the text file, you can see 1633::
1634
1635 $ bitbake -e virtual/kernel > some_text_file
1636
1637Within the text file, you can see
1357exactly how each variable is expanded and used by the OpenEmbedded build 1638exactly how each variable is expanded and used by the OpenEmbedded build
1358system. 1639system.
1359 1640
@@ -1366,22 +1647,27 @@ source directory. Follow these steps to clean up the version string:
1366 1647
13671. *Discover the Uncommitted Changes:* Go to the kernel's locally cloned 16481. *Discover the Uncommitted Changes:* Go to the kernel's locally cloned
1368 Git repository (source directory) and use the following Git command 1649 Git repository (source directory) and use the following Git command
1369 to list the files that have been changed, added, or removed: $ git 1650 to list the files that have been changed, added, or removed:
1370 status 1651 ::
1652
1653 $ git status
1371 1654
13722. *Commit the Changes:* You should commit those changes to the kernel 16552. *Commit the Changes:* You should commit those changes to the kernel
1373 source tree regardless of whether or not you will save, export, or 1656 source tree regardless of whether or not you will save, export, or
1374 use the changes: $ git add $ git commit -s -a -m "getting rid of 1657 use the changes:
1375 -dirty" 1658 ::
1659
1660 $ git add
1661 $ git commit -s -a -m "getting rid of -dirty"
1376 1662
13773. *Rebuild the Kernel Image:* Once you commit the changes, rebuild the 16633. *Rebuild the Kernel Image:* Once you commit the changes, rebuild the
1378 kernel. 1664 kernel.
1379 1665
1380 Depending on your particular kernel development workflow, the 1666 Depending on your particular kernel development workflow, the
1381 commands you use to rebuild the kernel might differ. For information 1667 commands you use to rebuild the kernel might differ. For information
1382 on building the kernel image when using ``devtool``, see the "`Using 1668 on building the kernel image when using ``devtool``, see the
1383 ``devtool`` to Patch the 1669 ":ref:`kernel-dev/kernel-dev-common:using \`\`devtool\`\` to patch the kernel`"
1384 Kernel <#using-devtool-to-patch-the-kernel>`__" section. For 1670 section. For
1385 information on building the kernel image when using Bitbake, see the 1671 information on building the kernel image when using Bitbake, see the
1386 "`Using Traditional Kernel Development to Patch the 1672 "`Using Traditional Kernel Development to Patch the
1387 Kernel <#using-traditional-kernel-development-to-patch-the-kernel>`__" 1673 Kernel <#using-traditional-kernel-development-to-patch-the-kernel>`__"
@@ -1405,7 +1691,10 @@ linux-yocto custom recipe (``linux-yocto-custom.bb``) that uses
1405``kernel.org`` sources and the Yocto Project Linux kernel tools for 1691``kernel.org`` sources and the Yocto Project Linux kernel tools for
1406managing kernel Metadata. You can find this recipe in the ``poky`` Git 1692managing kernel Metadata. You can find this recipe in the ``poky`` Git
1407repository of the Yocto Project :yocto_git:`Source Repository <>` 1693repository of the Yocto Project :yocto_git:`Source Repository <>`
1408at: poky/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb 1694at:
1695::
1696
1697 poky/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb
1409 1698
1410Here are some basic steps you can use to work with your own sources: 1699Here are some basic steps you can use to work with your own sources:
1411 1700
@@ -1424,7 +1713,12 @@ Here are some basic steps you can use to work with your own sources:
1424 ``defconfig`` file or configuration fragment files in your layer. 1713 ``defconfig`` file or configuration fragment files in your layer.
1425 When you use the ``linux-yocto-custom.bb`` recipe, you must specify a 1714 When you use the ``linux-yocto-custom.bb`` recipe, you must specify a
1426 configuration. If you do not have a ``defconfig`` file, you can run 1715 configuration. If you do not have a ``defconfig`` file, you can run
1427 the following: $ make defconfig After running the command, copy the 1716 the following:
1717 ::
1718
1719 $ make defconfig
1720
1721 After running the command, copy the
1428 resulting ``.config`` file to the ``files`` directory in your layer 1722 resulting ``.config`` file to the ``files`` directory in your layer
1429 as "defconfig" and then add it to the 1723 as "defconfig" and then add it to the
1430 :term:`SRC_URI` variable in the 1724 :term:`SRC_URI` variable in the
@@ -1518,8 +1812,13 @@ is running that image.
1518 1812
1519Prior to attempting to build the out-of-tree modules, you need to be on 1813Prior to attempting to build the out-of-tree modules, you need to be on
1520the target as root and you need to change to the ``/usr/src/kernel`` 1814the target as root and you need to change to the ``/usr/src/kernel``
1521directory. Next, ``make`` the scripts: # cd /usr/src/kernel # make 1815directory. Next, ``make`` the scripts:
1522scripts Because all SDK image recipes include ``dev-pkgs``, the 1816::
1817
1818 # cd /usr/src/kernel
1819 # make scripts
1820
1821Because all SDK image recipes include ``dev-pkgs``, the
1523``kernel-dev`` packages will be installed as part of the SDK image and 1822``kernel-dev`` packages will be installed as part of the SDK image and
1524the ``kernel-devsrc`` packages will be installed as part of applicable 1823the ``kernel-devsrc`` packages will be installed as part of applicable
1525SDK images. The SDK uses the scripts when building out-of-tree modules. 1824SDK images. The SDK uses the scripts when building out-of-tree modules.
@@ -1536,7 +1835,9 @@ create your own out-of-tree Linux kernel module recipe.
1536 1835
1537This template recipe is located in the ``poky`` Git repository of the 1836This template recipe is located in the ``poky`` Git repository of the
1538Yocto Project :yocto_git:`Source Repository <>` at: 1837Yocto Project :yocto_git:`Source Repository <>` at:
1539poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb 1838::
1839
1840 poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
1540 1841
1541To get started, copy this recipe to your layer and give it a meaningful 1842To get started, copy this recipe to your layer and give it a meaningful
1542name (e.g. ``mymodule_1.0.bb``). In the same directory, create a new 1843name (e.g. ``mymodule_1.0.bb``). In the same directory, create a new
@@ -1555,14 +1856,22 @@ Typically, you will need to set the following variables:
1555 1856
1556Depending on the build system used by the module sources, you might need 1857Depending on the build system used by the module sources, you might need
1557to make some adjustments. For example, a typical module ``Makefile`` 1858to make some adjustments. For example, a typical module ``Makefile``
1558looks much like the one provided with the ``hello-mod`` template: obj-m 1859looks much like the one provided with the ``hello-mod`` template:
1559:= hello.o SRC := $(shell pwd) all: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) 1860::
1560modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install ... 1861
1561 1862 obj-m := hello.o
1562The important point to note here is the 1863
1563:term:`KERNEL_SRC` variable. The 1864 SRC := $(shell pwd)
1564:ref:`module <ref-classes-module>` class sets this 1865
1565variable and the 1866 all:
1867 $(MAKE) -C $(KERNEL_SRC) M=$(SRC)
1868
1869 modules_install:
1870 $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
1871 ...
1872
1873The important point to note here is the :term:`KERNEL_SRC` variable. The
1874:ref:`module <ref-classes-module>` class sets this variable and the
1566:term:`KERNEL_PATH` variable to 1875:term:`KERNEL_PATH` variable to
1567``${STAGING_KERNEL_DIR}`` with the necessary Linux kernel build 1876``${STAGING_KERNEL_DIR}`` with the necessary Linux kernel build
1568information to build modules. If your module ``Makefile`` uses a 1877information to build modules. If your module ``Makefile`` uses a
@@ -1586,7 +1895,11 @@ them appropriately for your machine configuration file:
1586 1895
1587Modules are often not required for boot and can be excluded from certain 1896Modules are often not required for boot and can be excluded from certain
1588build configurations. The following allows for the most flexibility: 1897build configurations. The following allows for the most flexibility:
1589MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule" The value is 1898::
1899
1900 MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule"
1901
1902The value is
1590derived by appending the module filename without the ``.ko`` extension 1903derived by appending the module filename without the ``.ko`` extension
1591to the string "kernel-module-". 1904to the string "kernel-module-".
1592 1905
@@ -1628,32 +1941,50 @@ Here is an example that looks at what has changed in the ``emenlow``
1628branch of the ``linux-yocto-3.19`` kernel. The lower commit range is the 1941branch of the ``linux-yocto-3.19`` kernel. The lower commit range is the
1629commit associated with the ``standard/base`` branch, while the upper 1942commit associated with the ``standard/base`` branch, while the upper
1630commit range is the commit associated with the ``standard/emenlow`` 1943commit range is the commit associated with the ``standard/emenlow``
1631branch. $ git whatchanged origin/standard/base..origin/standard/emenlow 1944branch.
1945::
1946
1947 $ git whatchanged origin/standard/base..origin/standard/emenlow
1632 1948
1633To see short, one line summaries of changes use the ``git log`` command: 1949To see short, one line summaries of changes use the ``git log`` command:
1634$ git log --oneline origin/standard/base..origin/standard/emenlow 1950::
1951
1952 $ git log --oneline origin/standard/base..origin/standard/emenlow
1953
1954Use this command to see code differences for the changes:
1955::
1635 1956
1636Use this command to see code differences for the changes: $ git diff 1957 $ git diff origin/standard/base..origin/standard/emenlow
1637origin/standard/base..origin/standard/emenlow
1638 1958
1639Use this command to see the commit log messages and the text 1959Use this command to see the commit log messages and the text
1640differences: $ git show origin/standard/base..origin/standard/emenlow 1960differences:
1961::
1962
1963 $ git show origin/standard/base..origin/standard/emenlow
1641 1964
1642Use this command to create individual patches for each change. Here is 1965Use this command to create individual patches for each change. Here is
1643an example that that creates patch files for each commit and places them 1966an example that that creates patch files for each commit and places them
1644in your ``Documents`` directory: $ git format-patch -o $HOME/Documents 1967in your ``Documents`` directory:
1645origin/standard/base..origin/standard/emenlow 1968::
1969
1970 $ git format-patch -o $HOME/Documents origin/standard/base..origin/standard/emenlow
1646 1971
1647Showing a Particular Feature or Branch Change 1972Showing a Particular Feature or Branch Change
1648--------------------------------------------- 1973---------------------------------------------
1649 1974
1650Tags in the Yocto Project kernel tree divide changes for significant 1975Tags in the Yocto Project kernel tree divide changes for significant
1651features or branches. The ``git show`` tag command shows changes based 1976features or branches. The ``git show`` tag command shows changes based
1652on a tag. Here is an example that shows ``systemtap`` changes: $ git 1977on a tag. Here is an example that shows ``systemtap`` changes:
1653show systemtap You can use the ``git branch --contains`` tag command to 1978::
1979
1980 $ git show systemtap
1981
1982You can use the ``git branch --contains`` tag command to
1654show the branches that contain a particular feature. This command shows 1983show the branches that contain a particular feature. This command shows
1655the branches that contain the ``systemtap`` feature: $ git branch 1984the branches that contain the ``systemtap`` feature:
1656--contains systemtap 1985::
1986
1987 $ git branch --contains systemtap
1657 1988
1658Adding Recipe-Space Kernel Features 1989Adding Recipe-Space Kernel Features
1659=================================== 1990===================================
@@ -1706,19 +2037,37 @@ build.
1706 searched during the build as potential feature directories. 2037 searched during the build as potential feature directories.
1707 2038
1708 Continuing with the example, suppose the "test.scc" feature you are 2039 Continuing with the example, suppose the "test.scc" feature you are
1709 adding has a ``test.scc`` file in the following directory: my_recipe 2040 adding has a ``test.scc`` file in the following directory:
1710 \| +-linux-yocto \| +-test.cfg +-test.scc In this example, the 2041 ::
2042
2043 my_recipe
2044 |
2045 +-linux-yocto
2046 |
2047 +-test.cfg
2048 +-test.scc
2049
2050 In this example, the
1711 ``linux-yocto`` directory has both the feature ``test.scc`` file and 2051 ``linux-yocto`` directory has both the feature ``test.scc`` file and
1712 a similarly named configuration fragment file ``test.cfg``. 2052 a similarly named configuration fragment file ``test.cfg``.
1713 2053
17142. *Add the Feature File to ``SRC_URI``:* Add the ``.scc`` file to the 20542. *Add the Feature File to SRC_URI:* Add the ``.scc`` file to the
1715 recipe's ``SRC_URI`` statement: SRC_URI_append = " file://test.scc" 2055 recipe's ``SRC_URI`` statement:
2056 ::
2057
2058 SRC_URI_append = " file://test.scc"
2059
1716 The leading space before the path is important as the path is 2060 The leading space before the path is important as the path is
1717 appended to the existing path. 2061 appended to the existing path.
1718 2062
17193. *Specify the Feature as a Kernel Feature:* Use the 20633. *Specify the Feature as a Kernel Feature:* Use the
1720 ``KERNEL_FEATURES`` statement to specify the feature as a kernel 2064 ``KERNEL_FEATURES`` statement to specify the feature as a kernel
1721 feature: KERNEL_FEATURES_append = " test.scc" The OpenEmbedded build 2065 feature:
2066 ::
2067
2068 KERNEL_FEATURES_append = " test.scc"
2069
2070 The OpenEmbedded build
1722 system processes the kernel feature when it builds the kernel. 2071 system processes the kernel feature when it builds the kernel.
1723 2072
1724 .. note:: 2073 .. note::