diff options
Diffstat (limited to 'documentation/sdk-manual/sdk-using.xml')
| -rw-r--r-- | documentation/sdk-manual/sdk-using.xml | 297 |
1 files changed, 240 insertions, 57 deletions
diff --git a/documentation/sdk-manual/sdk-using.xml b/documentation/sdk-manual/sdk-using.xml index 66f2c0ed9d..f2acaa7fc4 100644 --- a/documentation/sdk-manual/sdk-using.xml +++ b/documentation/sdk-manual/sdk-using.xml | |||
| @@ -23,8 +23,9 @@ | |||
| 23 | <section id='sdk-standard-sdk-intro'> | 23 | <section id='sdk-standard-sdk-intro'> |
| 24 | <title>Why use the Standard SDK and What is in It?</title> | 24 | <title>Why use the Standard SDK and What is in It?</title> |
| 25 | 25 | ||
| 26 | <para role='writernotes'> | 26 | <para> |
| 27 | <emphasis>MANUAL DEVELOPMENT NOTES:</emphasis> | 27 | Fundamentally, the standard SDK exists so that you can access |
| 28 | cross-development tools. | ||
| 28 | This paragraph describes why you use the Standard SDK. | 29 | This paragraph describes why you use the Standard SDK. |
| 29 | Probably need to compare that against why you would not be interested | 30 | Probably need to compare that against why you would not be interested |
| 30 | in the extensible SDK here as well. | 31 | in the extensible SDK here as well. |
| @@ -37,46 +38,6 @@ | |||
| 37 | If there is more detail, I need to know about it. | 38 | If there is more detail, I need to know about it. |
| 38 | </para> | 39 | </para> |
| 39 | 40 | ||
| 40 | <para role='writernotes'> | ||
| 41 | <emphasis>MANUAL DEVELOPMENT NOTES:</emphasis> | ||
| 42 | Here is a list of items I think need addressed in these early | ||
| 43 | sections: | ||
| 44 | <itemizedlist> | ||
| 45 | <listitem><para role='writernotes'><emphasis>What is your situation?</emphasis></para> | ||
| 46 | <para role='writernotes'>In other words, is the developer on a machine that | ||
| 47 | has YP on it? | ||
| 48 | Are they on a machine that does not? | ||
| 49 | Is the image they are developing against available as a | ||
| 50 | pre-built, down-loadable image and can they get it?</para> | ||
| 51 | <para role='writernotes'>Depending on the scenario, there are different ways | ||
| 52 | to make sure the machine they are using is ready to use a | ||
| 53 | standard SDK. | ||
| 54 | I think we need to cover the various situations in this | ||
| 55 | section. | ||
| 56 | </para></listitem> | ||
| 57 | <listitem><para role='writernotes'><emphasis>What are the recommendations?</emphasis></para> | ||
| 58 | <para role='writernotes'>What is the most common development scenario? | ||
| 59 | Is there a recommended development flow we want to present | ||
| 60 | when using a standard SDK? | ||
| 61 | What conditions in a development scenario warrant use of | ||
| 62 | just the standard SDK as compared to the extensible SDK? | ||
| 63 | </para></listitem> | ||
| 64 | <listitem><para role='writernotes'><emphasis>What procedures do we want to cover to set up | ||
| 65 | the standard SDK?</emphasis></para> | ||
| 66 | <para role='writernotes'>There is a ton of setup information in the | ||
| 67 | current ADT manual regarding getting, building, and installing | ||
| 68 | an SDK. | ||
| 69 | We would ignore the stuff about the ADT installer script | ||
| 70 | since I presume that is going away. | ||
| 71 | But, there are steps to download and existing | ||
| 72 | <filename>.sh</filename> install script, build out the | ||
| 73 | toolchains assuming your system has YP on it and you can run | ||
| 74 | BitBake, getting the root filesystem, getting an image so you | ||
| 75 | run QEMU on your system, etc. | ||
| 76 | </para></listitem> | ||
| 77 | </itemizedlist> | ||
| 78 | </para> | ||
| 79 | |||
| 80 | <para> | 41 | <para> |
| 81 | The installed Standard SDK consists of several files and directories. | 42 | The installed Standard SDK consists of several files and directories. |
| 82 | Basically, it contains an SDK environment setup script, some | 43 | Basically, it contains an SDK environment setup script, some |
| @@ -161,15 +122,16 @@ | |||
| 161 | into <filename>/opt/poky</filename>. | 122 | into <filename>/opt/poky</filename>. |
| 162 | However, when you run the SDK installer, you can choose an | 123 | However, when you run the SDK installer, you can choose an |
| 163 | installation directory. | 124 | installation directory. |
| 125 | <note> | ||
| 126 | You must change the permissions on the toolchain | ||
| 127 | installer script so that it is executable. | ||
| 128 | </note> | ||
| 164 | </para> | 129 | </para> |
| 165 | 130 | ||
| 166 | <para> | 131 | <para> |
| 167 | The following command shows how to run the installer given a | 132 | The following command shows how to run the installer given a |
| 168 | toolchain tarball for a 64-bit x86 development host system and | 133 | toolchain tarball for a 64-bit x86 development host system and |
| 169 | a 32-bit x86 target architecture. | 134 | a 32-bit x86 target architecture. |
| 170 | When you run the installer, the script prompts you for a | ||
| 171 | system password so that you permissions can change enabling | ||
| 172 | you to run the installer script. | ||
| 173 | The example assumes the toolchain installer is located in | 135 | The example assumes the toolchain installer is located in |
| 174 | <filename>~/Downloads/</filename>. | 136 | <filename>~/Downloads/</filename>. |
| 175 | <note> | 137 | <note> |
| @@ -180,17 +142,16 @@ | |||
| 180 | run the installer again. | 142 | run the installer again. |
| 181 | </note> | 143 | </note> |
| 182 | <literallayout class='monospaced'> | 144 | <literallayout class='monospaced'> |
| 183 | $ ~/Downloads/poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh | 145 | $ ./poky-glibc-x86_64-core-image-sato-i586-toolchain-2.1.sh |
| 184 | Poky (Yocto Project Reference Distro) SDK installer version 2.1+snapshot | 146 | Poky (Yocto Project Reference Distro) SDK installer version 2.0 |
| 185 | ======================================================================== | 147 | =============================================================== |
| 186 | Enter target directory for SDK (default: /opt/poky/2.1+snapshot): | 148 | Enter target directory for SDK (default: /opt/poky/2.1): |
| 187 | You are about to install the SDK to "/opt/poky/2.1+snapshot". Proceed[Y/n]? Y | 149 | You are about to install the SDK to "/opt/poky/2.1". Proceed[Y/n]? Y |
| 188 | [sudo] password for scottrif: | 150 | Extracting SDK.......................................................................done |
| 189 | Extracting SDK.......................done | ||
| 190 | Setting it up...done | 151 | Setting it up...done |
| 191 | SDK has been successfully set up and is ready to be used. | 152 | SDK has been successfully set up and is ready to be used. |
| 192 | Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. | 153 | Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. |
| 193 | $ . /opt/poky/2.1+snapshot/environment-setup-i586-poky-linux | 154 | $ . /opt/poky/2.1/environment-setup-i586-poky-linux |
| 194 | </literallayout> | 155 | </literallayout> |
| 195 | </para> | 156 | </para> |
| 196 | 157 | ||
| @@ -221,11 +182,11 @@ | |||
| 221 | Environment setup scripts begin with the string | 182 | Environment setup scripts begin with the string |
| 222 | "<filename>environment-setup</filename>" and include as part of their | 183 | "<filename>environment-setup</filename>" and include as part of their |
| 223 | name the tuned target architecture. | 184 | name the tuned target architecture. |
| 224 | For example, the setup script for an IA-based target machine using | 185 | For example, the command to source a setup script for an IA-based |
| 225 | i586 tuning and located in the default SDK installation | 186 | target machine using i586 tuning and located in the default SDK |
| 226 | directory is as follows: | 187 | installation directory is as follows: |
| 227 | <literallayout class='monospaced'> | 188 | <literallayout class='monospaced'> |
| 228 | $ source /opt/poky/&DISTRO;+snapshot/environment-setup-i586-poky-linux | 189 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux |
| 229 | </literallayout> | 190 | </literallayout> |
| 230 | When you run the setup script, many environment variables are | 191 | When you run the setup script, many environment variables are |
| 231 | defined: | 192 | defined: |
| @@ -256,6 +217,228 @@ | |||
| 256 | </para> | 217 | </para> |
| 257 | </section> | 218 | </section> |
| 258 | 219 | ||
| 220 | <section id='autotools-based-projects'> | ||
| 221 | <title>Autotools-Based Projects</title> | ||
| 222 | |||
| 223 | <para> | ||
| 224 | Once you have a suitable cross-toolchain installed, it is very easy to | ||
| 225 | develop a project outside of the OpenEmbedded build system. | ||
| 226 | This section presents a simple "Helloworld" example that shows how | ||
| 227 | to set up, compile, and run the project. | ||
| 228 | </para> | ||
| 229 | |||
| 230 | <section id='creating-and-running-a-project-based-on-gnu-autotools'> | ||
| 231 | <title>Creating and Running a Project Based on GNU Autotools</title> | ||
| 232 | |||
| 233 | <para> | ||
| 234 | Follow these steps to create a simple Autotools-based project: | ||
| 235 | <orderedlist> | ||
| 236 | <listitem><para><emphasis>Create your directory:</emphasis> | ||
| 237 | Create a clean directory for your project and then make | ||
| 238 | that directory your working location: | ||
| 239 | <literallayout class='monospaced'> | ||
| 240 | $ mkdir $HOME/helloworld | ||
| 241 | $ cd $HOME/helloworld | ||
| 242 | </literallayout></para></listitem> | ||
| 243 | <listitem><para><emphasis>Populate the directory:</emphasis> | ||
| 244 | Create <filename>hello.c</filename>, <filename>Makefile.am</filename>, | ||
| 245 | and <filename>configure.in</filename> files as follows: | ||
| 246 | <itemizedlist> | ||
| 247 | <listitem><para>For <filename>hello.c</filename>, include | ||
| 248 | these lines: | ||
| 249 | <literallayout class='monospaced'> | ||
| 250 | #include <stdio.h> | ||
| 251 | |||
| 252 | main() | ||
| 253 | { | ||
| 254 | printf("Hello World!\n"); | ||
| 255 | } | ||
| 256 | </literallayout></para></listitem> | ||
| 257 | <listitem><para>For <filename>Makefile.am</filename>, | ||
| 258 | include these lines: | ||
| 259 | <literallayout class='monospaced'> | ||
| 260 | bin_PROGRAMS = hello | ||
| 261 | hello_SOURCES = hello.c | ||
| 262 | </literallayout></para></listitem> | ||
| 263 | <listitem><para>For <filename>configure.in</filename>, | ||
| 264 | include these lines: | ||
| 265 | <literallayout class='monospaced'> | ||
| 266 | AC_INIT(hello.c) | ||
| 267 | AM_INIT_AUTOMAKE(hello,0.1) | ||
| 268 | AC_PROG_CC | ||
| 269 | AC_PROG_INSTALL | ||
| 270 | AC_OUTPUT(Makefile) | ||
| 271 | </literallayout></para></listitem> | ||
| 272 | </itemizedlist></para></listitem> | ||
| 273 | <listitem><para><emphasis>Source the cross-toolchain | ||
| 274 | environment setup file:</emphasis> | ||
| 275 | Installation of the cross-toolchain creates a cross-toolchain | ||
| 276 | environment setup script in the directory that the ADT | ||
| 277 | was installed. | ||
| 278 | Before you can use the tools to develop your project, you must | ||
| 279 | source this setup script. | ||
| 280 | The script begins with the string "environment-setup" and contains | ||
| 281 | the machine architecture, which is followed by the string | ||
| 282 | "poky-linux". | ||
| 283 | Here is an example that sources a script from the | ||
| 284 | default ADT installation directory that uses the | ||
| 285 | 32-bit Intel x86 Architecture and the | ||
| 286 | &DISTRO_NAME; Yocto Project release: | ||
| 287 | <literallayout class='monospaced'> | ||
| 288 | $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux | ||
| 289 | </literallayout></para></listitem> | ||
| 290 | <listitem><para><emphasis>Generate the local aclocal.m4 | ||
| 291 | files and create the configure script:</emphasis> | ||
| 292 | The following GNU Autotools generate the local | ||
| 293 | <filename>aclocal.m4</filename> files and create the | ||
| 294 | configure script: | ||
| 295 | <literallayout class='monospaced'> | ||
| 296 | $ aclocal | ||
| 297 | $ autoconf | ||
| 298 | </literallayout></para></listitem> | ||
| 299 | <listitem><para><emphasis>Generate files needed by GNU | ||
| 300 | coding standards:</emphasis> | ||
| 301 | GNU coding standards require certain files in order for the | ||
| 302 | project to be compliant. | ||
| 303 | This command creates those files: | ||
| 304 | <literallayout class='monospaced'> | ||
| 305 | $ touch NEWS README AUTHORS ChangeLog | ||
| 306 | </literallayout></para></listitem> | ||
| 307 | <listitem><para><emphasis>Generate the configure | ||
| 308 | file:</emphasis> | ||
| 309 | This command generates the <filename>configure</filename>: | ||
| 310 | <literallayout class='monospaced'> | ||
| 311 | $ automake -a | ||
| 312 | </literallayout></para></listitem> | ||
| 313 | <listitem><para><emphasis>Cross-compile the project:</emphasis> | ||
| 314 | This command compiles the project using the cross-compiler. | ||
| 315 | The | ||
| 316 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS'><filename>CONFIGURE_FLAGS</filename></ulink> | ||
| 317 | environment variable provides the minimal arguments for | ||
| 318 | GNU configure: | ||
| 319 | <literallayout class='monospaced'> | ||
| 320 | $ ./configure ${CONFIGURE_FLAGS} | ||
| 321 | </literallayout></para></listitem> | ||
| 322 | <listitem><para><emphasis>Make and install the project:</emphasis> | ||
| 323 | These two commands generate and install the project into the | ||
| 324 | destination directory: | ||
| 325 | <literallayout class='monospaced'> | ||
| 326 | $ make | ||
| 327 | $ make install DESTDIR=./tmp | ||
| 328 | </literallayout></para></listitem> | ||
| 329 | <listitem><para><emphasis>Verify the installation:</emphasis> | ||
| 330 | This command is a simple way to verify the installation | ||
| 331 | of your project. | ||
| 332 | Running the command prints the architecture on which | ||
| 333 | the binary file can run. | ||
| 334 | This architecture should be the same architecture that | ||
| 335 | the installed cross-toolchain supports. | ||
| 336 | <literallayout class='monospaced'> | ||
| 337 | $ file ./tmp/usr/local/bin/hello | ||
| 338 | </literallayout></para></listitem> | ||
| 339 | <listitem><para><emphasis>Execute your project:</emphasis> | ||
| 340 | To execute the project in the shell, simply enter the name. | ||
| 341 | You could also copy the binary to the actual target hardware | ||
| 342 | and run the project there as well: | ||
| 343 | <literallayout class='monospaced'> | ||
| 344 | $ ./hello | ||
| 345 | </literallayout> | ||
| 346 | As expected, the project displays the "Hello World!" message. | ||
| 347 | </para></listitem> | ||
| 348 | </orderedlist> | ||
| 349 | </para> | ||
| 350 | </section> | ||
| 351 | |||
| 352 | <section id='passing-host-options'> | ||
| 353 | <title>Passing Host Options</title> | ||
| 354 | |||
| 355 | <para> | ||
| 356 | For an Autotools-based project, you can use the cross-toolchain by just | ||
| 357 | passing the appropriate host option to <filename>configure.sh</filename>. | ||
| 358 | The host option you use is derived from the name of the environment setup | ||
| 359 | script found in the directory in which you installed the cross-toolchain. | ||
| 360 | For example, the host option for an ARM-based target that uses the GNU EABI | ||
| 361 | is <filename>armv5te-poky-linux-gnueabi</filename>. | ||
| 362 | You will notice that the name of the script is | ||
| 363 | <filename>environment-setup-armv5te-poky-linux-gnueabi</filename>. | ||
| 364 | Thus, the following command works to update your project and | ||
| 365 | rebuild it using the appropriate cross-toolchain tools: | ||
| 366 | <literallayout class='monospaced'> | ||
| 367 | $ ./configure --host=armv5te-poky-linux-gnueabi \ | ||
| 368 | --with-libtool-sysroot=<replaceable>sysroot_dir</replaceable> | ||
| 369 | </literallayout> | ||
| 370 | <note> | ||
| 371 | If the <filename>configure</filename> script results in problems recognizing the | ||
| 372 | <filename>--with-libtool-sysroot=</filename><replaceable>sysroot-dir</replaceable> option, | ||
| 373 | regenerate the script to enable the support by doing the following and then | ||
| 374 | run the script again: | ||
| 375 | <literallayout class='monospaced'> | ||
| 376 | $ libtoolize --automake | ||
| 377 | $ aclocal -I ${OECORE_NATIVE_SYSROOT}/usr/share/aclocal \ | ||
| 378 | [-I <replaceable>dir_containing_your_project-specific_m4_macros</replaceable>] | ||
| 379 | $ autoconf | ||
| 380 | $ autoheader | ||
| 381 | $ automake -a | ||
| 382 | </literallayout> | ||
| 383 | </note> | ||
| 384 | </para> | ||
| 385 | </section> | ||
| 386 | </section> | ||
| 387 | |||
| 388 | <section id='makefile-based-projects'> | ||
| 389 | <title>Makefile-Based Projects</title> | ||
| 390 | |||
| 391 | <para> | ||
| 392 | For Makefile-based projects, the cross-toolchain environment variables | ||
| 393 | established by running the cross-toolchain environment setup script | ||
| 394 | are subject to general <filename>make</filename> rules. | ||
| 395 | </para> | ||
| 396 | |||
| 397 | <para> | ||
| 398 | To illustrate this, consider the following four cross-toolchain | ||
| 399 | environment variables: | ||
| 400 | <literallayout class='monospaced'> | ||
| 401 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'>CC</ulink>=i586-poky-linux-gcc -m32 -march=i586 --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux | ||
| 402 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'>LD</ulink>=i586-poky-linux-ld --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux | ||
| 403 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'>CFLAGS</ulink>=-O2 -pipe -g -feliminate-unused-debug-types | ||
| 404 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CXXFLAGS'>CXXFLAGS</ulink>=-O2 -pipe -g -feliminate-unused-debug-types | ||
| 405 | </literallayout> | ||
| 406 | Now, consider the following three cases: | ||
| 407 | <itemizedlist> | ||
| 408 | <listitem><para><emphasis>Case 1 - No Variables Set in the <filename>Makefile</filename>:</emphasis> | ||
| 409 | Because these variables are not specifically set in the | ||
| 410 | <filename>Makefile</filename>, the variables retain their | ||
| 411 | values based on the environment. | ||
| 412 | </para></listitem> | ||
| 413 | <listitem><para><emphasis>Case 2 - Variables Set in the <filename>Makefile</filename>:</emphasis> | ||
| 414 | Specifically setting variables in the | ||
| 415 | <filename>Makefile</filename> during the build results in the | ||
| 416 | environment settings of the variables being overwritten. | ||
| 417 | </para></listitem> | ||
| 418 | <listitem><para><emphasis>Case 3 - Variables Set when the <filename>Makefile</filename> is Executed from the Command Line:</emphasis> | ||
| 419 | Executing the <filename>Makefile</filename> from the command | ||
| 420 | line results in the variables being overwritten with | ||
| 421 | command-line content regardless of what is being set in the | ||
| 422 | <filename>Makefile</filename>. | ||
| 423 | In this case, environment variables are not considered unless | ||
| 424 | you use the "-e" flag during the build: | ||
| 425 | <literallayout class='monospaced'> | ||
| 426 | $ make -e <replaceable>file</replaceable> | ||
| 427 | </literallayout> | ||
| 428 | If you use this flag, then the environment values of the | ||
| 429 | variables override any variables specifically set in the | ||
| 430 | <filename>Makefile</filename>. | ||
| 431 | </para></listitem> | ||
| 432 | </itemizedlist> | ||
| 433 | <note> | ||
| 434 | For the list of variables set up by the cross-toolchain environment | ||
| 435 | setup script, see the | ||
| 436 | "<link linkend='sdk-running-the-sdk-environment-setup-script'>Running the SDK Environment Setup Script</link>" | ||
| 437 | section. | ||
| 438 | </note> | ||
| 439 | </para> | ||
| 440 | </section> | ||
| 441 | |||
| 259 | <section id='sdk-using-the-sdk-to-task-1'> | 442 | <section id='sdk-using-the-sdk-to-task-1'> |
| 260 | <title>Using the SDK to <replaceable>item 1</replaceable></title> | 443 | <title>Using the SDK to <replaceable>item 1</replaceable></title> |
| 261 | 444 | ||
