blob: 01f569f805ccb3d2d8ffed801f456afc5570507c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001<!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='adt-prepare'>
6
7<title>Preparing for Application Development</title>
8
9<para>
10 In order to develop applications, you need set up your host development system.
11 Several ways exist that allow you to install cross-development tools, QEMU, the
12 Eclipse Yocto Plug-in, and other tools.
13 This chapter describes how to prepare for application development.
14</para>
15
16<section id='installing-the-adt'>
17 <title>Installing the ADT and Toolchains</title>
18
19 <para>
20 The following list describes installation methods that set up varying
21 degrees of tool availability on your system.
22 Regardless of the installation method you choose,
23 you must <filename>source</filename> the cross-toolchain
24 environment setup script, which establishes several key
25 environment variables, before you use a toolchain.
26 See the
27 "<link linkend='setting-up-the-cross-development-environment'>Setting Up the Cross-Development Environment</link>"
28 section for more information.
29 </para>
30
31 <note>
32 <para>
33 Avoid mixing installation methods when installing toolchains for
34 different architectures.
35 For example, avoid using the ADT Installer to install some
36 toolchains and then hand-installing cross-development toolchains
37 by running the toolchain installer for different architectures.
38 Mixing installation methods can result in situations where the
39 ADT Installer becomes unreliable and might not install the
40 toolchain.
41 </para>
42
43 <para>
44 If you must mix installation methods, you might avoid problems by
45 deleting <filename>/var/lib/opkg</filename>, thus purging the
46 <filename>opkg</filename> package metadata.
47 </para>
48 </note>
49
50 <para>
51 <itemizedlist>
52 <listitem><para><emphasis>Use the ADT installer script:</emphasis>
53 This method is the recommended way to install the ADT because it
54 automates much of the process for you.
55 For example, you can configure the installation to install the QEMU emulator
56 and the user-space NFS, specify which root filesystem profiles to download,
57 and define the target sysroot location.</para></listitem>
58 <listitem><para><emphasis>Use an existing toolchain:</emphasis>
59 Using this method, you select and download an architecture-specific
60 toolchain installer and then run the script to hand-install the toolchain.
61 If you use this method, you just get the cross-toolchain and QEMU - you do not
62 get any of the other mentioned benefits had you run the ADT Installer script.</para></listitem>
63 <listitem><para><emphasis>Use the toolchain from within the Build Directory:</emphasis>
64 If you already have a
65 <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>,
66 you can build the cross-toolchain within the directory.
67 However, like the previous method mentioned, you only get the cross-toolchain and QEMU - you
68 do not get any of the other benefits without taking separate steps.</para></listitem>
69 </itemizedlist>
70 </para>
71
72 <section id='using-the-adt-installer'>
73 <title>Using the ADT Installer</title>
74
75 <para>
76 To run the ADT Installer, you need to get the ADT Installer tarball, be sure
77 you have the necessary host development packages that support the ADT Installer,
78 and then run the ADT Installer Script.
79 </para>
80
81 <para>
82 For a list of the host packages needed to support ADT installation and use, see the
83 "ADT Installer Extras" lists in the
84 "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>" section
85 of the Yocto Project Reference Manual.
86 </para>
87
88 <section id='getting-the-adt-installer-tarball'>
89 <title>Getting the ADT Installer Tarball</title>
90
91 <para>
92 The ADT Installer is contained in the ADT Installer tarball.
93 You can get the tarball using either of these methods:
94 <itemizedlist>
95 <listitem><para><emphasis>Download the Tarball:</emphasis>
96 You can download the tarball from
97 <ulink url='&YOCTO_ADTINSTALLER_DL_URL;'></ulink> into
98 any directory.</para></listitem>
99 <listitem><para><emphasis>Build the Tarball:</emphasis>
100 You can use
101 <ulink url='&YOCTO_DOCS_DEV_URL;#bitbake-term'>BitBake</ulink>
102 to generate the tarball inside an existing
103 <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>.
104 </para>
105 <para>If you use BitBake to generate the ADT Installer
106 tarball, you must <filename>source</filename> the
107 environment setup script
108 (<ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
109 or
110 <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
111 located in the Source Directory before running the
112 <filename>bitbake</filename> command that creates the
113 tarball.</para>
114 <para>The following example commands establish
115 the
116 <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink>,
117 check out the current release branch, set up the
118 build environment while also creating the default
119 Build Directory, and run the
120 <filename>bitbake</filename> command that results in the
121 tarball
122 <filename>poky/build/tmp/deploy/sdk/adt_installer.tar.bz2</filename>:
123 <note>
124 Before using BitBake to build the ADT tarball, be
125 sure to make sure your
126 <filename>local.conf</filename> file is properly
127 configured.
128 See the
129 "<ulink url='&YOCTO_DOCS_REF_URL;#user-configuration'>User Configuration</ulink>"
130 section in the Yocto Project Reference Manual for
131 general configuration information.
132 </note>
133 <literallayout class='monospaced'>
134 $ cd ~
135 $ git clone git://git.yoctoproject.org/poky
136 $ cd poky
137 $ git checkout -b &DISTRO_NAME; origin/&DISTRO_NAME;
138 $ source &OE_INIT_FILE;
139 $ bitbake adt-installer
140 </literallayout></para></listitem>
141 </itemizedlist>
142 </para>
143 </section>
144
145 <section id='configuring-and-running-the-adt-installer-script'>
146 <title>Configuring and Running the ADT Installer Script</title>
147
148 <para>
149 Before running the ADT Installer script, you need to unpack the tarball.
150 You can unpack the tarball in any directory you wish.
151 For example, this command copies the ADT Installer tarball from where
152 it was built into the home directory and then unpacks the tarball into
153 a top-level directory named <filename>adt-installer</filename>:
154 <literallayout class='monospaced'>
155 $ cd ~
156 $ cp poky/build/tmp/deploy/sdk/adt_installer.tar.bz2 $HOME
157 $ tar -xjf adt_installer.tar.bz2
158 </literallayout>
159 Unpacking it creates the directory <filename>adt-installer</filename>,
160 which contains the ADT Installer script (<filename>adt_installer</filename>)
161 and its configuration file (<filename>adt_installer.conf</filename>).
162 </para>
163
164 <para>
165 Before you run the script, however, you should examine the ADT Installer configuration
166 file and be sure you are going to get what you want.
167 Your configurations determine which kernel and filesystem image are downloaded.
168 </para>
169
170 <para>
171 The following list describes the configurations you can define for the ADT Installer.
172 For configuration values and restrictions, see the comments in
173 the <filename>adt-installer.conf</filename> file:
174
175 <itemizedlist>
176 <listitem><para><filename>YOCTOADT_REPO</filename>: This area
177 includes the IPKG-based packages and the root filesystem upon which
178 the installation is based.
179 If you want to set up your own IPKG repository pointed to by
180 <filename>YOCTOADT_REPO</filename>, you need to be sure that the
181 directory structure follows the same layout as the reference directory
182 set up at <ulink url='http://adtrepo.yoctoproject.org'></ulink>.
183 Also, your repository needs to be accessible through HTTP.</para></listitem>
184 <listitem><para><filename>YOCTOADT_TARGETS</filename>: The machine
185 target architectures for which you want to set up cross-development
186 environments.</para></listitem>
187 <listitem><para><filename>YOCTOADT_QEMU</filename>: Indicates whether
188 or not to install the emulator QEMU.</para></listitem>
189 <listitem><para><filename>YOCTOADT_NFS_UTIL</filename>: Indicates whether
190 or not to install user-mode NFS.
191 If you plan to use the Eclipse IDE Yocto plug-in against QEMU,
192 you should install NFS.
193 <note>To boot QEMU images using our userspace NFS server, you need
194 to be running <filename>portmap</filename> or <filename>rpcbind</filename>.
195 If you are running <filename>rpcbind</filename>, you will also need to add the
196 <filename>-i</filename> option when <filename>rpcbind</filename> starts up.
197 Please make sure you understand the security implications of doing this.
198 You might also have to modify your firewall settings to allow
199 NFS booting to work.</note></para></listitem>
200 <listitem><para><filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>: The root
201 filesystem images you want to download from the
202 <filename>YOCTOADT_IPKG_REPO</filename> repository.</para></listitem>
203 <listitem><para><filename>YOCTOADT_TARGET_SYSROOT_IMAGE_</filename><replaceable>arch</replaceable>: The
204 particular root filesystem used to extract and create the target sysroot.
205 The value of this variable must have been specified with
206 <filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>.
207 For example, if you downloaded both <filename>minimal</filename> and
208 <filename>sato-sdk</filename> images by setting
209 <filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>
210 to "minimal sato-sdk", then <filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>
211 must be set to either "minimal" or "sato-sdk".
212 </para></listitem>
213 <listitem><para><filename>YOCTOADT_TARGET_SYSROOT_LOC_</filename><replaceable>arch</replaceable>: The
214 location on the development host where the target sysroot is created.
215 </para></listitem>
216 </itemizedlist>
217 </para>
218
219 <para>
220 After you have configured the <filename>adt_installer.conf</filename> file,
221 run the installer using the following command:
222 <literallayout class='monospaced'>
223 $ cd adt-installer
224 $ ./adt_installer
225 </literallayout>
226 Once the installer begins to run, you are asked to enter the
227 location for cross-toolchain installation.
228 The default location is
229 <filename>/opt/poky/</filename><replaceable>release</replaceable>.
230 After either accepting the default location or selecting your
231 own location, you are prompted to run the installation script
232 interactively or in silent mode.
233 If you want to closely monitor the installation,
234 choose “I” for interactive mode rather than “S” for silent mode.
235 Follow the prompts from the script to complete the installation.
236 </para>
237
238 <para>
239 Once the installation completes, the ADT, which includes the
240 cross-toolchain, is installed in the selected installation
241 directory.
242 You will notice environment setup files for the cross-toolchain
243 in the installation directory, and image tarballs in the
244 <filename>adt-installer</filename> directory according to your
245 installer configurations, and the target sysroot located
246 according to the
247 <filename>YOCTOADT_TARGET_SYSROOT_LOC_</filename><replaceable>arch</replaceable>
248 variable also in your configuration file.
249 </para>
250 </section>
251 </section>
252
253 <section id='using-an-existing-toolchain-tarball'>
254 <title>Using a Cross-Toolchain Tarball</title>
255
256 <para>
257 If you want to simply install a cross-toolchain by hand, you can
258 do so by running the toolchain installer.
259 The installer includes the pre-built cross-toolchain, the
260 <filename>runqemu</filename> script, and support files.
261 If you use this method to install the cross-toolchain, you
262 might still need to install the target sysroot by installing and
263 extracting it separately.
264 For information on how to install the sysroot, see the
265 "<link linkend='extracting-the-root-filesystem'>Extracting the Root Filesystem</link>" section.
266 </para>
267
268 <para>
269 Follow these steps:
270 <orderedlist>
271 <listitem><para><emphasis>Get your toolchain installer using one of the following methods:</emphasis>
272 <itemizedlist>
273 <listitem><para>Go to
274 <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'></ulink>
275 and find the folder that matches your host
276 development system (i.e. <filename>i686</filename>
277 for 32-bit machines or <filename>x86_64</filename>
278 for 64-bit machines).</para>
279 <para>Go into that folder and download the toolchain
280 installer whose name includes the appropriate target
281 architecture.
282 The toolchains provided by the Yocto Project
283 are based off of the
284 <filename>core-image-sato</filename> image and
285 contain libraries appropriate for developing
286 against that image.
287 For example, if your host development system is a
288 64-bit x86 system and you are going to use
289 your cross-toolchain for a 32-bit x86
290 target, go into the <filename>x86_64</filename>
291 folder and download the following installer:
292 <literallayout class='monospaced'>
293 poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
294 </literallayout></para></listitem>
295 <listitem><para>Build your own toolchain installer.
296 For cases where you cannot use an installer
297 from the download area, you can build your own as
298 described in the
299 "<link linkend='optionally-building-a-toolchain-installer'>Optionally Building a Toolchain Installer</link>"
300 section.</para></listitem>
301 </itemizedlist></para></listitem>
302 <listitem><para><emphasis>Once you have the installer, run it to install the toolchain:</emphasis>
303 <note>
304 You must change the permissions on the toolchain
305 installer script so that it is executable.
306 </note></para>
307 <para>The following command shows how to run the installer
308 given a toolchain tarball for a 64-bit x86 development host
309 system and a 32-bit x86 target architecture.
310 The example assumes the toolchain installer is located
311 in <filename>~/Downloads/</filename>.
312 <literallayout class='monospaced'>
313 $ ~/Downloads/poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
314 </literallayout>
315 The first thing the installer prompts you for is the
316 directory into which you want to install the toolchain.
317 The default directory used is
318 <filename>/opt/poky/&DISTRO;</filename>.
319 If you do not have write permissions for the directory
320 into which you are installing the toolchain, the
321 toolchain installer notifies you and exits.
322 Be sure you have write permissions in the directory and
323 run the installer again.</para>
324 <para>When the script finishes, the cross-toolchain is
325 installed.
326 You will notice environment setup files for the
327 cross-toolchain in the installation directory.
328 </para></listitem>
329 </orderedlist>
330 </para>
331 </section>
332
333 <section id='using-the-toolchain-from-within-the-build-tree'>
334 <title>Using BitBake and the Build Directory</title>
335
336 <para>
337 A final way of making the cross-toolchain available is to use BitBake
338 to generate the toolchain within an existing
339 <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>.
340 This method does not install the toolchain into the default
341 <filename>/opt</filename> directory.
342 As with the previous method, if you need to install the target sysroot, you must
343 do that separately as well.
344 </para>
345
346 <para>
347 Follow these steps to generate the toolchain into the Build Directory:
348 <orderedlist>
349 <listitem><para><emphasis>Set up the Build Environment:</emphasis>
350 Source the OpenEmbedded build environment setup
351 script (i.e.
352 <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
353 or
354 <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
355 located in the
356 <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink>.
357 </para></listitem>
358 <listitem><para><emphasis>Check your Local Configuration File:</emphasis>
359 At this point, you should be sure that the
360 <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> variable
361 in the <filename>local.conf</filename> file found in the
362 <filename>conf</filename> directory of the Build Directory
363 is set for the target architecture.
364 Comments within the <filename>local.conf</filename> file
365 list the values you can use for the
366 <filename>MACHINE</filename> variable.
367 <note>
368 You can populate the Build Directory with the
369 cross-toolchains for more than a single architecture.
370 You just need to edit the <filename>MACHINE</filename>
371 variable in the <filename>local.conf</filename> file and
372 re-run the <filename>bitbake</filename> command.
373 </note></para></listitem>
374 <listitem><para><emphasis>Generate the Cross-Toolchain:</emphasis>
375 Run <filename>bitbake meta-ide-support</filename> to
376 complete the cross-toolchain generation.
377 Once the <filename>bitbake</filename> command finishes,
378 the cross-toolchain is
379 generated and populated within the Build Directory.
380 You will notice environment setup files for the
381 cross-toolchain that contain the string
382 "<filename>environment-setup</filename>" in the
383 Build Directory's <filename>tmp</filename> folder.</para>
384 <para>Be aware that when you use this method to install the
385 toolchain, you still need to separately extract and install
386 the sysroot filesystem.
387 For information on how to do this, see the
388 "<link linkend='extracting-the-root-filesystem'>Extracting the Root Filesystem</link>" section.
389 </para></listitem>
390 </orderedlist>
391 </para>
392 </section>
393</section>
394
395<section id='setting-up-the-cross-development-environment'>
396 <title>Setting Up the Cross-Development Environment</title>
397
398 <para>
399 Before you can develop using the cross-toolchain, you need to set up the
400 cross-development environment by sourcing the toolchain's environment setup script.
401 If you used the ADT Installer or hand-installed cross-toolchain,
402 then you can find this script in the directory you chose for installation.
403 For this release, the default installation directory is
404 <filename>&YOCTO_ADTPATH_DIR;</filename>.
405 If you installed the toolchain in the
406 <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>,
407 you can find the environment setup
408 script for the toolchain in the Build Directory's <filename>tmp</filename> directory.
409 </para>
410
411 <para>
412 Be sure to run the environment setup script that matches the
413 architecture for which you are developing.
414 Environment setup scripts begin with the string
415 "<filename>environment-setup</filename>" and include as part of their
416 name the architecture.
417 For example, the toolchain environment setup script for a 64-bit
418 IA-based architecture installed in the default installation directory
419 would be the following:
420 <literallayout class='monospaced'>
421 &YOCTO_ADTPATH_DIR;/environment-setup-x86_64-poky-linux
422 </literallayout>
423 When you run the setup script, many environment variables are
424 defined:
425 <literallayout class='monospaced'>
426 <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKTARGETSYSROOT'><filename>SDKTARGETSYSROOT</filename></ulink> - The path to the sysroot used for cross-compilation
427 <ulink url='&YOCTO_DOCS_REF_URL;#var-PKG_CONFIG_PATH'><filename>PKG_CONFIG_PATH</filename></ulink> - The path to the target pkg-config files
428 <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_SITE'><filename>CONFIG_SITE</filename></ulink> - A GNU autoconf site file preconfigured for the target
429 <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink> - The minimal command and arguments to run the C compiler
430 <ulink url='&YOCTO_DOCS_REF_URL;#var-CXX'><filename>CXX</filename></ulink> - The minimal command and arguments to run the C++ compiler
431 <ulink url='&YOCTO_DOCS_REF_URL;#var-CPP'><filename>CPP</filename></ulink> - The minimal command and arguments to run the C preprocessor
432 <ulink url='&YOCTO_DOCS_REF_URL;#var-AS'><filename>AS</filename></ulink> - The minimal command and arguments to run the assembler
433 <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink> - The minimal command and arguments to run the linker
434 <ulink url='&YOCTO_DOCS_REF_URL;#var-GDB'><filename>GDB</filename></ulink> - The minimal command and arguments to run the GNU Debugger
435 <ulink url='&YOCTO_DOCS_REF_URL;#var-STRIP'><filename>STRIP</filename></ulink> - The minimal command and arguments to run 'strip', which strips symbols
436 <ulink url='&YOCTO_DOCS_REF_URL;#var-RANLIB'><filename>RANLIB</filename></ulink> - The minimal command and arguments to run 'ranlib'
437 <ulink url='&YOCTO_DOCS_REF_URL;#var-OBJCOPY'><filename>OBJCOPY</filename></ulink> - The minimal command and arguments to run 'objcopy'
438 <ulink url='&YOCTO_DOCS_REF_URL;#var-OBJDUMP'><filename>OBJDUMP</filename></ulink> - The minimal command and arguments to run 'objdump'
439 <ulink url='&YOCTO_DOCS_REF_URL;#var-AR'><filename>AR</filename></ulink> - The minimal command and arguments to run 'ar'
440 <ulink url='&YOCTO_DOCS_REF_URL;#var-NM'><filename>NM</filename></ulink> - The minimal command and arguments to run 'nm'
441 <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_PREFIX'><filename>TARGET_PREFIX</filename></ulink> - The toolchain binary prefix for the target tools
442 <ulink url='&YOCTO_DOCS_REF_URL;#var-CROSS_COMPILE'><filename>CROSS_COMPILE</filename></ulink> - The toolchain binary prefix for the target tools
443 <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS'><filename>CONFIGURE_FLAGS</filename></ulink> - The minimal arguments for GNU configure
444 <ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'><filename>CFLAGS</filename></ulink> - Suggested C flags
445 <ulink url='&YOCTO_DOCS_REF_URL;#var-CXXFLAGS'><filename>CXXFLAGS</filename></ulink> - Suggested C++ flags
446 <ulink url='&YOCTO_DOCS_REF_URL;#var-LDFLAGS'><filename>LDFLAGS</filename></ulink> - Suggested linker flags when you use CC to link
447 <ulink url='&YOCTO_DOCS_REF_URL;#var-CPPFLAGS'><filename>CPPFLAGS</filename></ulink> - Suggested preprocessor flags
448 </literallayout>
449 </para>
450</section>
451
452<section id='securing-kernel-and-filesystem-images'>
453 <title>Securing Kernel and Filesystem Images</title>
454
455 <para>
456 You will need to have a kernel and filesystem image to boot using your
457 hardware or the QEMU emulator.
458 Furthermore, if you plan on booting your image using NFS or you want to use the root filesystem
459 as the target sysroot, you need to extract the root filesystem.
460 </para>
461
462 <section id='getting-the-images'>
463 <title>Getting the Images</title>
464
465 <para>
466 To get the kernel and filesystem images, you either have to build them or download
467 pre-built versions.
468 For an example of how to build these images, see the
469 "<ulink url='&YOCTO_DOCS_QS_URL;#qs-buiding-images'>Buiding Images</ulink>"
470 section of the Yocto Project Quick Start.
471 For an example of downloading pre-build versions, see the
472 "<link linkend='using-pre-built'>Example Using Pre-Built Binaries and QEMU</link>"
473 section.
474 </para>
475
476 <para>
477 The Yocto Project ships basic kernel and filesystem images for several
478 architectures (<filename>x86</filename>, <filename>x86-64</filename>,
479 <filename>mips</filename>, <filename>powerpc</filename>, and <filename>arm</filename>)
480 that you can use unaltered in the QEMU emulator.
481 These kernel images reside in the release
482 area - <ulink url='&YOCTO_MACHINES_DL_URL;'></ulink>
483 and are ideal for experimentation using Yocto Project.
484 For information on the image types you can build using the OpenEmbedded build system,
485 see the
486 "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
487 chapter in the Yocto Project Reference Manual.
488 </para>
489
490 <para>
491 If you are planning on developing against your image and you are not
492 building or using one of the Yocto Project development images
493 (e.g. <filename>core-image-*-dev</filename>), you must be sure to
494 include the development packages as part of your image recipe.
495 </para>
496
497 <para>
498 If you plan on remotely deploying and debugging your
499 application from within the Eclipse IDE, you must have an image
500 that contains the Yocto Target Communication Framework (TCF) agent
501 (<filename>tcf-agent</filename>).
502 You can do this by including the <filename>eclipse-debug</filename>
503 image feature.
504 <note>
505 See the
506 "<ulink url='&YOCTO_DOCS_REF_URL;#ref-features-image'>Image Features</ulink>"
507 section in the Yocto Project Reference Manual for information on
508 image features.
509 </note>
510 To include the <filename>eclipse-debug</filename> image feature,
511 modify your <filename>local.conf</filename> file in the
512 <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>
513 so that the
514 <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
515 variable includes the "eclipse-debug" feature.
516 After modifying the configuration file, you can rebuild the image.
517 Once the image is rebuilt, the <filename>tcf-agent</filename>
518 will be included in the image and is launched automatically after
519 the boot.
520 </para>
521 </section>
522
523 <section id='extracting-the-root-filesystem'>
524 <title>Extracting the Root Filesystem</title>
525
526 <para>
527 If you install your toolchain by hand or build it using BitBake and
528 you need a root filesystem, you need to extract it separately.
529 If you use the ADT Installer to install the ADT, the root
530 filesystem is automatically extracted and installed.
531 </para>
532
533 <para>
534 Here are some cases where you need to extract the root filesystem:
535 <itemizedlist>
536 <listitem><para>You want to boot the image using NFS.
537 </para></listitem>
538 <listitem><para>You want to use the root filesystem as the
539 target sysroot.
540 For example, the Eclipse IDE environment with the Eclipse
541 Yocto Plug-in installed allows you to use QEMU to boot
542 under NFS.</para></listitem>
543 <listitem><para>You want to develop your target application
544 using the root filesystem as the target sysroot.
545 </para></listitem>
546 </itemizedlist>
547 </para>
548
549 <para>
550 To extract the root filesystem, first <filename>source</filename>
551 the cross-development environment setup script to establish
552 necessary environment variables.
553 If you built the toolchain in the Build Directory, you will find
554 the toolchain environment script in the
555 <filename>tmp</filename> directory.
556 If you installed the toolchain by hand, the environment setup
557 script is located in <filename>/opt/poky/&DISTRO;</filename>.
558 </para>
559
560 <para>
561 After sourcing the environment script, use the
562 <filename>runqemu-extract-sdk</filename> command and provide the
563 filesystem image.
564 </para>
565
566 <para>
567 Following is an example.
568 The second command sets up the environment.
569 In this case, the setup script is located in the
570 <filename>/opt/poky/&DISTRO;</filename> directory.
571 The third command extracts the root filesystem from a previously
572 built filesystem that is located in the
573 <filename>~/Downloads</filename> directory.
574 Furthermore, this command extracts the root filesystem into the
575 <filename>qemux86-sato</filename> directory:
576 <literallayout class='monospaced'>
577 $ cd ~
578 $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux
579 $ runqemu-extract-sdk \
580 ~/Downloads/core-image-sato-sdk-qemux86-2011091411831.rootfs.tar.bz2 \
581 $HOME/qemux86-sato
582 </literallayout>
583 You could now point to the target sysroot at
584 <filename>qemux86-sato</filename>.
585 </para>
586 </section>
587</section>
588
589<section id='optionally-building-a-toolchain-installer'>
590 <title>Optionally Building a Toolchain Installer</title>
591
592 <para>
593 As an alternative to locating and downloading a toolchain installer,
594 you can build the toolchain installer if you have a
595 <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>.
596 <note>
597 Although not the preferred method, it is also possible to use
598 <filename>bitbake meta-toolchain</filename> to build the toolchain
599 installer.
600 If you do use this method, you must separately install and extract
601 the target sysroot.
602 For information on how to install the sysroot, see the
603 "<link linkend='extracting-the-root-filesystem'>Extracting the Root Filesystem</link>"
604 section.
605 </note>
606 </para>
607
608 <para>
609 To build the toolchain installer and populate the SDK image, use the
610 following command:
611 <literallayout class='monospaced'>
612 $ bitbake <replaceable>image</replaceable> -c populate_sdk
613 </literallayout>
614 The command results in a toolchain installer that contains the sysroot
615 that matches your target root filesystem.
616 </para>
617
618 <para>
619 Another powerful feature is that the toolchain is completely
620 self-contained.
621 The binaries are linked against their own copy of
622 <filename>libc</filename>, which results in no dependencies
623 on the target system.
624 To achieve this, the pointer to the dynamic loader is
625 configured at install time since that path cannot be dynamically
626 altered.
627 This is the reason for a wrapper around the
628 <filename>populate_sdk</filename> archive.
629 </para>
630
631 <para>
632 Another feature is that only one set of cross-canadian toolchain
633 binaries are produced per architecture.
634 This feature takes advantage of the fact that the target hardware can
635 be passed to <filename>gcc</filename> as a set of compiler options.
636 Those options are set up by the environment script and contained in
637 variables such as
638 <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink>
639 and
640 <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink>.
641 This reduces the space needed for the tools.
642 Understand, however, that a sysroot is still needed for every target
643 since those binaries are target-specific.
644 </para>
645
646 <para>
647 Remember, before using any BitBake command, you
648 must source the build environment setup script
649 (i.e.
650 <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
651 or
652 <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
653 located in the Source Directory and you must make sure your
654 <filename>conf/local.conf</filename> variables are correct.
655 In particular, you need to be sure the
656 <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
657 variable matches the architecture for which you are building and that
658 the
659 <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>
660 variable is correctly set if you are building a toolchain designed to
661 run on an architecture that differs from your current development host
662 machine (i.e. the build machine).
663 </para>
664
665 <para>
666 When the <filename>bitbake</filename> command completes, the toolchain
667 installer will be in
668 <filename>tmp/deploy/sdk</filename> in the Build Directory.
669 <note>
670 By default, this toolchain does not build static binaries.
671 If you want to use the toolchain to build these types of libraries,
672 you need to be sure your image has the appropriate static
673 development libraries.
674 Use the
675 <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
676 variable inside your <filename>local.conf</filename> file to
677 install the appropriate library packages.
678 Following is an example using <filename>glibc</filename> static
679 development libraries:
680 <literallayout class='monospaced'>
681 IMAGE_INSTALL_append = " glibc-staticdev"
682 </literallayout>
683 </note>
684 </para>
685</section>
686
687<section id='optionally-using-an-external-toolchain'>
688 <title>Optionally Using an External Toolchain</title>
689
690 <para>
691 You might want to use an external toolchain as part of your
692 development.
693 If this is the case, the fundamental steps you need to accomplish
694 are as follows:
695 <itemizedlist>
696 <listitem><para>
697 Understand where the installed toolchain resides.
698 For cases where you need to build the external toolchain, you
699 would need to take separate steps to build and install the
700 toolchain.
701 </para></listitem>
702 <listitem><para>
703 Make sure you add the layer that contains the toolchain to
704 your <filename>bblayers.conf</filename> file through the
705 <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
706 variable.
707 </para></listitem>
708 <listitem><para>
709 Set the
710 <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink>
711 variable in your <filename>local.conf</filename> file
712 to the location in which you installed the toolchain.
713 </para></listitem>
714 </itemizedlist>
715 A good example of an external toolchain used with the Yocto Project
716 is <trademark class='registered'>Mentor Graphics</trademark>
717 Sourcery G++ Toolchain.
718 You can see information on how to use that particular layer in the
719 <filename>README</filename> file at
720 <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
721 You can find further information by reading about the
722 <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
723 variable in the Yocto Project Reference Manual's variable glossary.
724 </para>
725</section>
726
727 <section id='using-pre-built'>
728 <title>Example Using Pre-Built Binaries and QEMU</title>
729
730 <para>
731 If hardware, libraries and services are stable, you can get started by using a pre-built binary
732 of the filesystem image, kernel, and toolchain and run it using the QEMU emulator.
733 This scenario is useful for developing application software.
734 </para>
735
736 <mediaobject>
737 <imageobject>
738 <imagedata fileref="figures/using-a-pre-built-image.png" format="PNG" align='center' scalefit='1'/>
739 </imageobject>
740 <caption>
741 <para>Using a Pre-Built Image</para>
742 </caption>
743 </mediaobject>
744
745 <para>
746 For this scenario, you need to do several things:
747 </para>
748
749 <itemizedlist>
750 <listitem><para>Install the appropriate stand-alone toolchain tarball.</para></listitem>
751 <listitem><para>Download the pre-built image that will boot with QEMU.
752 You need to be sure to get the QEMU image that matches your target machine’s
753 architecture (e.g. x86, ARM, etc.).</para></listitem>
754 <listitem><para>Download the filesystem image for your target machine's architecture.
755 </para></listitem>
756 <listitem><para>Set up the environment to emulate the hardware and then start the QEMU emulator.
757 </para></listitem>
758 </itemizedlist>
759
760 <section id='installing-the-toolchain'>
761 <title>Installing the Toolchain</title>
762
763 <para>
764 You can download a tarball installer, which includes the
765 pre-built toolchain, the <filename>runqemu</filename>
766 script, and support files from the appropriate directory under
767 <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'></ulink>.
768 Toolchains are available for 32-bit and 64-bit x86 development
769 systems from the <filename>i686</filename> and
770 <filename>x86_64</filename> directories, respectively.
771 The toolchains the Yocto Project provides are based off the
772 <filename>core-image-sato</filename> image and contain
773 libraries appropriate for developing against that image.
774 Each type of development system supports five or more target
775 architectures.
776 </para>
777
778 <para>
779 The names of the tarball installer scripts are such that a
780 string representing the host system appears first in the
781 filename and then is immediately followed by a string
782 representing the target architecture.
783 </para>
784
785 <literallayout class='monospaced'>
786 poky-glibc-<replaceable>host_system</replaceable>-<replaceable>image_type</replaceable>-<replaceable>arch</replaceable>-toolchain-<replaceable>release_version</replaceable>.sh
787
788 Where:
789 <replaceable>host_system</replaceable> is a string representing your development system:
790
791 i686 or x86_64.
792
793 <replaceable>image_type</replaceable> is a string representing the image you wish to
794 develop a Software Development Toolkit (SDK) for use against.
795 The Yocto Project builds toolchain installers using the
796 following BitBake command:
797
798 bitbake core-image-sato -c populate_sdk
799
800 <replaceable>arch</replaceable> is a string representing the tuned target architecture:
801
802 i586, x86_64, powerpc, mips, armv7a or armv5te
803
804 <replaceable>release_version</replaceable> is a string representing the release number of the
805 Yocto Project:
806
807 &DISTRO;, &DISTRO;+snapshot
808 </literallayout>
809
810 <para>
811 For example, the following toolchain installer is for a 64-bit
812 development host system and a i586-tuned target architecture
813 based off the SDK for <filename>core-image-sato</filename>:
814 <literallayout class='monospaced'>
815 poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
816 </literallayout>
817 </para>
818
819 <para>
820 Toolchains are self-contained and by default are installed into
821 <filename>/opt/poky</filename>.
822 However, when you run the toolchain installer, you can choose an
823 installation directory.
824 </para>
825
826 <para>
827 The following command shows how to run the installer given a toolchain tarball
828 for a 64-bit x86 development host system and a 32-bit x86 target architecture.
829 You must change the permissions on the toolchain
830 installer script so that it is executable.
831 </para>
832
833 <para>
834 The example assumes the toolchain installer is located in <filename>~/Downloads/</filename>.
835 <note>
836 If you do not have write permissions for the directory into which you are installing
837 the toolchain, the toolchain installer notifies you and exits.
838 Be sure you have write permissions in the directory and run the installer again.
839 </note>
840 </para>
841
842 <para>
843 <literallayout class='monospaced'>
844 $ ~/Downloads/poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
845 </literallayout>
846 </para>
847
848 <para>
849 For more information on how to install tarballs, see the
850 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-an-existing-toolchain-tarball'>Using a Cross-Toolchain Tarball</ulink>" and
851 "<ulink url='&YOCTO_DOCS_ADT_URL;#using-the-toolchain-from-within-the-build-tree'>Using BitBake and the Build Directory</ulink>" sections in the Yocto Project Application Developer's Guide.
852 </para>
853 </section>
854
855 <section id='downloading-the-pre-built-linux-kernel'>
856 <title>Downloading the Pre-Built Linux Kernel</title>
857
858 <para>
859 You can download the pre-built Linux kernel suitable for running in the QEMU emulator from
860 <ulink url='&YOCTO_QEMU_DL_URL;'></ulink>.
861 Be sure to use the kernel that matches the architecture you want to simulate.
862 Download areas exist for the five supported machine architectures:
863 <filename>qemuarm</filename>, <filename>qemumips</filename>, <filename>qemuppc</filename>,
864 <filename>qemux86</filename>, and <filename>qemux86-64</filename>.
865 </para>
866
867 <para>
868 Most kernel files have one of the following forms:
869 <literallayout class='monospaced'>
870 *zImage-qemu<replaceable>arch</replaceable>.bin
871 vmlinux-qemu<replaceable>arch</replaceable>.bin
872
873 Where:
874 <replaceable>arch</replaceable> is a string representing the target architecture:
875 x86, x86-64, ppc, mips, or arm.
876 </literallayout>
877 </para>
878
879 <para>
880 You can learn more about downloading a Yocto Project kernel in the
881 "<ulink url='&YOCTO_DOCS_DEV_URL;#local-kernel-files'>Yocto Project Kernel</ulink>"
882 bulleted item in the Yocto Project Development Manual.
883 </para>
884 </section>
885
886 <section id='downloading-the-filesystem'>
887 <title>Downloading the Filesystem</title>
888
889 <para>
890 You can also download the filesystem image suitable for your target architecture from
891 <ulink url='&YOCTO_QEMU_DL_URL;'></ulink>.
892 Again, be sure to use the filesystem that matches the architecture you want
893 to simulate.
894 </para>
895
896 <para>
897 The filesystem image has two tarball forms: <filename>ext3</filename> and
898 <filename>tar</filename>.
899 You must use the <filename>ext3</filename> form when booting an image using the
900 QEMU emulator.
901 The <filename>tar</filename> form can be flattened out in your host development system
902 and used for build purposes with the Yocto Project.
903 <literallayout class='monospaced'>
904 core-image-<replaceable>profile</replaceable>-qemu<replaceable>arch</replaceable>.ext3
905 core-image-<replaceable>profile</replaceable>-qemu<replaceable>arch</replaceable>.tar.bz2
906
907 Where:
908 <replaceable>profile</replaceable> is the filesystem image's profile:
909 lsb, lsb-dev, lsb-sdk, lsb-qt3, minimal, minimal-dev, sato,
910 sato-dev, or sato-sdk. For information on these types of image
911 profiles, see the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
912 chapter in the Yocto Project Reference Manual.
913
914 <replaceable>arch</replaceable> is a string representing the target architecture:
915 x86, x86-64, ppc, mips, or arm.
916 </literallayout>
917 </para>
918 </section>
919
920 <section id='setting-up-the-environment-and-starting-the-qemu-emulator'>
921 <title>Setting Up the Environment and Starting the QEMU Emulator</title>
922
923 <para>
924 Before you start the QEMU emulator, you need to set up the emulation environment.
925 The following command form sets up the emulation environment.
926 <literallayout class='monospaced'>
927 $ source &YOCTO_ADTPATH_DIR;/environment-setup-<replaceable>arch</replaceable>-poky-linux-<replaceable>if</replaceable>
928
929 Where:
930 <replaceable>arch</replaceable> is a string representing the target architecture:
931 i586, x86_64, ppc603e, mips, or armv5te.
932
933 <replaceable>if</replaceable> is a string representing an embedded application binary interface.
934 Not all setup scripts include this string.
935 </literallayout>
936 </para>
937
938 <para>
939 Finally, this command form invokes the QEMU emulator
940 <literallayout class='monospaced'>
941 $ runqemu <replaceable>qemuarch</replaceable> <replaceable>kernel-image</replaceable> <replaceable>filesystem-image</replaceable>
942
943 Where:
944 <replaceable>qemuarch</replaceable> is a string representing the target architecture: qemux86, qemux86-64,
945 qemuppc, qemumips, or qemuarm.
946
947 <replaceable>kernel-image</replaceable> is the architecture-specific kernel image.
948
949 <replaceable>filesystem-image</replaceable> is the .ext3 filesystem image.
950
951 </literallayout>
952 </para>
953
954 <para>
955 Continuing with the example, the following two commands setup the emulation
956 environment and launch QEMU.
957 This example assumes the root filesystem (<filename>.ext3</filename> file) and
958 the pre-built kernel image file both reside in your home directory.
959 The kernel and filesystem are for a 32-bit target architecture.
960 <literallayout class='monospaced'>
961 $ cd $HOME
962 $ source &YOCTO_ADTPATH_DIR;/environment-setup-i586-poky-linux
963 $ runqemu qemux86 bzImage-qemux86.bin \
964 core-image-sato-qemux86.ext3
965 </literallayout>
966 </para>
967
968 <para>
969 The environment in which QEMU launches varies depending on the filesystem image and on the
970 target architecture.
971 For example, if you source the environment for the ARM target
972 architecture and then boot the minimal QEMU image, the emulator comes up in a new
973 shell in command-line mode.
974 However, if you boot the SDK image, QEMU comes up with a GUI.
975 <note>Booting the PPC image results in QEMU launching in the same shell in
976 command-line mode.</note>
977 </para>
978 </section>
979</section>
980
981</chapter>
982<!--
983vim: expandtab tw=80 ts=4
984-->