diff options
Diffstat (limited to 'documentation/adt-manual')
| -rw-r--r-- | documentation/adt-manual/adt-command.rst | 178 | ||||
| -rw-r--r-- | documentation/adt-manual/adt-intro.rst | 136 | ||||
| -rw-r--r-- | documentation/adt-manual/adt-manual-intro.rst | 22 | ||||
| -rw-r--r-- | documentation/adt-manual/adt-manual.rst | 13 | ||||
| -rw-r--r-- | documentation/adt-manual/adt-package.rst | 68 | ||||
| -rw-r--r-- | documentation/adt-manual/adt-prepare.rst | 753 |
6 files changed, 1170 insertions, 0 deletions
diff --git a/documentation/adt-manual/adt-command.rst b/documentation/adt-manual/adt-command.rst new file mode 100644 index 0000000000..41bc41e149 --- /dev/null +++ b/documentation/adt-manual/adt-command.rst | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | ********************** | ||
| 2 | Using the Command Line | ||
| 3 | ********************** | ||
| 4 | |||
| 5 | Recall that earlier the manual discussed how to use an existing | ||
| 6 | toolchain tarball that had been installed into the default installation | ||
| 7 | directory, ``/opt/poky/DISTRO``, which is outside of the `Build | ||
| 8 | Directory <&YOCTO_DOCS_DEV_URL;#build-directory>`__ (see the section | ||
| 9 | "`Using a Cross-Toolchain | ||
| 10 | Tarball) <#using-an-existing-toolchain-tarball>`__". And, that sourcing | ||
| 11 | your architecture-specific environment setup script initializes a | ||
| 12 | suitable cross-toolchain development environment. | ||
| 13 | |||
| 14 | During this setup, locations for the compiler, QEMU scripts, QEMU | ||
| 15 | binary, a special version of ``pkgconfig`` and other useful utilities | ||
| 16 | are added to the ``PATH`` variable. Also, variables to assist | ||
| 17 | ``pkgconfig`` and ``autotools`` are also defined so that, for example, | ||
| 18 | ``configure.sh`` can find pre-generated test results for tests that need | ||
| 19 | target hardware on which to run. You can see the "`Setting Up the | ||
| 20 | Cross-Development | ||
| 21 | Environment <#setting-up-the-cross-development-environment>`__" section | ||
| 22 | for the list of cross-toolchain environment variables established by the | ||
| 23 | script. | ||
| 24 | |||
| 25 | Collectively, these conditions allow you to easily use the toolchain | ||
| 26 | outside of the OpenEmbedded build environment on both Autotools-based | ||
| 27 | projects and Makefile-based projects. This chapter provides information | ||
| 28 | for both these types of projects. | ||
| 29 | |||
| 30 | Autotools-Based Projects | ||
| 31 | ======================== | ||
| 32 | |||
| 33 | Once you have a suitable cross-toolchain installed, it is very easy to | ||
| 34 | develop a project outside of the OpenEmbedded build system. This section | ||
| 35 | presents a simple "Helloworld" example that shows how to set up, | ||
| 36 | compile, and run the project. | ||
| 37 | |||
| 38 | Creating and Running a Project Based on GNU Autotools | ||
| 39 | ----------------------------------------------------- | ||
| 40 | |||
| 41 | Follow these steps to create a simple Autotools-based project: | ||
| 42 | |||
| 43 | 1. *Create your directory:* Create a clean directory for your project | ||
| 44 | and then make that directory your working location: $ mkdir | ||
| 45 | $HOME/helloworld $ cd $HOME/helloworld | ||
| 46 | |||
| 47 | 2. *Populate the directory:* Create ``hello.c``, ``Makefile.am``, and | ||
| 48 | ``configure.in`` files as follows: | ||
| 49 | |||
| 50 | - For ``hello.c``, include these lines: #include <stdio.h> main() { | ||
| 51 | printf("Hello World!\n"); } | ||
| 52 | |||
| 53 | - For ``Makefile.am``, include these lines: bin_PROGRAMS = hello | ||
| 54 | hello_SOURCES = hello.c | ||
| 55 | |||
| 56 | - For ``configure.in``, include these lines: AC_INIT(hello.c) | ||
| 57 | AM_INIT_AUTOMAKE(hello,0.1) AC_PROG_CC AC_PROG_INSTALL | ||
| 58 | AC_OUTPUT(Makefile) | ||
| 59 | |||
| 60 | 3. *Source the cross-toolchain environment setup file:* Installation of | ||
| 61 | the cross-toolchain creates a cross-toolchain environment setup | ||
| 62 | script in the directory that the ADT was installed. Before you can | ||
| 63 | use the tools to develop your project, you must source this setup | ||
| 64 | script. The script begins with the string "environment-setup" and | ||
| 65 | contains the machine architecture, which is followed by the string | ||
| 66 | "poky-linux". Here is an example that sources a script from the | ||
| 67 | default ADT installation directory that uses the 32-bit Intel x86 | ||
| 68 | Architecture and the DISTRO_NAME Yocto Project release: $ source | ||
| 69 | /opt/poky/DISTRO/environment-setup-i586-poky-linux | ||
| 70 | |||
| 71 | 4. *Generate the local aclocal.m4 files and create the configure | ||
| 72 | script:* The following GNU Autotools generate the local | ||
| 73 | ``aclocal.m4`` files and create the configure script: $ aclocal $ | ||
| 74 | autoconf | ||
| 75 | |||
| 76 | 5. *Generate files needed by GNU coding standards:* GNU coding | ||
| 77 | standards require certain files in order for the project to be | ||
| 78 | compliant. This command creates those files: $ touch NEWS README | ||
| 79 | AUTHORS ChangeLog | ||
| 80 | |||
| 81 | 6. *Generate the configure file:* This command generates the | ||
| 82 | ``configure``: $ automake -a | ||
| 83 | |||
| 84 | 7. *Cross-compile the project:* This command compiles the project using | ||
| 85 | the cross-compiler. The | ||
| 86 | ```CONFIGURE_FLAGS`` <&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS>`__ | ||
| 87 | environment variable provides the minimal arguments for GNU | ||
| 88 | configure: $ ./configure ${CONFIGURE_FLAGS} | ||
| 89 | |||
| 90 | 8. *Make and install the project:* These two commands generate and | ||
| 91 | install the project into the destination directory: $ make $ make | ||
| 92 | install DESTDIR=./tmp | ||
| 93 | |||
| 94 | 9. *Verify the installation:* This command is a simple way to verify | ||
| 95 | the installation of your project. Running the command prints the | ||
| 96 | architecture on which the binary file can run. This architecture | ||
| 97 | should be the same architecture that the installed cross-toolchain | ||
| 98 | supports. $ file ./tmp/usr/local/bin/hello | ||
| 99 | |||
| 100 | 10. *Execute your project:* To execute the project in the shell, simply | ||
| 101 | enter the name. You could also copy the binary to the actual target | ||
| 102 | hardware and run the project there as well: $ ./hello As expected, | ||
| 103 | the project displays the "Hello World!" message. | ||
| 104 | |||
| 105 | Passing Host Options | ||
| 106 | -------------------- | ||
| 107 | |||
| 108 | For an Autotools-based project, you can use the cross-toolchain by just | ||
| 109 | passing the appropriate host option to ``configure.sh``. The host option | ||
| 110 | you use is derived from the name of the environment setup script found | ||
| 111 | in the directory in which you installed the cross-toolchain. For | ||
| 112 | example, the host option for an ARM-based target that uses the GNU EABI | ||
| 113 | is ``armv5te-poky-linux-gnueabi``. You will notice that the name of the | ||
| 114 | script is ``environment-setup-armv5te-poky-linux-gnueabi``. Thus, the | ||
| 115 | following command works to update your project and rebuild it using the | ||
| 116 | appropriate cross-toolchain tools: $ ./configure | ||
| 117 | --host=armv5te-poky-linux-gnueabi \\ --with-libtool-sysroot=sysroot_dir | ||
| 118 | |||
| 119 | .. note:: | ||
| 120 | |||
| 121 | If the | ||
| 122 | configure | ||
| 123 | script results in problems recognizing the | ||
| 124 | --with-libtool-sysroot= | ||
| 125 | sysroot-dir | ||
| 126 | option, regenerate the script to enable the support by doing the | ||
| 127 | following and then run the script again: | ||
| 128 | :: | ||
| 129 | |||
| 130 | $ libtoolize --automake | ||
| 131 | $ aclocal -I ${OECORE_NATIVE_SYSROOT}/usr/share/aclocal \ | ||
| 132 | [-I dir_containing_your_project-specific_m4_macros] | ||
| 133 | $ autoconf | ||
| 134 | $ autoheader | ||
| 135 | $ automake -a | ||
| 136 | |||
| 137 | |||
| 138 | Makefile-Based Projects | ||
| 139 | ======================= | ||
| 140 | |||
| 141 | For Makefile-based projects, the cross-toolchain environment variables | ||
| 142 | established by running the cross-toolchain environment setup script are | ||
| 143 | subject to general ``make`` rules. | ||
| 144 | |||
| 145 | To illustrate this, consider the following four cross-toolchain | ||
| 146 | environment variables: | ||
| 147 | `CC <&YOCTO_DOCS_REF_URL;#var-CC>`__\ =i586-poky-linux-gcc -m32 | ||
| 148 | -march=i586 --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux | ||
| 149 | `LD <&YOCTO_DOCS_REF_URL;#var-LD>`__\ =i586-poky-linux-ld | ||
| 150 | --sysroot=/opt/poky/1.8/sysroots/i586-poky-linux | ||
| 151 | `CFLAGS <&YOCTO_DOCS_REF_URL;#var-CFLAGS>`__\ =-O2 -pipe -g | ||
| 152 | -feliminate-unused-debug-types | ||
| 153 | `CXXFLAGS <&YOCTO_DOCS_REF_URL;#var-CXXFLAGS>`__\ =-O2 -pipe -g | ||
| 154 | -feliminate-unused-debug-types Now, consider the following three cases: | ||
| 155 | |||
| 156 | - *Case 1 - No Variables Set in the ``Makefile``:* Because these | ||
| 157 | variables are not specifically set in the ``Makefile``, the variables | ||
| 158 | retain their values based on the environment. | ||
| 159 | |||
| 160 | - *Case 2 - Variables Set in the ``Makefile``:* Specifically setting | ||
| 161 | variables in the ``Makefile`` during the build results in the | ||
| 162 | environment settings of the variables being overwritten. | ||
| 163 | |||
| 164 | - *Case 3 - Variables Set when the ``Makefile`` is Executed from the | ||
| 165 | Command Line:* Executing the ``Makefile`` from the command line | ||
| 166 | results in the variables being overwritten with command-line content | ||
| 167 | regardless of what is being set in the ``Makefile``. In this case, | ||
| 168 | environment variables are not considered unless you use the "-e" flag | ||
| 169 | during the build: $ make -e file If you use this flag, then the | ||
| 170 | environment values of the variables override any variables | ||
| 171 | specifically set in the ``Makefile``. | ||
| 172 | |||
| 173 | .. note:: | ||
| 174 | |||
| 175 | For the list of variables set up by the cross-toolchain environment | ||
| 176 | setup script, see the " | ||
| 177 | Setting Up the Cross-Development Environment | ||
| 178 | " section. | ||
diff --git a/documentation/adt-manual/adt-intro.rst b/documentation/adt-manual/adt-intro.rst new file mode 100644 index 0000000000..4e44afacbe --- /dev/null +++ b/documentation/adt-manual/adt-intro.rst | |||
| @@ -0,0 +1,136 @@ | |||
| 1 | ***************************************** | ||
| 2 | The Application Development Toolkit (ADT) | ||
| 3 | ***************************************** | ||
| 4 | |||
| 5 | Part of the Yocto Project development solution is an Application | ||
| 6 | Development Toolkit (ADT). The ADT provides you with a custom-built, | ||
| 7 | cross-development platform suited for developing a user-targeted product | ||
| 8 | application. | ||
| 9 | |||
| 10 | Fundamentally, the ADT consists of the following: | ||
| 11 | |||
| 12 | - An architecture-specific cross-toolchain and matching sysroot both | ||
| 13 | built by the `OpenEmbedded build | ||
| 14 | system <&YOCTO_DOCS_DEV_URL;#build-system-term>`__. The toolchain and | ||
| 15 | sysroot are based on a `Metadata <&YOCTO_DOCS_DEV_URL;#metadata>`__ | ||
| 16 | configuration and extensions, which allows you to cross-develop on | ||
| 17 | the host machine for the target hardware. | ||
| 18 | |||
| 19 | - The Eclipse IDE Yocto Plug-in. | ||
| 20 | |||
| 21 | - The Quick EMUlator (QEMU), which lets you simulate target hardware. | ||
| 22 | |||
| 23 | - Various user-space tools that greatly enhance your application | ||
| 24 | development experience. | ||
| 25 | |||
| 26 | The Cross-Development Toolchain | ||
| 27 | =============================== | ||
| 28 | |||
| 29 | The `Cross-Development | ||
| 30 | Toolchain <&YOCTO_DOCS_DEV_URL;#cross-development-toolchain>`__ consists | ||
| 31 | of a cross-compiler, cross-linker, and cross-debugger that are used to | ||
| 32 | develop user-space applications for targeted hardware. This toolchain is | ||
| 33 | created either by running the ADT Installer script, a toolchain | ||
| 34 | installer script, or through a `Build | ||
| 35 | Directory <&YOCTO_DOCS_DEV_URL;#build-directory>`__ that is based on | ||
| 36 | your Metadata configuration or extension for your targeted device. The | ||
| 37 | cross-toolchain works with a matching target sysroot. | ||
| 38 | |||
| 39 | Sysroot | ||
| 40 | ======= | ||
| 41 | |||
| 42 | The matching target sysroot contains needed headers and libraries for | ||
| 43 | generating binaries that run on the target architecture. The sysroot is | ||
| 44 | based on the target root filesystem image that is built by the | ||
| 45 | OpenEmbedded build system and uses the same Metadata configuration used | ||
| 46 | to build the cross-toolchain. | ||
| 47 | |||
| 48 | .. _eclipse-overview: | ||
| 49 | |||
| 50 | Eclipse Yocto Plug-in | ||
| 51 | ===================== | ||
| 52 | |||
| 53 | The Eclipse IDE is a popular development environment and it fully | ||
| 54 | supports development using the Yocto Project. When you install and | ||
| 55 | configure the Eclipse Yocto Project Plug-in into the Eclipse IDE, you | ||
| 56 | maximize your Yocto Project experience. Installing and configuring the | ||
| 57 | Plug-in results in an environment that has extensions specifically | ||
| 58 | designed to let you more easily develop software. These extensions allow | ||
| 59 | for cross-compilation, deployment, and execution of your output into a | ||
| 60 | QEMU emulation session. You can also perform cross-debugging and | ||
| 61 | profiling. The environment also supports a suite of tools that allows | ||
| 62 | you to perform remote profiling, tracing, collection of power data, | ||
| 63 | collection of latency data, and collection of performance data. | ||
| 64 | |||
| 65 | For information about the application development workflow that uses the | ||
| 66 | Eclipse IDE and for a detailed example of how to install and configure | ||
| 67 | the Eclipse Yocto Project Plug-in, see the "`Working Within | ||
| 68 | Eclipse <&YOCTO_DOCS_DEV_URL;#adt-eclipse>`__" section of the Yocto | ||
| 69 | Project Development Manual. | ||
| 70 | |||
| 71 | The QEMU Emulator | ||
| 72 | ================= | ||
| 73 | |||
| 74 | The QEMU emulator allows you to simulate your hardware while running | ||
| 75 | your application or image. QEMU is made available a number of ways: | ||
| 76 | |||
| 77 | - If you use the ADT Installer script to install ADT, you can specify | ||
| 78 | whether or not to install QEMU. | ||
| 79 | |||
| 80 | - If you have cloned the ``poky`` Git repository to create a `Source | ||
| 81 | Directory <&YOCTO_DOCS_DEV_URL;#source-directory>`__ and you have | ||
| 82 | sourced the environment setup script, QEMU is installed and | ||
| 83 | automatically available. | ||
| 84 | |||
| 85 | - If you have downloaded a Yocto Project release and unpacked it to | ||
| 86 | create a `Source Directory <&YOCTO_DOCS_DEV_URL;#source-directory>`__ | ||
| 87 | and you have sourced the environment setup script, QEMU is installed | ||
| 88 | and automatically available. | ||
| 89 | |||
| 90 | - If you have installed the cross-toolchain tarball and you have | ||
| 91 | sourced the toolchain's setup environment script, QEMU is also | ||
| 92 | installed and automatically available. | ||
| 93 | |||
| 94 | User-Space Tools | ||
| 95 | ================ | ||
| 96 | |||
| 97 | User-space tools are included as part of the Yocto Project. You will | ||
| 98 | find these tools helpful during development. The tools include | ||
| 99 | LatencyTOP, PowerTOP, OProfile, Perf, SystemTap, and Lttng-ust. These | ||
| 100 | tools are common development tools for the Linux platform. | ||
| 101 | |||
| 102 | - *LatencyTOP:* LatencyTOP focuses on latency that causes skips in | ||
| 103 | audio, stutters in your desktop experience, or situations that | ||
| 104 | overload your server even when you have plenty of CPU power left. | ||
| 105 | |||
| 106 | - *PowerTOP:* Helps you determine what software is using the most | ||
| 107 | power. You can find out more about PowerTOP at | ||
| 108 | ` <https://01.org/powertop/>`__. | ||
| 109 | |||
| 110 | - *OProfile:* A system-wide profiler for Linux systems that is capable | ||
| 111 | of profiling all running code at low overhead. You can find out more | ||
| 112 | about OProfile at ` <http://oprofile.sourceforge.net/about/>`__. For | ||
| 113 | examples on how to setup and use this tool, see the | ||
| 114 | "`OProfile <&YOCTO_DOCS_PROF_URL;#profile-manual-oprofile>`__" | ||
| 115 | section in the Yocto Project Profiling and Tracing Manual. | ||
| 116 | |||
| 117 | - *Perf:* Performance counters for Linux used to keep track of certain | ||
| 118 | types of hardware and software events. For more information on these | ||
| 119 | types of counters see ` <https://perf.wiki.kernel.org/>`__. For | ||
| 120 | examples on how to setup and use this tool, see the | ||
| 121 | "`perf <&YOCTO_DOCS_PROF_URL;#profile-manual-perf>`__" section in the | ||
| 122 | Yocto Project Profiling and Tracing Manual. | ||
| 123 | |||
| 124 | - *SystemTap:* A free software infrastructure that simplifies | ||
| 125 | information gathering about a running Linux system. This information | ||
| 126 | helps you diagnose performance or functional problems. SystemTap is | ||
| 127 | not available as a user-space tool through the Eclipse IDE Yocto | ||
| 128 | Plug-in. See ` <http://sourceware.org/systemtap>`__ for more | ||
| 129 | information on SystemTap. For examples on how to setup and use this | ||
| 130 | tool, see the | ||
| 131 | "`SystemTap <&YOCTO_DOCS_PROF_URL;#profile-manual-systemtap>`__" | ||
| 132 | section in the Yocto Project Profiling and Tracing Manual. | ||
| 133 | |||
| 134 | - *Lttng-ust:* A User-space Tracer designed to provide detailed | ||
| 135 | information on user-space activity. See ` <http://lttng.org/ust>`__ | ||
| 136 | for more information on Lttng-ust. | ||
diff --git a/documentation/adt-manual/adt-manual-intro.rst b/documentation/adt-manual/adt-manual-intro.rst new file mode 100644 index 0000000000..6e914dc8ef --- /dev/null +++ b/documentation/adt-manual/adt-manual-intro.rst | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | ************ | ||
| 2 | Introduction | ||
| 3 | ************ | ||
| 4 | |||
| 5 | Welcome to the Yocto Project Application Developer's Guide. This manual | ||
| 6 | provides information that lets you begin developing applications using | ||
| 7 | the Yocto Project. | ||
| 8 | |||
| 9 | The Yocto Project provides an application development environment based | ||
| 10 | on an Application Development Toolkit (ADT) and the availability of | ||
| 11 | stand-alone cross-development toolchains and other tools. This manual | ||
| 12 | describes the ADT and how you can configure and install it, how to | ||
| 13 | access and use the cross-development toolchains, how to customize the | ||
| 14 | development packages installation, how to use command-line development | ||
| 15 | for both Autotools-based and Makefile-based projects, and an | ||
| 16 | introduction to the Eclipse IDE Yocto Plug-in. | ||
| 17 | |||
| 18 | .. note:: | ||
| 19 | |||
| 20 | The ADT is distribution-neutral and does not require the Yocto | ||
| 21 | Project reference distribution, which is called Poky. This manual, | ||
| 22 | however, uses examples that use the Poky distribution. | ||
diff --git a/documentation/adt-manual/adt-manual.rst b/documentation/adt-manual/adt-manual.rst new file mode 100644 index 0000000000..d53c38b550 --- /dev/null +++ b/documentation/adt-manual/adt-manual.rst | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | =========================================== | ||
| 2 | Yocto Project Application Developer's Guide | ||
| 3 | =========================================== | ||
| 4 | |||
| 5 | .. toctree:: | ||
| 6 | :caption: Table of Contents | ||
| 7 | :numbered: | ||
| 8 | |||
| 9 | adt-manual-intro | ||
| 10 | adt-intro | ||
| 11 | adt-prepare | ||
| 12 | adt-package | ||
| 13 | adt-command | ||
diff --git a/documentation/adt-manual/adt-package.rst b/documentation/adt-manual/adt-package.rst new file mode 100644 index 0000000000..6a6da1dd8f --- /dev/null +++ b/documentation/adt-manual/adt-package.rst | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | ************************************************************ | ||
| 2 | Optionally Customizing the Development Packages Installation | ||
| 3 | ************************************************************ | ||
| 4 | |||
| 5 | Because the Yocto Project is suited for embedded Linux development, it | ||
| 6 | is likely that you will need to customize your development packages | ||
| 7 | installation. For example, if you are developing a minimal image, then | ||
| 8 | you might not need certain packages (e.g. graphics support packages). | ||
| 9 | Thus, you would like to be able to remove those packages from your | ||
| 10 | target sysroot. | ||
| 11 | |||
| 12 | Package Management Systems | ||
| 13 | ========================== | ||
| 14 | |||
| 15 | The OpenEmbedded build system supports the generation of sysroot files | ||
| 16 | using three different Package Management Systems (PMS): | ||
| 17 | |||
| 18 | - *OPKG:* A less well known PMS whose use originated in the | ||
| 19 | OpenEmbedded and OpenWrt embedded Linux projects. This PMS works with | ||
| 20 | files packaged in an ``.ipk`` format. See | ||
| 21 | ` <http://en.wikipedia.org/wiki/Opkg>`__ for more information about | ||
| 22 | OPKG. | ||
| 23 | |||
| 24 | - *RPM:* A more widely known PMS intended for GNU/Linux distributions. | ||
| 25 | This PMS works with files packaged in an ``.rpm`` format. The build | ||
| 26 | system currently installs through this PMS by default. See | ||
| 27 | ` <http://en.wikipedia.org/wiki/RPM_Package_Manager>`__ for more | ||
| 28 | information about RPM. | ||
| 29 | |||
| 30 | - *Debian:* The PMS for Debian-based systems is built on many PMS | ||
| 31 | tools. The lower-level PMS tool ``dpkg`` forms the base of the Debian | ||
| 32 | PMS. For information on dpkg see | ||
| 33 | ` <http://en.wikipedia.org/wiki/Dpkg>`__. | ||
| 34 | |||
| 35 | Configuring the PMS | ||
| 36 | =================== | ||
| 37 | |||
| 38 | Whichever PMS you are using, you need to be sure that the | ||
| 39 | ```PACKAGE_CLASSES`` <&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES>`__ | ||
| 40 | variable in the ``conf/local.conf`` file is set to reflect that system. | ||
| 41 | The first value you choose for the variable specifies the package file | ||
| 42 | format for the root filesystem at sysroot. Additional values specify | ||
| 43 | additional formats for convenience or testing. See the | ||
| 44 | ``conf/local.conf`` configuration file for details. | ||
| 45 | |||
| 46 | .. note:: | ||
| 47 | |||
| 48 | For build performance information related to the PMS, see the " | ||
| 49 | package.bbclass | ||
| 50 | " section in the Yocto Project Reference Manual. | ||
| 51 | |||
| 52 | As an example, consider a scenario where you are using OPKG and you want | ||
| 53 | to add the ``libglade`` package to the target sysroot. | ||
| 54 | |||
| 55 | First, you should generate the IPK file for the ``libglade`` package and | ||
| 56 | add it into a working ``opkg`` repository. Use these commands: $ bitbake | ||
| 57 | libglade $ bitbake package-index | ||
| 58 | |||
| 59 | Next, source the cross-toolchain environment setup script found in the | ||
| 60 | `Source Directory <&YOCTO_DOCS_DEV_URL;#source-directory>`__. Follow | ||
| 61 | that by setting up the installation destination to point to your sysroot | ||
| 62 | as sysroot_dir. Finally, have an OPKG configuration file conf_file that | ||
| 63 | corresponds to the ``opkg`` repository you have just created. The | ||
| 64 | following command forms should now work: $ opkg-cl –f conf_file -o | ||
| 65 | sysroot_dir update $ opkg-cl –f cconf_file -o sysroot_dir \\ | ||
| 66 | --force-overwrite install libglade $ opkg-cl –f cconf_file -o | ||
| 67 | sysroot_dir \\ --force-overwrite install libglade-dbg $ opkg-cl –f | ||
| 68 | conf_file> -osysroot_dir> \\ --force-overwrite install libglade-dev | ||
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 | ||
