what-i-wish-id-known.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. =========================================
  3. What I wish I'd known about Yocto Project
  4. =========================================
  5. |
  6. .. note::
  7. Before reading further, make sure you've taken a look at the
  8. :yocto_home:`Software Overview</software-overview>` page which presents the
  9. definitions for many of the terms referenced here. Also, know that some of the
  10. information here won't make sense now, but as you start developing, it is the
  11. information you'll want to keep close at hand. These are best known methods for
  12. working with Yocto Project and they are updated regularly.
  13. Using the Yocto Project is fairly easy, *until something goes wrong*. Without an
  14. understanding of how the build process works, you'll find yourself trying to
  15. troubleshoot "a black box". Here are a few items that new users wished they had
  16. known before embarking on their first build with Yocto Project. Feel free to
  17. contact us with other suggestions.
  18. #. **Use Git, not the tarball download:**
  19. If you use git the software will be automatically updated with bug updates
  20. because of how git works. If you download the tarball instead, you will need
  21. to be responsible for your own updates.
  22. #. **Get to know the layer index:**
  23. All layers can be found in the :oe_layerindex:`layer index <>`. Layers which
  24. have applied for Yocto Project Compatible status (structure continuity
  25. assurance and testing) can be found in the :yocto_home:`Yocto Project Compatible index
  26. </software-over/layer/>`. Generally check the Compatible layer index first,
  27. and if you don't find the necessary layer check the general layer index. The
  28. layer index is an original artifact from the Open Embedded Project. As such,
  29. that index doesn't have the curating and testing that the Yocto Project
  30. provides on Yocto Project Compatible layer list, but the latter has fewer
  31. entries. Know that when you start searching in the layer index that not all
  32. layers have the same level of maturity, validation, or usability. Nor do
  33. searches prioritize displayed results. There is no easy way to help you
  34. through the process of choosing the best layer to suit your needs.
  35. Consequently, it is often trial and error, checking the mailing lists, or
  36. working with other developers through collaboration rooms that can help you
  37. make good choices.
  38. #. **Use existing BSP layers from silicon vendors when possible:**
  39. Intel, TI, NXP and others have information on what BSP layers to use with
  40. their silicon. These layers have names such as "meta-intel" or "meta-ti". Try
  41. not to build layers from scratch. If you do have custom silicon, use one of
  42. these layers as a guide or template and familiarize yourself with the
  43. :doc:`bsp-guide/index`.
  44. #. **Do not put everything into one layer:**
  45. Use different layers to logically separate information in your build. As an
  46. example, you could have a BSP layer, a GUI layer, a distro configuration,
  47. middleware, or an application (e.g. "meta-filesystems", "meta-python",
  48. "meta-intel", and so forth). Putting your entire build into one layer limits
  49. and complicates future customization and reuse. Isolating information into
  50. layers, on the other hand, helps keep simplify future customizations and
  51. reuse.
  52. #. **Never modify the POKY layer. Never. Ever. When you update to the next
  53. release, you'll lose all of your work. ALL OF IT.**
  54. #. **Don't be fooled by documentation searching results:**
  55. Yocto Project documentation is always being updated. Unfortunately, when you
  56. use Google to search for Yocto Project concepts or terms, Google consistently
  57. searches and retrieves older versions of Yocto Project manuals. For example,
  58. searching for a particular topic using Google could result in a "hit" on a
  59. Yocto Project manual that is several releases old. To be sure that you are
  60. using the most current Yocto Project documentation, use the drop-down menu at
  61. the top of any of its page.
  62. Many developers look through the :yocto_docs:`All-in-one 'Mega' Manual </singleindex.html>`
  63. for a concept or term by doing a search through the whole page. This manual
  64. is a concatenation of the core set of Yocto Project manual. Thus, a simple
  65. string search using Ctrl-F in this manual produces all the "hits" for a
  66. desired term or concept. Once you find the area in which you are
  67. interested, you can display the actual manual, if desired. It is also
  68. possible to use the search bar in the menu or in the left navigation pane.
  69. #. **Understand the basic concepts of how the build system works: the workflow:**
  70. Understanding the Yocto Project workflow is important as it can help you both
  71. pinpoint where trouble is occurring and how the build is breaking. The
  72. workflow breaks down into the following steps:
  73. #. Fetch – get the source code
  74. #. Extract – unpack the sources
  75. #. Patch – apply patches for bug fixes and new capability
  76. #. Configure – set up your environment specifications
  77. #. Build – compile and link
  78. #. Install – copy files to target directories
  79. #. Package – bundle files for installation
  80. During "fetch", there may be an inability to find code. During "extract",
  81. there is likely an invalid zip or something similar. In other words, the
  82. function of a particular part of the workflow gives you an idea of what might
  83. be going wrong.
  84. .. image:: figures/yp-how-it-works-new-diagram.png
  85. :width: 100%
  86. #. **Know that you can generate a dependency graph and learn how to do it:**
  87. A dependency graph shows dependencies between recipes, tasks, and targets.
  88. You can use the "-g" option with BitBake to generate this graph. When you
  89. start a build and the build breaks, you could see packages you have no clue
  90. about or have any idea why the build system has included them. The
  91. dependency graph can clarify that confusion. You can learn more about
  92. dependency graphs and how to generate them in the
  93. :ref:`bitbake-user-manual/bitbake-user-manual-intro:generating dependency
  94. graphs` section in the BitBake User Manual.
  95. #. **Here's how you decode "magic" folder names in tmp/work:**
  96. The build system fetches, unpacks, preprocesses, and builds. If something
  97. goes wrong, the build system reports to you directly the path to a folder
  98. where the temporary (build/tmp) files and packages reside resulting from the
  99. build. For a detailed example of this process, see the :yocto_wiki:`example
  100. </Cookbook:Example:Adding_packages_to_your_OS_image>`. Unfortunately this
  101. example is on an earlier release of Yocto Project.
  102. When you perform a build, you can use the "-u" BitBake command-line option to
  103. specify a user interface viewer into the dependency graph (e.g. knotty,
  104. ncurses, or taskexp) that helps you understand the build dependencies better.
  105. #. **You can build more than just images:**
  106. You can build and run a specific task for a specific package (including
  107. devshell) or even a single recipe. When developers first start using the
  108. Yocto Project, the instructions found in the
  109. :doc:`brief-yoctoprojectqs/index` show how to create an image
  110. and then run or flash that image. However, you can actually build just a
  111. single recipe. Thus, if some dependency or recipe isn't working, you can just
  112. say "bitbake foo" where "foo" is the name for a specific recipe. As you
  113. become more advanced using the Yocto Project, and if builds are failing, it
  114. can be useful to make sure the fetch itself works as desired. Here are some
  115. valuable links: :ref:`dev-manual/development-shell:Using a Development
  116. Shell` for information on how to build and run a specific task using
  117. devshell. Also, the :ref:`SDK manual shows how to build out a specific recipe
  118. <sdk-manual/extensible:use \`\`devtool modify\`\` to modify the source of an existing component>`.
  119. #. **An ambiguous definition: Package vs Recipe:**
  120. A recipe contains instructions the build system uses to create
  121. packages. Recipes and Packages are the difference between the front end and
  122. the result of the build process.
  123. As mentioned, the build system takes the recipe and creates packages from the
  124. recipe's instructions. The resulting packages are related to the one thing
  125. the recipe is building but are different parts (packages) of the build
  126. (i.e. the main package, the doc package, the debug symbols package, the
  127. separate utilities package, and so forth). The build system splits out the
  128. packages so that you don't need to install the packages you don't want or
  129. need, which is advantageous because you are building for small devices when
  130. developing for embedded and IoT.
  131. #. **You will want to learn about and know what's packaged in the root filesystem.**
  132. #. **Create your own image recipe:**
  133. There are a number of ways to create your own image recipe. We suggest you
  134. create your own image recipe as opposed to appending an existing recipe. It
  135. is trivial and easy to write an image recipe. Again, do not try appending to
  136. an existing image recipe. Create your own and do it right from the start.
  137. #. **Finally, here is a list of the basic skills you will need as a systems
  138. developer. You must be able to:**
  139. * deal with corporate proxies
  140. * add a package to an image
  141. * understand the difference between a recipe and package
  142. * build a package by itself and why that's useful
  143. * find out what packages are created by a recipe
  144. * find out what files are in a package
  145. * find out what files are in an image
  146. * add an ssh server to an image (enable transferring of files to target)
  147. * know the anatomy of a recipe
  148. * know how to create and use layers
  149. * find recipes (with the :oe_layerindex:`OpenEmbedded Layer index <>`)
  150. * understand difference between machine and distro settings
  151. * find and use the right BSP (machine) for your hardware
  152. * find examples of distro features and know where to set them
  153. * understanding the task pipeline and executing individual tasks
  154. * understand devtool and how it simplifies your workflow
  155. * improve build speeds with shared downloads and shared state cache
  156. * generate and understand a dependency graph
  157. * generate and understand BitBake environment
  158. * build an Extensible SDK for applications development
  159. #. **Depending on what you primary interests are with the Yocto Project, you
  160. could consider any of the following reading:**
  161. * **Look Through the Yocto Project Development Tasks Manual**: This manual
  162. contains procedural information grouped to help you get set up, work with
  163. layers, customize images, write new recipes, work with libraries, and use
  164. QEMU. The information is task-based and spans the breadth of the Yocto
  165. Project. See the :doc:`/dev-manual/index`.
  166. * **Look Through the Yocto Project Application Development and the Extensible
  167. Software Development Kit (eSDK) manual**: This manual describes how to use
  168. both the standard SDK and the extensible SDK, which are used primarily for
  169. application development. The :doc:`/sdk-manual/extensible` also provides
  170. example workflows that use devtool. See the section
  171. :ref:`sdk-manual/extensible:using \`\`devtool\`\` in your sdk workflow`
  172. for more information.
  173. * **Learn About Kernel Development**: If you want to see how to work with the
  174. kernel and understand Yocto Linux kernels, see the :doc:`/kernel-dev/index`.
  175. This manual provides information on how to patch the kernel, modify kernel
  176. recipes, and configure the kernel.
  177. * **Learn About Board Support Packages (BSPs)**: If you want to learn about
  178. BSPs, see the :doc:`/bsp-guide/index`. This manual also provides an
  179. example BSP creation workflow. See the :doc:`/bsp-guide/bsp` section.
  180. * **Learn About Toaster**: Toaster is a web interface to the Yocto Project's
  181. OpenEmbedded build system. If you are interested in using this type of
  182. interface to create images, see the :doc:`/toaster-manual/index`.
  183. * **Have Available the Yocto Project Reference Manual**: Unlike the rest of
  184. the Yocto Project manual set, this manual is comprised of material suited
  185. for reference rather than procedures. You can get build details, a closer
  186. look at how the pieces of the Yocto Project development environment work
  187. together, information on various technical details, guidance on migrating
  188. to a newer Yocto Project release, reference material on the directory
  189. structure, classes, and tasks. The :doc:`/ref-manual/index` also
  190. contains a fairly comprehensive glossary of variables used within the Yocto
  191. Project.
  192. .. include:: /boilerplate.rst