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