diff options
Diffstat (limited to 'documentation/sdk-manual/sdk-working-projects.xml')
-rw-r--r-- | documentation/sdk-manual/sdk-working-projects.xml | 1461 |
1 files changed, 1461 insertions, 0 deletions
diff --git a/documentation/sdk-manual/sdk-working-projects.xml b/documentation/sdk-manual/sdk-working-projects.xml new file mode 100644 index 0000000000..15e533000c --- /dev/null +++ b/documentation/sdk-manual/sdk-working-projects.xml | |||
@@ -0,0 +1,1461 @@ | |||
1 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | ||
2 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" | ||
3 | [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] > | ||
4 | |||
5 | <chapter id='sdk-working-projects'> | ||
6 | |||
7 | <title>Working with Different Types of Projects</title> | ||
8 | |||
9 | <para> | ||
10 | You can use extensible and standard SDKs when working with Makefile, | ||
11 | Autotools, and <trademark class='trade'>Eclipse</trademark> based | ||
12 | projects. | ||
13 | This chapter covers information specific to each of these types of | ||
14 | projects. | ||
15 | </para> | ||
16 | |||
17 | <section id='autotools-based-projects'> | ||
18 | <title>Autotools-Based Projects</title> | ||
19 | |||
20 | <para> | ||
21 | Once you have a suitable cross-toolchain installed, it is very easy | ||
22 | to develop a project outside of the OpenEmbedded build system. | ||
23 | This section presents a simple "Helloworld" example that shows how | ||
24 | to set up, compile, and run the project. | ||
25 | </para> | ||
26 | |||
27 | <section id='creating-and-running-a-project-based-on-gnu-autotools'> | ||
28 | <title>Creating and Running a Project Based on GNU Autotools</title> | ||
29 | |||
30 | <para> | ||
31 | Follow these steps to create a simple Autotools-based project: | ||
32 | <orderedlist> | ||
33 | <listitem><para> | ||
34 | <emphasis>Create your directory:</emphasis> | ||
35 | Create a clean directory for your project and then make | ||
36 | that directory your working location: | ||
37 | <literallayout class='monospaced'> | ||
38 | $ mkdir $HOME/helloworld | ||
39 | $ cd $HOME/helloworld | ||
40 | </literallayout> | ||
41 | </para></listitem> | ||
42 | <listitem><para> | ||
43 | <emphasis>Populate the directory:</emphasis> | ||
44 | Create <filename>hello.c</filename>, | ||
45 | <filename>Makefile.am</filename>, | ||
46 | and <filename>configure.ac</filename> files as follows: | ||
47 | <itemizedlist> | ||
48 | <listitem><para> | ||
49 | For <filename>hello.c</filename>, include | ||
50 | these lines: | ||
51 | <literallayout class='monospaced'> | ||
52 | #include <stdio.h> | ||
53 | |||
54 | main() | ||
55 | { | ||
56 | printf("Hello World!\n"); | ||
57 | } | ||
58 | </literallayout> | ||
59 | </para></listitem> | ||
60 | <listitem><para> | ||
61 | For <filename>Makefile.am</filename>, | ||
62 | include these lines: | ||
63 | <literallayout class='monospaced'> | ||
64 | bin_PROGRAMS = hello | ||
65 | hello_SOURCES = hello.c | ||
66 | </literallayout> | ||
67 | </para></listitem> | ||
68 | <listitem><para> | ||
69 | For <filename>configure.in</filename>, | ||
70 | include these lines: | ||
71 | <literallayout class='monospaced'> | ||
72 | AC_INIT(hello,0.1) | ||
73 | AM_INIT_AUTOMAKE([foreign]) | ||
74 | AC_PROG_CC | ||
75 | AC_PROG_INSTALL | ||
76 | AC_OUTPUT(Makefile) | ||
77 | </literallayout> | ||
78 | </para></listitem> | ||
79 | </itemizedlist> | ||
80 | </para></listitem> | ||
81 | <listitem><para> | ||
82 | <emphasis>Source the cross-toolchain | ||
83 | environment setup file:</emphasis> | ||
84 | As described earlier in the manual, installing the | ||
85 | cross-toolchain creates a cross-toolchain | ||
86 | environment setup script in the directory that the SDK | ||
87 | was installed. | ||
88 | Before you can use the tools to develop your project, | ||
89 | you must source this setup script. | ||
90 | The script begins with the string "environment-setup" | ||
91 | and contains the machine architecture, which is | ||
92 | followed by the string "poky-linux". | ||
93 | Here is an example that sources a script from the | ||
94 | default SDK installation directory that uses the | ||
95 | 32-bit Intel x86 Architecture and the | ||
96 | &DISTRO_NAME; Yocto Project release: | ||
97 | <literallayout class='monospaced'> | ||
98 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
99 | </literallayout> | ||
100 | </para></listitem> | ||
101 | <listitem><para> | ||
102 | <emphasis>Generate the local aclocal.m4 | ||
103 | files and create the configure script:</emphasis> | ||
104 | The following GNU Autotools generate the local | ||
105 | <filename>aclocal.m4</filename> files and create the | ||
106 | configure script: | ||
107 | <literallayout class='monospaced'> | ||
108 | $ aclocal | ||
109 | $ autoconf | ||
110 | </literallayout> | ||
111 | </para></listitem> | ||
112 | <listitem><para> | ||
113 | <emphasis>Generate files needed by GNU coding | ||
114 | standards:</emphasis> | ||
115 | GNU coding standards require certain files in order | ||
116 | for the project to be compliant. | ||
117 | This command creates those files: | ||
118 | <literallayout class='monospaced'> | ||
119 | $ touch NEWS README AUTHORS ChangeLog | ||
120 | </literallayout> | ||
121 | </para></listitem> | ||
122 | <listitem><para> | ||
123 | <emphasis>Generate the configure file:</emphasis> | ||
124 | This command generates the | ||
125 | <filename>configure</filename>: | ||
126 | <literallayout class='monospaced'> | ||
127 | $ automake -a | ||
128 | </literallayout> | ||
129 | </para></listitem> | ||
130 | <listitem><para> | ||
131 | <emphasis>Cross-compile the project:</emphasis> | ||
132 | This command compiles the project using the | ||
133 | cross-compiler. | ||
134 | The | ||
135 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS'><filename>CONFIGURE_FLAGS</filename></ulink> | ||
136 | environment variable provides the minimal arguments for | ||
137 | GNU configure: | ||
138 | <literallayout class='monospaced'> | ||
139 | $ ./configure ${CONFIGURE_FLAGS} | ||
140 | </literallayout> | ||
141 | </para></listitem> | ||
142 | <listitem><para> | ||
143 | <emphasis>Make and install the project:</emphasis> | ||
144 | These two commands generate and install the project | ||
145 | into the destination directory: | ||
146 | <literallayout class='monospaced'> | ||
147 | $ make | ||
148 | $ make install DESTDIR=./tmp | ||
149 | </literallayout> | ||
150 | </para></listitem> | ||
151 | <listitem><para> | ||
152 | <emphasis>Verify the installation:</emphasis> | ||
153 | This command is a simple way to verify the installation | ||
154 | of your project. | ||
155 | Running the command prints the architecture on which | ||
156 | the binary file can run. | ||
157 | This architecture should be the same architecture that | ||
158 | the installed cross-toolchain supports. | ||
159 | <literallayout class='monospaced'> | ||
160 | $ file ./tmp/usr/local/bin/hello | ||
161 | </literallayout> | ||
162 | </para></listitem> | ||
163 | <listitem><para> | ||
164 | <emphasis>Execute your project:</emphasis> | ||
165 | To execute the project in the shell, simply enter | ||
166 | the name. | ||
167 | You could also copy the binary to the actual target | ||
168 | hardware and run the project there as well: | ||
169 | <literallayout class='monospaced'> | ||
170 | $ ./hello | ||
171 | </literallayout> | ||
172 | As expected, the project displays the "Hello World!" | ||
173 | message. | ||
174 | </para></listitem> | ||
175 | </orderedlist> | ||
176 | </para> | ||
177 | </section> | ||
178 | |||
179 | <section id='passing-host-options'> | ||
180 | <title>Passing Host Options</title> | ||
181 | |||
182 | <para> | ||
183 | For an Autotools-based project, you can use the cross-toolchain | ||
184 | by just passing the appropriate host option to | ||
185 | <filename>configure.sh</filename>. | ||
186 | The host option you use is derived from the name of the | ||
187 | environment setup script found in the directory in which you | ||
188 | installed the cross-toolchain. | ||
189 | For example, the host option for an ARM-based target that uses | ||
190 | the GNU EABI is <filename>armv5te-poky-linux-gnueabi</filename>. | ||
191 | You will notice that the name of the script is | ||
192 | <filename>environment-setup-armv5te-poky-linux-gnueabi</filename>. | ||
193 | Thus, the following command works to update your project and | ||
194 | rebuild it using the appropriate cross-toolchain tools: | ||
195 | <literallayout class='monospaced'> | ||
196 | $ ./configure --host=armv5te-poky-linux-gnueabi \ | ||
197 | --with-libtool-sysroot=<replaceable>sysroot_dir</replaceable> | ||
198 | </literallayout> | ||
199 | <note> | ||
200 | If the <filename>configure</filename> script results in | ||
201 | problems recognizing the | ||
202 | <filename>--with-libtool-sysroot=</filename><replaceable>sysroot-dir</replaceable> | ||
203 | option, regenerate the script to enable the support by | ||
204 | doing the following and then run the script again: | ||
205 | <literallayout class='monospaced'> | ||
206 | $ libtoolize --automake | ||
207 | $ aclocal -I ${OECORE_TARGET_SYSROOT}/usr/share/aclocal \ | ||
208 | [-I <replaceable>dir_containing_your_project-specific_m4_macros</replaceable>] | ||
209 | $ autoconf | ||
210 | $ autoheader | ||
211 | $ automake -a | ||
212 | </literallayout> | ||
213 | </note> | ||
214 | </para> | ||
215 | </section> | ||
216 | </section> | ||
217 | |||
218 | <section id='makefile-based-projects'> | ||
219 | <title>Makefile-Based Projects</title> | ||
220 | |||
221 | <para> | ||
222 | For Makefile-based projects, the cross-toolchain environment | ||
223 | variables established by running the cross-toolchain environment | ||
224 | setup script are subject to general <filename>make</filename> | ||
225 | rules. | ||
226 | </para> | ||
227 | |||
228 | <para> | ||
229 | To illustrate this, consider the following four cross-toolchain | ||
230 | environment variables: | ||
231 | <literallayout class='monospaced'> | ||
232 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'>CC</ulink>=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux | ||
233 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'>LD</ulink>=i586-poky-linux-ld --sysroot=/opt/poky/&DISTRO;/sysroots/i586-poky-linux | ||
234 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink>=-O2 -pipe -g -feliminate-unused-debug-types | ||
235 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CXXFLAGS'>CXXFLAGS</ulink>=-O2 -pipe -g -feliminate-unused-debug-types | ||
236 | </literallayout> | ||
237 | Now, consider the following three cases: | ||
238 | <itemizedlist> | ||
239 | <listitem><para> | ||
240 | <emphasis>Case 1 - No Variables Set in the | ||
241 | <filename>Makefile</filename>:</emphasis> | ||
242 | Because these variables are not specifically set in the | ||
243 | <filename>Makefile</filename>, the variables retain their | ||
244 | values based on the environment. | ||
245 | </para></listitem> | ||
246 | <listitem><para> | ||
247 | <emphasis>Case 2 - Variables Set in the | ||
248 | <filename>Makefile</filename>:</emphasis> | ||
249 | Specifically setting variables in the | ||
250 | <filename>Makefile</filename> during the build results in | ||
251 | the environment settings of the variables being | ||
252 | overwritten. | ||
253 | </para></listitem> | ||
254 | <listitem><para> | ||
255 | <emphasis>Case 3 - Variables Set when the | ||
256 | <filename>Makefile</filename> is Executed from the | ||
257 | Command Line:</emphasis> | ||
258 | Executing the <filename>Makefile</filename> from the | ||
259 | command-line results in the variables being overwritten | ||
260 | with command-line content regardless of what is being set | ||
261 | in the <filename>Makefile</filename>. | ||
262 | In this case, environment variables are not considered | ||
263 | unless you use the "-e" flag during the build: | ||
264 | <literallayout class='monospaced'> | ||
265 | $ make -e <replaceable>file</replaceable> | ||
266 | </literallayout> | ||
267 | If you use this flag, then the environment values of the | ||
268 | variables override any variables specifically set in the | ||
269 | <filename>Makefile</filename>. | ||
270 | </para></listitem> | ||
271 | </itemizedlist> | ||
272 | <note> | ||
273 | For the list of variables set up by the cross-toolchain | ||
274 | environment setup script, see the | ||
275 | "<link linkend='sdk-running-the-sdk-environment-setup-script'>Running the SDK Environment Setup Script</link>" | ||
276 | section. | ||
277 | </note> | ||
278 | </para> | ||
279 | </section> | ||
280 | |||
281 | <section id='sdk-developing-applications-using-eclipse'> | ||
282 | <title>Developing Applications Using <trademark class='trade'>Eclipse</trademark></title> | ||
283 | |||
284 | <para> | ||
285 | If you are familiar with the popular Eclipse IDE, you can use an | ||
286 | Eclipse Yocto Plug-in to allow you to develop, deploy, and test your | ||
287 | application all from within Eclipse. | ||
288 | This section describes general workflow using the SDK and Eclipse | ||
289 | and how to configure and set up Eclipse. | ||
290 | </para> | ||
291 | |||
292 | <section id='workflow-using-eclipse'> | ||
293 | <title>Workflow Using <trademark class='trade'>Eclipse</trademark></title> | ||
294 | |||
295 | <para> | ||
296 | The following figure and supporting list summarize the | ||
297 | application development general workflow that employs both the | ||
298 | SDK Eclipse. | ||
299 | </para> | ||
300 | |||
301 | <para> | ||
302 | <imagedata fileref="figures/sdk-eclipse-dev-flow.png" | ||
303 | width="7in" depth="7in" align="center" scale="100" /> | ||
304 | </para> | ||
305 | |||
306 | <para> | ||
307 | <orderedlist> | ||
308 | <listitem><para> | ||
309 | <emphasis>Prepare the host system for the Yocto | ||
310 | Project</emphasis>: | ||
311 | See | ||
312 | "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" | ||
313 | and | ||
314 | "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>" | ||
315 | sections both in the Yocto Project Reference Manual for | ||
316 | requirements. | ||
317 | In particular, be sure your host system has the | ||
318 | <filename>xterm</filename> package installed. | ||
319 | </para></listitem> | ||
320 | <listitem><para> | ||
321 | <emphasis>Secure the Yocto Project kernel target | ||
322 | image</emphasis>: | ||
323 | You must have a target kernel image that has been built | ||
324 | using the OpenEmbedded build system.</para> | ||
325 | <para>Depending on whether the Yocto Project has a | ||
326 | pre-built image that matches your target architecture | ||
327 | and where you are going to run the image while you | ||
328 | develop your application (QEMU or real hardware), the | ||
329 | area from which you get the image differs. | ||
330 | <itemizedlist> | ||
331 | <listitem><para> | ||
332 | Download the image from | ||
333 | <ulink url='&YOCTO_MACHINES_DL_URL;'><filename>machines</filename></ulink> | ||
334 | if your target architecture is supported and | ||
335 | you are going to develop and test your | ||
336 | application on actual hardware. | ||
337 | </para></listitem> | ||
338 | <listitem><para> | ||
339 | Download the image from | ||
340 | <ulink url='&YOCTO_QEMU_DL_URL;'> | ||
341 | <filename>machines/qemu</filename></ulink> if | ||
342 | your target architecture is supported and you | ||
343 | are going to develop and test your application | ||
344 | using the QEMU emulator. | ||
345 | </para></listitem> | ||
346 | <listitem><para> | ||
347 | Build your image if you cannot find a pre-built | ||
348 | image that matches your target architecture. | ||
349 | If your target architecture is similar to a | ||
350 | supported architecture, you can modify the | ||
351 | kernel image before you build it. | ||
352 | See the | ||
353 | "<ulink url='&YOCTO_DOCS_DEV_URL;#patching-the-kernel'>Patching the Kernel</ulink>" | ||
354 | section in the Yocto Project Development | ||
355 | manual for an example. | ||
356 | </para></listitem> | ||
357 | </itemizedlist> | ||
358 | </para></listitem> | ||
359 | <listitem> | ||
360 | <para><emphasis>Install the SDK</emphasis>: | ||
361 | The SDK provides a target-specific cross-development | ||
362 | toolchain, the root filesystem, the QEMU emulator, and | ||
363 | other tools that can help you develop your application. | ||
364 | For information on how to install the SDK, see the | ||
365 | "<link linkend='sdk-installing-the-sdk'>Installing the SDK</link>" | ||
366 | section. | ||
367 | </para></listitem> | ||
368 | <listitem><para> | ||
369 | <emphasis>Secure the target root filesystem | ||
370 | and the Cross-development toolchain</emphasis>: | ||
371 | You need to find and download the appropriate root | ||
372 | filesystem and the cross-development toolchain.</para> | ||
373 | <para>You can find the tarballs for the root filesystem | ||
374 | in the same area used for the kernel image. | ||
375 | Depending on the type of image you are running, the | ||
376 | root filesystem you need differs. | ||
377 | For example, if you are developing an application that | ||
378 | runs on an image that supports Sato, you need to get a | ||
379 | root filesystem that supports Sato.</para> | ||
380 | <para>You can find the cross-development toolchains at | ||
381 | <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'><filename>toolchains</filename></ulink>. | ||
382 | Be sure to get the correct toolchain for your | ||
383 | development host and your target architecture. | ||
384 | See the "<link linkend='sdk-locating-pre-built-sdk-installers'>Locating Pre-Built SDK Installers</link>" | ||
385 | section for information and the | ||
386 | "<link linkend='sdk-installing-the-sdk'>Installing the SDK</link>" | ||
387 | section for installation information. | ||
388 | <note> | ||
389 | As an alternative to downloading an SDK, you can | ||
390 | build the toolchain installer. | ||
391 | For information on building the installer, see the | ||
392 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" | ||
393 | section. | ||
394 | Another helpful resource for building an installer | ||
395 | is the | ||
396 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>Cookbook guide to Making an Eclipse Debug Capable Image</ulink> | ||
397 | wiki page. | ||
398 | </note> | ||
399 | </para></listitem> | ||
400 | <listitem><para> | ||
401 | <emphasis>Create and build your application</emphasis>: | ||
402 | At this point, you need to have source files for your | ||
403 | application. | ||
404 | Once you have the files, you can use the Eclipse IDE | ||
405 | to import them and build the project. | ||
406 | If you are not using Eclipse, you need to use the | ||
407 | cross-development tools you have installed to create | ||
408 | the image.</para></listitem> | ||
409 | <listitem><para> | ||
410 | <emphasis>Deploy the image with the | ||
411 | application</emphasis>: | ||
412 | Using the Eclipse IDE, you can deploy your image to the | ||
413 | hardware or to QEMU through the project's preferences. | ||
414 | You can also use Eclipse to load and test your image | ||
415 | under QEMU. | ||
416 | See the | ||
417 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-qemu'>Using the Quick EMUlator (QEMU)</ulink>" | ||
418 | chapter in the Yocto Project Development Manual | ||
419 | for information on using QEMU. | ||
420 | </para></listitem> | ||
421 | <listitem><para> | ||
422 | <emphasis>Test and debug the application</emphasis>: | ||
423 | Once your application is deployed, you need to test it. | ||
424 | Within the Eclipse IDE, you can use the debugging | ||
425 | environment along with supported performance enhancing | ||
426 | <ulink url='http://www.eclipse.org/linuxtools/'>Linux Tools</ulink>. | ||
427 | </para></listitem> | ||
428 | </orderedlist> | ||
429 | </para> | ||
430 | </section> | ||
431 | |||
432 | <section id='adt-eclipse'> | ||
433 | <title>Working Within Eclipse</title> | ||
434 | |||
435 | <para> | ||
436 | The Eclipse IDE is a popular development environment and it | ||
437 | fully supports development using the Yocto Project. | ||
438 | </para> | ||
439 | |||
440 | <para> | ||
441 | When you install and configure the Eclipse Yocto Project | ||
442 | Plug-in into the Eclipse IDE, you maximize your Yocto | ||
443 | Project experience. | ||
444 | Installing and configuring the Plug-in results in an | ||
445 | environment that has extensions specifically designed to let | ||
446 | you more easily develop software. | ||
447 | These extensions allow for cross-compilation, deployment, and | ||
448 | execution of your output into a QEMU emulation session as well | ||
449 | as actual target hardware. | ||
450 | You can also perform cross-debugging and profiling. | ||
451 | The environment also supports performance enhancing | ||
452 | <ulink url='http://www.eclipse.org/linuxtools/'>tools</ulink> | ||
453 | that allow you to perform remote profiling, tracing, | ||
454 | collection of power data, collection of latency data, and | ||
455 | collection of performance data. | ||
456 | <note> | ||
457 | This release of the Yocto Project supports both the Neon | ||
458 | and Mars versions of the Eclipse IDE. | ||
459 | This section provides information on how to use the Neon | ||
460 | release with the Yocto Project. | ||
461 | For information on how to use the Mars version of Eclipse | ||
462 | with the Yocto Project, see | ||
463 | "<link linkend='sdk-appendix-mars'>Appendix C</link>. | ||
464 | </note> | ||
465 | </para> | ||
466 | |||
467 | <section id='neon-setting-up-the-eclipse-ide'> | ||
468 | <title>Setting Up the Neon Version of the Eclipse IDE</title> | ||
469 | |||
470 | <para> | ||
471 | To develop within the Eclipse IDE, you need to do the | ||
472 | following: | ||
473 | <orderedlist> | ||
474 | <listitem><para> | ||
475 | Install the Neon version of the Eclipse IDE. | ||
476 | </para></listitem> | ||
477 | <listitem><para> | ||
478 | Configure the Eclipse IDE. | ||
479 | </para></listitem> | ||
480 | <listitem><para> | ||
481 | Install the Eclipse Yocto Plug-in. | ||
482 | </para></listitem> | ||
483 | <listitem><para> | ||
484 | Configure the Eclipse Yocto Plug-in. | ||
485 | </para></listitem> | ||
486 | </orderedlist> | ||
487 | <note> | ||
488 | Do not install Eclipse from your distribution's package | ||
489 | repository. | ||
490 | Be sure to install Eclipse from the official Eclipse | ||
491 | download site as directed in the next section. | ||
492 | </note> | ||
493 | </para> | ||
494 | |||
495 | <section id='neon-installing-eclipse-ide'> | ||
496 | <title>Installing the Neon Eclipse IDE</title> | ||
497 | |||
498 | <para> | ||
499 | Follow these steps to locate, install, and configure | ||
500 | Neon Eclipse: | ||
501 | <orderedlist> | ||
502 | <listitem><para> | ||
503 | <emphasis>Locate the Neon Download:</emphasis> | ||
504 | Open a browser and go to | ||
505 | <ulink url='http://www.eclipse.org/mars/'>http://www.eclipse.org/neon/</ulink>. | ||
506 | </para></listitem> | ||
507 | <listitem><para> | ||
508 | <emphasis>Download the Tarball:</emphasis> | ||
509 | Click through the "Download" buttons to | ||
510 | download the file. | ||
511 | </para></listitem> | ||
512 | <listitem><para> | ||
513 | <emphasis>Unpack the Tarball:</emphasis> | ||
514 | Move to a clean directory and unpack the | ||
515 | tarball. | ||
516 | Here is an example: | ||
517 | <literallayout class='monospaced'> | ||
518 | $ cd ~ | ||
519 | $ tar -xzvf ~/Downloads/eclipse-inst-linux64.tar.gz | ||
520 | </literallayout> | ||
521 | Everything unpacks into a folder named | ||
522 | "eclipse-installer". | ||
523 | </para></listitem> | ||
524 | <listitem><para> | ||
525 | <emphasis>Launch the Installer:</emphasis> | ||
526 | Use the following commands to launch the | ||
527 | installer: | ||
528 | <literallayout class='monospaced'> | ||
529 | $ cd ~/eclipse-installer | ||
530 | $ ./eclipse-inst | ||
531 | </literallayout> | ||
532 | </para></listitem> | ||
533 | <listitem><para> | ||
534 | <emphasis>Select Your IDE:</emphasis> | ||
535 | From the list, select the "Eclipse IDE for | ||
536 | C/C++ Developers". | ||
537 | </para></listitem> | ||
538 | <listitem><para> | ||
539 | <emphasis>Install the Software:</emphasis> | ||
540 | Accept the default "cpp-neon" directory and | ||
541 | click "Install". | ||
542 | Accept any license agreements and approve any | ||
543 | certificates. | ||
544 | </para></listitem> | ||
545 | <listitem><para> | ||
546 | <emphasis>Launch Neon:</emphasis> | ||
547 | Click the "Launch" button and accept the | ||
548 | default "workspace". | ||
549 | </para></listitem> | ||
550 | </orderedlist> | ||
551 | </para> | ||
552 | </section> | ||
553 | |||
554 | <section id='neon-configuring-the-mars-eclipse-ide'> | ||
555 | <title>Configuring the Neon Eclipse IDE</title> | ||
556 | |||
557 | <para> | ||
558 | Follow these steps to configure the Neon Eclipse IDE. | ||
559 | <note> | ||
560 | Depending on how you installed Eclipse and what | ||
561 | you have already done, some of the options will | ||
562 | not appear. | ||
563 | If you cannot find an option as directed by the | ||
564 | manual, it has already been installed. | ||
565 | </note> | ||
566 | <orderedlist> | ||
567 | <listitem><para> | ||
568 | Be sure Eclipse is running and you are in your | ||
569 | workbench. | ||
570 | </para></listitem> | ||
571 | <listitem><para> | ||
572 | Select "Install New Software" from the "Help" | ||
573 | pull-down menu. | ||
574 | </para></listitem> | ||
575 | <listitem><para> | ||
576 | Select | ||
577 | "Neon - http://download.eclipse.org/releases/neon" | ||
578 | from the "Work with:" pull-down menu. | ||
579 | </para></listitem> | ||
580 | <listitem><para> | ||
581 | Expand the box next to "Linux Tools" and select | ||
582 | the following: | ||
583 | <literallayout class='monospaced'> | ||
584 | C/C++ Remote (Over TCF/TE) Run/Debug Launcher | ||
585 | TM Terminal | ||
586 | </literallayout> | ||
587 | </para></listitem> | ||
588 | <listitem><para> | ||
589 | Expand the box next to "Mobile and Device | ||
590 | Development" and select the following | ||
591 | boxes: | ||
592 | <literallayout class='monospaced'> | ||
593 | C/C++ Remote (Over TCF/TE) Run/Debug Launcher | ||
594 | Remote System Explorer User Actions | ||
595 | TM Terminal | ||
596 | TCF Remote System Explorer add-in | ||
597 | TCF Target Explorer | ||
598 | </literallayout> | ||
599 | </para></listitem> | ||
600 | <listitem><para> | ||
601 | Expand the box next to "Programming Languages" | ||
602 | and select the following box: | ||
603 | <literallayout class='monospaced'> | ||
604 | C/C++ Development Tools SDK | ||
605 | </literallayout> | ||
606 | </para></listitem> | ||
607 | <listitem><para> | ||
608 | Complete the installation by clicking through | ||
609 | appropriate "Next" and "Finish" buttons. | ||
610 | </para></listitem> | ||
611 | </orderedlist> | ||
612 | </para> | ||
613 | </section> | ||
614 | |||
615 | <section id='neon-installing-the-eclipse-yocto-plug-in'> | ||
616 | <title>Installing or Accessing the Neon Eclipse Yocto Plug-in</title> | ||
617 | |||
618 | <para> | ||
619 | You can install the Eclipse Yocto Plug-in into the | ||
620 | Eclipse IDE one of two ways: use the Yocto Project's | ||
621 | Eclipse Update site to install the pre-built plug-in | ||
622 | or build and install the plug-in from the latest | ||
623 | source code. | ||
624 | </para> | ||
625 | |||
626 | <section id='neon-new-software'> | ||
627 | <title>Installing the Pre-built Plug-in from the Yocto Project Eclipse Update Site</title> | ||
628 | |||
629 | <para> | ||
630 | To install the Neon Eclipse Yocto Plug-in from the | ||
631 | update site, follow these steps: | ||
632 | <orderedlist> | ||
633 | <listitem><para> | ||
634 | Start up the Eclipse IDE. | ||
635 | </para></listitem> | ||
636 | <listitem><para> | ||
637 | In Eclipse, select "Install New | ||
638 | Software" from the "Help" menu. | ||
639 | </para></listitem> | ||
640 | <listitem><para> | ||
641 | Click "Add..." in the "Work with:" area. | ||
642 | </para></listitem> | ||
643 | <listitem><para> | ||
644 | Enter | ||
645 | <filename>&ECLIPSE_DL_PLUGIN_URL;/neon</filename> | ||
646 | in the URL field and provide a meaningful | ||
647 | name in the "Name" field. | ||
648 | </para></listitem> | ||
649 | <listitem><para> | ||
650 | Click "OK" to have the entry added | ||
651 | to the "Work with:" drop-down list. | ||
652 | </para></listitem> | ||
653 | <listitem><para> | ||
654 | Select the entry for the plug-in | ||
655 | from the "Work with:" drop-down list. | ||
656 | </para></listitem> | ||
657 | <listitem><para> | ||
658 | Check the boxes next to the following: | ||
659 | <literallayout class='monospaced'> | ||
660 | Yocto Project SDK Plug-in | ||
661 | Yocto Project Documentation plug-in | ||
662 | </literallayout> | ||
663 | </para></listitem> | ||
664 | <listitem><para> | ||
665 | Complete the remaining software | ||
666 | installation steps and then restart the | ||
667 | Eclipse IDE to finish the installation of | ||
668 | the plug-in. | ||
669 | <note> | ||
670 | You can click "OK" when prompted about | ||
671 | installing software that contains | ||
672 | unsigned content. | ||
673 | </note> | ||
674 | </para></listitem> | ||
675 | </orderedlist> | ||
676 | </para> | ||
677 | </section> | ||
678 | |||
679 | <section id='neon-zip-file-method'> | ||
680 | <title>Installing the Plug-in Using the Latest Source Code</title> | ||
681 | |||
682 | <para> | ||
683 | To install the Neon Eclipse Yocto Plug-in from the | ||
684 | latest source code, follow these steps: | ||
685 | <orderedlist> | ||
686 | <listitem><para> | ||
687 | Be sure your development system | ||
688 | has JDK 1.8+ | ||
689 | </para></listitem> | ||
690 | <listitem><para> | ||
691 | Install X11-related packages: | ||
692 | <literallayout class='monospaced'> | ||
693 | $ sudo apt-get install xauth | ||
694 | </literallayout> | ||
695 | </para></listitem> | ||
696 | <listitem><para> | ||
697 | In a new terminal shell, create a | ||
698 | Git repository with: | ||
699 | <literallayout class='monospaced'> | ||
700 | $ cd ~ | ||
701 | $ git clone git://git.yoctoproject.org/eclipse-poky | ||
702 | </literallayout> | ||
703 | </para></listitem> | ||
704 | <listitem><para> | ||
705 | Use Git to create the correct tag: | ||
706 | <literallayout class='monospaced'> | ||
707 | $ cd ~/eclipse-poky | ||
708 | $ git checkout neon/yocto-&DISTRO; | ||
709 | </literallayout> | ||
710 | This creates a local tag named | ||
711 | <filename>neon/yocto-&DISTRO;</filename> | ||
712 | based on the branch | ||
713 | <filename>origin/neon-master</filename>. | ||
714 | You are put into a detached HEAD state, | ||
715 | which is fine since you are only going to | ||
716 | be building and not developing. | ||
717 | </para></listitem> | ||
718 | <listitem><para> | ||
719 | Change to the <filename>scripts</filename> | ||
720 | directory within the Git repository: | ||
721 | <literallayout class='monospaced'> | ||
722 | $ cd scripts | ||
723 | </literallayout> | ||
724 | </para></listitem> | ||
725 | <listitem><para> | ||
726 | Set up the local build environment | ||
727 | by running the setup script: | ||
728 | <literallayout class='monospaced'> | ||
729 | $ ./setup.sh | ||
730 | </literallayout> | ||
731 | When the script finishes execution, | ||
732 | it prompts you with instructions on how to | ||
733 | run the <filename>build.sh</filename> | ||
734 | script, which is also in the | ||
735 | <filename>scripts</filename> directory of | ||
736 | the Git repository created earlier. | ||
737 | </para></listitem> | ||
738 | <listitem><para> | ||
739 | Run the <filename>build.sh</filename> | ||
740 | script as directed. | ||
741 | Be sure to provide the tag name, | ||
742 | documentation branch, and a release name. | ||
743 | </para> | ||
744 | <para> | ||
745 | Following is an example: | ||
746 | <literallayout class='monospaced'> | ||
747 | $ ECLIPSE_HOME=/home/scottrif/eclipse-poky/scripts/eclipse ./build.sh -l neon/yocto-&DISTRO; master yocto-&DISTRO; 2>&1 | tee build.log | ||
748 | </literallayout> | ||
749 | The previous example command adds the tag | ||
750 | you need for | ||
751 | <filename>mars/yocto-&DISTRO;</filename> | ||
752 | to <filename>HEAD</filename>, then tells | ||
753 | the build script to use the local (-l) Git | ||
754 | checkout for the build. | ||
755 | After running the script, the file | ||
756 | <filename>org.yocto.sdk-</filename><replaceable>release</replaceable><filename>-</filename><replaceable>date</replaceable><filename>-archive.zip</filename> | ||
757 | is in the current directory. | ||
758 | </para></listitem> | ||
759 | <listitem><para> | ||
760 | If necessary, start the Eclipse IDE | ||
761 | and be sure you are in the Workbench. | ||
762 | </para></listitem> | ||
763 | <listitem><para> | ||
764 | Select "Install New Software" from | ||
765 | the "Help" pull-down menu. | ||
766 | </para></listitem> | ||
767 | <listitem><para> | ||
768 | Click "Add". | ||
769 | </para></listitem> | ||
770 | <listitem><para> | ||
771 | Provide anything you want in the | ||
772 | "Name" field. | ||
773 | </para></listitem> | ||
774 | <listitem><para> | ||
775 | Click "Archive" and browse to the | ||
776 | ZIP file you built earlier. | ||
777 | This ZIP file should not be "unzipped", and | ||
778 | must be the | ||
779 | <filename>*archive.zip</filename> file | ||
780 | created by running the | ||
781 | <filename>build.sh</filename> script. | ||
782 | </para></listitem> | ||
783 | <listitem><para> | ||
784 | Click the "OK" button. | ||
785 | </para></listitem> | ||
786 | <listitem><para> | ||
787 | Check the boxes that appear in | ||
788 | the installation window to install the | ||
789 | following: | ||
790 | <literallayout class='monospaced'> | ||
791 | Yocto Project SDK Plug-in | ||
792 | Yocto Project Documentation plug-in | ||
793 | </literallayout> | ||
794 | </para></listitem> | ||
795 | <listitem><para> | ||
796 | Finish the installation by clicking | ||
797 | through the appropriate buttons. | ||
798 | You can click "OK" when prompted about | ||
799 | installing software that contains unsigned | ||
800 | content. | ||
801 | </para></listitem> | ||
802 | <listitem><para> | ||
803 | Restart the Eclipse IDE if necessary. | ||
804 | </para></listitem> | ||
805 | </orderedlist> | ||
806 | </para> | ||
807 | |||
808 | <para> | ||
809 | At this point you should be able to configure the | ||
810 | Eclipse Yocto Plug-in as described in the | ||
811 | "<link linkend='mars-configuring-the-eclipse-yocto-plug-in'>Configuring the Neon Eclipse Yocto Plug-in</link>" | ||
812 | section. | ||
813 | </para> | ||
814 | </section> | ||
815 | </section> | ||
816 | |||
817 | <section id='neon-configuring-the-eclipse-yocto-plug-in'> | ||
818 | <title>Configuring the Neon Eclipse Yocto Plug-in</title> | ||
819 | |||
820 | <para> | ||
821 | Configuring the Neon Eclipse Yocto Plug-in involves | ||
822 | setting the Cross Compiler options and the Target | ||
823 | options. | ||
824 | The configurations you choose become the default | ||
825 | settings for all projects. | ||
826 | You do have opportunities to change them later when | ||
827 | you configure the project (see the following section). | ||
828 | </para> | ||
829 | |||
830 | <para> | ||
831 | To start, you need to do the following from within the | ||
832 | Eclipse IDE: | ||
833 | <itemizedlist> | ||
834 | <listitem><para> | ||
835 | Choose "Preferences" from the "Window" menu to | ||
836 | display the Preferences Dialog. | ||
837 | </para></listitem> | ||
838 | <listitem><para> | ||
839 | Click "Yocto Project SDK" to display | ||
840 | the configuration screen. | ||
841 | </para></listitem> | ||
842 | </itemizedlist> | ||
843 | The following sub-sections describe how to configure | ||
844 | the plug-in. | ||
845 | <note> | ||
846 | Throughout the descriptions, a start-to-finish | ||
847 | example for preparing a QEMU image for use with | ||
848 | Eclipse is referenced as the "wiki" and is linked | ||
849 | to the example on the | ||
850 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'> Cookbook guide to Making an Eclipse Debug Capable Image</ulink> | ||
851 | wiki page. | ||
852 | </note> | ||
853 | </para> | ||
854 | |||
855 | <section id='neon-configuring-the-cross-compiler-options'> | ||
856 | <title>Configuring the Cross-Compiler Options</title> | ||
857 | |||
858 | <para> | ||
859 | Cross Compiler options enable Eclipse to use your | ||
860 | specific cross compiler toolchain. | ||
861 | To configure these options, you must select | ||
862 | the type of toolchain, point to the toolchain, | ||
863 | specify the sysroot location, and select the target | ||
864 | architecture. | ||
865 | <itemizedlist> | ||
866 | <listitem><para> | ||
867 | <emphasis>Selecting the Toolchain | ||
868 | Type:</emphasis> | ||
869 | Choose between | ||
870 | <filename>Standalone pre-built toolchain</filename> | ||
871 | and | ||
872 | <filename>Build system derived toolchain</filename> | ||
873 | for Cross Compiler Options. | ||
874 | <itemizedlist> | ||
875 | <listitem><para> | ||
876 | <emphasis> | ||
877 | <filename>Standalone Pre-built Toolchain:</filename> | ||
878 | </emphasis> | ||
879 | Select this type when you are using | ||
880 | a stand-alone cross-toolchain. | ||
881 | For example, suppose you are an | ||
882 | application developer and do not | ||
883 | need to build a target image. | ||
884 | Instead, you just want to use an | ||
885 | architecture-specific toolchain on | ||
886 | an existing kernel and target root | ||
887 | filesystem. | ||
888 | In other words, you have downloaded | ||
889 | and installed a pre-built toolchain | ||
890 | for an existing image. | ||
891 | </para></listitem> | ||
892 | <listitem><para> | ||
893 | <emphasis> | ||
894 | <filename>Build System Derived Toolchain:</filename> | ||
895 | </emphasis> | ||
896 | Select this type if you built the | ||
897 | toolchain as part of the | ||
898 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>. | ||
899 | When you select | ||
900 | <filename>Build system derived toolchain</filename>, | ||
901 | you are using the toolchain built | ||
902 | and bundled inside the Build | ||
903 | Directory. | ||
904 | For example, suppose you created a | ||
905 | suitable image using the steps in the | ||
906 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. | ||
907 | In this situation, you would select | ||
908 | the | ||
909 | <filename>Build system derived toolchain</filename>. | ||
910 | </para></listitem> | ||
911 | </itemizedlist> | ||
912 | </para></listitem> | ||
913 | <listitem><para> | ||
914 | <emphasis>Specify the Toolchain Root | ||
915 | Location:</emphasis> | ||
916 | If you are using a stand-alone pre-built | ||
917 | toolchain, you should be pointing to where | ||
918 | it is installed (e.g. | ||
919 | <filename>/opt/poky/&DISTRO;</filename>). | ||
920 | See the | ||
921 | "<link linkend='sdk-installing-the-sdk'>Installing the SDK</link>" | ||
922 | section for information about how the SDK is | ||
923 | installed.</para> | ||
924 | <para>If you are using a build system | ||
925 | derived toolchain, the path you provide for | ||
926 | the | ||
927 | <filename>Toolchain Root Location</filename> | ||
928 | field is the | ||
929 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> | ||
930 | from which you run the | ||
931 | <filename>bitbake</filename> command (e.g | ||
932 | <filename>/home/scottrif/poky/build</filename>). | ||
933 | </para> | ||
934 | <para>For more information, see the | ||
935 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" | ||
936 | section. | ||
937 | </para></listitem> | ||
938 | <listitem><para> | ||
939 | <emphasis>Specify Sysroot Location: | ||
940 | </emphasis> | ||
941 | This location is where the root filesystem | ||
942 | for the target hardware resides. | ||
943 | </para> | ||
944 | <para>This location depends on where you | ||
945 | separately extracted and installed the | ||
946 | target filesystem. | ||
947 | As an example, suppose you prepared an | ||
948 | image using the steps in the | ||
949 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. | ||
950 | If so, the | ||
951 | <filename>MY_QEMU_ROOTFS</filename> | ||
952 | directory is found in the | ||
953 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> | ||
954 | and you would browse to and select that | ||
955 | directory (e.g. | ||
956 | <filename>/home/scottrif/poky/build/MY_QEMU_ROOTFS</filename>). | ||
957 | </para> | ||
958 | <para>For more information on how to | ||
959 | install the toolchain and on how to extract | ||
960 | and install the sysroot filesystem, see the | ||
961 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" | ||
962 | section. | ||
963 | </para></listitem> | ||
964 | <listitem><para> | ||
965 | <emphasis>Select the Target Architecture: | ||
966 | </emphasis> | ||
967 | The target architecture is the type of | ||
968 | hardware you are going to use or emulate. | ||
969 | Use the pull-down | ||
970 | <filename>Target Architecture</filename> | ||
971 | menu to make your selection. | ||
972 | The pull-down menu should have the | ||
973 | supported architectures. | ||
974 | If the architecture you need is not listed | ||
975 | in the menu, you will need to build the | ||
976 | image. | ||
977 | See the | ||
978 | "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>" | ||
979 | section of the Yocto Project Quick Start | ||
980 | for more information. | ||
981 | You can also see the | ||
982 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. | ||
983 | </para></listitem> | ||
984 | </itemizedlist> | ||
985 | </para> | ||
986 | </section> | ||
987 | |||
988 | <section id='neon-configuring-the-target-options'> | ||
989 | <title>Configuring the Target Options</title> | ||
990 | |||
991 | <para> | ||
992 | You can choose to emulate hardware using the QEMU | ||
993 | emulator, or you can choose to run your image on | ||
994 | actual hardware. | ||
995 | <itemizedlist> | ||
996 | <listitem><para> | ||
997 | <emphasis>QEMU:</emphasis> | ||
998 | Select this option if you will be using the | ||
999 | QEMU emulator. | ||
1000 | If you are using the emulator, you also | ||
1001 | need to locate the kernel and specify any | ||
1002 | custom options.</para> | ||
1003 | <para>If you selected the | ||
1004 | <filename>Build system derived toolchain</filename>, | ||
1005 | the target kernel you built will be located | ||
1006 | in the | ||
1007 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> | ||
1008 | in | ||
1009 | <filename>tmp/deploy/images/<replaceable>machine</replaceable></filename> | ||
1010 | directory. | ||
1011 | As an example, suppose you performed the | ||
1012 | steps in the | ||
1013 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>wiki</ulink>. | ||
1014 | In this case, you specify your Build | ||
1015 | Directory path followed by the image (e.g. | ||
1016 | <filename>/home/scottrif/poky/build/tmp/deploy/images/qemux86/bzImage-qemux86.bin</filename>). | ||
1017 | </para> | ||
1018 | <para>If you selected the standalone | ||
1019 | pre-built toolchain, the pre-built image | ||
1020 | you downloaded is located in the directory | ||
1021 | you specified when you downloaded the | ||
1022 | image.</para> | ||
1023 | <para>Most custom options are for advanced | ||
1024 | QEMU users to further customize their QEMU | ||
1025 | instance. | ||
1026 | These options are specified between paired | ||
1027 | angled brackets. | ||
1028 | Some options must be specified outside the | ||
1029 | brackets. | ||
1030 | In particular, the options | ||
1031 | <filename>serial</filename>, | ||
1032 | <filename>nographic</filename>, and | ||
1033 | <filename>kvm</filename> must all be | ||
1034 | outside the brackets. | ||
1035 | Use the <filename>man qemu</filename> | ||
1036 | command to get help on all the options and | ||
1037 | their use. | ||
1038 | The following is an example: | ||
1039 | <literallayout class='monospaced'> | ||
1040 | serial ‘<-m 256 -full-screen>’ | ||
1041 | </literallayout></para> | ||
1042 | <para> | ||
1043 | Regardless of the mode, Sysroot is already | ||
1044 | defined as part of the Cross-Compiler | ||
1045 | Options configuration in the | ||
1046 | <filename>Sysroot Location:</filename> | ||
1047 | field. | ||
1048 | </para></listitem> | ||
1049 | <listitem><para> | ||
1050 | <emphasis>External HW:</emphasis> | ||
1051 | Select this option if you will be using | ||
1052 | actual hardware.</para></listitem> | ||
1053 | </itemizedlist> | ||
1054 | </para> | ||
1055 | |||
1056 | <para> | ||
1057 | Click the "Apply" and "OK" to save your plug-in | ||
1058 | configurations. | ||
1059 | </para> | ||
1060 | </section> | ||
1061 | </section> | ||
1062 | </section> | ||
1063 | |||
1064 | <section id='neon-creating-the-project'> | ||
1065 | <title>Creating the Project</title> | ||
1066 | |||
1067 | <para> | ||
1068 | You can create two types of projects: Autotools-based, or | ||
1069 | Makefile-based. | ||
1070 | This section describes how to create Autotools-based | ||
1071 | projects from within the Eclipse IDE. | ||
1072 | For information on creating Makefile-based projects in a | ||
1073 | terminal window, see the | ||
1074 | "<link linkend='makefile-based-projects'>Makefile-Based Projects</link>" | ||
1075 | section. | ||
1076 | <note> | ||
1077 | Do not use special characters in project names | ||
1078 | (e.g. spaces, underscores, etc.). Doing so can | ||
1079 | cause configuration to fail. | ||
1080 | </note> | ||
1081 | </para> | ||
1082 | |||
1083 | <para> | ||
1084 | To create a project based on a Yocto template and then | ||
1085 | display the source code, follow these steps: | ||
1086 | <orderedlist> | ||
1087 | <listitem><para> | ||
1088 | Select "C Project" from the "File -> New" menu. | ||
1089 | </para></listitem> | ||
1090 | <listitem><para> | ||
1091 | Expand | ||
1092 | <filename>Yocto Project SDK Autotools Project</filename>. | ||
1093 | </para></listitem> | ||
1094 | <listitem><para> | ||
1095 | Select <filename>Hello World ANSI C Autotools Projects</filename>. | ||
1096 | This is an Autotools-based project based on a Yocto | ||
1097 | template. | ||
1098 | </para></listitem> | ||
1099 | <listitem><para> | ||
1100 | Put a name in the | ||
1101 | <filename>Project name:</filename> field. | ||
1102 | Do not use hyphens as part of the name | ||
1103 | (e.g. <filename>hello</filename>). | ||
1104 | </para></listitem> | ||
1105 | <listitem><para> | ||
1106 | Click "Next". | ||
1107 | </para></listitem> | ||
1108 | <listitem><para> | ||
1109 | Add appropriate information in the various fields. | ||
1110 | </para></listitem> | ||
1111 | <listitem><para> | ||
1112 | Click "Finish". | ||
1113 | </para></listitem> | ||
1114 | <listitem><para> | ||
1115 | If the "open perspective" prompt appears, | ||
1116 | click "Yes" so that you in the C/C++ perspective. | ||
1117 | </para></listitem> | ||
1118 | <listitem><para>The left-hand navigation pane shows | ||
1119 | your project. | ||
1120 | You can display your source by double clicking the | ||
1121 | project's source file. | ||
1122 | </para></listitem> | ||
1123 | </orderedlist> | ||
1124 | </para> | ||
1125 | </section> | ||
1126 | |||
1127 | <section id='neon-configuring-the-cross-toolchains'> | ||
1128 | <title>Configuring the Cross-Toolchains</title> | ||
1129 | |||
1130 | <para> | ||
1131 | The earlier section, | ||
1132 | "<link linkend='neon-configuring-the-eclipse-yocto-plug-in'>Configuring the Neon Eclipse Yocto Plug-in</link>", | ||
1133 | sets up the default project configurations. | ||
1134 | You can override these settings for a given project by | ||
1135 | following these steps: | ||
1136 | <orderedlist> | ||
1137 | <listitem><para> | ||
1138 | Select "Yocto Project Settings" from | ||
1139 | the "Project -> Properties" menu. | ||
1140 | This selection brings up the Yocto Project Settings | ||
1141 | Dialog and allows you to make changes specific to | ||
1142 | an individual project.</para> | ||
1143 | <para>By default, the Cross Compiler Options and | ||
1144 | Target Options for a project are inherited from | ||
1145 | settings you provided using the Preferences Dialog | ||
1146 | as described earlier in the | ||
1147 | "<link linkend='neon-configuring-the-eclipse-yocto-plug-in'>Configuring the Neon Eclipse Yocto Plug-in</link>" | ||
1148 | section. | ||
1149 | The Yocto Project Settings Dialog allows you to | ||
1150 | override those default settings for a given | ||
1151 | project. | ||
1152 | </para></listitem> | ||
1153 | <listitem><para> | ||
1154 | Make or verify your configurations for the | ||
1155 | project and click "OK". | ||
1156 | </para></listitem> | ||
1157 | <listitem><para> | ||
1158 | Right-click in the navigation pane and | ||
1159 | select "Reconfigure Project" from the pop-up menu. | ||
1160 | This selection reconfigures the project by running | ||
1161 | <filename>autogen.sh</filename> in the workspace | ||
1162 | for your project. | ||
1163 | The script also runs | ||
1164 | <filename>libtoolize</filename>, | ||
1165 | <filename>aclocal</filename>, | ||
1166 | <filename>autoconf</filename>, | ||
1167 | <filename>autoheader</filename>, | ||
1168 | <filename>automake --a</filename>, and | ||
1169 | <filename>./configure</filename>. | ||
1170 | Click on the "Console" tab beneath your source code | ||
1171 | to see the results of reconfiguring your project. | ||
1172 | </para></listitem> | ||
1173 | </orderedlist> | ||
1174 | </para> | ||
1175 | </section> | ||
1176 | |||
1177 | <section id='neon-building-the-project'> | ||
1178 | <title>Building the Project</title> | ||
1179 | |||
1180 | <para> | ||
1181 | To build the project select "Build All" from the | ||
1182 | "Project" menu. | ||
1183 | The console should update and you can note the | ||
1184 | cross-compiler you are using. | ||
1185 | <note> | ||
1186 | When building "Yocto Project SDK Autotools" projects, | ||
1187 | the Eclipse IDE might display error messages for | ||
1188 | Functions/Symbols/Types that cannot be "resolved", | ||
1189 | even when the related include file is listed at the | ||
1190 | project navigator and when the project is able to | ||
1191 | build. | ||
1192 | For these cases only, it is recommended to add a new | ||
1193 | linked folder to the appropriate sysroot. | ||
1194 | Use these steps to add the linked folder: | ||
1195 | <orderedlist> | ||
1196 | <listitem><para> | ||
1197 | Select the project. | ||
1198 | </para></listitem> | ||
1199 | <listitem><para> | ||
1200 | Select "Folder" from the | ||
1201 | <filename>File > New</filename> menu. | ||
1202 | </para></listitem> | ||
1203 | <listitem><para> | ||
1204 | In the "New Folder" Dialog, select "Link to | ||
1205 | alternate location (linked folder)". | ||
1206 | </para></listitem> | ||
1207 | <listitem><para> | ||
1208 | Click "Browse" to navigate to the include | ||
1209 | folder inside the same sysroot location | ||
1210 | selected in the Yocto Project | ||
1211 | configuration preferences. | ||
1212 | </para></listitem> | ||
1213 | <listitem><para> | ||
1214 | Click "OK". | ||
1215 | </para></listitem> | ||
1216 | <listitem><para> | ||
1217 | Click "Finish" to save the linked folder. | ||
1218 | </para></listitem> | ||
1219 | </orderedlist> | ||
1220 | </note> | ||
1221 | </para> | ||
1222 | </section> | ||
1223 | |||
1224 | <section id='neon-starting-qemu-in-user-space-nfs-mode'> | ||
1225 | <title>Starting QEMU in User-Space NFS Mode</title> | ||
1226 | |||
1227 | <para> | ||
1228 | To start the QEMU emulator from within Eclipse, follow | ||
1229 | these steps: | ||
1230 | <note> | ||
1231 | See the | ||
1232 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-manual-qemu'>Using the Quick EMUlator (QEMU)</ulink>" | ||
1233 | chapter in the Yocto Project Development Manual | ||
1234 | for more information on using QEMU. | ||
1235 | </note> | ||
1236 | <orderedlist> | ||
1237 | <listitem><para>Expose and select "External Tools | ||
1238 | Configurations ..." from the "Run -> External | ||
1239 | Tools" menu. | ||
1240 | </para></listitem> | ||
1241 | <listitem><para> | ||
1242 | Locate and select your image in the navigation | ||
1243 | panel to the left | ||
1244 | (e.g. <filename>qemu_i586-poky-linux</filename>). | ||
1245 | </para></listitem> | ||
1246 | <listitem><para> | ||
1247 | Click "Run" to launch QEMU. | ||
1248 | <note> | ||
1249 | The host on which you are running QEMU must | ||
1250 | have the <filename>rpcbind</filename> utility | ||
1251 | running to be able to make RPC calls on a | ||
1252 | server on that machine. | ||
1253 | If QEMU does not invoke and you receive error | ||
1254 | messages involving | ||
1255 | <filename>rpcbind</filename>, follow the | ||
1256 | suggestions to get the service running. | ||
1257 | As an example, on a new Ubuntu 16.04 LTS | ||
1258 | installation, you must do the following in | ||
1259 | order to get QEMU to launch: | ||
1260 | <literallayout class='monospaced'> | ||
1261 | $ sudo apt-get install rpcbind | ||
1262 | </literallayout> | ||
1263 | After installing <filename>rpcbind</filename>, | ||
1264 | you need to edit the | ||
1265 | <filename>/etc/init.d/rpcbind</filename> file | ||
1266 | to include the following line: | ||
1267 | <literallayout class='monospaced'> | ||
1268 | OPTIONS="-i -w" | ||
1269 | </literallayout> | ||
1270 | After modifying the file, you need to start the | ||
1271 | service: | ||
1272 | <literallayout class='monospaced'> | ||
1273 | $ sudo service portmap restart | ||
1274 | </literallayout> | ||
1275 | </note> | ||
1276 | </para></listitem> | ||
1277 | <listitem><para> | ||
1278 | If needed, enter your host root password in | ||
1279 | the shell window at the prompt. | ||
1280 | This sets up a <filename>Tap 0</filename> | ||
1281 | connection needed for running in user-space NFS | ||
1282 | mode. | ||
1283 | </para></listitem> | ||
1284 | <listitem><para> | ||
1285 | Wait for QEMU to launch. | ||
1286 | </para></listitem> | ||
1287 | <listitem><para> | ||
1288 | Once QEMU launches, you can begin operating | ||
1289 | within that environment. | ||
1290 | One useful task at this point would be to determine | ||
1291 | the IP Address for the user-space NFS by using the | ||
1292 | <filename>ifconfig</filename> command. | ||
1293 | The IP address of the QEMU machine appears in the | ||
1294 | xterm window. | ||
1295 | You can use this address to help you see which | ||
1296 | particular | ||
1297 | IP address the instance of QEMU is using. | ||
1298 | </para></listitem> | ||
1299 | </orderedlist> | ||
1300 | </para> | ||
1301 | </section> | ||
1302 | |||
1303 | <section id='neon-deploying-and-debugging-the-application'> | ||
1304 | <title>Deploying and Debugging the Application</title> | ||
1305 | |||
1306 | <para> | ||
1307 | Once the QEMU emulator is running the image, you can deploy | ||
1308 | your application using the Eclipse IDE and then use | ||
1309 | the emulator to perform debugging. | ||
1310 | Follow these steps to deploy the application. | ||
1311 | <note> | ||
1312 | Currently, Eclipse does not support SSH port | ||
1313 | forwarding. | ||
1314 | Consequently, if you need to run or debug a remote | ||
1315 | application using the host display, you must create a | ||
1316 | tunneling connection from outside Eclipse and keep | ||
1317 | that connection alive during your work. | ||
1318 | For example, in a new terminal, run the following: | ||
1319 | <literallayout class='monospaced'> | ||
1320 | $ ssh -XY <replaceable>user_name</replaceable>@<replaceable>remote_host_ip</replaceable> | ||
1321 | </literallayout> | ||
1322 | Using the above form, here is an example: | ||
1323 | <literallayout class='monospaced'> | ||
1324 | $ ssh -XY root@192.168.7.2 | ||
1325 | </literallayout> | ||
1326 | After running the command, add the command to be | ||
1327 | executed in Eclipse's run configuration before the | ||
1328 | application as follows: | ||
1329 | <literallayout class='monospaced'> | ||
1330 | export DISPLAY=:10.0 | ||
1331 | </literallayout> | ||
1332 | Be sure to not destroy the connection during your QEMU | ||
1333 | session (i.e. do not | ||
1334 | exit out of or close that shell). | ||
1335 | </note> | ||
1336 | <orderedlist> | ||
1337 | <listitem><para> | ||
1338 | Select "Debug Configurations..." from the | ||
1339 | "Run" menu. | ||
1340 | </para></listitem> | ||
1341 | <listitem><para> | ||
1342 | In the left area, expand | ||
1343 | <filename>C/C++Remote Application</filename>. | ||
1344 | </para></listitem> | ||
1345 | <listitem><para> | ||
1346 | Locate your project and select it to bring | ||
1347 | up a new tabbed view in the Debug Configurations | ||
1348 | Dialog. | ||
1349 | </para></listitem> | ||
1350 | <listitem><para> | ||
1351 | Click on the "Debugger" tab to see the | ||
1352 | cross-tool debugger you are using. | ||
1353 | Be sure to change to the debugger perspective in | ||
1354 | Eclipse. | ||
1355 | </para></listitem> | ||
1356 | <listitem><para> | ||
1357 | Click on the "Main" tab. | ||
1358 | </para></listitem> | ||
1359 | <listitem><para> | ||
1360 | Create a new connection to the QEMU instance | ||
1361 | by clicking on "new".</para></listitem> | ||
1362 | <listitem><para>Select <filename>SSH</filename>, which | ||
1363 | means Secure Socket Shell and then click "OK". | ||
1364 | Optionally, you can select an TCF connection | ||
1365 | instead. | ||
1366 | </para></listitem> | ||
1367 | <listitem><para> | ||
1368 | Clear out the "Connection name" field and | ||
1369 | enter any name you want for the connection. | ||
1370 | </para></listitem> | ||
1371 | <listitem><para> | ||
1372 | Put the IP address for the connection in | ||
1373 | the "Host" field. | ||
1374 | For QEMU, the default is | ||
1375 | <filename>192.168.7.2</filename>. | ||
1376 | However, if a previous QEMU session did not exit | ||
1377 | cleanly, the IP address increments (e.g. | ||
1378 | <filename>192.168.7.3</filename>). | ||
1379 | <note> | ||
1380 | You can find the IP address for the current | ||
1381 | QEMU session by looking in the xterm that | ||
1382 | opens when you launch QEMU. | ||
1383 | </note> | ||
1384 | </para></listitem> | ||
1385 | <listitem><para> | ||
1386 | Enter <filename>root</filename>, which | ||
1387 | is the default for QEMU, for the "User" field. | ||
1388 | Be sure to leave the password field empty. | ||
1389 | </para></listitem> | ||
1390 | <listitem><para> | ||
1391 | Click "Finish" to close the New Connections Dialog. | ||
1392 | </para></listitem> | ||
1393 | <listitem><para> | ||
1394 | If necessary, use the drop-down menu now in the | ||
1395 | "Connection" field and pick the IP Address you | ||
1396 | entered. | ||
1397 | </para></listitem> | ||
1398 | <listitem><para> | ||
1399 | Assuming you are connecting as the root | ||
1400 | user, which is the default for QEMU x86-64 SDK | ||
1401 | images provided by the Yocto Project, in the | ||
1402 | "Remote Absolute File Path for C/C++ Application" | ||
1403 | field, browse to | ||
1404 | <filename>/home/root/</filename><replaceable>ProjectName</replaceable> | ||
1405 | (e.g. <filename>/home/root/hello</filename>). | ||
1406 | You could also browse to any other path you have | ||
1407 | write access to on the target such as | ||
1408 | <filename>/usr/bin</filename>. | ||
1409 | This location is where your application will be | ||
1410 | located on the QEMU system. | ||
1411 | If you fail to browse to and specify an appropriate | ||
1412 | location, QEMU will not understand what to remotely | ||
1413 | launch. | ||
1414 | Eclipse is helpful in that it auto fills your | ||
1415 | application name for you assuming you browsed to a | ||
1416 | directory. | ||
1417 | <note> | ||
1418 | If you are prompted to provide a username and | ||
1419 | to optionally set a password, be sure you | ||
1420 | provide "root" as the username and you leave | ||
1421 | the password field blank. | ||
1422 | </note> | ||
1423 | </para></listitem> | ||
1424 | <listitem><para> | ||
1425 | Be sure you change to the "Debug" perspective in | ||
1426 | Eclipse. | ||
1427 | </para></listitem> | ||
1428 | <listitem><para> | ||
1429 | Click "Debug" | ||
1430 | </para></listitem> | ||
1431 | <listitem><para> | ||
1432 | Accept the debug perspective. | ||
1433 | </para></listitem> | ||
1434 | </orderedlist> | ||
1435 | </para> | ||
1436 | </section> | ||
1437 | |||
1438 | <section id='neon-using-Linuxtools'> | ||
1439 | <title>Using Linuxtools</title> | ||
1440 | |||
1441 | <para> | ||
1442 | As mentioned earlier in the manual, performance tools exist | ||
1443 | (Linuxtools) that enhance your development experience. | ||
1444 | These tools are aids in developing and debugging | ||
1445 | applications and images. | ||
1446 | You can run these tools from within the Eclipse IDE through | ||
1447 | the "Linuxtools" menu. | ||
1448 | </para> | ||
1449 | |||
1450 | <para> | ||
1451 | For information on how to configure and use these tools, | ||
1452 | see | ||
1453 | <ulink url='http://www.eclipse.org/linuxtools/'>http://www.eclipse.org/linuxtools/</ulink>. | ||
1454 | </para> | ||
1455 | </section> | ||
1456 | </section> | ||
1457 | </section> | ||
1458 | </chapter> | ||
1459 | <!-- | ||
1460 | vim: expandtab tw=80 ts=4 | ||
1461 | --> | ||