xref: /OK3568_Linux_fs/yocto/poky/documentation/transitioning-to-a-custom-environment.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=============================================================
4*4882a593SmuzhiyunTransitioning to a custom environment for systems development
5*4882a593Smuzhiyun=============================================================
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun|
8*4882a593Smuzhiyun
9*4882a593Smuzhiyun.. note::
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun   So you've finished the :doc:`brief-yoctoprojectqs/index` and
12*4882a593Smuzhiyun   glanced over the document :doc:`what-i-wish-id-known`, the latter contains
13*4882a593Smuzhiyun   important information learned from other users. You're well prepared. But
14*4882a593Smuzhiyun   now, as you are starting your own project, it isn't exactly straightforward what
15*4882a593Smuzhiyun   to do. And, the documentation is daunting. We've put together a few hints to
16*4882a593Smuzhiyun   get you started.
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun#. **Make a list of the processor, target board, technologies, and capabilities
19*4882a593Smuzhiyun   that will be part of your project**.
20*4882a593Smuzhiyun   You will be finding layers with recipes and other metadata that support these
21*4882a593Smuzhiyun   things, and adding them to your configuration. (See #3)
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun#. **Set up your board support**.
24*4882a593Smuzhiyun   Even if you're using custom hardware, it might be easier to start with an
25*4882a593Smuzhiyun   existing target board that uses the same processor or at least the same
26*4882a593Smuzhiyun   architecture as your custom hardware. Knowing the board already has a
27*4882a593Smuzhiyun   functioning Board Support Package (BSP) within the project makes it easier
28*4882a593Smuzhiyun   for you to get comfortable with project concepts.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun#. **Find and acquire the best BSP for your target**.
31*4882a593Smuzhiyun   Use the :yocto_home:`Yocto Project curated layer index
32*4882a593Smuzhiyun   </software-overview/layers/>` or even the :oe_layerindex:`OpenEmbedded
33*4882a593Smuzhiyun   layer index <>` to find and acquire the best BSP for your
34*4882a593Smuzhiyun   target board. The Yocto Project layer index BSPs are regularly validated. The
35*4882a593Smuzhiyun   best place to get your first BSP is from your silicon manufacturer or board
36*4882a593Smuzhiyun   vendor – they can point you to their most qualified efforts. In general, for
37*4882a593Smuzhiyun   Intel silicon use meta-intel, for Texas Instruments use meta-ti, and so
38*4882a593Smuzhiyun   forth. Choose a BSP that has been tested with the same Yocto Project release
39*4882a593Smuzhiyun   that you've downloaded. Be aware that some BSPs may not be immediately
40*4882a593Smuzhiyun   supported on the very latest release, but they will be eventually.
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun   You might want to start with the build specification that Poky provides
43*4882a593Smuzhiyun   (which is reference embedded distribution) and then add your newly chosen
44*4882a593Smuzhiyun   layers to that. Here is the information :ref:`about adding layers
45*4882a593Smuzhiyun   <dev-manual/common-tasks:Understanding and Creating Layers>`.
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun#. **Based on the layers you've chosen, make needed changes in your
48*4882a593Smuzhiyun   configuration**.
49*4882a593Smuzhiyun   For instance, you've chosen a machine type and added in the corresponding BSP
50*4882a593Smuzhiyun   layer. You'll then need to change the value of the :term:`MACHINE` variable in your
51*4882a593Smuzhiyun   configuration file (build/local.conf) to point to that same machine
52*4882a593Smuzhiyun   type. There could be other layer-specific settings you need to change as
53*4882a593Smuzhiyun   well. Each layer has a ``README`` document that you can look at for this type of
54*4882a593Smuzhiyun   usage information.
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun#. **Add a new layer for any custom recipes and metadata you create**.
57*4882a593Smuzhiyun   Use the ``bitbake-layers create-layer`` tool for Yocto Project 2.4+
58*4882a593Smuzhiyun   releases. If you are using a Yocto Project release earlier than 2.4, use the
59*4882a593Smuzhiyun   ``yocto-layer create`` tool. The ``bitbake-layers`` tool also provides a number
60*4882a593Smuzhiyun   of other useful layer-related commands. See
61*4882a593Smuzhiyun   :ref:`dev-manual/common-tasks:creating a general layer using the
62*4882a593Smuzhiyun   \`\`bitbake-layers\`\` script` section.
63*4882a593Smuzhiyun
64*4882a593Smuzhiyun#. **Create your own layer for the BSP you're going to use**.
65*4882a593Smuzhiyun   It is not common that you would need to create an entire BSP from scratch
66*4882a593Smuzhiyun   unless you have a *really* special device. Even if you are using an existing
67*4882a593Smuzhiyun   BSP, :ref:`create your own layer for the BSP <bsp-guide/bsp:creating a new
68*4882a593Smuzhiyun   bsp layer using the \`\`bitbake-layers\`\` script>`. For example, given a
69*4882a593Smuzhiyun   64-bit x86-based machine, copy the conf/intel-corei7-64 definition and give
70*4882a593Smuzhiyun   the machine a relevant name (think board name, not product name). Make sure
71*4882a593Smuzhiyun   the layer configuration is dependent on the meta-intel layer (or at least,
72*4882a593Smuzhiyun   meta-intel remains in your bblayers.conf). Now you can put your custom BSP
73*4882a593Smuzhiyun   settings into your layer and you can re-use it for different applications.
74*4882a593Smuzhiyun
75*4882a593Smuzhiyun#. **Write your own recipe to build additional software support that isn't
76*4882a593Smuzhiyun   already available in the form of a recipe**.
77*4882a593Smuzhiyun   Creating your own recipe is especially important for custom application
78*4882a593Smuzhiyun   software that you want to run on your device. Writing new recipes is a
79*4882a593Smuzhiyun   process of refinement. Start by getting each step of the build process
80*4882a593Smuzhiyun   working beginning with fetching all the way through packaging. Next, run the
81*4882a593Smuzhiyun   software on your target and refine further as needed. See :ref:`Writing a New
82*4882a593Smuzhiyun   Recipe <dev-manual/common-tasks:writing a new recipe>` in the
83*4882a593Smuzhiyun   Yocto Project Development Tasks Manual for more information.
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun#. **Now you're ready to create an image recipe**.
86*4882a593Smuzhiyun   There are a number of ways to do this. However, it is strongly recommended
87*4882a593Smuzhiyun   that you have your own image recipe - don't try appending to existing image
88*4882a593Smuzhiyun   recipes. Recipes for images are trivial to create and you usually want to
89*4882a593Smuzhiyun   fully customize their contents.
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun#. **Build your image and refine it**.
92*4882a593Smuzhiyun   Add what's missing and fix anything that's broken using your knowledge of the
93*4882a593Smuzhiyun   :ref:`workflow <sdk-manual/extensible:using \`\`devtool\`\` in your sdk
94*4882a593Smuzhiyun   workflow>` to identify where issues might be occurring.
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun#. **Consider creating your own distribution**.
97*4882a593Smuzhiyun   When you get to a certain level of customization, consider creating your own
98*4882a593Smuzhiyun   distribution rather than using the default reference distribution.
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun   Distribution settings define the packaging back-end (e.g. rpm or other) as
101*4882a593Smuzhiyun   well as the package feed and possibly the update solution. You would create
102*4882a593Smuzhiyun   your own distribution in a new layer inheriting from Poky but overriding what
103*4882a593Smuzhiyun   needs to change for your distribution. If you find yourself adding a lot of
104*4882a593Smuzhiyun   configuration to your local.conf file aside from paths and other typical
105*4882a593Smuzhiyun   local settings, it's time to :ref:`consider creating your own distribution
106*4882a593Smuzhiyun   <dev-manual/common-tasks:creating your own distribution>`.
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun   You can add product specifications that can customize the distribution if
109*4882a593Smuzhiyun   needed in other layers. You can also add other functionality specific to the
110*4882a593Smuzhiyun   product. But to update the distribution, not individual products, you update
111*4882a593Smuzhiyun   the distribution feature through that layer.
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun#. **Congratulations! You're well on your way.**
114*4882a593Smuzhiyun   Welcome to the Yocto Project community.
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun.. include:: /boilerplate.rst
117