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