kernel-dev-common.xml 139 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
  3. [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] >
  4. <chapter id='kernel-dev-common'>
  5. <title>Common Tasks</title>
  6. <para>
  7. This chapter presents several common tasks you perform when you
  8. work with the Yocto Project Linux kernel.
  9. These tasks include preparing your host development system for
  10. kernel development, preparing a layer, modifying an existing recipe,
  11. patching the kernel, configuring the kernel, iterative development,
  12. working with your own sources, and incorporating out-of-tree modules.
  13. <note>
  14. The examples presented in this chapter work with the Yocto Project
  15. 2.4 Release and forward.
  16. </note>
  17. </para>
  18. <section id='preparing-the-build-host-to-work-on-the-kernel'>
  19. <title>Preparing the Build Host to Work on the Kernel</title>
  20. <para>
  21. Before you can do any kernel development, you need to be
  22. sure your build host is set up to use the Yocto Project.
  23. For information on how to get set up, see the
  24. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-preparing-the-build-host'>Preparing the Build Host</ulink>"
  25. section in the Yocto Project Development Tasks Manual.
  26. Part of preparing the system is creating a local Git
  27. repository of the
  28. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  29. (<filename>poky</filename>) on your system.
  30. Follow the steps in the
  31. "<ulink url='&YOCTO_DOCS_DEV_URL;#cloning-the-poky-repository'>Cloning the <filename>poky</filename> Repository</ulink>"
  32. section in the Yocto Project Development Tasks Manual to set up your
  33. Source Directory.
  34. <note>
  35. Be sure you check out the appropriate development branch or
  36. you create your local branch by checking out a specific tag
  37. to get the desired version of Yocto Project.
  38. See the
  39. "<ulink url='&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky'>Checking Out by Branch in Poky</ulink>"
  40. and
  41. "<ulink url='&YOCTO_DOCS_DEV_URL;#checkout-out-by-tag-in-poky'>Checking Out by Tag in Poky</ulink>"
  42. sections in the Yocto Project Development Tasks Manual for more
  43. information.
  44. </note>
  45. </para>
  46. <para>
  47. Kernel development is best accomplished using
  48. <ulink url='&YOCTO_DOCS_SDK_URL;#using-devtool-in-your-sdk-workflow'><filename>devtool</filename></ulink>
  49. and not through traditional kernel workflow methods.
  50. The remainder of this section provides information for both
  51. scenarios.
  52. </para>
  53. <section id='getting-ready-to-develop-using-devtool'>
  54. <title>Getting Ready to Develop Using <filename>devtool</filename></title>
  55. <para>
  56. Follow these steps to prepare to update the kernel image using
  57. <filename>devtool</filename>.
  58. Completing this procedure leaves you with a clean kernel image
  59. and ready to make modifications as described in the
  60. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  61. section:
  62. <orderedlist>
  63. <listitem><para>
  64. <emphasis>Initialize the BitBake Environment:</emphasis>
  65. Before building an extensible SDK, you need to
  66. initialize the BitBake build environment by sourcing the
  67. build environment script
  68. (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>):
  69. <literallayout class='monospaced'>
  70. $ cd ~/poky
  71. $ source oe-init-build-env
  72. </literallayout>
  73. <note>
  74. The previous commands assume the
  75. <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink>
  76. (i.e. <filename>poky</filename>) have been cloned
  77. using Git and the local repository is named
  78. "poky".
  79. </note>
  80. </para></listitem>
  81. <listitem><para>
  82. <emphasis>Prepare Your <filename>local.conf</filename> File:</emphasis>
  83. By default, the
  84. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  85. variable is set to "qemux86", which is fine if you are
  86. building for the QEMU emulator in 32-bit mode.
  87. However, if you are not, you need to set the
  88. <filename>MACHINE</filename> variable appropriately in
  89. your <filename>conf/local.conf</filename> file found in
  90. the
  91. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  92. (i.e. <filename>~/poky/build</filename> in this
  93. example).</para>
  94. <para>Also, since you are preparing to work on the
  95. kernel image, you need to set the
  96. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
  97. variable to include kernel modules.</para>
  98. <para>This example uses the default "qemux86" for the
  99. <filename>MACHINE</filename> variable but needs to
  100. add the "kernel-modules":
  101. <literallayout class='monospaced'>
  102. MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
  103. </literallayout>
  104. </para></listitem>
  105. <listitem><para>
  106. <emphasis>Create a Layer for Patches:</emphasis>
  107. You need to create a layer to hold patches created
  108. for the kernel image.
  109. You can use the
  110. <filename>bitbake-layers create-layer</filename>
  111. command as follows:
  112. <literallayout class='monospaced'>
  113. $ cd ~/poky/build
  114. $ bitbake-layers create-layer ../../meta-mylayer
  115. NOTE: Starting bitbake server...
  116. Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer'
  117. $
  118. </literallayout>
  119. <note>
  120. For background information on working with
  121. common and BSP layers, see the
  122. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  123. section in the Yocto Project Development Tasks
  124. Manual and the
  125. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  126. section in the Yocto Project Board Support (BSP)
  127. Developer's Guide, respectively.
  128. For information on how to use the
  129. <filename>bitbake-layers create-layer</filename>
  130. command to quickly set up a layer, see the
  131. "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  132. section in the Yocto Project Development Tasks
  133. Manual.
  134. </note>
  135. </para></listitem>
  136. <listitem><para>
  137. <emphasis>Inform the BitBake Build Environment About
  138. Your Layer:</emphasis>
  139. As directed when you created your layer, you need to
  140. add the layer to the
  141. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  142. variable in the <filename>bblayers.conf</filename> file
  143. as follows:
  144. <literallayout class='monospaced'>
  145. $ cd ~/poky/build
  146. $ bitbake-layers add-layer ../../meta-mylayer
  147. NOTE: Starting bitbake server...
  148. $
  149. </literallayout>
  150. </para></listitem>
  151. <listitem><para>
  152. <emphasis>Build the Extensible SDK:</emphasis>
  153. Use BitBake to build the extensible SDK specifically
  154. for use with images to be run using QEMU:
  155. <literallayout class='monospaced'>
  156. $ cd ~/poky/build
  157. $ bitbake core-image-minimal -c populate_sdk_ext
  158. </literallayout>
  159. Once the build finishes, you can find the SDK installer
  160. file (i.e. <filename>*.sh</filename> file) in the
  161. following directory:
  162. <literallayout class='monospaced'>
  163. ~/poky/build/tmp/deploy/sdk
  164. </literallayout>
  165. For this example, the installer file is named
  166. <filename>poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-&DISTRO;.sh</filename>
  167. </para></listitem>
  168. <listitem><para>
  169. <emphasis>Install the Extensible SDK:</emphasis>
  170. Use the following command to install the SDK.
  171. For this example, install the SDK in the default
  172. <filename>~/poky_sdk</filename> directory:
  173. <literallayout class='monospaced'>
  174. $ cd ~/poky/build/tmp/deploy/sdk
  175. $ ./poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-&DISTRO;.sh
  176. Poky (Yocto Project Reference Distro) Extensible SDK installer version &DISTRO;
  177. ============================================================================
  178. Enter target directory for SDK (default: ~/poky_sdk):
  179. You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed[Y/n]? Y
  180. Extracting SDK......................................done
  181. Setting it up...
  182. Extracting buildtools...
  183. Preparing build system...
  184. Parsing recipes: 100% |#################################################################| Time: 0:00:52
  185. Initializing tasks: 100% |############## ###############################################| Time: 0:00:04
  186. Checking sstate mirror object availability: 100% |######################################| Time: 0:00:00
  187. Parsing recipes: 100% |#################################################################| Time: 0:00:33
  188. Initializing tasks: 100% |##############################################################| Time: 0:00:00
  189. done
  190. SDK has been successfully set up and is ready to be used.
  191. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
  192. $ . /home/scottrif/poky_sdk/environment-setup-i586-poky-linux
  193. </literallayout>
  194. </para></listitem>
  195. <listitem><para id='setting-up-the-esdk-terminal'>
  196. <emphasis>Set Up a New Terminal to Work With the
  197. Extensible SDK:</emphasis>
  198. You must set up a new terminal to work with the SDK.
  199. You cannot use the same BitBake shell used to build the
  200. installer.</para>
  201. <para>After opening a new shell, run the SDK environment
  202. setup script as directed by the output from installing
  203. the SDK:
  204. <literallayout class='monospaced'>
  205. $ source ~/poky_sdk/environment-setup-i586-poky-linux
  206. "SDK environment now set up; additionally you may now run devtool to perform development tasks.
  207. Run devtool --help for further details.
  208. </literallayout>
  209. <note>
  210. If you get a warning about attempting to use the
  211. extensible SDK in an environment set up to run
  212. BitBake, you did not use a new shell.
  213. </note>
  214. </para></listitem>
  215. <listitem><para>
  216. <emphasis>Build the Clean Image:</emphasis>
  217. The final step in preparing to work on the kernel is to
  218. build an initial image using
  219. <filename>devtool</filename> in the new terminal you
  220. just set up and initialized for SDK work:
  221. <literallayout class='monospaced'>
  222. $ devtool build-image
  223. Parsing recipes: 100% |##########################################| Time: 0:00:05
  224. Parsing of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 skipped, 0 masked, 0 errors.
  225. WARNING: No packages to add, building image core-image-minimal unmodified
  226. Loading cache: 100% |############################################| Time: 0:00:00
  227. Loaded 1299 entries from dependency cache.
  228. NOTE: Resolving any missing task queue dependencies
  229. Initializing tasks: 100% |#######################################| Time: 0:00:07
  230. Checking sstate mirror object availability: 100% |###############| Time: 0:00:00
  231. NOTE: Executing SetScene Tasks
  232. NOTE: Executing RunQueue Tasks
  233. NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need to be rerun and all succeeded.
  234. NOTE: Successfully built core-image-minimal. You can find output files in /home/scottrif/poky_sdk/tmp/deploy/images/qemux86
  235. </literallayout>
  236. If you were building for actual hardware and not for
  237. emulation, you could flash the image to a USB stick
  238. on <filename>/dev/sdd</filename> and boot your device.
  239. For an example that uses a Minnowboard, see the
  240. <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/KernelDevelopmentWithEsdk'>TipsAndTricks/KernelDevelopmentWithEsdk</ulink>
  241. Wiki page.
  242. </para></listitem>
  243. </orderedlist>
  244. </para>
  245. <para>
  246. At this point you have set up to start making modifications to
  247. the kernel by using the extensible SDK.
  248. For a continued example, see the
  249. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  250. section.
  251. </para>
  252. </section>
  253. <section id='getting-ready-for-traditional-kernel-development'>
  254. <title>Getting Ready for Traditional Kernel Development</title>
  255. <para>
  256. Getting ready for traditional kernel development using the Yocto
  257. Project involves many of the same steps as described in the
  258. previous section.
  259. However, you need to establish a local copy of the kernel source
  260. since you will be editing these files.
  261. </para>
  262. <para>
  263. Follow these steps to prepare to update the kernel image using
  264. traditional kernel development flow with the Yocto Project.
  265. Completing this procedure leaves you ready to make modifications
  266. to the kernel source as described in the
  267. "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
  268. section:
  269. <orderedlist>
  270. <listitem><para>
  271. <emphasis>Initialize the BitBake Environment:</emphasis>
  272. Before you can do anything using BitBake, you need to
  273. initialize the BitBake build environment by sourcing the
  274. build environment script
  275. (i.e. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>oe-init-build-env</filename></ulink>).
  276. Also, for this example, be sure that the local branch
  277. you have checked out for <filename>poky</filename> is
  278. the Yocto Project &DISTRO_NAME; branch.
  279. If you need to checkout out the &DISTRO_NAME; branch,
  280. see the
  281. "<ulink url='&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky'>Checking out by Branch in Poky</ulink>"
  282. section in the Yocto Project Development Tasks Manual.
  283. <literallayout class='monospaced'>
  284. $ cd ~/poky
  285. $ git branch
  286. master
  287. * &DISTRO_NAME;
  288. $ source oe-init-build-env
  289. </literallayout>
  290. <note>
  291. The previous commands assume the
  292. <ulink url='&YOCTO_DOCS_OM_URL;#source-repositories'>Source Repositories</ulink>
  293. (i.e. <filename>poky</filename>) have been cloned
  294. using Git and the local repository is named
  295. "poky".
  296. </note>
  297. </para></listitem>
  298. <listitem><para>
  299. <emphasis>Prepare Your <filename>local.conf</filename>
  300. File:</emphasis>
  301. By default, the
  302. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  303. variable is set to "qemux86", which is fine if you are
  304. building for the QEMU emulator in 32-bit mode.
  305. However, if you are not, you need to set the
  306. <filename>MACHINE</filename> variable appropriately in
  307. your <filename>conf/local.conf</filename> file found
  308. in the
  309. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  310. (i.e. <filename>~/poky/build</filename> in this
  311. example).</para>
  312. <para>Also, since you are preparing to work on the
  313. kernel image, you need to set the
  314. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
  315. variable to include kernel modules.</para>
  316. <para>This example uses the default "qemux86" for the
  317. <filename>MACHINE</filename> variable but needs to
  318. add the "kernel-modules":
  319. <literallayout class='monospaced'>
  320. MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
  321. </literallayout>
  322. </para></listitem>
  323. <listitem><para>
  324. <emphasis>Create a Layer for Patches:</emphasis>
  325. You need to create a layer to hold patches created
  326. for the kernel image.
  327. You can use the
  328. <filename>bitbake-layers create-layer</filename>
  329. command as follows:
  330. <literallayout class='monospaced'>
  331. $ cd ~/poky/build
  332. $ bitbake-layers create-layer ../../meta-mylayer
  333. NOTE: Starting bitbake server...
  334. Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer'
  335. </literallayout>
  336. <note>
  337. For background information on working with
  338. common and BSP layers, see the
  339. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  340. section in the Yocto Project Development Tasks
  341. Manual and the
  342. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  343. section in the Yocto Project Board Support (BSP)
  344. Developer's Guide, respectively.
  345. For information on how to use the
  346. <filename>bitbake-layers create-layer</filename>
  347. command to quickly set up a layer, see the
  348. "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  349. section in the Yocto Project Development Tasks
  350. Manual.
  351. </note>
  352. </para></listitem>
  353. <listitem><para>
  354. <emphasis>Inform the BitBake Build Environment About
  355. Your Layer:</emphasis>
  356. As directed when you created your layer, you need to add
  357. the layer to the
  358. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  359. variable in the <filename>bblayers.conf</filename> file
  360. as follows:
  361. <literallayout class='monospaced'>
  362. $ cd ~/poky/build
  363. $ bitbake-layers add-layer ../../meta-mylayer
  364. NOTE: Starting bitbake server ...
  365. $
  366. </literallayout>
  367. </para></listitem>
  368. <listitem><para>
  369. <emphasis>Create a Local Copy of the Kernel Git
  370. Repository:</emphasis>
  371. You can find Git repositories of supported Yocto Project
  372. kernels organized under "Yocto Linux Kernel" in the
  373. Yocto Project Source Repositories at
  374. <ulink url='&YOCTO_GIT_URL;'></ulink>.
  375. </para>
  376. <para>
  377. For simplicity, it is recommended that you create your
  378. copy of the kernel Git repository outside of the
  379. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>,
  380. which is usually named <filename>poky</filename>.
  381. Also, be sure you are in the
  382. <filename>standard/base</filename> branch.
  383. </para>
  384. <para>
  385. The following commands show how to create a local copy
  386. of the <filename>linux-yocto-4.12</filename> kernel and
  387. be in the <filename>standard/base</filename> branch.
  388. <note>
  389. The <filename>linux-yocto-4.12</filename> kernel
  390. can be used with the Yocto Project 2.4 release
  391. and forward.
  392. You cannot use the
  393. <filename>linux-yocto-4.12</filename> kernel with
  394. releases prior to Yocto Project 2.4:
  395. </note>
  396. <literallayout class='monospaced'>
  397. $ cd ~
  398. $ git clone git://git.yoctoproject.org/linux-yocto-4.12 --branch standard/base
  399. Cloning into 'linux-yocto-4.12'...
  400. remote: Counting objects: 6097195, done.
  401. remote: Compressing objects: 100% (901026/901026), done.
  402. remote: Total 6097195 (delta 5152604), reused 6096847 (delta 5152256)
  403. Receiving objects: 100% (6097195/6097195), 1.24 GiB | 7.81 MiB/s, done.
  404. Resolving deltas: 100% (5152604/5152604), done.
  405. Checking connectivity... done.
  406. Checking out files: 100% (59846/59846), done.
  407. </literallayout>
  408. </para></listitem>
  409. <listitem><para>
  410. <emphasis>Create a Local Copy of the Kernel Cache Git
  411. Repository:</emphasis>
  412. For simplicity, it is recommended that you create your
  413. copy of the kernel cache Git repository outside of the
  414. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>,
  415. which is usually named <filename>poky</filename>.
  416. Also, for this example, be sure you are in the
  417. <filename>yocto-4.12</filename> branch.
  418. </para>
  419. <para>
  420. The following commands show how to create a local copy
  421. of the <filename>yocto-kernel-cache</filename> and
  422. be in the <filename>yocto-4.12</filename> branch:
  423. <literallayout class='monospaced'>
  424. $ cd ~
  425. $ git clone git://git.yoctoproject.org/yocto-kernel-cache --branch yocto-4.12
  426. Cloning into 'yocto-kernel-cache'...
  427. remote: Counting objects: 22639, done.
  428. remote: Compressing objects: 100% (9761/9761), done.
  429. remote: Total 22639 (delta 12400), reused 22586 (delta 12347)
  430. Receiving objects: 100% (22639/22639), 22.34 MiB | 6.27 MiB/s, done.
  431. Resolving deltas: 100% (12400/12400), done.
  432. Checking connectivity... done.
  433. </literallayout>
  434. </para></listitem>
  435. </orderedlist>
  436. </para>
  437. <para>
  438. At this point, you are ready to start making modifications to
  439. the kernel using traditional kernel development steps.
  440. For a continued example, see the
  441. "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
  442. section.
  443. </para>
  444. </section>
  445. </section>
  446. <section id='creating-and-preparing-a-layer'>
  447. <title>Creating and Preparing a Layer</title>
  448. <para>
  449. If you are going to be modifying kernel recipes, it is recommended
  450. that you create and prepare your own layer in which to do your
  451. work.
  452. Your layer contains its own
  453. <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>
  454. append files (<filename>.bbappend</filename>) and provides a
  455. convenient mechanism to create your own recipe files
  456. (<filename>.bb</filename>) as well as store and use kernel
  457. patch files.
  458. For background information on working with layers, see the
  459. "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>"
  460. section in the Yocto Project Development Tasks Manual.
  461. <note><title>Tip</title>
  462. The Yocto Project comes with many tools that simplify
  463. tasks you need to perform.
  464. One such tool is the
  465. <filename>bitbake-layers create-layer</filename>
  466. command, which simplifies creating a new layer.
  467. See the
  468. "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  469. section in the Yocto Project Development Tasks Manual for
  470. information on how to use this script to quick set up a
  471. new layer.
  472. </note>
  473. </para>
  474. <para>
  475. To better understand the layer you create for kernel development,
  476. the following section describes how to create a layer
  477. without the aid of tools.
  478. These steps assume creation of a layer named
  479. <filename>mylayer</filename> in your home directory:
  480. <orderedlist>
  481. <listitem><para>
  482. <emphasis>Create Structure</emphasis>:
  483. Create the layer's structure:
  484. <literallayout class='monospaced'>
  485. $ cd $HOME
  486. $ mkdir meta-mylayer
  487. $ mkdir meta-mylayer/conf
  488. $ mkdir meta-mylayer/recipes-kernel
  489. $ mkdir meta-mylayer/recipes-kernel/linux
  490. $ mkdir meta-mylayer/recipes-kernel/linux/linux-yocto
  491. </literallayout>
  492. The <filename>conf</filename> directory holds your
  493. configuration files, while the
  494. <filename>recipes-kernel</filename> directory holds your
  495. append file and eventual patch files.
  496. </para></listitem>
  497. <listitem><para>
  498. <emphasis>Create the Layer Configuration File</emphasis>:
  499. Move to the <filename>meta-mylayer/conf</filename>
  500. directory and create the <filename>layer.conf</filename>
  501. file as follows:
  502. <literallayout class='monospaced'>
  503. # We have a conf and classes directory, add to BBPATH
  504. BBPATH .= ":${LAYERDIR}"
  505. # We have recipes-* directories, add to BBFILES
  506. BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
  507. ${LAYERDIR}/recipes-*/*/*.bbappend"
  508. BBFILE_COLLECTIONS += "mylayer"
  509. BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"
  510. BBFILE_PRIORITY_mylayer = "5"
  511. </literallayout>
  512. Notice <filename>mylayer</filename> as part of the last
  513. three statements.
  514. </para></listitem>
  515. <listitem><para>
  516. <emphasis>Create the Kernel Recipe Append File</emphasis>:
  517. Move to the
  518. <filename>meta-mylayer/recipes-kernel/linux</filename>
  519. directory and create the kernel's append file.
  520. This example uses the
  521. <filename>linux-yocto-4.12</filename> kernel.
  522. Thus, the name of the append file is
  523. <filename>linux-yocto_4.12.bbappend</filename>:
  524. <literallayout class='monospaced'>
  525. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  526. SRC_URI_append += "file://<replaceable>patch-file-one</replaceable>"
  527. SRC_URI_append += "file://<replaceable>patch-file-two</replaceable>"
  528. SRC_URI_append += "file://<replaceable>patch-file-three</replaceable>"
  529. </literallayout>
  530. The
  531. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  532. and
  533. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  534. statements enable the OpenEmbedded build system to find
  535. patch files.
  536. For more information on using append files, see the
  537. "<ulink url='&YOCTO_DOCS_DEV_URL;#using-bbappend-files'>Using .bbappend Files in Your Layer</ulink>"
  538. section in the Yocto Project Development Tasks Manual.
  539. </para></listitem>
  540. </orderedlist>
  541. </para>
  542. </section>
  543. <section id='modifying-an-existing-recipe'>
  544. <title>Modifying an Existing Recipe</title>
  545. <para>
  546. In many cases, you can customize an existing linux-yocto recipe to
  547. meet the needs of your project.
  548. Each release of the Yocto Project provides a few Linux
  549. kernel recipes from which you can choose.
  550. These are located in the
  551. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  552. in <filename>meta/recipes-kernel/linux</filename>.
  553. </para>
  554. <para>
  555. Modifying an existing recipe can consist of the following:
  556. <itemizedlist>
  557. <listitem><para>Creating the append file</para></listitem>
  558. <listitem><para>Applying patches</para></listitem>
  559. <listitem><para>Changing the configuration</para></listitem>
  560. </itemizedlist>
  561. </para>
  562. <para>
  563. Before modifying an existing recipe, be sure that you have created
  564. a minimal, custom layer from which you can work.
  565. See the
  566. "<link linkend='creating-and-preparing-a-layer'>Creating and Preparing a Layer</link>"
  567. section for information.
  568. </para>
  569. <section id='creating-the-append-file'>
  570. <title>Creating the Append File</title>
  571. <para>
  572. You create this file in your custom layer.
  573. You also name it accordingly based on the linux-yocto recipe
  574. you are using.
  575. For example, if you are modifying the
  576. <filename>meta/recipes-kernel/linux/linux-yocto_4.12.bb</filename>
  577. recipe, the append file will typically be located as follows
  578. within your custom layer:
  579. <literallayout class='monospaced'>
  580. <replaceable>your-layer</replaceable>/recipes-kernel/linux/linux-yocto_4.12.bbappend
  581. </literallayout>
  582. The append file should initially extend the
  583. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  584. search path by prepending the directory that contains your
  585. files to the
  586. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  587. variable as follows:
  588. <literallayout class='monospaced'>
  589. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  590. </literallayout>
  591. The path <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-THISDIR'><filename>THISDIR</filename></ulink><filename>}/${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  592. expands to "linux-yocto" in the current directory for this
  593. example.
  594. If you add any new files that modify the kernel recipe and you
  595. have extended <filename>FILESPATH</filename> as
  596. described above, you must place the files in your layer in the
  597. following area:
  598. <literallayout class='monospaced'>
  599. <replaceable>your-layer</replaceable>/recipes-kernel/linux/linux-yocto/
  600. </literallayout>
  601. <note>If you are working on a new machine Board Support Package
  602. (BSP), be sure to refer to the
  603. <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>.
  604. </note>
  605. </para>
  606. <para>
  607. As an example, consider the following append file
  608. used by the BSPs in <filename>meta-yocto-bsp</filename>:
  609. <literallayout class='monospaced'>
  610. meta-yocto-bsp/recipes-kernel/linux/linux-yocto_4.12.bbappend
  611. </literallayout>
  612. The following listing shows the file.
  613. Be aware that the actual commit ID strings in this
  614. example listing might be different than the actual strings
  615. in the file from the <filename>meta-yocto-bsp</filename>
  616. layer upstream.
  617. <literallayout class='monospaced'>
  618. KBRANCH_genericx86 = "standard/base"
  619. KBRANCH_genericx86-64 = "standard/base"
  620. KMACHINE_genericx86 ?= "common-pc"
  621. KMACHINE_genericx86-64 ?= "common-pc-64"
  622. KBRANCH_edgerouter = "standard/edgerouter"
  623. KBRANCH_beaglebone = "standard/beaglebone"
  624. KBRANCH_mpc8315e-rdb = "standard/fsl-mpc8315e-rdb"
  625. SRCREV_machine_genericx86 ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19"
  626. SRCREV_machine_genericx86-64 ?= "d09f2ce584d60ecb7890550c22a80c48b83c2e19"
  627. SRCREV_machine_edgerouter ?= "b5c8cfda2dfe296410d51e131289fb09c69e1e7d"
  628. SRCREV_machine_beaglebone ?= "b5c8cfda2dfe296410d51e131289fb09c69e1e7d"
  629. SRCREV_machine_mpc8315e-rdb ?= "2d1d010240846d7bff15d1fcc0cb6eb8a22fc78a"
  630. COMPATIBLE_MACHINE_genericx86 = "genericx86"
  631. COMPATIBLE_MACHINE_genericx86-64 = "genericx86-64"
  632. COMPATIBLE_MACHINE_edgerouter = "edgerouter"
  633. COMPATIBLE_MACHINE_beaglebone = "beaglebone"
  634. COMPATIBLE_MACHINE_mpc8315e-rdb = "mpc8315e-rdb"
  635. LINUX_VERSION_genericx86 = "4.12.7"
  636. LINUX_VERSION_genericx86-64 = "4.12.7"
  637. LINUX_VERSION_edgerouter = "4.12.10"
  638. LINUX_VERSION_beaglebone = "4.12.10"
  639. LINUX_VERSION_mpc8315e-rdb = "4.12.10"
  640. </literallayout>
  641. This append file contains statements used to support
  642. several BSPs that ship with the Yocto Project.
  643. The file defines machines using the
  644. <ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'><filename>COMPATIBLE_MACHINE</filename></ulink>
  645. variable and uses the
  646. <ulink url='&YOCTO_DOCS_REF_URL;#var-KMACHINE'><filename>KMACHINE</filename></ulink>
  647. variable to ensure the machine name used by the OpenEmbedded
  648. build system maps to the machine name used by the Linux Yocto
  649. kernel.
  650. The file also uses the optional
  651. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink>
  652. variable to ensure the build process uses the
  653. appropriate kernel branch.
  654. </para>
  655. <para>
  656. Although this particular example does not use it, the
  657. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink>
  658. variable could be used to enable features specific to
  659. the kernel.
  660. The append file points to specific commits in the
  661. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  662. Git repository and the <filename>meta</filename> Git repository
  663. branches to identify the exact kernel needed to build the
  664. BSP.
  665. </para>
  666. <para>
  667. One thing missing in this particular BSP, which you will
  668. typically need when developing a BSP, is the kernel
  669. configuration file (<filename>.config</filename>) for your BSP.
  670. When developing a BSP, you probably have a kernel configuration
  671. file or a set of kernel configuration files that, when taken
  672. together, define the kernel configuration for your BSP.
  673. You can accomplish this definition by putting the configurations
  674. in a file or a set of files inside a directory located at the
  675. same level as your kernel's append file and having the same
  676. name as the kernel's main recipe file.
  677. With all these conditions met, simply reference those files in
  678. the
  679. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  680. statement in the append file.
  681. </para>
  682. <para>
  683. For example, suppose you had some configuration options
  684. in a file called <filename>network_configs.cfg</filename>.
  685. You can place that file inside a directory named
  686. <filename>linux-yocto</filename> and then add
  687. a <filename>SRC_URI</filename> statement such as the
  688. following to the append file.
  689. When the OpenEmbedded build system builds the kernel, the
  690. configuration options are picked up and applied.
  691. <literallayout class='monospaced'>
  692. SRC_URI += "file://network_configs.cfg"
  693. </literallayout>
  694. </para>
  695. <para>
  696. To group related configurations into multiple files, you
  697. perform a similar procedure.
  698. Here is an example that groups separate configurations
  699. specifically for Ethernet and graphics into their own
  700. files and adds the configurations by using a
  701. <filename>SRC_URI</filename> statement like the following
  702. in your append file:
  703. <literallayout class='monospaced'>
  704. SRC_URI += "file://myconfig.cfg \
  705. file://eth.cfg \
  706. file://gfx.cfg"
  707. </literallayout>
  708. </para>
  709. <para>
  710. Another variable you can use in your kernel recipe append
  711. file is the
  712. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  713. variable.
  714. When you use this statement, you are extending the locations
  715. used by the OpenEmbedded system to look for files and
  716. patches as the recipe is processed.
  717. </para>
  718. <note>
  719. <para>
  720. Other methods exist to accomplish grouping and defining
  721. configuration options.
  722. For example, if you are working with a local clone of the
  723. kernel repository, you could checkout the kernel's
  724. <filename>meta</filename> branch, make your changes, and
  725. then push the changes to the local bare clone of the
  726. kernel.
  727. The result is that you directly add configuration options
  728. to the <filename>meta</filename> branch for your BSP.
  729. The configuration options will likely end up in that
  730. location anyway if the BSP gets added to the Yocto Project.
  731. </para>
  732. <para>
  733. In general, however, the Yocto Project maintainers take
  734. care of moving the <filename>SRC_URI</filename>-specified
  735. configuration options to the kernel's
  736. <filename>meta</filename> branch.
  737. Not only is it easier for BSP developers to not have to
  738. worry about putting those configurations in the branch,
  739. but having the maintainers do it allows them to apply
  740. 'global' knowledge about the kinds of common configuration
  741. options multiple BSPs in the tree are typically using.
  742. This allows for promotion of common configurations into
  743. common features.
  744. </para>
  745. </note>
  746. </section>
  747. <section id='applying-patches'>
  748. <title>Applying Patches</title>
  749. <para>
  750. If you have a single patch or a small series of patches
  751. that you want to apply to the Linux kernel source, you
  752. can do so just as you would with any other recipe.
  753. You first copy the patches to the path added to
  754. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  755. in your <filename>.bbappend</filename> file as described in
  756. the previous section, and then reference them in
  757. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  758. statements.
  759. </para>
  760. <para>
  761. For example, you can apply a three-patch series by adding the
  762. following lines to your linux-yocto
  763. <filename>.bbappend</filename> file in your layer:
  764. <literallayout class='monospaced'>
  765. SRC_URI += "file://0001-first-change.patch"
  766. SRC_URI += "file://0002-second-change.patch"
  767. SRC_URI += "file://0003-third-change.patch"
  768. </literallayout>
  769. The next time you run BitBake to build the Linux kernel,
  770. BitBake detects the change in the recipe and fetches and
  771. applies the patches before building the kernel.
  772. </para>
  773. <para>
  774. For a detailed example showing how to patch the kernel using
  775. <filename>devtool</filename>, see the
  776. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  777. and
  778. "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
  779. sections.
  780. </para>
  781. </section>
  782. <section id='changing-the-configuration'>
  783. <title>Changing the Configuration</title>
  784. <para>
  785. You can make wholesale or incremental changes to the final
  786. <filename>.config</filename> file used for the eventual
  787. Linux kernel configuration by including a
  788. <filename>defconfig</filename> file and by specifying
  789. configuration fragments in the
  790. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  791. to be applied to that file.
  792. </para>
  793. <para>
  794. If you have a complete, working Linux kernel
  795. <filename>.config</filename>
  796. file you want to use for the configuration, as before, copy
  797. that file to the appropriate <filename>${PN}</filename>
  798. directory in your layer's
  799. <filename>recipes-kernel/linux</filename> directory,
  800. and rename the copied file to "defconfig".
  801. Then, add the following lines to the linux-yocto
  802. <filename>.bbappend</filename> file in your layer:
  803. <literallayout class='monospaced'>
  804. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  805. SRC_URI += "file://defconfig"
  806. </literallayout>
  807. The <filename>SRC_URI</filename> tells the build system how to
  808. search for the file, while the
  809. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  810. extends the
  811. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  812. variable (search directories) to include the
  813. <filename>${PN}</filename> directory you created to hold the
  814. configuration changes.
  815. </para>
  816. <note>
  817. The build system applies the configurations from the
  818. <filename>defconfig</filename> file before applying any
  819. subsequent configuration fragments.
  820. The final kernel configuration is a combination of the
  821. configurations in the <filename>defconfig</filename> file and
  822. any configuration fragments you provide.
  823. You need to realize that if you have any configuration
  824. fragments, the build system applies these on top of and
  825. after applying the existing <filename>defconfig</filename>
  826. file configurations.
  827. </note>
  828. <para>
  829. Generally speaking, the preferred approach is to determine the
  830. incremental change you want to make and add that as a
  831. configuration fragment.
  832. For example, if you want to add support for a basic serial
  833. console, create a file named <filename>8250.cfg</filename> in
  834. the <filename>${PN}</filename> directory with the following
  835. content (without indentation):
  836. <literallayout class='monospaced'>
  837. CONFIG_SERIAL_8250=y
  838. CONFIG_SERIAL_8250_CONSOLE=y
  839. CONFIG_SERIAL_8250_PCI=y
  840. CONFIG_SERIAL_8250_NR_UARTS=4
  841. CONFIG_SERIAL_8250_RUNTIME_UARTS=4
  842. CONFIG_SERIAL_CORE=y
  843. CONFIG_SERIAL_CORE_CONSOLE=y
  844. </literallayout>
  845. Next, include this configuration fragment and extend the
  846. <filename>FILESPATH</filename> variable in your
  847. <filename>.bbappend</filename> file:
  848. <literallayout class='monospaced'>
  849. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  850. SRC_URI += "file://8250.cfg"
  851. </literallayout>
  852. The next time you run BitBake to build the Linux kernel, BitBake
  853. detects the change in the recipe and fetches and applies the
  854. new configuration before building the kernel.
  855. </para>
  856. <para>
  857. For a detailed example showing how to configure the kernel,
  858. see the
  859. "<link linkend='configuring-the-kernel'>Configuring the Kernel</link>"
  860. section.
  861. </para>
  862. </section>
  863. <section id='using-an-in-tree-defconfig-file'>
  864. <title>Using an "In-Tree"&nbsp;&nbsp;<filename>defconfig</filename> File</title>
  865. <para>
  866. It might be desirable to have kernel configuration fragment
  867. support through a <filename>defconfig</filename> file that
  868. is pulled from the kernel source tree for the configured
  869. machine.
  870. By default, the OpenEmbedded build system looks for
  871. <filename>defconfig</filename> files in the layer used for
  872. Metadata, which is "out-of-tree", and then configures them
  873. using the following:
  874. <literallayout class='monospaced'>
  875. SRC_URI += "file://defconfig"
  876. </literallayout>
  877. If you do not want to maintain copies of
  878. <filename>defconfig</filename> files in your layer but would
  879. rather allow users to use the default configuration from the
  880. kernel tree and still be able to add configuration fragments
  881. to the
  882. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  883. through, for example, append files, you can direct the
  884. OpenEmbedded build system to use a
  885. <filename>defconfig</filename> file that is "in-tree".
  886. </para>
  887. <para>
  888. To specify an "in-tree" <filename>defconfig</filename> file,
  889. use the following statement form:
  890. <literallayout class='monospaced'>
  891. KBUILD_DEFCONFIG_<replaceable>KMACHINE</replaceable> ?= <replaceable>defconfig_file</replaceable>
  892. </literallayout>
  893. Here is an example that appends the
  894. <filename>KBUILD_DEFCONFIG</filename> variable with
  895. "common-pc" and provides the path to the "in-tree"
  896. <filename>defconfig</filename> file:
  897. <literallayout class='monospaced'>
  898. KBUILD_DEFCONFIG_common-pc ?= "/home/scottrif/configfiles/my_defconfig_file"
  899. </literallayout>
  900. </para>
  901. <para>
  902. Aside from modifying your kernel recipe and providing your own
  903. <filename>defconfig</filename> file, you need to be sure no
  904. files or statements set <filename>SRC_URI</filename> to use a
  905. <filename>defconfig</filename> other than your "in-tree"
  906. file (e.g. a kernel's
  907. <filename>linux-</filename><replaceable>machine</replaceable><filename>.inc</filename>
  908. file).
  909. In other words, if the build system detects a statement
  910. that identifies an "out-of-tree"
  911. <filename>defconfig</filename> file, that statement
  912. will override your
  913. <filename>KBUILD_DEFCONFIG</filename> variable.
  914. </para>
  915. <para>
  916. See the
  917. <ulink url='&YOCTO_DOCS_REF_URL;#var-KBUILD_DEFCONFIG'><filename>KBUILD_DEFCONFIG</filename></ulink>
  918. variable description for more information.
  919. </para>
  920. </section>
  921. </section>
  922. <section id="using-devtool-to-patch-the-kernel">
  923. <title>Using <filename>devtool</filename> to Patch the Kernel</title>
  924. <para>
  925. The steps in this procedure show you how you can patch the
  926. kernel using the extensible SDK and <filename>devtool</filename>.
  927. <note>
  928. Before attempting this procedure, be sure you have performed
  929. the steps to get ready for updating the kernel as described
  930. in the
  931. "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>"
  932. section.
  933. </note>
  934. </para>
  935. <para>
  936. Patching the kernel involves changing or adding configurations
  937. to an existing kernel, changing or adding recipes to the kernel
  938. that are needed to support specific hardware features, or even
  939. altering the source code itself.
  940. </para>
  941. <para>
  942. This example creates a simple patch by adding some QEMU emulator
  943. console output at boot time through <filename>printk</filename>
  944. statements in the kernel's <filename>calibrate.c</filename> source
  945. code file.
  946. Applying the patch and booting the modified image causes the added
  947. messages to appear on the emulator's console.
  948. The example is a continuation of the setup procedure found in
  949. the
  950. "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>"
  951. Section.
  952. <orderedlist>
  953. <listitem><para>
  954. <emphasis>Check Out the Kernel Source Files:</emphasis>
  955. First you must use <filename>devtool</filename> to checkout
  956. the kernel source code in its workspace.
  957. Be sure you are in the terminal set up to do work
  958. with the extensible SDK.
  959. <note>
  960. See this
  961. <link linkend='setting-up-the-esdk-terminal'>step</link>
  962. in the
  963. "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using <filename>devtool</filename></link>"
  964. section for more information.
  965. </note>
  966. Use the following <filename>devtool</filename> command
  967. to check out the code:
  968. <literallayout class='monospaced'>
  969. $ devtool modify linux-yocto
  970. </literallayout>
  971. <note>
  972. During the checkout operation, a bug exists that could
  973. cause errors such as the following to appear:
  974. <literallayout class='monospaced'>
  975. ERROR: Taskhash mismatch 2c793438c2d9f8c3681fd5f7bc819efa versus
  976. be3a89ce7c47178880ba7bf6293d7404 for
  977. /path/to/esdk/layers/poky/meta/recipes-kernel/linux/linux-yocto_4.10.bb.do_unpack
  978. </literallayout>
  979. You can safely ignore these messages.
  980. The source code is correctly checked out.
  981. </note>
  982. </para></listitem>
  983. <listitem><para>
  984. <emphasis>Edit the Source Files</emphasis>
  985. Follow these steps to make some simple changes to the source
  986. files:
  987. <orderedlist>
  988. <listitem><para>
  989. <emphasis>Change the working directory</emphasis>:
  990. In the previous step, the output noted where you can find
  991. the source files (e.g.
  992. <filename>~/poky_sdk/workspace/sources/linux-yocto</filename>).
  993. Change to where the kernel source code is before making
  994. your edits to the <filename>calibrate.c</filename> file:
  995. <literallayout class='monospaced'>
  996. $ cd ~/poky_sdk/workspace/sources/linux-yocto
  997. </literallayout>
  998. </para></listitem>
  999. <listitem><para>
  1000. <emphasis>Edit the source file</emphasis>:
  1001. Edit the <filename>init/calibrate.c</filename> file to have
  1002. the following changes:
  1003. <literallayout class='monospaced'>
  1004. void calibrate_delay(void)
  1005. {
  1006. unsigned long lpj;
  1007. static bool printed;
  1008. int this_cpu = smp_processor_id();
  1009. printk("*************************************\n");
  1010. printk("* *\n");
  1011. printk("* HELLO YOCTO KERNEL *\n");
  1012. printk("* *\n");
  1013. printk("*************************************\n");
  1014. if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
  1015. .
  1016. .
  1017. .
  1018. </literallayout>
  1019. </para></listitem>
  1020. </orderedlist>
  1021. </para></listitem>
  1022. <listitem><para>
  1023. <emphasis>Build the Updated Kernel Source:</emphasis>
  1024. To build the updated kernel source, use
  1025. <filename>devtool</filename>:
  1026. <literallayout class='monospaced'>
  1027. $ devtool build linux-yocto
  1028. </literallayout>
  1029. </para></listitem>
  1030. <listitem><para>
  1031. <emphasis>Create the Image With the New Kernel:</emphasis>
  1032. Use the <filename>devtool build-image</filename> command
  1033. to create a new image that has the new kernel.
  1034. <note>
  1035. If the image you originally created resulted in a Wic
  1036. file, you can use an alternate method to create the new
  1037. image with the updated kernel.
  1038. For an example, see the steps in the
  1039. <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/KernelDevelopmentWithEsdk'>TipsAndTricks/KernelDevelopmentWithEsdk</ulink>
  1040. Wiki Page.
  1041. </note>
  1042. <literallayout class='monospaced'>
  1043. $ cd ~
  1044. $ devtool build-image core-image-minimal
  1045. </literallayout>
  1046. </para></listitem>
  1047. <listitem><para>
  1048. <emphasis>Test the New Image:</emphasis>
  1049. For this example, you can run the new image using QEMU
  1050. to verify your changes:
  1051. <orderedlist>
  1052. <listitem><para>
  1053. <emphasis>Boot the image</emphasis>:
  1054. Boot the modified image in the QEMU emulator
  1055. using this command:
  1056. <literallayout class='monospaced'>
  1057. $ runqemu qemux86
  1058. </literallayout>
  1059. </para></listitem>
  1060. <listitem><para>
  1061. <emphasis>Verify the changes</emphasis>:
  1062. Log into the machine using <filename>root</filename>
  1063. with no password and then use the following shell
  1064. command to scroll through the console's boot output.
  1065. <literallayout class='monospaced'>
  1066. # dmesg | less
  1067. </literallayout>
  1068. You should see the results of your
  1069. <filename>printk</filename> statements
  1070. as part of the output when you scroll down the
  1071. console window.
  1072. </para></listitem>
  1073. </orderedlist>
  1074. </para></listitem>
  1075. <listitem><para>
  1076. <emphasis>Stage and commit your changes</emphasis>:
  1077. Within your eSDK terminal, change your working directory to
  1078. where you modified the <filename>calibrate.c</filename>
  1079. file and use these Git commands to stage and commit your
  1080. changes:
  1081. <literallayout class='monospaced'>
  1082. $ cd ~/poky_sdk/workspace/sources/linux-yocto
  1083. $ git status
  1084. $ git add init/calibrate.c
  1085. $ git commit -m "calibrate: Add printk example"
  1086. </literallayout>
  1087. </para></listitem>
  1088. <listitem><para>
  1089. <emphasis>Export the Patches and Create an Append File:</emphasis>
  1090. To export your commits as patches and create a
  1091. <filename>.bbappend</filename> file, use the following
  1092. command in the terminal used to work with the extensible
  1093. SDK.
  1094. This example uses the previously established layer named
  1095. <filename>meta-mylayer</filename>.
  1096. <note>
  1097. See Step 3 of the
  1098. "<link linkend='getting-ready-to-develop-using-devtool'>Getting Ready to Develop Using devtool</link>"
  1099. section for information on setting up this layer.
  1100. </note>
  1101. <literallayout class='monospaced'>
  1102. $ devtool finish linux-yocto ~/meta-mylayer
  1103. </literallayout>
  1104. Once the command finishes, the patches and the
  1105. <filename>.bbappend</filename> file are located in the
  1106. <filename>~/meta-mylayer/recipes-kernel/linux</filename>
  1107. directory.
  1108. </para></listitem>
  1109. <listitem><para>
  1110. <emphasis>Build the Image With Your Modified Kernel:</emphasis>
  1111. You can now build an image that includes your kernel
  1112. patches.
  1113. Execute the following command from your
  1114. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>
  1115. in the terminal set up to run BitBake:
  1116. <literallayout class='monospaced'>
  1117. $ cd ~/poky/build
  1118. $ bitbake core-image-minimal
  1119. </literallayout>
  1120. </para></listitem>
  1121. </orderedlist>
  1122. </para>
  1123. </section>
  1124. <section id="using-traditional-kernel-development-to-patch-the-kernel">
  1125. <title>Using Traditional Kernel Development to Patch the Kernel</title>
  1126. <para>
  1127. The steps in this procedure show you how you can patch the
  1128. kernel using traditional kernel development (i.e. not using
  1129. <filename>devtool</filename> and the extensible SDK as
  1130. described in the
  1131. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  1132. section).
  1133. <note>
  1134. Before attempting this procedure, be sure you have performed
  1135. the steps to get ready for updating the kernel as described
  1136. in the
  1137. "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
  1138. section.
  1139. </note>
  1140. </para>
  1141. <para>
  1142. Patching the kernel involves changing or adding configurations
  1143. to an existing kernel, changing or adding recipes to the kernel
  1144. that are needed to support specific hardware features, or even
  1145. altering the source code itself.
  1146. </para>
  1147. <para>
  1148. The example in this section creates a simple patch by adding some
  1149. QEMU emulator console output at boot time through
  1150. <filename>printk</filename> statements in the kernel's
  1151. <filename>calibrate.c</filename> source code file.
  1152. Applying the patch and booting the modified image causes the added
  1153. messages to appear on the emulator's console.
  1154. The example is a continuation of the setup procedure found in
  1155. the
  1156. "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
  1157. Section.
  1158. <orderedlist>
  1159. <listitem><para>
  1160. <emphasis>Edit the Source Files</emphasis>
  1161. Prior to this step, you should have used Git to create a
  1162. local copy of the repository for your kernel.
  1163. Assuming you created the repository as directed in the
  1164. "<link linkend='getting-ready-for-traditional-kernel-development'>Getting Ready for Traditional Kernel Development</link>"
  1165. section, use the following commands to edit the
  1166. <filename>calibrate.c</filename> file:
  1167. <orderedlist>
  1168. <listitem><para>
  1169. <emphasis>Change the working directory</emphasis>:
  1170. You need to locate the source files in the
  1171. local copy of the kernel Git repository:
  1172. Change to where the kernel source code is before making
  1173. your edits to the <filename>calibrate.c</filename> file:
  1174. <literallayout class='monospaced'>
  1175. $ cd ~/linux-yocto-4.12/init
  1176. </literallayout>
  1177. </para></listitem>
  1178. <listitem><para>
  1179. <emphasis>Edit the source file</emphasis>:
  1180. Edit the <filename>calibrate.c</filename> file to have
  1181. the following changes:
  1182. <literallayout class='monospaced'>
  1183. void calibrate_delay(void)
  1184. {
  1185. unsigned long lpj;
  1186. static bool printed;
  1187. int this_cpu = smp_processor_id();
  1188. printk("*************************************\n");
  1189. printk("* *\n");
  1190. printk("* HELLO YOCTO KERNEL *\n");
  1191. printk("* *\n");
  1192. printk("*************************************\n");
  1193. if (per_cpu(cpu_loops_per_jiffy, this_cpu)) {
  1194. .
  1195. .
  1196. .
  1197. </literallayout>
  1198. </para></listitem>
  1199. </orderedlist>
  1200. </para></listitem>
  1201. <listitem><para>
  1202. <emphasis>Stage and Commit Your Changes:</emphasis>
  1203. Use standard Git commands to stage and commit the changes
  1204. you just made:
  1205. <literallayout class='monospaced'>
  1206. $ git add calibrate.c
  1207. $ git commit -m "calibrate.c - Added some printk statements"
  1208. </literallayout>
  1209. If you do not stage and commit your changes, the OpenEmbedded
  1210. Build System will not pick up the changes.
  1211. </para></listitem>
  1212. <listitem><para>
  1213. <emphasis>Update Your <filename>local.conf</filename> File
  1214. to Point to Your Source Files:</emphasis>
  1215. In addition to your <filename>local.conf</filename> file
  1216. specifying to use "kernel-modules" and the "qemux86"
  1217. machine, it must also point to the updated kernel source
  1218. files.
  1219. Add
  1220. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1221. and
  1222. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>
  1223. statements similar to the following to your
  1224. <filename>local.conf</filename>:
  1225. <literallayout class='monospaced'>
  1226. $ cd ~/poky/build/conf
  1227. </literallayout>
  1228. Add the following to the <filename>local.conf</filename>:
  1229. <literallayout class='monospaced'>
  1230. SRC_URI_pn-linux-yocto = "git:///<replaceable>path-to</replaceable>/linux-yocto-4.12;protocol=file;name=machine;branch=standard/base; \
  1231. git:///<replaceable>path-to</replaceable>/yocto-kernel-cache;protocol=file;type=kmeta;name=meta;branch=yocto-4.12;destsuffix=${KMETA}"
  1232. SRCREV_meta_qemux86 = "${AUTOREV}"
  1233. SRCREV_machine_qemux86 = "${AUTOREV}"
  1234. </literallayout>
  1235. <note>
  1236. Be sure to replace
  1237. <replaceable>path-to</replaceable> with the pathname
  1238. to your local Git repositories.
  1239. Also, you must be sure to specify the correct branch
  1240. and machine types.
  1241. For this example, the branch is
  1242. <filename>standard/base</filename> and the machine is
  1243. "qemux86".
  1244. </note>
  1245. </para></listitem>
  1246. <listitem><para>
  1247. <emphasis>Build the Image:</emphasis>
  1248. With the source modified, your changes staged and
  1249. committed, and the <filename>local.conf</filename> file
  1250. pointing to the kernel files, you can now use BitBake to
  1251. build the image:
  1252. <literallayout class='monospaced'>
  1253. $ cd ~/poky/build
  1254. $ bitbake core-image-minimal
  1255. </literallayout>
  1256. </para></listitem>
  1257. <listitem><para>
  1258. <emphasis>Boot the image</emphasis>:
  1259. Boot the modified image in the QEMU emulator
  1260. using this command.
  1261. When prompted to login to the QEMU console, use "root"
  1262. with no password:
  1263. <literallayout class='monospaced'>
  1264. $ cd ~/poky/build
  1265. $ runqemu qemux86
  1266. </literallayout>
  1267. </para></listitem>
  1268. <listitem><para>
  1269. <emphasis>Look for Your Changes:</emphasis>
  1270. As QEMU booted, you might have seen your changes rapidly
  1271. scroll by.
  1272. If not, use these commands to see your changes:
  1273. <literallayout class='monospaced'>
  1274. # dmesg | less
  1275. </literallayout>
  1276. You should see the results of your
  1277. <filename>printk</filename> statements
  1278. as part of the output when you scroll down the
  1279. console window.
  1280. </para></listitem>
  1281. <listitem><para>
  1282. <emphasis>Generate the Patch File:</emphasis>
  1283. Once you are sure that your patch works correctly, you
  1284. can generate a <filename>*.patch</filename> file in the
  1285. kernel source repository:
  1286. <literallayout class='monospaced'>
  1287. $ cd ~/linux-yocto-4.12/init
  1288. $ git format-patch -1
  1289. 0001-calibrate.c-Added-some-printk-statements.patch
  1290. </literallayout>
  1291. </para></listitem>
  1292. <listitem><para>
  1293. <emphasis>Move the Patch File to Your Layer:</emphasis>
  1294. In order for subsequent builds to pick up patches, you
  1295. need to move the patch file you created in the previous
  1296. step to your layer <filename>meta-mylayer</filename>.
  1297. For this example, the layer created earlier is located
  1298. in your home directory as <filename>meta-mylayer</filename>.
  1299. When the layer was created using the
  1300. <filename>yocto-create</filename> script, no additional
  1301. hierarchy was created to support patches.
  1302. Before moving the patch file, you need to add additional
  1303. structure to your layer using the following commands:
  1304. <literallayout class='monospaced'>
  1305. $ cd ~/meta-mylayer
  1306. $ mkdir recipes-kernel
  1307. $ mkdir recipes-kernel/linux
  1308. $ mkdir recipes-kernel/linux/linux-yocto
  1309. </literallayout>
  1310. Once you have created this hierarchy in your layer, you can
  1311. move the patch file using the following command:
  1312. <literallayout class='monospaced'>
  1313. $ mv ~/linux-yocto-4.12/init/0001-calibrate.c-Added-some-printk-statements.patch ~/meta-mylayer/recipes-kernel/linux/linux-yocto
  1314. </literallayout>
  1315. </para></listitem>
  1316. <listitem><para>
  1317. <emphasis>Create the Append File:</emphasis>
  1318. Finally, you need to create the
  1319. <filename>linux-yocto_4.12.bbappend</filename> file and
  1320. insert statements that allow the OpenEmbedded build
  1321. system to find the patch.
  1322. The append file needs to be in your layer's
  1323. <filename>recipes-kernel/linux</filename>
  1324. directory and it must be named
  1325. <filename>linux-yocto_4.12.bbappend</filename> and have
  1326. the following contents:
  1327. <literallayout class='monospaced'>
  1328. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  1329. SRC_URI_append = " file://0001-calibrate.c-Added-some-printk-statements.patch"
  1330. </literallayout>
  1331. The
  1332. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  1333. and
  1334. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1335. statements enable the OpenEmbedded build system to find
  1336. the patch file.</para>
  1337. <para>For more information on append files and patches,
  1338. see the
  1339. "<link linkend='creating-the-append-file'>Creating the Append File</link>"
  1340. and
  1341. "<link linkend='applying-patches'>Applying Patches</link>"
  1342. sections.
  1343. You can also see the
  1344. "<ulink url='&YOCTO_DOCS_DEV_URL;#using-bbappend-files'>Using .bbappend Files in Your Layer"</ulink>"
  1345. section in the Yocto Project Development Tasks Manual.
  1346. <note>
  1347. To build <filename>core-image-minimal</filename>
  1348. again and see the effects of your patch, you can
  1349. essentially eliminate the temporary source files
  1350. saved in <filename>poky/build/tmp/work/...</filename>
  1351. and residual effects of the build by entering the
  1352. following sequence of commands:
  1353. <literallayout class='monospaced'>
  1354. $ cd ~/poky/build
  1355. $ bitbake -c cleanall yocto-linux
  1356. $ bitbake core-image-minimal -c cleanall
  1357. $ bitbake core-image-minimal
  1358. $ runqemu qemux86
  1359. </literallayout>
  1360. </note>
  1361. </para></listitem>
  1362. </orderedlist>
  1363. </para>
  1364. </section>
  1365. <section id='configuring-the-kernel'>
  1366. <title>Configuring the Kernel</title>
  1367. <para>
  1368. Configuring the Yocto Project kernel consists of making sure the
  1369. <filename>.config</filename> file has all the right information
  1370. in it for the image you are building.
  1371. You can use the <filename>menuconfig</filename> tool and
  1372. configuration fragments to make sure your
  1373. <filename>.config</filename> file is just how you need it.
  1374. You can also save known configurations in a
  1375. <filename>defconfig</filename> file that the build system can use
  1376. for kernel configuration.
  1377. </para>
  1378. <para>
  1379. This section describes how to use <filename>menuconfig</filename>,
  1380. create and use configuration fragments, and how to interactively
  1381. modify your <filename>.config</filename> file to create the
  1382. leanest kernel configuration file possible.
  1383. </para>
  1384. <para>
  1385. For more information on kernel configuration, see the
  1386. "<link linkend='changing-the-configuration'>Changing the Configuration</link>"
  1387. section.
  1388. </para>
  1389. <section id='using-menuconfig'>
  1390. <title>Using&nbsp;&nbsp;<filename>menuconfig</filename></title>
  1391. <para>
  1392. The easiest way to define kernel configurations is to set
  1393. them through the <filename>menuconfig</filename> tool.
  1394. This tool provides an interactive method with which
  1395. to set kernel configurations.
  1396. For general information on <filename>menuconfig</filename>, see
  1397. <ulink url='http://en.wikipedia.org/wiki/Menuconfig'></ulink>.
  1398. </para>
  1399. <para>
  1400. To use the <filename>menuconfig</filename> tool in the Yocto
  1401. Project development environment, you must launch it using
  1402. BitBake.
  1403. Thus, the environment must be set up using the
  1404. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  1405. script found in the
  1406. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1407. You must also be sure of the state of your build's
  1408. configuration in the
  1409. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  1410. The following commands initialize the BitBake environment,
  1411. run the
  1412. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configme'><filename>do_kernel_configme</filename></ulink>
  1413. task, and launch <filename>menuconfig</filename>.
  1414. These commands assume the Source Directory's top-level folder
  1415. is <filename>~/poky</filename>:
  1416. <literallayout class='monospaced'>
  1417. $ cd poky
  1418. $ source oe-init-build-env
  1419. $ bitbake linux-yocto -c kernel_configme -f
  1420. $ bitbake linux-yocto -c menuconfig
  1421. </literallayout>
  1422. Once <filename>menuconfig</filename> comes up, its standard
  1423. interface allows you to interactively examine and configure
  1424. all the kernel configuration parameters.
  1425. After making your changes, simply exit the tool and save your
  1426. changes to create an updated version of the
  1427. <filename>.config</filename> configuration file.
  1428. <note>
  1429. You can use the entire <filename>.config</filename> file
  1430. as the <filename>defconfig</filename> file.
  1431. For information on <filename>defconfig</filename> files,
  1432. see the
  1433. "<link linkend='changing-the-configuration'>Changing the Configuration</link>",
  1434. "<link linkend='using-an-in-tree-defconfig-file'>Using an In-Tree <filename>defconfig</filename> File</link>,
  1435. and
  1436. "<link linkend='creating-a-defconfig-file'>Creating a <filename>defconfig</filename> File</link>"
  1437. sections.
  1438. </note>
  1439. </para>
  1440. <para>
  1441. Consider an example that configures the "CONFIG_SMP" setting
  1442. for the <filename>linux-yocto-4.12</filename> kernel.
  1443. <note>
  1444. The OpenEmbedded build system recognizes this kernel as
  1445. <filename>linux-yocto</filename> through Metadata (e.g.
  1446. <ulink url='&YOCTO_DOCS_REF_URL;#var-PREFERRED_VERSION'><filename>PREFERRED_VERSION</filename></ulink><filename>_linux-yocto ?= "12.4%"</filename>).
  1447. </note>
  1448. Once <filename>menuconfig</filename> launches, use the
  1449. interface to navigate through the selections to find the
  1450. configuration settings in which you are interested.
  1451. For this example, you deselect "CONFIG_SMP" by clearing the
  1452. "Symmetric Multi-Processing Support" option.
  1453. Using the interface, you can find the option under
  1454. "Processor Type and Features".
  1455. To deselect "CONFIG_SMP", use the arrow keys to
  1456. highlight "Symmetric Multi-Processing Support" and enter "N"
  1457. to clear the asterisk.
  1458. When you are finished, exit out and save the change.
  1459. </para>
  1460. <para>
  1461. Saving the selections updates the <filename>.config</filename>
  1462. configuration file.
  1463. This is the file that the OpenEmbedded build system uses to
  1464. configure the kernel during the build.
  1465. You can find and examine this file in the Build Directory in
  1466. <filename>tmp/work/</filename>.
  1467. The actual <filename>.config</filename> is located in the
  1468. area where the specific kernel is built.
  1469. For example, if you were building a Linux Yocto kernel based
  1470. on the <filename>linux-yocto-4.12</filename> kernel and you
  1471. were building a QEMU image targeted for
  1472. <filename>x86</filename> architecture, the
  1473. <filename>.config</filename> file would be:
  1474. <literallayout class='monospaced'>
  1475. poky/build/tmp/work/qemux86-poky-linux/linux-yocto/4.12.12+gitAUTOINC+eda4d18...
  1476. ...967-r0/linux-qemux86-standard-build/.config
  1477. </literallayout>
  1478. <note>
  1479. The previous example directory is artificially split and
  1480. many of the characters in the actual filename are omitted
  1481. in order to make it more readable.
  1482. Also, depending on the kernel you are using, the exact
  1483. pathname might differ.
  1484. </note>
  1485. </para>
  1486. <para>
  1487. Within the <filename>.config</filename> file, you can see the
  1488. kernel settings.
  1489. For example, the following entry shows that symmetric
  1490. multi-processor support is not set:
  1491. <literallayout class='monospaced'>
  1492. # CONFIG_SMP is not set
  1493. </literallayout>
  1494. </para>
  1495. <para>
  1496. A good method to isolate changed configurations is to use a
  1497. combination of the <filename>menuconfig</filename> tool and
  1498. simple shell commands.
  1499. Before changing configurations with
  1500. <filename>menuconfig</filename>, copy the existing
  1501. <filename>.config</filename> and rename it to something else,
  1502. use <filename>menuconfig</filename> to make as many changes as
  1503. you want and save them, then compare the renamed configuration
  1504. file against the newly created file.
  1505. You can use the resulting differences as your base to create
  1506. configuration fragments to permanently save in your kernel
  1507. layer.
  1508. <note>
  1509. Be sure to make a copy of the <filename>.config</filename>
  1510. file and do not just rename it.
  1511. The build system needs an existing
  1512. <filename>.config</filename> file from which to work.
  1513. </note>
  1514. </para>
  1515. </section>
  1516. <section id='creating-a-defconfig-file'>
  1517. <title>Creating a&nbsp;&nbsp;<filename>defconfig</filename> File</title>
  1518. <para>
  1519. A <filename>defconfig</filename> file in the context of
  1520. the Yocto Project is often a <filename>.config</filename>
  1521. file that is copied from a build or a
  1522. <filename>defconfig</filename> taken from the kernel tree
  1523. and moved into recipe space.
  1524. You can use a <filename>defconfig</filename> file
  1525. to retain a known set of kernel configurations from which the
  1526. OpenEmbedded build system can draw to create the final
  1527. <filename>.config</filename> file.
  1528. <note>
  1529. Out-of-the-box, the Yocto Project never ships a
  1530. <filename>defconfig</filename> or
  1531. <filename>.config</filename> file.
  1532. The OpenEmbedded build system creates the final
  1533. <filename>.config</filename> file used to configure the
  1534. kernel.
  1535. </note>
  1536. </para>
  1537. <para>
  1538. To create a <filename>defconfig</filename>, start with a
  1539. complete, working Linux kernel <filename>.config</filename>
  1540. file.
  1541. Copy that file to the appropriate
  1542. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename>
  1543. directory in your layer's
  1544. <filename>recipes-kernel/linux</filename> directory, and rename
  1545. the copied file to "defconfig" (e.g.
  1546. <filename>~/meta-mylayer/recipes-kernel/linux/linux-yocto/defconfig</filename>).
  1547. Then, add the following lines to the linux-yocto
  1548. <filename>.bbappend</filename> file in your layer:
  1549. <literallayout class='monospaced'>
  1550. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  1551. SRC_URI += "file://defconfig"
  1552. </literallayout>
  1553. The
  1554. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1555. tells the build system how to search for the file, while the
  1556. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESEXTRAPATHS'><filename>FILESEXTRAPATHS</filename></ulink>
  1557. extends the
  1558. <ulink url='&YOCTO_DOCS_REF_URL;#var-FILESPATH'><filename>FILESPATH</filename></ulink>
  1559. variable (search directories) to include the
  1560. <filename>${PN}</filename> directory you created to hold the
  1561. configuration changes.
  1562. <note>
  1563. The build system applies the configurations from the
  1564. <filename>defconfig</filename> file before applying any
  1565. subsequent configuration fragments.
  1566. The final kernel configuration is a combination of the
  1567. configurations in the <filename>defconfig</filename>
  1568. file and any configuration fragments you provide.
  1569. You need to realize that if you have any configuration
  1570. fragments, the build system applies these on top of and
  1571. after applying the existing defconfig file configurations.
  1572. </note>
  1573. For more information on configuring the kernel, see the
  1574. "<link linkend='changing-the-configuration'>Changing the Configuration</link>"
  1575. section.
  1576. </para>
  1577. </section>
  1578. <section id='creating-config-fragments'>
  1579. <title>Creating Configuration Fragments</title>
  1580. <para>
  1581. Configuration fragments are simply kernel options that
  1582. appear in a file placed where the OpenEmbedded build system
  1583. can find and apply them.
  1584. The build system applies configuration fragments after
  1585. applying configurations from a <filename>defconfig</filename>
  1586. file.
  1587. Thus, the final kernel configuration is a combination of the
  1588. configurations in the <filename>defconfig</filename>
  1589. file and then any configuration fragments you provide.
  1590. The build system applies fragments on top of and
  1591. after applying the existing defconfig file configurations.
  1592. </para>
  1593. <para>
  1594. Syntactically, the configuration statement is identical to
  1595. what would appear in the <filename>.config</filename> file,
  1596. which is in the
  1597. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>.
  1598. <note>
  1599. For more information about where the
  1600. <filename>.config</filename> file is located, see the
  1601. example in the
  1602. "<link linkend='using-menuconfig'>Using <filename>menuconfig</filename></link>"
  1603. section.
  1604. </note>
  1605. </para>
  1606. <para>
  1607. It is simple to create a configuration fragment.
  1608. One method is to use shell commands.
  1609. For example, issuing the following from the shell creates a
  1610. configuration fragment file named
  1611. <filename>my_smp.cfg</filename> that enables multi-processor
  1612. support within the kernel:
  1613. <literallayout class='monospaced'>
  1614. $ echo "CONFIG_SMP=y" >> my_smp.cfg
  1615. </literallayout>
  1616. <note>
  1617. All configuration fragment files must use the
  1618. <filename>.cfg</filename> extension in order for the
  1619. OpenEmbedded build system to recognize them as a
  1620. configuration fragment.
  1621. </note>
  1622. </para>
  1623. <para>
  1624. Another method is to create a configuration fragment using the
  1625. differences between two configuration files: one previously
  1626. created and saved, and one freshly created using the
  1627. <filename>menuconfig</filename> tool.
  1628. </para>
  1629. <para>
  1630. To create a configuration fragment using this method, follow
  1631. these steps:
  1632. <orderedlist>
  1633. <listitem><para>
  1634. <emphasis>Complete a Build Through Kernel Configuration:</emphasis>
  1635. Complete a build at least through the kernel
  1636. configuration task as follows:
  1637. <literallayout class='monospaced'>
  1638. $ bitbake linux-yocto -c kernel_configme -f
  1639. </literallayout>
  1640. This step ensures that you create a
  1641. <filename>.config</filename> file from a known state.
  1642. Because situations exist where your build state might
  1643. become unknown, it is best to run this task prior
  1644. to starting <filename>menuconfig</filename>.
  1645. </para></listitem>
  1646. <listitem><para>
  1647. <emphasis>Launch <filename>menuconfig</filename>:</emphasis>
  1648. Run the <filename>menuconfig</filename> command:
  1649. <literallayout class='monospaced'>
  1650. $ bitbake linux-yocto -c menuconfig
  1651. </literallayout>
  1652. </para></listitem>
  1653. <listitem><para>
  1654. <emphasis>Create the Configuration Fragment:</emphasis>
  1655. Run the <filename>diffconfig</filename>
  1656. command to prepare a configuration fragment.
  1657. The resulting file <filename>fragment.cfg</filename>
  1658. is placed in the
  1659. <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> directory:
  1660. <literallayout class='monospaced'>
  1661. $ bitbake linux-yocto -c diffconfig
  1662. </literallayout>
  1663. </para></listitem>
  1664. </orderedlist>
  1665. </para>
  1666. <para>
  1667. The <filename>diffconfig</filename> command creates a file
  1668. that is a list of Linux kernel <filename>CONFIG_</filename>
  1669. assignments.
  1670. See the "<link linkend='changing-the-configuration'>Changing the Configuration</link>"
  1671. section for additional information on how to use the output
  1672. as a configuration fragment.
  1673. <note>
  1674. You can also use this method to create configuration
  1675. fragments for a BSP.
  1676. See the "<link linkend='bsp-descriptions'>BSP Descriptions</link>"
  1677. section for more information.
  1678. </note>
  1679. </para>
  1680. <para>
  1681. Where do you put your configuration fragment files?
  1682. You can place these files in an area pointed to by
  1683. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  1684. as directed by your <filename>bblayers.conf</filename> file,
  1685. which is located in your layer.
  1686. The OpenEmbedded build system picks up the configuration and
  1687. adds it to the kernel's configuration.
  1688. For example, suppose you had a set of configuration options
  1689. in a file called <filename>myconfig.cfg</filename>.
  1690. If you put that file inside a directory named
  1691. <filename>linux-yocto</filename> that resides in the same
  1692. directory as the kernel's append file within your layer
  1693. and then add the following statements to the kernel's append
  1694. file, those configuration options will be picked up and applied
  1695. when the kernel is built:
  1696. <literallayout class='monospaced'>
  1697. FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  1698. SRC_URI += "file://myconfig.cfg"
  1699. </literallayout>
  1700. </para>
  1701. <para>
  1702. As mentioned earlier, you can group related configurations
  1703. into multiple files and name them all in the
  1704. <filename>SRC_URI</filename> statement as well.
  1705. For example, you could group separate configurations
  1706. specifically for Ethernet and graphics into their own files
  1707. and add those by using a <filename>SRC_URI</filename> statement
  1708. like the following in your append file:
  1709. <literallayout class='monospaced'>
  1710. SRC_URI += "file://myconfig.cfg \
  1711. file://eth.cfg \
  1712. file://gfx.cfg"
  1713. </literallayout>
  1714. </para>
  1715. </section>
  1716. <section id='validating-configuration'>
  1717. <title>Validating Configuration</title>
  1718. <para>
  1719. You can use the
  1720. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configcheck'><filename>do_kernel_configcheck</filename></ulink>
  1721. task to provide configuration validation:
  1722. <literallayout class='monospaced'>
  1723. $ bitbake linux-yocto -c kernel_configcheck -f
  1724. </literallayout>
  1725. Running this task produces warnings for when a
  1726. requested configuration does not appear in the final
  1727. <filename>.config</filename> file or when you override a
  1728. policy configuration in a hardware configuration fragment.
  1729. </para>
  1730. <para>
  1731. In order to run this task, you must have an existing
  1732. <filename>.config</filename> file.
  1733. See the
  1734. "<link linkend='using-menuconfig'>Using <filename>menuconfig</filename></link>"
  1735. section for information on how to create a configuration file.
  1736. </para>
  1737. <para>
  1738. Following is sample output from the
  1739. <filename>do_kernel_configcheck</filename> task:
  1740. <literallayout class='monospaced'>
  1741. Loading cache: 100% |########################################################| Time: 0:00:00
  1742. Loaded 1275 entries from dependency cache.
  1743. NOTE: Resolving any missing task queue dependencies
  1744. Build Configuration:
  1745. .
  1746. .
  1747. .
  1748. NOTE: Executing SetScene Tasks
  1749. NOTE: Executing RunQueue Tasks
  1750. WARNING: linux-yocto-4.12.12+gitAUTOINC+eda4d18ce4_16de014967-r0 do_kernel_configcheck:
  1751. [kernel config]: specified values did not make it into the kernel's final configuration:
  1752. ---------- CONFIG_X86_TSC -----------------
  1753. Config: CONFIG_X86_TSC
  1754. From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc-cpu.cfg
  1755. Requested value: CONFIG_X86_TSC=y
  1756. Actual value:
  1757. ---------- CONFIG_X86_BIGSMP -----------------
  1758. Config: CONFIG_X86_BIGSMP
  1759. From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg
  1760. /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig
  1761. Requested value: # CONFIG_X86_BIGSMP is not set
  1762. Actual value:
  1763. ---------- CONFIG_NR_CPUS -----------------
  1764. Config: CONFIG_NR_CPUS
  1765. From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg
  1766. /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/bsp/common-pc/common-pc.cfg
  1767. /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig
  1768. Requested value: CONFIG_NR_CPUS=8
  1769. Actual value: CONFIG_NR_CPUS=1
  1770. ---------- CONFIG_SCHED_SMT -----------------
  1771. Config: CONFIG_SCHED_SMT
  1772. From: /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/cfg/smp.cfg
  1773. /home/scottrif/poky/build/tmp/work-shared/qemux86/kernel-source/.kernel-meta/configs/standard/defconfig
  1774. Requested value: CONFIG_SCHED_SMT=y
  1775. Actual value:
  1776. NOTE: Tasks Summary: Attempted 288 tasks of which 285 didn't need to be rerun and all succeeded.
  1777. Summary: There were 3 WARNING messages shown.
  1778. </literallayout>
  1779. <note>
  1780. The previous output example has artificial line breaks
  1781. to make it more readable.
  1782. </note>
  1783. </para>
  1784. <para>
  1785. The output describes the various problems that you can
  1786. encounter along with where to find the offending configuration
  1787. items.
  1788. You can use the information in the logs to adjust your
  1789. configuration files and then repeat the
  1790. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configme'><filename>do_kernel_configme</filename></ulink>
  1791. and
  1792. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-kernel_configcheck'><filename>do_kernel_configcheck</filename></ulink>
  1793. tasks until they produce no warnings.
  1794. </para>
  1795. <para>
  1796. For more information on how to use the
  1797. <filename>menuconfig</filename> tool, see the
  1798. "<link linkend='using-menuconfig'>Using <filename>menuconfig</filename></link>"
  1799. section.
  1800. </para>
  1801. </section>
  1802. <section id='fine-tuning-the-kernel-configuration-file'>
  1803. <title>Fine-Tuning the Kernel Configuration File</title>
  1804. <para>
  1805. You can make sure the <filename>.config</filename> file is as
  1806. lean or efficient as possible by reading the output of the
  1807. kernel configuration fragment audit, noting any issues, making
  1808. changes to correct the issues, and then repeating.
  1809. </para>
  1810. <para>
  1811. As part of the kernel build process, the
  1812. <filename>do_kernel_configcheck</filename> task runs.
  1813. This task validates the kernel configuration by checking the
  1814. final <filename>.config</filename> file against the input
  1815. files.
  1816. During the check, the task produces warning messages for the
  1817. following issues:
  1818. <itemizedlist>
  1819. <listitem><para>
  1820. Requested options that did not make the final
  1821. <filename>.config</filename> file.
  1822. </para></listitem>
  1823. <listitem><para>
  1824. Configuration items that appear twice in the same
  1825. configuration fragment.
  1826. </para></listitem>
  1827. <listitem><para>
  1828. Configuration items tagged as "required" that were
  1829. overridden.
  1830. </para></listitem>
  1831. <listitem><para>
  1832. A board overrides a non-board specific option.
  1833. </para></listitem>
  1834. <listitem><para>
  1835. Listed options not valid for the kernel being
  1836. processed.
  1837. In other words, the option does not appear anywhere.
  1838. </para></listitem>
  1839. </itemizedlist>
  1840. <note>
  1841. The <filename>do_kernel_configcheck</filename> task can
  1842. also optionally report if an option is overridden during
  1843. processing.
  1844. </note>
  1845. </para>
  1846. <para>
  1847. For each output warning, a message points to the file
  1848. that contains a list of the options and a pointer to the
  1849. configuration fragment that defines them.
  1850. Collectively, the files are the key to streamlining the
  1851. configuration.
  1852. </para>
  1853. <para>
  1854. To streamline the configuration, do the following:
  1855. <orderedlist>
  1856. <listitem><para>
  1857. <emphasis>Use a Working Configuration:</emphasis>
  1858. Start with a full configuration that you
  1859. know works.
  1860. Be sure the configuration builds and boots
  1861. successfully.
  1862. Use this configuration file as your baseline.
  1863. </para></listitem>
  1864. <listitem><para>
  1865. <emphasis>Run Configure and Check Tasks:</emphasis>
  1866. Separately run the
  1867. <filename>do_kernel_configme</filename> and
  1868. <filename>do_kernel_configcheck</filename> tasks:
  1869. <literallayout class='monospaced'>
  1870. $ bitbake linux-yocto -c kernel_configme -f
  1871. $ bitbake linux-yocto -c kernel_configcheck -f
  1872. </literallayout>
  1873. </para></listitem>
  1874. <listitem><para>
  1875. <emphasis>Process the Results:</emphasis>
  1876. Take the resulting list of files from the
  1877. <filename>do_kernel_configcheck</filename> task
  1878. warnings and do the following:
  1879. <itemizedlist>
  1880. <listitem><para>
  1881. Drop values that are redefined in the fragment
  1882. but do not change the final
  1883. <filename>.config</filename> file.
  1884. </para></listitem>
  1885. <listitem><para>
  1886. Analyze and potentially drop values from the
  1887. <filename>.config</filename> file that override
  1888. required configurations.
  1889. </para></listitem>
  1890. <listitem><para>
  1891. Analyze and potentially remove non-board
  1892. specific options.
  1893. </para></listitem>
  1894. <listitem><para>
  1895. Remove repeated and invalid options.
  1896. </para></listitem>
  1897. </itemizedlist>
  1898. </para></listitem>
  1899. <listitem><para>
  1900. <emphasis>Re-Run Configure and Check Tasks:</emphasis>
  1901. After you have worked through the output of the kernel
  1902. configuration audit, you can re-run the
  1903. <filename>do_kernel_configme</filename> and
  1904. <filename>do_kernel_configcheck</filename> tasks to
  1905. see the results of your changes.
  1906. If you have more issues, you can deal with them as
  1907. described in the previous step.
  1908. </para></listitem>
  1909. </orderedlist>
  1910. </para>
  1911. <para>
  1912. Iteratively working through steps two through four eventually
  1913. yields a minimal, streamlined configuration file.
  1914. Once you have the best <filename>.config</filename>, you can
  1915. build the Linux Yocto kernel.
  1916. </para>
  1917. </section>
  1918. </section>
  1919. <section id='expanding-variables'>
  1920. <title>Expanding Variables</title>
  1921. <para>
  1922. Sometimes it is helpful to determine what a variable expands
  1923. to during a build.
  1924. You can do examine the values of variables by examining the
  1925. output of the <filename>bitbake -e</filename> command.
  1926. The output is long and is more easily managed in a text file,
  1927. which allows for easy searches:
  1928. <literallayout class='monospaced'>
  1929. $ bitbake -e virtual/kernel > <replaceable>some_text_file</replaceable>
  1930. </literallayout>
  1931. Within the text file, you can see exactly how each variable is
  1932. expanded and used by the OpenEmbedded build system.
  1933. </para>
  1934. </section>
  1935. <section id='working-with-a-dirty-kernel-version-string'>
  1936. <title>Working with a "Dirty" Kernel Version String</title>
  1937. <para>
  1938. If you build a kernel image and the version string has a
  1939. "+" or a "-dirty" at the end, uncommitted modifications exist
  1940. in the kernel's source directory.
  1941. Follow these steps to clean up the version string:
  1942. <orderedlist>
  1943. <listitem><para>
  1944. <emphasis>Discover the Uncommitted Changes:</emphasis>
  1945. Go to the kernel's locally cloned Git repository
  1946. (source directory) and use the following Git command
  1947. to list the files that have been changed, added, or
  1948. removed:
  1949. <literallayout class='monospaced'>
  1950. $ git status
  1951. </literallayout>
  1952. </para></listitem>
  1953. <listitem><para>
  1954. <emphasis>Commit the Changes:</emphasis>
  1955. You should commit those changes to the kernel source
  1956. tree regardless of whether or not you will save,
  1957. export, or use the changes:
  1958. <literallayout class='monospaced'>
  1959. $ git add
  1960. $ git commit -s -a -m "getting rid of -dirty"
  1961. </literallayout>
  1962. </para></listitem>
  1963. <listitem><para>
  1964. <emphasis>Rebuild the Kernel Image:</emphasis>
  1965. Once you commit the changes, rebuild the kernel.</para>
  1966. <para>Depending on your particular kernel development
  1967. workflow, the commands you use to rebuild the
  1968. kernel might differ.
  1969. For information on building the kernel image when
  1970. using <filename>devtool</filename>, see the
  1971. "<link linkend='using-devtool-to-patch-the-kernel'>Using <filename>devtool</filename> to Patch the Kernel</link>"
  1972. section.
  1973. For information on building the kernel image when
  1974. using Bitbake, see the
  1975. "<link linkend='using-traditional-kernel-development-to-patch-the-kernel'>Using Traditional Kernel Development to Patch the Kernel</link>"
  1976. section.
  1977. </para></listitem>
  1978. </orderedlist>
  1979. </para>
  1980. </section>
  1981. <section id='working-with-your-own-sources'>
  1982. <title>Working With Your Own Sources</title>
  1983. <para>
  1984. If you cannot work with one of the Linux kernel
  1985. versions supported by existing linux-yocto recipes, you can
  1986. still make use of the Yocto Project Linux kernel tooling by
  1987. working with your own sources.
  1988. When you use your own sources, you will not be able to
  1989. leverage the existing kernel
  1990. <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink> and
  1991. stabilization work of the linux-yocto sources.
  1992. However, you will be able to manage your own Metadata in the same
  1993. format as the linux-yocto sources.
  1994. Maintaining format compatibility facilitates converging with
  1995. linux-yocto on a future, mutually-supported kernel version.
  1996. </para>
  1997. <para>
  1998. To help you use your own sources, the Yocto Project provides a
  1999. linux-yocto custom recipe
  2000. (<filename>linux-yocto-custom.bb</filename>) that uses
  2001. <filename>kernel.org</filename> sources
  2002. and the Yocto Project Linux kernel tools for managing
  2003. kernel Metadata.
  2004. You can find this recipe in the
  2005. <filename>poky</filename> Git repository of the
  2006. Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink>
  2007. at:
  2008. <literallayout class="monospaced">
  2009. poky/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb
  2010. </literallayout>
  2011. </para>
  2012. <para>
  2013. Here are some basic steps you can use to work with your own
  2014. sources:
  2015. <orderedlist>
  2016. <listitem><para>
  2017. <emphasis>Create a Copy of the Kernel Recipe:</emphasis>
  2018. Copy the <filename>linux-yocto-custom.bb</filename>
  2019. recipe to your layer and give it a meaningful name.
  2020. The name should include the version of the Yocto Linux
  2021. kernel you are using (e.g.
  2022. <filename>linux-yocto-myproject_4.12.bb</filename>,
  2023. where "4.12" is the base version of the Linux kernel
  2024. with which you would be working).
  2025. </para></listitem>
  2026. <listitem><para>
  2027. <emphasis>Create a Directory for Your Patches:</emphasis>
  2028. In the same directory inside your layer, create a matching
  2029. directory to store your patches and configuration files
  2030. (e.g. <filename>linux-yocto-myproject</filename>).
  2031. </para></listitem>
  2032. <listitem><para>
  2033. <emphasis>Ensure You Have Configurations:</emphasis>
  2034. Make sure you have either a <filename>defconfig</filename>
  2035. file or configuration fragment files in your layer.
  2036. When you use the <filename>linux-yocto-custom.bb</filename>
  2037. recipe, you must specify a configuration.
  2038. If you do not have a <filename>defconfig</filename> file,
  2039. you can run the following:
  2040. <literallayout class='monospaced'>
  2041. $ make defconfig
  2042. </literallayout>
  2043. After running the command, copy the resulting
  2044. <filename>.config</filename> file to the
  2045. <filename>files</filename> directory in your layer
  2046. as "defconfig" and then add it to the
  2047. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  2048. variable in the recipe.</para>
  2049. <para>Running the <filename>make defconfig</filename>
  2050. command results in the default configuration for your
  2051. architecture as defined by your kernel.
  2052. However, no guarantee exists that this configuration is
  2053. valid for your use case, or that your board will even boot.
  2054. This is particularly true for non-x86 architectures.</para>
  2055. <para>To use non-x86 <filename>defconfig</filename> files,
  2056. you need to be more specific and find one that matches your
  2057. board (i.e. for arm, you look in
  2058. <filename>arch/arm/configs</filename> and use the one that
  2059. is the best starting point for your board).
  2060. </para></listitem>
  2061. <listitem><para>
  2062. <emphasis>Edit the Recipe:</emphasis>
  2063. Edit the following variables in your recipe as appropriate
  2064. for your project:
  2065. <itemizedlist>
  2066. <listitem><para>
  2067. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>:
  2068. The <filename>SRC_URI</filename> should specify
  2069. a Git repository that uses one of the supported Git
  2070. fetcher protocols (i.e. <filename>file</filename>,
  2071. <filename>git</filename>, <filename>http</filename>,
  2072. and so forth).
  2073. The <filename>SRC_URI</filename> variable should
  2074. also specify either a <filename>defconfig</filename>
  2075. file or some configuration fragment files.
  2076. The skeleton recipe provides an example
  2077. <filename>SRC_URI</filename> as a syntax reference.
  2078. </para></listitem>
  2079. <listitem><para>
  2080. <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_VERSION'><filename>LINUX_VERSION</filename></ulink>:
  2081. The Linux kernel version you are using (e.g.
  2082. "4.12").
  2083. </para></listitem>
  2084. <listitem><para>
  2085. <ulink url='&YOCTO_DOCS_REF_URL;#var-LINUX_VERSION_EXTENSION'><filename>LINUX_VERSION_EXTENSION</filename></ulink>:
  2086. The Linux kernel
  2087. <filename>CONFIG_LOCALVERSION</filename> that is
  2088. compiled into the resulting kernel and visible
  2089. through the <filename>uname</filename> command.
  2090. </para></listitem>
  2091. <listitem><para>
  2092. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink>:
  2093. The commit ID from which you want to build.
  2094. </para></listitem>
  2095. <listitem><para>
  2096. <ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink>:
  2097. Treat this variable the same as you would in any
  2098. other recipe.
  2099. Increment the variable to indicate to the
  2100. OpenEmbedded build system that the recipe has
  2101. changed.
  2102. </para></listitem>
  2103. <listitem><para>
  2104. <ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>:
  2105. The default <filename>PV</filename> assignment is
  2106. typically adequate.
  2107. It combines the <filename>LINUX_VERSION</filename>
  2108. with the Source Control Manager (SCM) revision
  2109. as derived from the
  2110. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCPV'><filename>SRCPV</filename></ulink>
  2111. variable.
  2112. The combined results are a string with the
  2113. following form:
  2114. <literallayout class='monospaced'>
  2115. 3.19.11+git1+68a635bf8dfb64b02263c1ac80c948647cc76d5f_1+218bd8d2022b9852c60d32f0d770931e3cf343e2
  2116. </literallayout>
  2117. While lengthy, the extra verbosity in
  2118. <filename>PV</filename> helps ensure you are using
  2119. the exact sources from which you intend to build.
  2120. </para></listitem>
  2121. <listitem><para>
  2122. <ulink url='&YOCTO_DOCS_REF_URL;#var-COMPATIBLE_MACHINE'><filename>COMPATIBLE_MACHINE</filename></ulink>:
  2123. A list of the machines supported by your new recipe.
  2124. This variable in the example recipe is set
  2125. by default to a regular expression that matches
  2126. only the empty string, "(^$)".
  2127. This default setting triggers an explicit build
  2128. failure.
  2129. You must change it to match a list of the machines
  2130. that your new recipe supports.
  2131. For example, to support the
  2132. <filename>qemux86</filename> and
  2133. <filename>qemux86-64</filename> machines, use
  2134. the following form:
  2135. <literallayout class='monospaced'>
  2136. COMPATIBLE_MACHINE = "qemux86|qemux86-64"
  2137. </literallayout>
  2138. </para></listitem>
  2139. </itemizedlist>
  2140. </para></listitem>
  2141. <listitem><para>
  2142. <emphasis>Customize Your Recipe as Needed:</emphasis>
  2143. Provide further customizations to your recipe
  2144. as needed just as you would customize an existing
  2145. linux-yocto recipe.
  2146. See the
  2147. "<link linkend='modifying-an-existing-recipe'>Modifying an Existing Recipe</link>"
  2148. section for information.
  2149. </para></listitem>
  2150. </orderedlist>
  2151. </para>
  2152. </section>
  2153. <section id='working-with-out-of-tree-modules'>
  2154. <title>Working with Out-of-Tree Modules</title>
  2155. <para>
  2156. This section describes steps to build out-of-tree modules on
  2157. your target and describes how to incorporate out-of-tree modules
  2158. in the build.
  2159. </para>
  2160. <section id='building-out-of-tree-modules-on-the-target'>
  2161. <title>Building Out-of-Tree Modules on the Target</title>
  2162. <para>
  2163. While the traditional Yocto Project development model would be
  2164. to include kernel modules as part of the normal build
  2165. process, you might find it useful to build modules on the
  2166. target.
  2167. This could be the case if your target system is capable
  2168. and powerful enough to handle the necessary compilation.
  2169. Before deciding to build on your target, however, you should
  2170. consider the benefits of using a proper cross-development
  2171. environment from your build host.
  2172. </para>
  2173. <para>
  2174. If you want to be able to build out-of-tree modules on
  2175. the target, there are some steps you need to take
  2176. on the target that is running your SDK image.
  2177. Briefly, the <filename>kernel-dev</filename> package
  2178. is installed by default on all
  2179. <filename>*.sdk</filename> images and the
  2180. <filename>kernel-devsrc</filename> package is installed
  2181. on many of the <filename>*.sdk</filename> images.
  2182. However, you need to create some scripts prior to
  2183. attempting to build the out-of-tree modules on the target
  2184. that is running that image.
  2185. </para>
  2186. <para>
  2187. Prior to attempting to build the out-of-tree modules,
  2188. you need to be on the target as root and you need to
  2189. change to the <filename>/usr/src/kernel</filename> directory.
  2190. Next, <filename>make</filename> the scripts:
  2191. <literallayout class='monospaced'>
  2192. # cd /usr/src/kernel
  2193. # make scripts
  2194. </literallayout>
  2195. Because all SDK image recipes include
  2196. <filename>dev-pkgs</filename>, the
  2197. <filename>kernel-dev</filename> packages will be installed
  2198. as part of the SDK image and the
  2199. <filename>kernel-devsrc</filename> packages will be installed
  2200. as part of applicable SDK images.
  2201. The SDK uses the scripts when building out-of-tree
  2202. modules.
  2203. Once you have switched to that directory and created the
  2204. scripts, you should be able to build your out-of-tree modules
  2205. on the target.
  2206. </para>
  2207. </section>
  2208. <section id='incorporating-out-of-tree-modules'>
  2209. <title>Incorporating Out-of-Tree Modules</title>
  2210. <para>
  2211. While it is always preferable to work with sources integrated
  2212. into the Linux kernel sources, if you need an external kernel
  2213. module, the <filename>hello-mod.bb</filename> recipe is
  2214. available as a template from which you can create your
  2215. own out-of-tree Linux kernel module recipe.
  2216. </para>
  2217. <para>
  2218. This template recipe is located in the
  2219. <filename>poky</filename> Git repository of the
  2220. Yocto Project <ulink url='&YOCTO_GIT_URL;'>Source Repository</ulink>
  2221. at:
  2222. <literallayout class="monospaced">
  2223. poky/meta-skeleton/recipes-kernel/hello-mod/hello-mod_0.1.bb
  2224. </literallayout>
  2225. </para>
  2226. <para>
  2227. To get started, copy this recipe to your layer and give it a
  2228. meaningful name (e.g. <filename>mymodule_1.0.bb</filename>).
  2229. In the same directory, create a new directory named
  2230. <filename>files</filename> where you can store any source files,
  2231. patches, or other files necessary for building
  2232. the module that do not come with the sources.
  2233. Finally, update the recipe as needed for the module.
  2234. Typically, you will need to set the following variables:
  2235. <itemizedlist>
  2236. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DESCRIPTION'><filename>DESCRIPTION</filename></ulink>
  2237. </para></listitem>
  2238. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE*</filename></ulink>
  2239. </para></listitem>
  2240. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  2241. </para></listitem>
  2242. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink>
  2243. </para></listitem>
  2244. </itemizedlist>
  2245. </para>
  2246. <para>
  2247. Depending on the build system used by the module sources,
  2248. you might need to make some adjustments.
  2249. For example, a typical module <filename>Makefile</filename>
  2250. looks much like the one provided with the
  2251. <filename>hello-mod</filename> template:
  2252. <literallayout class='monospaced'>
  2253. obj-m := hello.o
  2254. SRC := $(shell pwd)
  2255. all:
  2256. $(MAKE) -C $(KERNEL_SRC) M=$(SRC)
  2257. modules_install:
  2258. $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
  2259. ...
  2260. </literallayout>
  2261. </para>
  2262. <para>
  2263. The important point to note here is the
  2264. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_SRC'><filename>KERNEL_SRC</filename></ulink>
  2265. variable.
  2266. The
  2267. <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-module'><filename>module</filename></ulink>
  2268. class sets this variable and the
  2269. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_PATH'><filename>KERNEL_PATH</filename></ulink>
  2270. variable to
  2271. <filename>${<ulink url='&YOCTO_DOCS_REF_URL;#var-STAGING_KERNEL_DIR'><filename>STAGING_KERNEL_DIR</filename></ulink>}</filename>
  2272. with the necessary Linux kernel build information to build
  2273. modules.
  2274. If your module <filename>Makefile</filename> uses a different
  2275. variable, you might want to override the
  2276. <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink>
  2277. step, or create a patch to
  2278. the <filename>Makefile</filename> to work with the more typical
  2279. <filename>KERNEL_SRC</filename> or
  2280. <filename>KERNEL_PATH</filename> variables.
  2281. </para>
  2282. <para>
  2283. After you have prepared your recipe, you will likely want to
  2284. include the module in your images.
  2285. To do this, see the documentation for the following variables in
  2286. the Yocto Project Reference Manual and set one of them
  2287. appropriately for your machine configuration file:
  2288. <itemizedlist>
  2289. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RDEPENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RDEPENDS</filename></ulink>
  2290. </para></listitem>
  2291. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS'><filename>MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS</filename></ulink>
  2292. </para></listitem>
  2293. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RDEPENDS'><filename>MACHINE_EXTRA_RDEPENDS</filename></ulink>
  2294. </para></listitem>
  2295. <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE_EXTRA_RRECOMMENDS'><filename>MACHINE_EXTRA_RRECOMMENDS</filename></ulink>
  2296. </para></listitem>
  2297. </itemizedlist>
  2298. </para>
  2299. <para>
  2300. Modules are often not required for boot and can be excluded from
  2301. certain build configurations.
  2302. The following allows for the most flexibility:
  2303. <literallayout class='monospaced'>
  2304. MACHINE_EXTRA_RRECOMMENDS += "kernel-module-mymodule"
  2305. </literallayout>
  2306. The value is derived by appending the module filename without
  2307. the <filename>.ko</filename> extension to the string
  2308. "kernel-module-".
  2309. </para>
  2310. <para>
  2311. Because the variable is
  2312. <ulink url='&YOCTO_DOCS_REF_URL;#var-RRECOMMENDS'><filename>RRECOMMENDS</filename></ulink>
  2313. and not a
  2314. <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink>
  2315. variable, the build will not fail if this module is not
  2316. available to include in the image.
  2317. </para>
  2318. </section>
  2319. </section>
  2320. <section id='inspecting-changes-and-commits'>
  2321. <title>Inspecting Changes and Commits</title>
  2322. <para>
  2323. A common question when working with a kernel is:
  2324. "What changes have been applied to this tree?"
  2325. Rather than using "grep" across directories to see what has
  2326. changed, you can use Git to inspect or search the kernel tree.
  2327. Using Git is an efficient way to see what has changed in the tree.
  2328. </para>
  2329. <section id='what-changed-in-a-kernel'>
  2330. <title>What Changed in a Kernel?</title>
  2331. <para>
  2332. Following are a few examples that show how to use Git
  2333. commands to examine changes.
  2334. These examples are by no means the only way to see changes.
  2335. <note>
  2336. In the following examples, unless you provide a commit
  2337. range, <filename>kernel.org</filename> history is blended
  2338. with Yocto Project kernel changes.
  2339. You can form ranges by using branch names from the
  2340. kernel tree as the upper and lower commit markers with
  2341. the Git commands.
  2342. You can see the branch names through the web interface
  2343. to the Yocto Project source repositories at
  2344. <ulink url='&YOCTO_GIT_URL;'></ulink>.
  2345. </note>
  2346. To see a full range of the changes, use the
  2347. <filename>git whatchanged</filename> command and specify a
  2348. commit range for the branch
  2349. (<replaceable>commit</replaceable><filename>..</filename><replaceable>commit</replaceable>).
  2350. </para>
  2351. <para>
  2352. Here is an example that looks at what has changed in the
  2353. <filename>emenlow</filename> branch of the
  2354. <filename>linux-yocto-3.19</filename> kernel.
  2355. The lower commit range is the commit associated with the
  2356. <filename>standard/base</filename> branch, while
  2357. the upper commit range is the commit associated with the
  2358. <filename>standard/emenlow</filename> branch.
  2359. <literallayout class='monospaced'>
  2360. $ git whatchanged origin/standard/base..origin/standard/emenlow
  2361. </literallayout>
  2362. </para>
  2363. <para>
  2364. To see short, one line summaries of changes use the
  2365. <filename>git log</filename> command:
  2366. <literallayout class='monospaced'>
  2367. $ git log --oneline origin/standard/base..origin/standard/emenlow
  2368. </literallayout>
  2369. </para>
  2370. <para>
  2371. Use this command to see code differences for the changes:
  2372. <literallayout class='monospaced'>
  2373. $ git diff origin/standard/base..origin/standard/emenlow
  2374. </literallayout>
  2375. </para>
  2376. <para>
  2377. Use this command to see the commit log messages and the
  2378. text differences:
  2379. <literallayout class='monospaced'>
  2380. $ git show origin/standard/base..origin/standard/emenlow
  2381. </literallayout>
  2382. </para>
  2383. <para>
  2384. Use this command to create individual patches for
  2385. each change.
  2386. Here is an example that that creates patch files for each
  2387. commit and places them in your <filename>Documents</filename>
  2388. directory:
  2389. <literallayout class='monospaced'>
  2390. $ git format-patch -o $HOME/Documents origin/standard/base..origin/standard/emenlow
  2391. </literallayout>
  2392. </para>
  2393. </section>
  2394. <section id='showing-a-particular-feature-or-branch-change'>
  2395. <title>Showing a Particular Feature or Branch Change</title>
  2396. <para>
  2397. Tags in the Yocto Project kernel tree divide changes for
  2398. significant features or branches.
  2399. The <filename>git show</filename>&nbsp;<replaceable>tag</replaceable>
  2400. command shows changes based on a tag.
  2401. Here is an example that shows <filename>systemtap</filename>
  2402. changes:
  2403. <literallayout class='monospaced'>
  2404. $ git show systemtap
  2405. </literallayout>
  2406. You can use the
  2407. <filename>git branch --contains</filename>&nbsp;<replaceable>tag</replaceable>
  2408. command to show the branches that contain a particular feature.
  2409. This command shows the branches that contain the
  2410. <filename>systemtap</filename> feature:
  2411. <literallayout class='monospaced'>
  2412. $ git branch --contains systemtap
  2413. </literallayout>
  2414. </para>
  2415. </section>
  2416. </section>
  2417. <section id='adding-recipe-space-kernel-features'>
  2418. <title>Adding Recipe-Space Kernel Features</title>
  2419. <para>
  2420. You can add kernel features in the
  2421. <link linkend='recipe-space-metadata'>recipe-space</link> by
  2422. using the
  2423. <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_FEATURES'><filename>KERNEL_FEATURES</filename></ulink>
  2424. variable and by specifying the feature's <filename>.scc</filename>
  2425. file path in the
  2426. <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink>
  2427. statement.
  2428. When you add features using this method, the OpenEmbedded build
  2429. system checks to be sure the features are present.
  2430. If the features are not present, the build stops.
  2431. Kernel features are the last elements processed for configuring
  2432. and patching the kernel.
  2433. Therefore, adding features in this manner is a way
  2434. to enforce specific features are present and enabled
  2435. without needing to do a full audit of any other layer's additions
  2436. to the <filename>SRC_URI</filename> statement.
  2437. </para>
  2438. <para>
  2439. You add a kernel feature by providing the feature as part of the
  2440. <filename>KERNEL_FEATURES</filename> variable and by providing the
  2441. path to the feature's <filename>.scc</filename> file, which is
  2442. relative to the root of the kernel Metadata.
  2443. The OpenEmbedded build system searches all forms of kernel
  2444. Metadata on the <filename>SRC_URI</filename> statement regardless
  2445. of whether the Metadata is in the "kernel-cache", system kernel
  2446. Metadata, or a recipe-space Metadata (i.e. part of the kernel
  2447. recipe).
  2448. See the
  2449. "<link linkend='kernel-metadata-location'>Kernel Metadata Location</link>"
  2450. section for additional information.
  2451. </para>
  2452. <para>
  2453. When you specify the feature's <filename>.scc</filename> file
  2454. on the <filename>SRC_URI</filename> statement, the OpenEmbedded
  2455. build system adds the directory of that
  2456. <filename>.scc</filename> file along with all its subdirectories
  2457. to the kernel feature search path.
  2458. Because subdirectories are searched, you can reference a single
  2459. <filename>.scc</filename> file in the
  2460. <filename>SRC_URI</filename> statement to reference multiple kernel
  2461. features.
  2462. </para>
  2463. <para>
  2464. Consider the following example that adds the "test.scc" feature
  2465. to the build.
  2466. <orderedlist>
  2467. <listitem><para>
  2468. <emphasis>Create the Feature File:</emphasis>
  2469. Create a <filename>.scc</filename> file and locate it
  2470. just as you would any other patch file,
  2471. <filename>.cfg</filename> file, or fetcher item
  2472. you specify in the <filename>SRC_URI</filename>
  2473. statement.
  2474. <note><title>Notes</title>
  2475. <itemizedlist>
  2476. <listitem><para>
  2477. You must add the directory of the
  2478. <filename>.scc</filename> file to the fetcher's
  2479. search path in the same manner as you would
  2480. add a <filename>.patch</filename> file.
  2481. </para></listitem>
  2482. <listitem><para>
  2483. You can create additional
  2484. <filename>.scc</filename> files beneath the
  2485. directory that contains the file you are
  2486. adding.
  2487. All subdirectories are searched during the
  2488. build as potential feature directories.
  2489. </para></listitem>
  2490. </itemizedlist>
  2491. </note>
  2492. Continuing with the example, suppose the "test.scc"
  2493. feature you are adding has a
  2494. <filename>test.scc</filename> file in the following
  2495. directory:
  2496. <literallayout class='monospaced'>
  2497. <replaceable>my_recipe</replaceable>
  2498. |
  2499. +-linux-yocto
  2500. |
  2501. +-test.cfg
  2502. +-test.scc
  2503. </literallayout>
  2504. In this example, the <filename>linux-yocto</filename>
  2505. directory has both the feature
  2506. <filename>test.scc</filename> file and a similarly
  2507. named configuration fragment file
  2508. <filename>test.cfg</filename>.
  2509. </para></listitem>
  2510. <listitem><para>
  2511. <emphasis>Add the Feature File to <filename>SRC_URI</filename>:</emphasis>
  2512. Add the <filename>.scc</filename> file to the
  2513. recipe's <filename>SRC_URI</filename> statement:
  2514. <literallayout class='monospaced'>
  2515. SRC_URI_append = " file://test.scc"
  2516. </literallayout>
  2517. The leading space before the path is important as the
  2518. path is appended to the existing path.
  2519. </para></listitem>
  2520. <listitem><para>
  2521. <emphasis>Specify the Feature as a Kernel Feature:</emphasis>
  2522. Use the <filename>KERNEL_FEATURES</filename> statement
  2523. to specify the feature as a kernel feature:
  2524. <literallayout class='monospaced'>
  2525. KERNEL_FEATURES_append = " test.scc"
  2526. </literallayout>
  2527. The OpenEmbedded build system processes the kernel feature
  2528. when it builds the kernel.
  2529. <note>
  2530. If other features are contained below "test.scc",
  2531. then their directories are relative to the directory
  2532. containing the <filename>test.scc</filename> file.
  2533. </note>
  2534. </para></listitem>
  2535. </orderedlist>
  2536. </para>
  2537. </section>
  2538. </chapter>
  2539. <!--
  2540. vim: expandtab tw=80 ts=4
  2541. -->