xref: /OK3568_Linux_fs/yocto/poky/documentation/sdk-manual/intro.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun************
4*4882a593SmuzhiyunIntroduction
5*4882a593Smuzhiyun************
6*4882a593Smuzhiyun
7*4882a593SmuzhiyuneSDK Introduction
8*4882a593Smuzhiyun=================
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunWelcome to the Yocto Project Application Development and the Extensible
11*4882a593SmuzhiyunSoftware Development Kit (eSDK) manual. This manual
12*4882a593Smuzhiyunexplains how to use both the Yocto Project extensible and standard
13*4882a593SmuzhiyunSDKs to develop applications and images.
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunAll SDKs consist of the following:
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun-  *Cross-Development Toolchain*: This toolchain contains a compiler,
18*4882a593Smuzhiyun   debugger, and various associated tools.
19*4882a593Smuzhiyun
20*4882a593Smuzhiyun-  *Libraries, Headers, and Symbols*: The libraries, headers, and
21*4882a593Smuzhiyun   symbols are specific to the image (i.e. they match the image
22*4882a593Smuzhiyun   against which the SDK was built).
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun-  *Environment Setup Script*: This ``*.sh`` file, once sourced, sets up the
25*4882a593Smuzhiyun   cross-development environment by defining variables and preparing for
26*4882a593Smuzhiyun   SDK use.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunAdditionally, an extensible SDK has tools that allow you to easily add
29*4882a593Smuzhiyunnew applications and libraries to an image, modify the source of an
30*4882a593Smuzhiyunexisting component, test changes on the target hardware, and easily
31*4882a593Smuzhiyunintegrate an application into the :term:`OpenEmbedded Build System`.
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunYou can use an SDK to independently develop and test code that is
34*4882a593Smuzhiyundestined to run on some target machine. SDKs are completely
35*4882a593Smuzhiyunself-contained. The binaries are linked against their own copy of
36*4882a593Smuzhiyun``libc``, which results in no dependencies on the target system. To
37*4882a593Smuzhiyunachieve this, the pointer to the dynamic loader is configured at install
38*4882a593Smuzhiyuntime since that path cannot be dynamically altered. This is the reason
39*4882a593Smuzhiyunfor a wrapper around the ``populate_sdk`` and ``populate_sdk_ext``
40*4882a593Smuzhiyunarchives.
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunAnother feature of the SDKs is that only one set of cross-compiler
43*4882a593Smuzhiyuntoolchain binaries are produced for any given architecture. This feature
44*4882a593Smuzhiyuntakes advantage of the fact that the target hardware can be passed to
45*4882a593Smuzhiyun``gcc`` as a set of compiler options. Those options are set up by the
46*4882a593Smuzhiyunenvironment script and contained in variables such as
47*4882a593Smuzhiyun:term:`CC` and
48*4882a593Smuzhiyun:term:`LD`. This reduces the space needed
49*4882a593Smuzhiyunfor the tools. Understand, however, that every target still needs its own
50*4882a593Smuzhiyunsysroot because those binaries are target-specific.
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunThe SDK development environment consists of the following:
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun-  The self-contained SDK, which is an architecture-specific
55*4882a593Smuzhiyun   cross-toolchain and matching sysroots (target and native) all built
56*4882a593Smuzhiyun   by the OpenEmbedded build system (e.g. the SDK). The toolchain and
57*4882a593Smuzhiyun   sysroots are based on a :term:`Metadata`
58*4882a593Smuzhiyun   configuration and extensions, which allows you to cross-develop on
59*4882a593Smuzhiyun   the host machine for the target hardware. Additionally, the
60*4882a593Smuzhiyun   extensible SDK contains the ``devtool`` functionality.
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun-  The Quick EMUlator (QEMU), which lets you simulate target hardware.
63*4882a593Smuzhiyun   QEMU is not literally part of the SDK. You must build and include
64*4882a593Smuzhiyun   this emulator separately. However, QEMU plays an important role in
65*4882a593Smuzhiyun   the development process that revolves around use of the SDK.
66*4882a593Smuzhiyun
67*4882a593SmuzhiyunIn summary, the extensible and standard SDK share many features.
68*4882a593SmuzhiyunHowever, the extensible SDK has powerful development tools to help you
69*4882a593Smuzhiyunmore quickly develop applications. Following is a table that summarizes
70*4882a593Smuzhiyunthe primary differences between the standard and extensible SDK types
71*4882a593Smuzhiyunwhen considering which to build:
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
74*4882a593Smuzhiyun| *Feature*             | *Standard SDK*        | *Extensible SDK*      |
75*4882a593Smuzhiyun+=======================+=======================+=======================+
76*4882a593Smuzhiyun| Toolchain             | Yes                   | Yes [1]_              |
77*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
78*4882a593Smuzhiyun| Debugger              | Yes                   | Yes [1]_              |
79*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
80*4882a593Smuzhiyun| Size                  | 100+ MBytes           | 1+ GBytes (or 300+    |
81*4882a593Smuzhiyun|                       |                       | MBytes for minimal    |
82*4882a593Smuzhiyun|                       |                       | w/toolchain)          |
83*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
84*4882a593Smuzhiyun| ``devtool``           | No                    | Yes                   |
85*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
86*4882a593Smuzhiyun| Build Images          | No                    | Yes                   |
87*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
88*4882a593Smuzhiyun| Updateable            | No                    | Yes                   |
89*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
90*4882a593Smuzhiyun| Managed Sysroot [2]_  | No                    | Yes                   |
91*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
92*4882a593Smuzhiyun| Installed Packages    | No  [3]_              | Yes  [4]_             |
93*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
94*4882a593Smuzhiyun| Construction          | Packages              | Shared State          |
95*4882a593Smuzhiyun+-----------------------+-----------------------+-----------------------+
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun.. [1] Extensible SDK contains the toolchain and debugger if :term:`SDK_EXT_TYPE`
98*4882a593Smuzhiyun       is "full" or :term:`SDK_INCLUDE_TOOLCHAIN` is "1", which is the default.
99*4882a593Smuzhiyun.. [2] Sysroot is managed through the use of ``devtool``. Thus, it is less
100*4882a593Smuzhiyun       likely that you will corrupt your SDK sysroot when you try to add
101*4882a593Smuzhiyun       additional libraries.
102*4882a593Smuzhiyun.. [3] You can add runtime package management to the standard SDK but it is not
103*4882a593Smuzhiyun       supported by default.
104*4882a593Smuzhiyun.. [4] You must build and make the shared state available to extensible SDK
105*4882a593Smuzhiyun       users for "packages" you want to enable users to install.
106*4882a593Smuzhiyun
107*4882a593SmuzhiyunThe Cross-Development Toolchain
108*4882a593Smuzhiyun-------------------------------
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunThe :term:`Cross-Development Toolchain` consists
111*4882a593Smuzhiyunof a cross-compiler, cross-linker, and cross-debugger that are used to
112*4882a593Smuzhiyundevelop user-space applications for targeted hardware; in addition,
113*4882a593Smuzhiyunthe extensible SDK comes with built-in ``devtool``
114*4882a593Smuzhiyunfunctionality. This toolchain is created by running a SDK installer
115*4882a593Smuzhiyunscript or through a :term:`Build Directory` that is based on
116*4882a593Smuzhiyunyour metadata configuration or extension for your targeted device. The
117*4882a593Smuzhiyuncross-toolchain works with a matching target sysroot.
118*4882a593Smuzhiyun
119*4882a593SmuzhiyunSysroots
120*4882a593Smuzhiyun--------
121*4882a593Smuzhiyun
122*4882a593SmuzhiyunThe native and target sysroots contain needed headers and libraries for
123*4882a593Smuzhiyungenerating binaries that run on the target architecture. The target
124*4882a593Smuzhiyunsysroot is based on the target root filesystem image that is built by
125*4882a593Smuzhiyunthe OpenEmbedded build system and uses the same metadata configuration
126*4882a593Smuzhiyunused to build the cross-toolchain.
127*4882a593Smuzhiyun
128*4882a593SmuzhiyunThe QEMU Emulator
129*4882a593Smuzhiyun-----------------
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunThe QEMU emulator allows you to simulate your hardware while running
132*4882a593Smuzhiyunyour application or image. QEMU is not part of the SDK but is
133*4882a593Smuzhiyunautomatically installed and available if you have done any one of
134*4882a593Smuzhiyunthe following:
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun-  cloned the ``poky`` Git repository to create a
137*4882a593Smuzhiyun   :term:`Source Directory` and sourced the environment setup script.
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun-  downloaded a Yocto Project release and unpacked it to
140*4882a593Smuzhiyun   create a Source Directory and sourced the environment setup
141*4882a593Smuzhiyun   script.
142*4882a593Smuzhiyun
143*4882a593Smuzhiyun-  installed the cross-toolchain tarball and
144*4882a593Smuzhiyun   sourced the toolchain's setup environment script.
145*4882a593Smuzhiyun
146*4882a593SmuzhiyunSDK Development Model
147*4882a593Smuzhiyun=====================
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunFundamentally, the SDK fits into the development process as follows:
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun.. image:: figures/sdk-environment.png
152*4882a593Smuzhiyun   :align: center
153*4882a593Smuzhiyun
154*4882a593SmuzhiyunThe SDK is installed on any machine and can be used to develop applications,
155*4882a593Smuzhiyunimages, and kernels. An SDK can even be used by a QA Engineer or Release
156*4882a593SmuzhiyunEngineer. The fundamental concept is that the machine that has the SDK
157*4882a593Smuzhiyuninstalled does not have to be associated with the machine that has the
158*4882a593SmuzhiyunYocto Project installed. A developer can independently compile and test
159*4882a593Smuzhiyunan object on their machine and then, when the object is ready for
160*4882a593Smuzhiyunintegration into an image, they can simply make it available to the
161*4882a593Smuzhiyunmachine that has the Yocto Project. Once the object is available, the
162*4882a593Smuzhiyunimage can be rebuilt using the Yocto Project to produce the modified
163*4882a593Smuzhiyunimage.
164*4882a593Smuzhiyun
165*4882a593SmuzhiyunYou just need to follow these general steps:
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun1. *Install the SDK for your target hardware:* For information on how to
168*4882a593Smuzhiyun   install the SDK, see the ":ref:`sdk-manual/using:installing the sdk`"
169*4882a593Smuzhiyun   section.
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun2. *Download or Build the Target Image:* The Yocto Project supports
172*4882a593Smuzhiyun   several target architectures and has many pre-built kernel images and
173*4882a593Smuzhiyun   root filesystem images.
174*4882a593Smuzhiyun
175*4882a593Smuzhiyun   If you are going to develop your application on hardware, go to the
176*4882a593Smuzhiyun   :yocto_dl:`machines </releases/yocto/yocto-&DISTRO;/machines/>` download area and choose a
177*4882a593Smuzhiyun   target machine area from which to download the kernel image and root
178*4882a593Smuzhiyun   filesystem. This download area could have several files in it that
179*4882a593Smuzhiyun   support development using actual hardware. For example, the area
180*4882a593Smuzhiyun   might contain ``.hddimg`` files that combine the kernel image with
181*4882a593Smuzhiyun   the filesystem, boot loaders, and so forth. Be sure to get the files
182*4882a593Smuzhiyun   you need for your particular development process.
183*4882a593Smuzhiyun
184*4882a593Smuzhiyun   If you are going to develop your application and then run and test it
185*4882a593Smuzhiyun   using the QEMU emulator, go to the
186*4882a593Smuzhiyun   :yocto_dl:`machines/qemu </releases/yocto/yocto-&DISTRO;/machines/qemu>` download area. From this
187*4882a593Smuzhiyun   area, go down into the directory for your target architecture (e.g.
188*4882a593Smuzhiyun   ``qemux86_64`` for an Intel-based 64-bit architecture). Download the
189*4882a593Smuzhiyun   kernel, root filesystem, and any other files you need for your
190*4882a593Smuzhiyun   process.
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun   .. note::
193*4882a593Smuzhiyun
194*4882a593Smuzhiyun      To use the root filesystem in QEMU, you need to extract it. See the
195*4882a593Smuzhiyun      ":ref:`sdk-manual/appendix-obtain:extracting the root filesystem`"
196*4882a593Smuzhiyun      section for information on how to do this extraction.
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun3. *Develop and Test your Application:* At this point, you have the
199*4882a593Smuzhiyun   tools to develop your application. If you need to separately install
200*4882a593Smuzhiyun   and use the QEMU emulator, you can go to `QEMU Home
201*4882a593Smuzhiyun   Page <https://wiki.qemu.org/Main_Page>`__ to download and learn about
202*4882a593Smuzhiyun   the emulator. See the ":doc:`/dev-manual/qemu`" chapter in the
203*4882a593Smuzhiyun   Yocto Project Development Tasks Manual for information on using QEMU
204*4882a593Smuzhiyun   within the Yocto Project.
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunThe remainder of this manual describes how to use the extensible and
207*4882a593Smuzhiyunstandard SDKs. There is also information in appendix form describing
208*4882a593Smuzhiyunhow you can build, install, and modify an SDK.
209