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