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