| Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | 
|  | 2 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" | 
|  | 3 | [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] > | 
|  | 4 |  | 
|  | 5 | <chapter id='sdk-intro'> | 
|  | 6 | <title>Introduction</title> | 
|  | 7 |  | 
|  | 8 | <section id='sdk-manual-intro'> | 
|  | 9 | <title>Introduction</title> | 
|  | 10 |  | 
|  | 11 | <para> | 
|  | 12 | Welcome to the Yocto Project Software Development Kit (SDK) | 
|  | 13 | Developer's Guide. | 
|  | 14 | This manual provides information that lets you use both the standard | 
|  | 15 | Yocto Project SDK and an extensible SDK to develop applications and | 
|  | 16 | images using the Yocto Project. | 
|  | 17 | Additionally, the manual also provides information on how to use | 
|  | 18 | the popular <trademark class='trade'>Eclipse</trademark> IDE as part | 
|  | 19 | of your application development workflow. | 
|  | 20 | </para> | 
|  | 21 |  | 
|  | 22 | <para> | 
|  | 23 | Prior to the 2.0 Release of the Yocto Project, application | 
|  | 24 | development was primarily accomplished through the use of the | 
|  | 25 | Application Development Toolkit (ADT) and the availability | 
|  | 26 | of stand-alone cross-development toolchains and other tools. | 
|  | 27 | With the 2.1 Release of the Yocto Project, application development | 
|  | 28 | has transitioned to within a more traditional SDK and extensible | 
|  | 29 | SDK. | 
|  | 30 | </para> | 
|  | 31 |  | 
|  | 32 | <para> | 
|  | 33 | A standard SDK consists of a cross-development toolchain that contains | 
|  | 34 | a compiler, debugger, and various miscellaneous tools; libraries, | 
|  | 35 | headers, and symbols to match an image; and environment setup script. | 
|  | 36 | You can use this SDK to independently develop and test code that is | 
|  | 37 | destined to run on some target machine. | 
|  | 38 | </para> | 
|  | 39 |  | 
|  | 40 | <para> | 
|  | 41 | An extensible SDK consists of everything that the standard SDK has plus | 
|  | 42 | tools that allow you to easily add new applications and libraries to | 
|  | 43 | an image, modify the source of an existing component, test changes on | 
|  | 44 | the target hardware, and easily integrate an application into the | 
|  | 45 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-system-term'>OpenEmbedded build system</ulink>. | 
|  | 46 | </para> | 
|  | 47 |  | 
|  | 48 | <para> | 
|  | 49 | SDKs are completely self-contained. | 
|  | 50 | The binaries are linked against their own copy of | 
|  | 51 | <filename>libc</filename>, which results in no dependencies | 
|  | 52 | on the target system. | 
|  | 53 | To achieve this, the pointer to the dynamic loader is | 
|  | 54 | configured at install time since that path cannot be dynamically | 
|  | 55 | altered. | 
|  | 56 | This is the reason for a wrapper around the | 
|  | 57 | <filename>populate_sdk</filename> and | 
|  | 58 | <filename>populate_sdk_ext</filename> archives. | 
|  | 59 | </para> | 
|  | 60 |  | 
|  | 61 | <para> | 
|  | 62 | Another feature for the SDKs is that only one set of cross-canadian | 
|  | 63 | toolchain binaries are produced per architecture. | 
|  | 64 | This feature takes advantage of the fact that the target hardware can | 
|  | 65 | be passed to <filename>gcc</filename> as a set of compiler options. | 
|  | 66 | Those options are set up by the environment script and contained in | 
|  | 67 | variables such as | 
|  | 68 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink> | 
|  | 69 | and | 
|  | 70 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink>. | 
|  | 71 | This reduces the space needed for the tools. | 
|  | 72 | Understand, however, that a sysroot is still needed for every target | 
|  | 73 | since those binaries are target-specific. | 
|  | 74 | </para> | 
|  | 75 |  | 
|  | 76 | <para> | 
|  | 77 | Going beyond the actual SDK, the SDK development environment consists | 
|  | 78 | of the following: | 
|  | 79 | <itemizedlist> | 
|  | 80 | <listitem><para>An architecture-specific cross-toolchain and | 
|  | 81 | matching sysroots (target and native) all built by the | 
|  | 82 | OpenEmbedded build system. | 
|  | 83 | The toolchain and sysroots are based on a | 
|  | 84 | <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink> | 
|  | 85 | configuration and extensions, | 
|  | 86 | which allows you to cross-develop on the host machine for the | 
|  | 87 | target hardware. | 
|  | 88 | </para></listitem> | 
|  | 89 | <listitem><para>The Quick EMUlator (QEMU), which lets you simulate | 
|  | 90 | target hardware. | 
|  | 91 | QEMU is not literally part of the SDK. | 
|  | 92 | You must build and include this emulator separately. | 
|  | 93 | However, QEMU plays an important role in the development | 
|  | 94 | process that revolves around use of and SDK. | 
|  | 95 | </para></listitem> | 
|  | 96 | <listitem><para>The Eclipse IDE Yocto Plug-in. | 
|  | 97 | This plug-in is also available for you if you are an Eclipse | 
|  | 98 | user. | 
|  | 99 | In the same manner as QEMU, the plug-in is not literally part | 
|  | 100 | of the SDK but is rather available for use as part of the | 
|  | 101 | development process. | 
|  | 102 | </para></listitem> | 
|  | 103 | <listitem><para>Various user-space tools that greatly enhance | 
|  | 104 | your application development experience. | 
|  | 105 | These tools are also separate from the actual SDK but can be | 
|  | 106 | independently obtained and used in the development process. | 
|  | 107 | </para></listitem> | 
|  | 108 | </itemizedlist> | 
|  | 109 | </para> | 
|  | 110 |  | 
|  | 111 | <section id='the-cross-development-toolchain'> | 
|  | 112 | <title>The Cross-Development Toolchain</title> | 
|  | 113 |  | 
|  | 114 | <para> | 
|  | 115 | The | 
|  | 116 | <ulink url='&YOCTO_DOCS_DEV_URL;#cross-development-toolchain'>Cross-Development Toolchain</ulink> | 
|  | 117 | consists of a cross-compiler, cross-linker, and cross-debugger | 
|  | 118 | that are used to develop user-space applications for targeted | 
|  | 119 | hardware. | 
|  | 120 | This toolchain is created by running a toolchain installer script | 
|  | 121 | or through a | 
|  | 122 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> | 
|  | 123 | that is based on your Metadata configuration or extension for | 
|  | 124 | your targeted device. | 
|  | 125 | The cross-toolchain works with a matching target sysroot. | 
|  | 126 | </para> | 
|  | 127 | </section> | 
|  | 128 |  | 
|  | 129 | <section id='sysroot'> | 
|  | 130 | <title>Sysroots</title> | 
|  | 131 |  | 
|  | 132 | <para> | 
|  | 133 | The native and target sysroots contain needed headers and libraries | 
|  | 134 | for generating binaries that run on the target architecture. | 
|  | 135 | The target sysroot is based on the target root filesystem image | 
|  | 136 | that is built by the OpenEmbedded build system and uses the same | 
|  | 137 | Metadata configuration used to build the cross-toolchain. | 
|  | 138 | </para> | 
|  | 139 | </section> | 
|  | 140 |  | 
|  | 141 | <section id='the-qemu-emulator'> | 
|  | 142 | <title>The QEMU Emulator</title> | 
|  | 143 |  | 
|  | 144 | <para> | 
|  | 145 | The QEMU emulator allows you to simulate your hardware while | 
|  | 146 | running your application or image. | 
|  | 147 | QEMU is not part of the SDK but is made available a number of ways: | 
|  | 148 | <itemizedlist> | 
|  | 149 | <listitem><para> | 
|  | 150 | If you have cloned the <filename>poky</filename> Git | 
|  | 151 | repository to create a | 
|  | 152 | <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink> | 
|  | 153 | and you have sourced the environment setup script, QEMU is | 
|  | 154 | installed and automatically available. | 
|  | 155 | </para></listitem> | 
|  | 156 | <listitem><para> | 
|  | 157 | If you have downloaded a Yocto Project release and unpacked | 
|  | 158 | it to create a | 
|  | 159 | <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink> | 
|  | 160 | and you have sourced the environment setup script, QEMU is | 
|  | 161 | installed and automatically available. | 
|  | 162 | </para></listitem> | 
|  | 163 | <listitem><para> | 
|  | 164 | If you have installed the cross-toolchain tarball and you | 
|  | 165 | have sourced the toolchain's setup environment script, QEMU | 
|  | 166 | is also installed and automatically available. | 
|  | 167 | </para></listitem> | 
|  | 168 | </itemizedlist> | 
|  | 169 | </para> | 
|  | 170 | </section> | 
|  | 171 |  | 
|  | 172 | <section id='eclipse-overview'> | 
|  | 173 | <title>Eclipse Yocto Plug-in</title> | 
|  | 174 |  | 
|  | 175 | <para> | 
|  | 176 | The Eclipse IDE is a popular development environment and it fully | 
|  | 177 | supports development using the Yocto Project. | 
|  | 178 | When you install and configure the Eclipse Yocto Project Plug-in | 
|  | 179 | into the Eclipse IDE, you maximize your Yocto Project experience. | 
|  | 180 | Installing and configuring the Plug-in results in an environment | 
|  | 181 | that has extensions specifically designed to let you more easily | 
|  | 182 | develop software. | 
|  | 183 | These extensions allow for cross-compilation, deployment, and | 
|  | 184 | execution of your output into a QEMU emulation session. | 
|  | 185 | You can also perform cross-debugging and profiling. | 
|  | 186 | The environment also supports a suite of tools that allows you to | 
|  | 187 | perform remote profiling, tracing, collection of power data, | 
|  | 188 | collection of latency data, and collection of performance data. | 
|  | 189 | </para> | 
|  | 190 |  | 
|  | 191 | <para> | 
|  | 192 | For information about the application development workflow that | 
|  | 193 | uses the Eclipse IDE and for a detailed example of how to install | 
|  | 194 | and configure the Eclipse Yocto Project Plug-in, see the | 
|  | 195 | "<link link='sdk-developing-applications-using-eclipse'>Developing Applications Using <trademark class='trade'>Eclipse</trademark></link>" | 
|  | 196 | section. | 
|  | 197 | </para> | 
|  | 198 | </section> | 
|  | 199 |  | 
|  | 200 | <section id='user-space-tools'> | 
|  | 201 | <title>User-Space Tools</title> | 
|  | 202 |  | 
|  | 203 | <para> | 
|  | 204 | User-space tools are available as part of the SDK development | 
|  | 205 | process and can be helpful. | 
|  | 206 | The tools include LatencyTOP, PowerTOP, Perf, SystemTap, | 
|  | 207 | and Lttng-ust. | 
|  | 208 | These tools are common development tools for the Linux platform. | 
|  | 209 | <itemizedlist> | 
|  | 210 | <listitem><para><emphasis>LatencyTOP:</emphasis> LatencyTOP | 
|  | 211 | focuses on latency that causes skips in audio, stutters in | 
|  | 212 | your desktop experience, or situations that overload your | 
|  | 213 | server even when you have plenty of CPU power left. | 
|  | 214 | </para></listitem> | 
|  | 215 | <listitem><para><emphasis>PowerTOP:</emphasis> Helps you | 
|  | 216 | determine what software is using the most power. | 
|  | 217 | You can find out more about PowerTOP at | 
|  | 218 | <ulink url='https://01.org/powertop/'></ulink>.</para></listitem> | 
|  | 219 | <listitem><para><emphasis>Perf:</emphasis> Performance counters | 
|  | 220 | for Linux used to keep track of certain types of hardware | 
|  | 221 | and software events. | 
|  | 222 | For more information on these types of counters see | 
|  | 223 | <ulink url='https://perf.wiki.kernel.org/'></ulink>. | 
|  | 224 | For examples on how to setup and use this tool, see the | 
|  | 225 | "<ulink url='&YOCTO_DOCS_PROF_URL;#profile-manual-perf'>perf</ulink>" | 
|  | 226 | section in the Yocto Project Profiling and Tracing Manual. | 
|  | 227 | </para></listitem> | 
|  | 228 | <listitem><para><emphasis>SystemTap:</emphasis> A free software | 
|  | 229 | infrastructure that simplifies information gathering about | 
|  | 230 | a running Linux system. | 
|  | 231 | This information helps you diagnose performance or | 
|  | 232 | functional problems. | 
|  | 233 | SystemTap is not available as a user-space tool through | 
|  | 234 | the Eclipse IDE Yocto Plug-in. | 
|  | 235 | See <ulink url='http://sourceware.org/systemtap'></ulink> | 
|  | 236 | for more information on SystemTap. | 
|  | 237 | For examples on how to setup and use this tool, see the | 
|  | 238 | "<ulink url='&YOCTO_DOCS_PROF_URL;#profile-manual-systemtap'>SystemTap</ulink>" | 
|  | 239 | section in the Yocto Project Profiling and Tracing Manual. | 
|  | 240 | </para></listitem> | 
|  | 241 | <listitem><para><emphasis>Lttng-ust:</emphasis> A User-space | 
|  | 242 | Tracer designed to provide detailed information on | 
|  | 243 | user-space activity. | 
|  | 244 | See <ulink url='http://lttng.org/ust'></ulink> for more | 
|  | 245 | information on Lttng-ust. | 
|  | 246 | </para></listitem> | 
|  | 247 | </itemizedlist> | 
|  | 248 | </para> | 
|  | 249 | </section> | 
|  | 250 | </section> | 
|  | 251 |  | 
|  | 252 | <section id='sdk-development-model'> | 
|  | 253 | <title>SDK Development Model</title> | 
|  | 254 |  | 
|  | 255 | <para> | 
|  | 256 | Fundamentally, the SDK fits into the development process as follows: | 
|  | 257 | <imagedata fileref="figures/sdk-environment.png" align="center" width="6in" depth="5in" scalefit="100" /> | 
|  | 258 | The SDK is installed on any machine and can be used to develop | 
|  | 259 | applications, images, and kernels. | 
|  | 260 | An SDK can even be used by a QA Engineer or Release Engineer. | 
|  | 261 | The fundamental concept is that the machine that has the SDK installed | 
|  | 262 | does not have to be associated with the machine that has the | 
|  | 263 | Yocto Project installed. | 
|  | 264 | A developer can independently compile and test an object on their | 
|  | 265 | machine and then, when the object is ready for integration into an | 
|  | 266 | image, they can simply make it available to the machine that has the | 
|  | 267 | the Yocto Project. | 
|  | 268 | Once the object is available, the image can be rebuilt using the | 
|  | 269 | Yocto Project to produce the modified image. | 
|  | 270 | </para> | 
|  | 271 |  | 
|  | 272 | <para> | 
|  | 273 | You just need to follow these general steps: | 
|  | 274 | <orderedlist> | 
|  | 275 | <listitem><para><emphasis>Install the SDK for your target hardware:</emphasis> | 
|  | 276 | For information on how to install the SDK, see the | 
|  | 277 | "<link url='sdk-installing-the-sdk'>Installing the SDK</link>" | 
|  | 278 | section.</para></listitem> | 
|  | 279 | <listitem><para><emphasis>Download the Target Image:</emphasis> | 
|  | 280 | The Yocto Project supports several target architectures | 
|  | 281 | and has many pre-built kernel images and root filesystem | 
|  | 282 | images.</para> | 
|  | 283 | <para>If you are going to develop your application on | 
|  | 284 | hardware, go to the | 
|  | 285 | <ulink url='&YOCTO_MACHINES_DL_URL;'><filename>machines</filename></ulink> | 
|  | 286 | download area and choose a target machine area | 
|  | 287 | from which to download the kernel image and root filesystem. | 
|  | 288 | This download area could have several files in it that | 
|  | 289 | support development using actual hardware. | 
|  | 290 | For example, the area might contain | 
|  | 291 | <filename>.hddimg</filename> files that combine the | 
|  | 292 | kernel image with the filesystem, boot loaders, and | 
|  | 293 | so forth. | 
|  | 294 | Be sure to get the files you need for your particular | 
|  | 295 | development process.</para> | 
|  | 296 | <para>If you are going to develop your application and | 
|  | 297 | then run and test it using the QEMU emulator, go to the | 
|  | 298 | <ulink url='&YOCTO_QEMU_DL_URL;'><filename>machines/qemu</filename></ulink> | 
|  | 299 | download area. | 
|  | 300 | From this area, go down into the directory for your | 
|  | 301 | target architecture (e.g. <filename>qemux86_64</filename> | 
|  | 302 | for an <trademark class='registered'>Intel</trademark>-based | 
|  | 303 | 64-bit architecture). | 
|  | 304 | Download kernel, root filesystem, and any other files you | 
|  | 305 | need for your process. | 
|  | 306 | <note>In order to use the root filesystem in QEMU, you | 
|  | 307 | need to extract it. | 
|  | 308 | See the | 
|  | 309 | "<link url='sdk-extracting-the-root-filesystem'>Extracting the Root Filesystem</link>" | 
|  | 310 | section for information on how to extract the root | 
|  | 311 | filesystem.</note></para></listitem> | 
|  | 312 | <listitem><para><emphasis>Develop and Test your | 
|  | 313 | Application:</emphasis>  At this point, you have the tools | 
|  | 314 | to develop your application. | 
|  | 315 | If you need to separately install and use the QEMU | 
|  | 316 | emulator, you can go to | 
|  | 317 | <ulink url='http://wiki.qemu.org/Main_Page'>QEMU Home Page</ulink> | 
|  | 318 | to download and learn about the emulator. | 
|  | 319 | You can see the | 
|  | 320 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-qemu'>Using the Quick EMUlator (QEMU)</ulink>" | 
|  | 321 | chapter in the Yocto Project Development Manual | 
|  | 322 | for information on using QEMU within the Yocto | 
|  | 323 | Project.</para></listitem> | 
|  | 324 | </orderedlist> | 
|  | 325 | </para> | 
|  | 326 |  | 
|  | 327 | <para> | 
|  | 328 | The remainder of this manual describes how to use both the standard | 
|  | 329 | SDK and the extensible SDK. | 
|  | 330 | Information also exists in appendix form that describes how you can | 
|  | 331 | build, install, and modify an SDK. | 
|  | 332 | </para> | 
|  | 333 | </section> | 
|  | 334 |  | 
|  | 335 | </chapter> | 
|  | 336 | <!-- | 
|  | 337 | vim: expandtab tw=80 ts=4 | 
|  | 338 | --> |