diff options
Diffstat (limited to 'documentation/adt-manual/adt-prepare.rst')
-rw-r--r-- | documentation/adt-manual/adt-prepare.rst | 753 |
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 | ************************************* | ||
2 | Preparing for Application Development | ||
3 | ************************************* | ||
4 | |||
5 | In order to develop applications, you need set up your host development | ||
6 | system. Several ways exist that allow you to install cross-development | ||
7 | tools, QEMU, the Eclipse Yocto Plug-in, and other tools. This chapter | ||
8 | describes how to prepare for application development. | ||
9 | |||
10 | .. _installing-the-adt: | ||
11 | |||
12 | Installing the ADT and Toolchains | ||
13 | ================================= | ||
14 | |||
15 | The following list describes installation methods that set up varying | ||
16 | degrees of tool availability on your system. Regardless of the | ||
17 | installation method you choose, you must ``source`` the cross-toolchain | ||
18 | environment setup script, which establishes several key environment | ||
19 | variables, before you use a toolchain. See the "`Setting Up the | ||
20 | Cross-Development | ||
21 | Environment <#setting-up-the-cross-development-environment>`__" section | ||
22 | for 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 | |||
57 | Using the ADT Installer | ||
58 | ----------------------- | ||
59 | |||
60 | To run the ADT Installer, you need to get the ADT Installer tarball, be | ||
61 | sure you have the necessary host development packages that support the | ||
62 | ADT Installer, and then run the ADT Installer Script. | ||
63 | |||
64 | For a list of the host packages needed to support ADT installation and | ||
65 | use, see the "ADT Installer Extras" lists in the "`Required Packages for | ||
66 | the Host Development | ||
67 | System <&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system>`__" | ||
68 | section of the Yocto Project Reference Manual. | ||
69 | |||
70 | Getting the ADT Installer Tarball | ||
71 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
72 | |||
73 | The ADT Installer is contained in the ADT Installer tarball. You can get | ||
74 | the 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 | |||
112 | Configuring and Running the ADT Installer Script | ||
113 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
114 | |||
115 | Before running the ADT Installer script, you need to unpack the tarball. | ||
116 | You can unpack the tarball in any directory you wish. For example, this | ||
117 | command copies the ADT Installer tarball from where it was built into | ||
118 | the home directory and then unpacks the tarball into a top-level | ||
119 | directory named ``adt-installer``: $ cd ~ $ cp | ||
120 | poky/build/tmp/deploy/sdk/adt_installer.tar.bz2 $HOME $ tar -xjf | ||
121 | adt_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 | |||
125 | Before you run the script, however, you should examine the ADT Installer | ||
126 | configuration file and be sure you are going to get what you want. Your | ||
127 | configurations determine which kernel and filesystem image are | ||
128 | downloaded. | ||
129 | |||
130 | The following list describes the configurations you can define for the | ||
131 | ADT Installer. For configuration values and restrictions, see the | ||
132 | comments 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 | |||
184 | After you have configured the ``adt_installer.conf`` file, run the | ||
185 | installer using the following command: $ cd adt-installer $ | ||
186 | ./adt_installer Once the installer begins to run, you are asked to enter | ||
187 | the location for cross-toolchain installation. The default location is | ||
188 | ``/opt/poky/``\ release. After either accepting the default location or | ||
189 | selecting your own location, you are prompted to run the installation | ||
190 | script interactively or in silent mode. If you want to closely monitor | ||
191 | the installation, choose “I” for interactive mode rather than “S” for | ||
192 | silent mode. Follow the prompts from the script to complete the | ||
193 | installation. | ||
194 | |||
195 | Once the installation completes, the ADT, which includes the | ||
196 | cross-toolchain, is installed in the selected installation directory. | ||
197 | You will notice environment setup files for the cross-toolchain in the | ||
198 | installation directory, and image tarballs in the ``adt-installer`` | ||
199 | directory according to your installer configurations, and the target | ||
200 | sysroot located according to the ``YOCTOADT_TARGET_SYSROOT_LOC_``\ arch | ||
201 | variable also in your configuration file. | ||
202 | |||
203 | .. _using-an-existing-toolchain-tarball: | ||
204 | |||
205 | Using a Cross-Toolchain Tarball | ||
206 | ------------------------------- | ||
207 | |||
208 | If you want to simply install a cross-toolchain by hand, you can do so | ||
209 | by running the toolchain installer. The installer includes the pre-built | ||
210 | cross-toolchain, the ``runqemu`` script, and support files. If you use | ||
211 | this method to install the cross-toolchain, you might still need to | ||
212 | install the target sysroot by installing and extracting it separately. | ||
213 | For information on how to install the sysroot, see the "`Extracting the | ||
214 | Root Filesystem <#extracting-the-root-filesystem>`__" section. | ||
215 | |||
216 | Follow these steps: | ||
217 | |||
218 | 1. *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 | |||
240 | 2. *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 | |||
265 | Using BitBake and the Build Directory | ||
266 | ------------------------------------- | ||
267 | |||
268 | A final way of making the cross-toolchain available is to use BitBake to | ||
269 | generate the toolchain within an existing `Build | ||
270 | Directory <&YOCTO_DOCS_DEV_URL;#build-directory>`__. This method does | ||
271 | not install the toolchain into the default ``/opt`` directory. As with | ||
272 | the previous method, if you need to install the target sysroot, you must | ||
273 | do that separately as well. | ||
274 | |||
275 | Follow these steps to generate the toolchain into the Build Directory: | ||
276 | |||
277 | 1. *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 | |||
284 | 2. *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 | |||
304 | 3. *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 | |||
313 | 4. *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 | |||
325 | Setting Up the Cross-Development Environment | ||
326 | ============================================ | ||
327 | |||
328 | Before you can develop using the cross-toolchain, you need to set up the | ||
329 | cross-development environment by sourcing the toolchain's environment | ||
330 | setup script. If you used the ADT Installer or hand-installed | ||
331 | cross-toolchain, then you can find this script in the directory you | ||
332 | chose for installation. For this release, the default installation | ||
333 | directory is ````. If you installed the toolchain in the `Build | ||
334 | Directory <&YOCTO_DOCS_DEV_URL;#build-directory>`__, you can find the | ||
335 | environment setup script for the toolchain in the Build Directory's | ||
336 | ``tmp`` directory. | ||
337 | |||
338 | Be sure to run the environment setup script that matches the | ||
339 | architecture for which you are developing. Environment setup scripts | ||
340 | begin with the string "``environment-setup``" and include as part of | ||
341 | their name the architecture. For example, the toolchain environment | ||
342 | setup script for a 64-bit IA-based architecture installed in the default | ||
343 | installation directory would be the following: | ||
344 | YOCTO_ADTPATH_DIR/environment-setup-x86_64-poky-linux When you run the | ||
345 | setup script, many environment variables are defined: | ||
346 | ```SDKTARGETSYSROOT`` <&YOCTO_DOCS_REF_URL;#var-SDKTARGETSYSROOT>`__ - | ||
347 | The path to the sysroot used for cross-compilation | ||
348 | ```PKG_CONFIG_PATH`` <&YOCTO_DOCS_REF_URL;#var-PKG_CONFIG_PATH>`__ - The | ||
349 | path to the target pkg-config files | ||
350 | ```CONFIG_SITE`` <&YOCTO_DOCS_REF_URL;#var-CONFIG_SITE>`__ - A GNU | ||
351 | autoconf site file preconfigured for the target | ||
352 | ```CC`` <&YOCTO_DOCS_REF_URL;#var-CC>`__ - The minimal command and | ||
353 | arguments to run the C compiler | ||
354 | ```CXX`` <&YOCTO_DOCS_REF_URL;#var-CXX>`__ - The minimal command and | ||
355 | arguments to run the C++ compiler | ||
356 | ```CPP`` <&YOCTO_DOCS_REF_URL;#var-CPP>`__ - The minimal command and | ||
357 | arguments to run the C preprocessor | ||
358 | ```AS`` <&YOCTO_DOCS_REF_URL;#var-AS>`__ - The minimal command and | ||
359 | arguments 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 | ||
362 | arguments to run the GNU Debugger | ||
363 | ```STRIP`` <&YOCTO_DOCS_REF_URL;#var-STRIP>`__ - The minimal command and | ||
364 | arguments to run 'strip', which strips symbols | ||
365 | ```RANLIB`` <&YOCTO_DOCS_REF_URL;#var-RANLIB>`__ - The minimal command | ||
366 | and arguments to run 'ranlib' | ||
367 | ```OBJCOPY`` <&YOCTO_DOCS_REF_URL;#var-OBJCOPY>`__ - The minimal command | ||
368 | and arguments to run 'objcopy' | ||
369 | ```OBJDUMP`` <&YOCTO_DOCS_REF_URL;#var-OBJDUMP>`__ - The minimal command | ||
370 | and 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 | ||
373 | arguments to run 'nm' | ||
374 | ```TARGET_PREFIX`` <&YOCTO_DOCS_REF_URL;#var-TARGET_PREFIX>`__ - The | ||
375 | toolchain binary prefix for the target tools | ||
376 | ```CROSS_COMPILE`` <&YOCTO_DOCS_REF_URL;#var-CROSS_COMPILE>`__ - The | ||
377 | toolchain binary prefix for the target tools | ||
378 | ```CONFIGURE_FLAGS`` <&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS>`__ - The | ||
379 | minimal 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++ | ||
382 | flags ```LDFLAGS`` <&YOCTO_DOCS_REF_URL;#var-LDFLAGS>`__ - Suggested | ||
383 | linker flags when you use CC to link | ||
384 | ```CPPFLAGS`` <&YOCTO_DOCS_REF_URL;#var-CPPFLAGS>`__ - Suggested | ||
385 | preprocessor flags | ||
386 | |||
387 | Securing Kernel and Filesystem Images | ||
388 | ===================================== | ||
389 | |||
390 | You will need to have a kernel and filesystem image to boot using your | ||
391 | hardware or the QEMU emulator. Furthermore, if you plan on booting your | ||
392 | image using NFS or you want to use the root filesystem as the target | ||
393 | sysroot, you need to extract the root filesystem. | ||
394 | |||
395 | Getting the Images | ||
396 | ------------------ | ||
397 | |||
398 | To get the kernel and filesystem images, you either have to build them | ||
399 | or download pre-built versions. For an example of how to build these | ||
400 | images, see the "`Buiding | ||
401 | Images <&YOCTO_DOCS_QS_URL;#qs-buiding-images>`__" section of the Yocto | ||
402 | Project Quick Start. For an example of downloading pre-build versions, | ||
403 | see the "`Example Using Pre-Built Binaries and | ||
404 | QEMU <#using-pre-built>`__" section. | ||
405 | |||
406 | The Yocto Project ships basic kernel and filesystem images for several | ||
407 | architectures (``x86``, ``x86-64``, ``mips``, ``powerpc``, and ``arm``) | ||
408 | that you can use unaltered in the QEMU emulator. These kernel images | ||
409 | reside in the release area - ` <&YOCTO_MACHINES_DL_URL;>`__ and are | ||
410 | ideal for experimentation using Yocto Project. For information on the | ||
411 | image types you can build using the OpenEmbedded build system, see the | ||
412 | "`Images <&YOCTO_DOCS_REF_URL;#ref-images>`__" chapter in the Yocto | ||
413 | Project Reference Manual. | ||
414 | |||
415 | If you are planning on developing against your image and you are not | ||
416 | building or using one of the Yocto Project development images (e.g. | ||
417 | ``core-image-*-dev``), you must be sure to include the development | ||
418 | packages as part of your image recipe. | ||
419 | |||
420 | If you plan on remotely deploying and debugging your application from | ||
421 | within the Eclipse IDE, you must have an image that contains the Yocto | ||
422 | Target Communication Framework (TCF) agent (``tcf-agent``). You can do | ||
423 | this 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 | |||
432 | To include the ``eclipse-debug`` image feature, modify your | ||
433 | ``local.conf`` file in the `Build | ||
434 | Directory <&YOCTO_DOCS_DEV_URL;#build-directory>`__ so that the | ||
435 | ```EXTRA_IMAGE_FEATURES`` <&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES>`__ | ||
436 | variable includes the "eclipse-debug" feature. After modifying the | ||
437 | configuration file, you can rebuild the image. Once the image is | ||
438 | rebuilt, the ``tcf-agent`` will be included in the image and is launched | ||
439 | automatically after the boot. | ||
440 | |||
441 | Extracting the Root Filesystem | ||
442 | ------------------------------ | ||
443 | |||
444 | If you install your toolchain by hand or build it using BitBake and you | ||
445 | need a root filesystem, you need to extract it separately. If you use | ||
446 | the ADT Installer to install the ADT, the root filesystem is | ||
447 | automatically extracted and installed. | ||
448 | |||
449 | Here 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 | |||
460 | To extract the root filesystem, first ``source`` the cross-development | ||
461 | environment setup script to establish necessary environment variables. | ||
462 | If you built the toolchain in the Build Directory, you will find the | ||
463 | toolchain environment script in the ``tmp`` directory. If you installed | ||
464 | the toolchain by hand, the environment setup script is located in | ||
465 | ``/opt/poky/DISTRO``. | ||
466 | |||
467 | After sourcing the environment script, use the ``runqemu-extract-sdk`` | ||
468 | command and provide the filesystem image. | ||
469 | |||
470 | Following is an example. The second command sets up the environment. In | ||
471 | this case, the setup script is located in the ``/opt/poky/DISTRO`` | ||
472 | directory. The third command extracts the root filesystem from a | ||
473 | previously built filesystem that is located in the ``~/Downloads`` | ||
474 | directory. Furthermore, this command extracts the root filesystem into | ||
475 | the ``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 | |||
481 | Optionally Building a Toolchain Installer | ||
482 | ========================================= | ||
483 | |||
484 | As an alternative to locating and downloading a toolchain installer, you | ||
485 | can build the toolchain installer if you have a `Build | ||
486 | Directory <&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 | |||
498 | To build the toolchain installer and populate the SDK image, use the | ||
499 | following command: $ bitbake image -c populate_sdk The command results | ||
500 | in a toolchain installer that contains the sysroot that matches your | ||
501 | target root filesystem. | ||
502 | |||
503 | Another powerful feature is that the toolchain is completely | ||
504 | self-contained. The binaries are linked against their own copy of | ||
505 | ``libc``, which results in no dependencies on the target system. To | ||
506 | achieve this, the pointer to the dynamic loader is configured at install | ||
507 | time since that path cannot be dynamically altered. This is the reason | ||
508 | for a wrapper around the ``populate_sdk`` archive. | ||
509 | |||
510 | Another feature is that only one set of cross-canadian toolchain | ||
511 | binaries are produced per architecture. This feature takes advantage of | ||
512 | the fact that the target hardware can be passed to ``gcc`` as a set of | ||
513 | compiler options. Those options are set up by the environment script and | ||
514 | contained in variables such as ```CC`` <&YOCTO_DOCS_REF_URL;#var-CC>`__ | ||
515 | and ```LD`` <&YOCTO_DOCS_REF_URL;#var-LD>`__. This reduces the space | ||
516 | needed for the tools. Understand, however, that a sysroot is still | ||
517 | needed for every target since those binaries are target-specific. | ||
518 | |||
519 | Remember, before using any BitBake command, you must source the build | ||
520 | environment 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>`__) | ||
523 | located in the Source Directory and you must make sure your | ||
524 | ``conf/local.conf`` variables are correct. In particular, you need to be | ||
525 | sure the ```MACHINE`` <&YOCTO_DOCS_REF_URL;#var-MACHINE>`__ variable | ||
526 | matches the architecture for which you are building and that the | ||
527 | ```SDKMACHINE`` <&YOCTO_DOCS_REF_URL;#var-SDKMACHINE>`__ variable is | ||
528 | correctly set if you are building a toolchain designed to run on an | ||
529 | architecture that differs from your current development host machine | ||
530 | (i.e. the build machine). | ||
531 | |||
532 | When the ``bitbake`` command completes, the toolchain installer will be | ||
533 | in ``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 | |||
553 | Optionally Using an External Toolchain | ||
554 | ====================================== | ||
555 | |||
556 | You might want to use an external toolchain as part of your development. | ||
557 | If this is the case, the fundamental steps you need to accomplish are as | ||
558 | follows: | ||
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 | |||
573 | A good example of an external toolchain used with the Yocto Project is | ||
574 | Mentor Graphics Sourcery G++ Toolchain. You can see information on how | ||
575 | to use that particular layer in the ``README`` file at | ||
576 | ` <http://github.com/MentorEmbedded/meta-sourcery/>`__. You can find | ||
577 | further information by reading about the | ||
578 | ```TCMODE`` <&YOCTO_DOCS_REF_URL;#var-TCMODE>`__ variable in the Yocto | ||
579 | Project Reference Manual's variable glossary. | ||
580 | |||
581 | .. _using-pre-built: | ||
582 | |||
583 | Example Using Pre-Built Binaries and QEMU | ||
584 | ========================================= | ||
585 | |||
586 | If hardware, libraries and services are stable, you can get started by | ||
587 | using a pre-built binary of the filesystem image, kernel, and toolchain | ||
588 | and run it using the QEMU emulator. This scenario is useful for | ||
589 | developing application software. | ||
590 | |||
591 | |Using a Pre-Built Image| | ||
592 | |||
593 | For 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 | |||
606 | Installing the Toolchain | ||
607 | ------------------------ | ||
608 | |||
609 | You can download a tarball installer, which includes the pre-built | ||
610 | toolchain, the ``runqemu`` script, and support files from the | ||
611 | appropriate directory under ` <&YOCTO_TOOLCHAIN_DL_URL;>`__. Toolchains | ||
612 | are available for 32-bit and 64-bit x86 development systems from the | ||
613 | ``i686`` and ``x86_64`` directories, respectively. The toolchains the | ||
614 | Yocto Project provides are based off the ``core-image-sato`` image and | ||
615 | contain libraries appropriate for developing against that image. Each | ||
616 | type of development system supports five or more target architectures. | ||
617 | |||
618 | The names of the tarball installer scripts are such that a string | ||
619 | representing the host system appears first in the filename and then is | ||
620 | immediately 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 | |||
648 | For example, the following toolchain installer is for a 64-bit | ||
649 | development host system and a i586-tuned target architecture based off | ||
650 | the SDK for ``core-image-sato``: | ||
651 | poky-glibc-x86_64-core-image-sato-i586-toolchain-DISTRO.sh | ||
652 | |||
653 | Toolchains are self-contained and by default are installed into | ||
654 | ``/opt/poky``. However, when you run the toolchain installer, you can | ||
655 | choose an installation directory. | ||
656 | |||
657 | The following command shows how to run the installer given a toolchain | ||
658 | tarball for a 64-bit x86 development host system and a 32-bit x86 target | ||
659 | architecture. You must change the permissions on the toolchain installer | ||
660 | script so that it is executable. | ||
661 | |||
662 | The 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 | |||
674 | For more information on how to install tarballs, see the "`Using a | ||
675 | Cross-Toolchain | ||
676 | Tarball <&YOCTO_DOCS_ADT_URL;#using-an-existing-toolchain-tarball>`__" | ||
677 | and "`Using BitBake and the Build | ||
678 | Directory <&YOCTO_DOCS_ADT_URL;#using-the-toolchain-from-within-the-build-tree>`__" | ||
679 | sections in the Yocto Project Application Developer's Guide. | ||
680 | |||
681 | Downloading the Pre-Built Linux Kernel | ||
682 | -------------------------------------- | ||
683 | |||
684 | You can download the pre-built Linux kernel suitable for running in the | ||
685 | QEMU emulator from ` <&YOCTO_QEMU_DL_URL;>`__. Be sure to use the kernel | ||
686 | that matches the architecture you want to simulate. Download areas exist | ||
687 | for the five supported machine architectures: ``qemuarm``, ``qemumips``, | ||
688 | ``qemuppc``, ``qemux86``, and ``qemux86-64``. | ||
689 | |||
690 | Most kernel files have one of the following forms: \*zImage-qemuarch.bin | ||
691 | vmlinux-qemuarch.bin Where: arch is a string representing the target | ||
692 | architecture: x86, x86-64, ppc, mips, or arm. | ||
693 | |||
694 | You can learn more about downloading a Yocto Project kernel in the | ||
695 | "`Yocto Project Kernel <&YOCTO_DOCS_DEV_URL;#local-kernel-files>`__" | ||
696 | bulleted item in the Yocto Project Development Manual. | ||
697 | |||
698 | Downloading the Filesystem | ||
699 | -------------------------- | ||
700 | |||
701 | You can also download the filesystem image suitable for your target | ||
702 | architecture from ` <&YOCTO_QEMU_DL_URL;>`__. Again, be sure to use the | ||
703 | filesystem that matches the architecture you want to simulate. | ||
704 | |||
705 | The filesystem image has two tarball forms: ``ext3`` and ``tar``. You | ||
706 | must use the ``ext3`` form when booting an image using the QEMU | ||
707 | emulator. The ``tar`` form can be flattened out in your host development | ||
708 | system and used for build purposes with the Yocto Project. | ||
709 | core-image-profile-qemuarch.ext3 core-image-profile-qemuarch.tar.bz2 | ||
710 | Where: profile is the filesystem image's profile: lsb, lsb-dev, lsb-sdk, | ||
711 | lsb-qt3, minimal, minimal-dev, sato, sato-dev, or sato-sdk. For | ||
712 | information on these types of image profiles, see the | ||
713 | "`Images <&YOCTO_DOCS_REF_URL;#ref-images>`__" chapter in the Yocto | ||
714 | Project Reference Manual. arch is a string representing the target | ||
715 | architecture: x86, x86-64, ppc, mips, or arm. | ||
716 | |||
717 | Setting Up the Environment and Starting the QEMU Emulator | ||
718 | --------------------------------------------------------- | ||
719 | |||
720 | Before you start the QEMU emulator, you need to set up the emulation | ||
721 | environment. The following command form sets up the emulation | ||
722 | environment. $ source | ||
723 | YOCTO_ADTPATH_DIR/environment-setup-arch-poky-linux-if Where: arch is a | ||
724 | string representing the target architecture: i586, x86_64, ppc603e, | ||
725 | mips, or armv5te. if is a string representing an embedded application | ||
726 | binary interface. Not all setup scripts include this string. | ||
727 | |||
728 | Finally, this command form invokes the QEMU emulator $ runqemu qemuarch | ||
729 | kernel-image filesystem-image Where: qemuarch is a string representing | ||
730 | the target architecture: qemux86, qemux86-64, qemuppc, qemumips, or | ||
731 | qemuarm. kernel-image is the architecture-specific kernel image. | ||
732 | filesystem-image is the .ext3 filesystem image. | ||
733 | |||
734 | Continuing with the example, the following two commands setup the | ||
735 | emulation environment and launch QEMU. This example assumes the root | ||
736 | filesystem (``.ext3`` file) and the pre-built kernel image file both | ||
737 | reside in your home directory. The kernel and filesystem are for a | ||
738 | 32-bit target architecture. $ cd $HOME $ source | ||
739 | YOCTO_ADTPATH_DIR/environment-setup-i586-poky-linux $ runqemu qemux86 | ||
740 | bzImage-qemux86.bin \\ core-image-sato-qemux86.ext3 | ||
741 | |||
742 | The environment in which QEMU launches varies depending on the | ||
743 | filesystem image and on the target architecture. For example, if you | ||
744 | source the environment for the ARM target architecture and then boot the | ||
745 | minimal QEMU image, the emulator comes up in a new shell in command-line | ||
746 | mode. 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 | ||