adt-prepare.xml 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  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. <chapter id='adt-prepare'>
  5. <title>Preparing for Application Development</title>
  6. <para>
  7. In order to develop applications, you need set up your host development system.
  8. Several ways exist that allow you to install cross-development tools, QEMU, the
  9. Eclipse Yocto Plug-in, and other tools.
  10. This chapter describes how to prepare for application development.
  11. </para>
  12. <section id='installing-the-adt'>
  13. <title>Installing the ADT and Toolchains</title>
  14. <para>
  15. The following list describes installation methods that set up varying
  16. degrees of tool availability on your system.
  17. Regardless of the installation method you choose,
  18. you must <filename>source</filename> the cross-toolchain
  19. environment setup script, which establishes several key
  20. environment variables, before you use a toolchain.
  21. See the
  22. "<link linkend='setting-up-the-cross-development-environment'>Setting Up the Cross-Development Environment</link>"
  23. section for more information.
  24. </para>
  25. <note>
  26. <para>
  27. Avoid mixing installation methods when installing toolchains for
  28. different architectures.
  29. For example, avoid using the ADT Installer to install some
  30. toolchains and then hand-installing cross-development toolchains
  31. by running the toolchain installer for different architectures.
  32. Mixing installation methods can result in situations where the
  33. ADT Installer becomes unreliable and might not install the
  34. toolchain.
  35. </para>
  36. <para>
  37. If you must mix installation methods, you might avoid problems by
  38. deleting <filename>/var/lib/opkg</filename>, thus purging the
  39. <filename>opkg</filename> package metadata.
  40. </para>
  41. </note>
  42. <para>
  43. <itemizedlist>
  44. <listitem><para><emphasis>Use the ADT installer script:</emphasis>
  45. This method is the recommended way to install the ADT because it
  46. automates much of the process for you.
  47. For example, you can configure the installation to install the QEMU emulator
  48. and the user-space NFS, specify which root filesystem profiles to download,
  49. and define the target sysroot location.</para></listitem>
  50. <listitem><para><emphasis>Use an existing toolchain:</emphasis>
  51. Using this method, you select and download an architecture-specific
  52. toolchain installer and then run the script to hand-install the toolchain.
  53. If you use this method, you just get the cross-toolchain and QEMU - you do not
  54. get any of the other mentioned benefits had you run the ADT Installer script.</para></listitem>
  55. <listitem><para><emphasis>Use the toolchain from within the Build Directory:</emphasis>
  56. If you already have a
  57. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>,
  58. you can build the cross-toolchain within the directory.
  59. However, like the previous method mentioned, you only get the cross-toolchain and QEMU - you
  60. do not get any of the other benefits without taking separate steps.</para></listitem>
  61. </itemizedlist>
  62. </para>
  63. <section id='using-the-adt-installer'>
  64. <title>Using the ADT Installer</title>
  65. <para>
  66. To run the ADT Installer, you need to get the ADT Installer tarball, be sure
  67. you have the necessary host development packages that support the ADT Installer,
  68. and then run the ADT Installer Script.
  69. </para>
  70. <para>
  71. For a list of the host packages needed to support ADT installation and use, see the
  72. "ADT Installer Extras" lists in the
  73. "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>" section
  74. of the Yocto Project Reference Manual.
  75. </para>
  76. <section id='getting-the-adt-installer-tarball'>
  77. <title>Getting the ADT Installer Tarball</title>
  78. <para>
  79. The ADT Installer is contained in the ADT Installer tarball.
  80. You can get the tarball using either of these methods:
  81. <itemizedlist>
  82. <listitem><para><emphasis>Download the Tarball:</emphasis>
  83. You can download the tarball from
  84. <ulink url='&YOCTO_ADTINSTALLER_DL_URL;'></ulink> into
  85. any directory.</para></listitem>
  86. <listitem><para><emphasis>Build the Tarball:</emphasis>
  87. You can use
  88. <ulink url='&YOCTO_DOCS_DEV_URL;#bitbake-term'>BitBake</ulink>
  89. to generate the tarball inside an existing
  90. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>.
  91. </para>
  92. <para>If you use BitBake to generate the ADT Installer
  93. tarball, you must <filename>source</filename> the
  94. environment setup script
  95. (<ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  96. or
  97. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  98. located in the Source Directory before running the
  99. <filename>bitbake</filename> command that creates the
  100. tarball.</para>
  101. <para>The following example commands establish
  102. the
  103. <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink>,
  104. check out the current release branch, set up the
  105. build environment while also creating the default
  106. Build Directory, and run the
  107. <filename>bitbake</filename> command that results in the
  108. tarball
  109. <filename>poky/build/tmp/deploy/sdk/adt_installer.tar.bz2</filename>:
  110. <note>
  111. Before using BitBake to build the ADT tarball, be
  112. sure to make sure your
  113. <filename>local.conf</filename> file is properly
  114. configured.
  115. See the
  116. "<ulink url='&YOCTO_DOCS_REF_URL;#user-configuration'>User Configuration</ulink>"
  117. section in the Yocto Project Reference Manual for
  118. general configuration information.
  119. </note>
  120. <literallayout class='monospaced'>
  121. $ cd ~
  122. $ git clone git://git.yoctoproject.org/poky
  123. $ cd poky
  124. $ git checkout -b &DISTRO_NAME; origin/&DISTRO_NAME;
  125. $ source &OE_INIT_FILE;
  126. $ bitbake adt-installer
  127. </literallayout></para></listitem>
  128. </itemizedlist>
  129. </para>
  130. </section>
  131. <section id='configuring-and-running-the-adt-installer-script'>
  132. <title>Configuring and Running the ADT Installer Script</title>
  133. <para>
  134. Before running the ADT Installer script, you need to unpack the tarball.
  135. You can unpack the tarball in any directory you wish.
  136. For example, this command copies the ADT Installer tarball from where
  137. it was built into the home directory and then unpacks the tarball into
  138. a top-level directory named <filename>adt-installer</filename>:
  139. <literallayout class='monospaced'>
  140. $ cd ~
  141. $ cp poky/build/tmp/deploy/sdk/adt_installer.tar.bz2 $HOME
  142. $ tar -xjf adt_installer.tar.bz2
  143. </literallayout>
  144. Unpacking it creates the directory <filename>adt-installer</filename>,
  145. which contains the ADT Installer script (<filename>adt_installer</filename>)
  146. and its configuration file (<filename>adt_installer.conf</filename>).
  147. </para>
  148. <para>
  149. Before you run the script, however, you should examine the ADT Installer configuration
  150. file and be sure you are going to get what you want.
  151. Your configurations determine which kernel and filesystem image are downloaded.
  152. </para>
  153. <para>
  154. The following list describes the configurations you can define for the ADT Installer.
  155. For configuration values and restrictions, see the comments in
  156. the <filename>adt-installer.conf</filename> file:
  157. <itemizedlist>
  158. <listitem><para><filename>YOCTOADT_REPO</filename>: This area
  159. includes the IPKG-based packages and the root filesystem upon which
  160. the installation is based.
  161. If you want to set up your own IPKG repository pointed to by
  162. <filename>YOCTOADT_REPO</filename>, you need to be sure that the
  163. directory structure follows the same layout as the reference directory
  164. set up at <ulink url='http://adtrepo.yoctoproject.org'></ulink>.
  165. Also, your repository needs to be accessible through HTTP.</para></listitem>
  166. <listitem><para><filename>YOCTOADT_TARGETS</filename>: The machine
  167. target architectures for which you want to set up cross-development
  168. environments.</para></listitem>
  169. <listitem><para><filename>YOCTOADT_QEMU</filename>: Indicates whether
  170. or not to install the emulator QEMU.</para></listitem>
  171. <listitem><para><filename>YOCTOADT_NFS_UTIL</filename>: Indicates whether
  172. or not to install user-mode NFS.
  173. If you plan to use the Eclipse IDE Yocto plug-in against QEMU,
  174. you should install NFS.
  175. <note>To boot QEMU images using our userspace NFS server, you need
  176. to be running <filename>portmap</filename> or <filename>rpcbind</filename>.
  177. If you are running <filename>rpcbind</filename>, you will also need to add the
  178. <filename>-i</filename> option when <filename>rpcbind</filename> starts up.
  179. Please make sure you understand the security implications of doing this.
  180. You might also have to modify your firewall settings to allow
  181. NFS booting to work.</note></para></listitem>
  182. <listitem><para><filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>: The root
  183. filesystem images you want to download from the
  184. <filename>YOCTOADT_IPKG_REPO</filename> repository.</para></listitem>
  185. <listitem><para><filename>YOCTOADT_TARGET_SYSROOT_IMAGE_</filename><replaceable>arch</replaceable>: The
  186. particular root filesystem used to extract and create the target sysroot.
  187. The value of this variable must have been specified with
  188. <filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>.
  189. For example, if you downloaded both <filename>minimal</filename> and
  190. <filename>sato-sdk</filename> images by setting
  191. <filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>
  192. to "minimal sato-sdk", then <filename>YOCTOADT_ROOTFS_</filename><replaceable>arch</replaceable>
  193. must be set to either "minimal" or "sato-sdk".
  194. </para></listitem>
  195. <listitem><para><filename>YOCTOADT_TARGET_SYSROOT_LOC_</filename><replaceable>arch</replaceable>: The
  196. location on the development host where the target sysroot is created.
  197. </para></listitem>
  198. </itemizedlist>
  199. </para>
  200. <para>
  201. After you have configured the <filename>adt_installer.conf</filename> file,
  202. run the installer using the following command:
  203. <literallayout class='monospaced'>
  204. $ cd adt-installer
  205. $ ./adt_installer
  206. </literallayout>
  207. Once the installer begins to run, you are asked to enter the
  208. location for cross-toolchain installation.
  209. The default location is
  210. <filename>/opt/poky/</filename><replaceable>release</replaceable>.
  211. After either accepting the default location or selecting your
  212. own location, you are prompted to run the installation script
  213. interactively or in silent mode.
  214. If you want to closely monitor the installation,
  215. choose “I” for interactive mode rather than “S” for silent mode.
  216. Follow the prompts from the script to complete the installation.
  217. </para>
  218. <para>
  219. Once the installation completes, the ADT, which includes the
  220. cross-toolchain, is installed in the selected installation
  221. directory.
  222. You will notice environment setup files for the cross-toolchain
  223. in the installation directory, and image tarballs in the
  224. <filename>adt-installer</filename> directory according to your
  225. installer configurations, and the target sysroot located
  226. according to the
  227. <filename>YOCTOADT_TARGET_SYSROOT_LOC_</filename><replaceable>arch</replaceable>
  228. variable also in your configuration file.
  229. </para>
  230. </section>
  231. </section>
  232. <section id='using-an-existing-toolchain-tarball'>
  233. <title>Using a Cross-Toolchain Tarball</title>
  234. <para>
  235. If you want to simply install a cross-toolchain by hand, you can
  236. do so by running the toolchain installer.
  237. The installer includes the pre-built cross-toolchain, the
  238. <filename>runqemu</filename> script, and support files.
  239. If you use this method to install the cross-toolchain, you
  240. might still need to install the target sysroot by installing and
  241. extracting it separately.
  242. For information on how to install the sysroot, see the
  243. "<link linkend='extracting-the-root-filesystem'>Extracting the Root Filesystem</link>" section.
  244. </para>
  245. <para>
  246. Follow these steps:
  247. <orderedlist>
  248. <listitem><para><emphasis>Get your toolchain installer using one of the following methods:</emphasis>
  249. <itemizedlist>
  250. <listitem><para>Go to
  251. <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'></ulink>
  252. and find the folder that matches your host
  253. development system (i.e. <filename>i686</filename>
  254. for 32-bit machines or <filename>x86_64</filename>
  255. for 64-bit machines).</para>
  256. <para>Go into that folder and download the toolchain
  257. installer whose name includes the appropriate target
  258. architecture.
  259. The toolchains provided by the Yocto Project
  260. are based off of the
  261. <filename>core-image-sato</filename> image and
  262. contain libraries appropriate for developing
  263. against that image.
  264. For example, if your host development system is a
  265. 64-bit x86 system and you are going to use
  266. your cross-toolchain for a 32-bit x86
  267. target, go into the <filename>x86_64</filename>
  268. folder and download the following installer:
  269. <literallayout class='monospaced'>
  270. poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
  271. </literallayout></para></listitem>
  272. <listitem><para>Build your own toolchain installer.
  273. For cases where you cannot use an installer
  274. from the download area, you can build your own as
  275. described in the
  276. "<link linkend='optionally-building-a-toolchain-installer'>Optionally Building a Toolchain Installer</link>"
  277. section.</para></listitem>
  278. </itemizedlist></para></listitem>
  279. <listitem><para><emphasis>Once you have the installer, run it to install the toolchain:</emphasis>
  280. <note>
  281. You must change the permissions on the toolchain
  282. installer script so that it is executable.
  283. </note></para>
  284. <para>The following command shows how to run the installer
  285. given a toolchain tarball for a 64-bit x86 development host
  286. system and a 32-bit x86 target architecture.
  287. The example assumes the toolchain installer is located
  288. in <filename>~/Downloads/</filename>.
  289. <literallayout class='monospaced'>
  290. $ ~/Downloads/poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
  291. </literallayout>
  292. The first thing the installer prompts you for is the
  293. directory into which you want to install the toolchain.
  294. The default directory used is
  295. <filename>/opt/poky/&DISTRO;</filename>.
  296. If you do not have write permissions for the directory
  297. into which you are installing the toolchain, the
  298. toolchain installer notifies you and exits.
  299. Be sure you have write permissions in the directory and
  300. run the installer again.</para>
  301. <para>When the script finishes, the cross-toolchain is
  302. installed.
  303. You will notice environment setup files for the
  304. cross-toolchain in the installation directory.
  305. </para></listitem>
  306. </orderedlist>
  307. </para>
  308. </section>
  309. <section id='using-the-toolchain-from-within-the-build-tree'>
  310. <title>Using BitBake and the Build Directory</title>
  311. <para>
  312. A final way of making the cross-toolchain available is to use BitBake
  313. to generate the toolchain within an existing
  314. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>.
  315. This method does not install the toolchain into the default
  316. <filename>/opt</filename> directory.
  317. As with the previous method, if you need to install the target sysroot, you must
  318. do that separately as well.
  319. </para>
  320. <para>
  321. Follow these steps to generate the toolchain into the Build Directory:
  322. <orderedlist>
  323. <listitem><para><emphasis>Set up the Build Environment:</emphasis>
  324. Source the OpenEmbedded build environment setup
  325. script (i.e.
  326. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  327. or
  328. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  329. located in the
  330. <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink>.
  331. </para></listitem>
  332. <listitem><para><emphasis>Check your Local Configuration File:</emphasis>
  333. At this point, you should be sure that the
  334. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> variable
  335. in the <filename>local.conf</filename> file found in the
  336. <filename>conf</filename> directory of the Build Directory
  337. is set for the target architecture.
  338. Comments within the <filename>local.conf</filename> file
  339. list the values you can use for the
  340. <filename>MACHINE</filename> variable.
  341. If you do not change the <filename>MACHINE</filename>
  342. variable, the OpenEmbedded build system uses
  343. <filename>qemux86</filename> as the default target
  344. machine when building the cross-toolchain.
  345. <note>
  346. You can populate the Build Directory with the
  347. cross-toolchains for more than a single architecture.
  348. You just need to edit the <filename>MACHINE</filename>
  349. variable in the <filename>local.conf</filename> file and
  350. re-run the <filename>bitbake</filename> command.
  351. </note></para></listitem>
  352. <listitem><para><emphasis>Make Sure Your Layers are Enabled:</emphasis>
  353. Examine the <filename>conf/bblayers.conf</filename> file
  354. and make sure that you have enabled all the compatible
  355. layers for your target machine.
  356. The OpenEmbedded build system needs to be aware of each
  357. layer you want included when building images and
  358. cross-toolchains.
  359. For information on how to enable a layer, see the
  360. "<ulink url='&YOCTO_DOCS_DEV_URL;#enabling-your-layer'>Enabling Your Layer</ulink>"
  361. section in the Yocto Project Development Manual.
  362. </para></listitem>
  363. <listitem><para><emphasis>Generate the Cross-Toolchain:</emphasis>
  364. Run <filename>bitbake meta-ide-support</filename> to
  365. complete the cross-toolchain generation.
  366. Once the <filename>bitbake</filename> command finishes,
  367. the cross-toolchain is
  368. generated and populated within the Build Directory.
  369. You will notice environment setup files for the
  370. cross-toolchain that contain the string
  371. "<filename>environment-setup</filename>" in the
  372. Build Directory's <filename>tmp</filename> folder.</para>
  373. <para>Be aware that when you use this method to install the
  374. toolchain, you still need to separately extract and install
  375. the sysroot filesystem.
  376. For information on how to do this, see the
  377. "<link linkend='extracting-the-root-filesystem'>Extracting the Root Filesystem</link>" section.
  378. </para></listitem>
  379. </orderedlist>
  380. </para>
  381. </section>
  382. </section>
  383. <section id='setting-up-the-cross-development-environment'>
  384. <title>Setting Up the Cross-Development Environment</title>
  385. <para>
  386. Before you can develop using the cross-toolchain, you need to set up the
  387. cross-development environment by sourcing the toolchain's environment setup script.
  388. If you used the ADT Installer or hand-installed cross-toolchain,
  389. then you can find this script in the directory you chose for installation.
  390. For this release, the default installation directory is
  391. <filename>&YOCTO_ADTPATH_DIR;</filename>.
  392. If you installed the toolchain in the
  393. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>,
  394. you can find the environment setup
  395. script for the toolchain in the Build Directory's <filename>tmp</filename> directory.
  396. </para>
  397. <para>
  398. Be sure to run the environment setup script that matches the
  399. architecture for which you are developing.
  400. Environment setup scripts begin with the string
  401. "<filename>environment-setup</filename>" and include as part of their
  402. name the architecture.
  403. For example, the toolchain environment setup script for a 64-bit
  404. IA-based architecture installed in the default installation directory
  405. would be the following:
  406. <literallayout class='monospaced'>
  407. &YOCTO_ADTPATH_DIR;/environment-setup-x86_64-poky-linux
  408. </literallayout>
  409. When you run the setup script, many environment variables are
  410. defined:
  411. <literallayout class='monospaced'>
  412. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKTARGETSYSROOT'><filename>SDKTARGETSYSROOT</filename></ulink> - The path to the sysroot used for cross-compilation
  413. <ulink url='&YOCTO_DOCS_REF_URL;#var-PKG_CONFIG_PATH'><filename>PKG_CONFIG_PATH</filename></ulink> - The path to the target pkg-config files
  414. <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_SITE'><filename>CONFIG_SITE</filename></ulink> - A GNU autoconf site file preconfigured for the target
  415. <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink> - The minimal command and arguments to run the C compiler
  416. <ulink url='&YOCTO_DOCS_REF_URL;#var-CXX'><filename>CXX</filename></ulink> - The minimal command and arguments to run the C++ compiler
  417. <ulink url='&YOCTO_DOCS_REF_URL;#var-CPP'><filename>CPP</filename></ulink> - The minimal command and arguments to run the C preprocessor
  418. <ulink url='&YOCTO_DOCS_REF_URL;#var-AS'><filename>AS</filename></ulink> - The minimal command and arguments to run the assembler
  419. <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink> - The minimal command and arguments to run the linker
  420. <ulink url='&YOCTO_DOCS_REF_URL;#var-GDB'><filename>GDB</filename></ulink> - The minimal command and arguments to run the GNU Debugger
  421. <ulink url='&YOCTO_DOCS_REF_URL;#var-STRIP'><filename>STRIP</filename></ulink> - The minimal command and arguments to run 'strip', which strips symbols
  422. <ulink url='&YOCTO_DOCS_REF_URL;#var-RANLIB'><filename>RANLIB</filename></ulink> - The minimal command and arguments to run 'ranlib'
  423. <ulink url='&YOCTO_DOCS_REF_URL;#var-OBJCOPY'><filename>OBJCOPY</filename></ulink> - The minimal command and arguments to run 'objcopy'
  424. <ulink url='&YOCTO_DOCS_REF_URL;#var-OBJDUMP'><filename>OBJDUMP</filename></ulink> - The minimal command and arguments to run 'objdump'
  425. <ulink url='&YOCTO_DOCS_REF_URL;#var-AR'><filename>AR</filename></ulink> - The minimal command and arguments to run 'ar'
  426. <ulink url='&YOCTO_DOCS_REF_URL;#var-NM'><filename>NM</filename></ulink> - The minimal command and arguments to run 'nm'
  427. <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_PREFIX'><filename>TARGET_PREFIX</filename></ulink> - The toolchain binary prefix for the target tools
  428. <ulink url='&YOCTO_DOCS_REF_URL;#var-CROSS_COMPILE'><filename>CROSS_COMPILE</filename></ulink> - The toolchain binary prefix for the target tools
  429. <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS'><filename>CONFIGURE_FLAGS</filename></ulink> - The minimal arguments for GNU configure
  430. <ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'><filename>CFLAGS</filename></ulink> - Suggested C flags
  431. <ulink url='&YOCTO_DOCS_REF_URL;#var-CXXFLAGS'><filename>CXXFLAGS</filename></ulink> - Suggested C++ flags
  432. <ulink url='&YOCTO_DOCS_REF_URL;#var-LDFLAGS'><filename>LDFLAGS</filename></ulink> - Suggested linker flags when you use CC to link
  433. <ulink url='&YOCTO_DOCS_REF_URL;#var-CPPFLAGS'><filename>CPPFLAGS</filename></ulink> - Suggested preprocessor flags
  434. </literallayout>
  435. </para>
  436. </section>
  437. <section id='securing-kernel-and-filesystem-images'>
  438. <title>Securing Kernel and Filesystem Images</title>
  439. <para>
  440. You will need to have a kernel and filesystem image to boot using your
  441. hardware or the QEMU emulator.
  442. Furthermore, if you plan on booting your image using NFS or you want to use the root filesystem
  443. as the target sysroot, you need to extract the root filesystem.
  444. </para>
  445. <section id='getting-the-images'>
  446. <title>Getting the Images</title>
  447. <para>
  448. To get the kernel and filesystem images, you either have to build them or download
  449. pre-built versions.
  450. For an example of how to build these images, see the
  451. "<ulink url='&YOCTO_DOCS_QS_URL;#qs-buiding-images'>Buiding Images</ulink>"
  452. section of the Yocto Project Quick Start.
  453. For an example of downloading pre-build versions, see the
  454. "<link linkend='using-pre-built'>Example Using Pre-Built Binaries and QEMU</link>"
  455. section.
  456. </para>
  457. <para>
  458. The Yocto Project ships basic kernel and filesystem images for several
  459. architectures (<filename>x86</filename>, <filename>x86-64</filename>,
  460. <filename>mips</filename>, <filename>powerpc</filename>, and <filename>arm</filename>)
  461. that you can use unaltered in the QEMU emulator.
  462. These kernel images reside in the release
  463. area - <ulink url='&YOCTO_MACHINES_DL_URL;'></ulink>
  464. and are ideal for experimentation using Yocto Project.
  465. For information on the image types you can build using the OpenEmbedded build system,
  466. see the
  467. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  468. chapter in the Yocto Project Reference Manual.
  469. </para>
  470. <para>
  471. If you are planning on developing against your image and you are not
  472. building or using one of the Yocto Project development images
  473. (e.g. <filename>core-image-*-dev</filename>), you must be sure to
  474. include the development packages as part of your image recipe.
  475. </para>
  476. <para>
  477. If you plan on remotely deploying and debugging your
  478. application from within the Eclipse IDE, you must have an image
  479. that contains the Yocto Target Communication Framework (TCF) agent
  480. (<filename>tcf-agent</filename>).
  481. You can do this by including the <filename>eclipse-debug</filename>
  482. image feature.
  483. <note>
  484. See the
  485. "<ulink url='&YOCTO_DOCS_REF_URL;#ref-features-image'>Image Features</ulink>"
  486. section in the Yocto Project Reference Manual for information on
  487. image features.
  488. </note>
  489. To include the <filename>eclipse-debug</filename> image feature,
  490. modify your <filename>local.conf</filename> file in the
  491. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>
  492. so that the
  493. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_IMAGE_FEATURES'><filename>EXTRA_IMAGE_FEATURES</filename></ulink>
  494. variable includes the "eclipse-debug" feature.
  495. After modifying the configuration file, you can rebuild the image.
  496. Once the image is rebuilt, the <filename>tcf-agent</filename>
  497. will be included in the image and is launched automatically after
  498. the boot.
  499. </para>
  500. </section>
  501. <section id='extracting-the-root-filesystem'>
  502. <title>Extracting the Root Filesystem</title>
  503. <para>
  504. If you install your toolchain by hand or build it using BitBake and
  505. you need a root filesystem, you need to extract it separately.
  506. If you use the ADT Installer to install the ADT, the root
  507. filesystem is automatically extracted and installed.
  508. </para>
  509. <para>
  510. Here are some cases where you need to extract the root filesystem:
  511. <itemizedlist>
  512. <listitem><para>You want to boot the image using NFS.
  513. </para></listitem>
  514. <listitem><para>You want to use the root filesystem as the
  515. target sysroot.
  516. For example, the Eclipse IDE environment with the Eclipse
  517. Yocto Plug-in installed allows you to use QEMU to boot
  518. under NFS.</para></listitem>
  519. <listitem><para>You want to develop your target application
  520. using the root filesystem as the target sysroot.
  521. </para></listitem>
  522. </itemizedlist>
  523. </para>
  524. <para>
  525. To extract the root filesystem, first <filename>source</filename>
  526. the cross-development environment setup script to establish
  527. necessary environment variables.
  528. If you built the toolchain in the Build Directory, you will find
  529. the toolchain environment script in the
  530. <filename>tmp</filename> directory.
  531. If you installed the toolchain by hand, the environment setup
  532. script is located in <filename>/opt/poky/&DISTRO;</filename>.
  533. </para>
  534. <para>
  535. After sourcing the environment script, use the
  536. <filename>runqemu-extract-sdk</filename> command and provide the
  537. filesystem image.
  538. </para>
  539. <para>
  540. Following is an example.
  541. The second command sets up the environment.
  542. In this case, the setup script is located in the
  543. <filename>/opt/poky/&DISTRO;</filename> directory.
  544. The third command extracts the root filesystem from a previously
  545. built filesystem that is located in the
  546. <filename>~/Downloads</filename> directory.
  547. Furthermore, this command extracts the root filesystem into the
  548. <filename>qemux86-sato</filename> directory:
  549. <literallayout class='monospaced'>
  550. $ cd ~
  551. $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux
  552. $ runqemu-extract-sdk \
  553. ~/Downloads/core-image-sato-sdk-qemux86-2011091411831.rootfs.tar.bz2 \
  554. $HOME/qemux86-sato
  555. </literallayout>
  556. You could now point to the target sysroot at
  557. <filename>qemux86-sato</filename>.
  558. </para>
  559. </section>
  560. </section>
  561. <section id='optionally-building-a-toolchain-installer'>
  562. <title>Optionally Building a Toolchain Installer</title>
  563. <para>
  564. As an alternative to locating and downloading a toolchain installer,
  565. you can build the toolchain installer if you have a
  566. <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>.
  567. <note>
  568. Although not the preferred method, it is also possible to use
  569. <filename>bitbake meta-toolchain</filename> to build the toolchain
  570. installer.
  571. If you do use this method, you must separately install and extract
  572. the target sysroot.
  573. For information on how to install the sysroot, see the
  574. "<link linkend='extracting-the-root-filesystem'>Extracting the Root Filesystem</link>"
  575. section.
  576. </note>
  577. </para>
  578. <para>
  579. To build the toolchain installer and populate the SDK image, use the
  580. following command:
  581. <literallayout class='monospaced'>
  582. $ bitbake <replaceable>image</replaceable> -c populate_sdk
  583. </literallayout>
  584. The command results in a toolchain installer that contains the sysroot
  585. that matches your target root filesystem.
  586. </para>
  587. <para>
  588. Another powerful feature is that the toolchain is completely
  589. self-contained.
  590. The binaries are linked against their own copy of
  591. <filename>libc</filename>, which results in no dependencies
  592. on the target system.
  593. To achieve this, the pointer to the dynamic loader is
  594. configured at install time since that path cannot be dynamically
  595. altered.
  596. This is the reason for a wrapper around the
  597. <filename>populate_sdk</filename> archive.
  598. </para>
  599. <para>
  600. Another feature is that only one set of cross-canadian toolchain
  601. binaries are produced per architecture.
  602. This feature takes advantage of the fact that the target hardware can
  603. be passed to <filename>gcc</filename> as a set of compiler options.
  604. Those options are set up by the environment script and contained in
  605. variables such as
  606. <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink>
  607. and
  608. <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink>.
  609. This reduces the space needed for the tools.
  610. Understand, however, that a sysroot is still needed for every target
  611. since those binaries are target-specific.
  612. </para>
  613. <para>
  614. Remember, before using any BitBake command, you
  615. must source the build environment setup script
  616. (i.e.
  617. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  618. or
  619. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>)
  620. located in the Source Directory and you must make sure your
  621. <filename>conf/local.conf</filename> variables are correct.
  622. In particular, you need to be sure the
  623. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  624. variable matches the architecture for which you are building and that
  625. the
  626. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>
  627. variable is correctly set if you are building a toolchain designed to
  628. run on an architecture that differs from your current development host
  629. machine (i.e. the build machine).
  630. </para>
  631. <para>
  632. When the <filename>bitbake</filename> command completes, the toolchain
  633. installer will be in
  634. <filename>tmp/deploy/sdk</filename> in the Build Directory.
  635. <note>
  636. By default, this toolchain does not build static binaries.
  637. If you want to use the toolchain to build these types of libraries,
  638. you need to be sure your image has the appropriate static
  639. development libraries.
  640. Use the
  641. <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>
  642. variable inside your <filename>local.conf</filename> file to
  643. install the appropriate library packages.
  644. Following is an example using <filename>glibc</filename> static
  645. development libraries:
  646. <literallayout class='monospaced'>
  647. IMAGE_INSTALL_append = " glibc-staticdev"
  648. </literallayout>
  649. </note>
  650. </para>
  651. </section>
  652. <section id='optionally-using-an-external-toolchain'>
  653. <title>Optionally Using an External Toolchain</title>
  654. <para>
  655. You might want to use an external toolchain as part of your
  656. development.
  657. If this is the case, the fundamental steps you need to accomplish
  658. are as follows:
  659. <itemizedlist>
  660. <listitem><para>
  661. Understand where the installed toolchain resides.
  662. For cases where you need to build the external toolchain, you
  663. would need to take separate steps to build and install the
  664. toolchain.
  665. </para></listitem>
  666. <listitem><para>
  667. Make sure you add the layer that contains the toolchain to
  668. your <filename>bblayers.conf</filename> file through the
  669. <ulink url='&YOCTO_DOCS_REF_URL;#var-BBLAYERS'><filename>BBLAYERS</filename></ulink>
  670. variable.
  671. </para></listitem>
  672. <listitem><para>
  673. Set the
  674. <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTERNAL_TOOLCHAIN'><filename>EXTERNAL_TOOLCHAIN</filename></ulink>
  675. variable in your <filename>local.conf</filename> file
  676. to the location in which you installed the toolchain.
  677. </para></listitem>
  678. </itemizedlist>
  679. A good example of an external toolchain used with the Yocto Project
  680. is <trademark class='registered'>Mentor Graphics</trademark>
  681. Sourcery G++ Toolchain.
  682. You can see information on how to use that particular layer in the
  683. <filename>README</filename> file at
  684. <ulink url='http://github.com/MentorEmbedded/meta-sourcery/'></ulink>.
  685. You can find further information by reading about the
  686. <ulink url='&YOCTO_DOCS_REF_URL;#var-TCMODE'><filename>TCMODE</filename></ulink>
  687. variable in the Yocto Project Reference Manual's variable glossary.
  688. </para>
  689. </section>
  690. <section id='using-pre-built'>
  691. <title>Example Using Pre-Built Binaries and QEMU</title>
  692. <para>
  693. If hardware, libraries and services are stable, you can get started by using a pre-built binary
  694. of the filesystem image, kernel, and toolchain and run it using the QEMU emulator.
  695. This scenario is useful for developing application software.
  696. </para>
  697. <mediaobject>
  698. <imageobject>
  699. <imagedata fileref="figures/using-a-pre-built-image.png" format="PNG" align='center' scalefit='1'/>
  700. </imageobject>
  701. <caption>
  702. <para>Using a Pre-Built Image</para>
  703. </caption>
  704. </mediaobject>
  705. <para>
  706. For this scenario, you need to do several things:
  707. </para>
  708. <itemizedlist>
  709. <listitem><para>Install the appropriate stand-alone toolchain tarball.</para></listitem>
  710. <listitem><para>Download the pre-built image that will boot with QEMU.
  711. You need to be sure to get the QEMU image that matches your target machine’s
  712. architecture (e.g. x86, ARM, etc.).</para></listitem>
  713. <listitem><para>Download the filesystem image for your target machine's architecture.
  714. </para></listitem>
  715. <listitem><para>Set up the environment to emulate the hardware and then start the QEMU emulator.
  716. </para></listitem>
  717. </itemizedlist>
  718. <section id='installing-the-toolchain'>
  719. <title>Installing the Toolchain</title>
  720. <para>
  721. You can download a tarball installer, which includes the
  722. pre-built toolchain, the <filename>runqemu</filename>
  723. script, and support files from the appropriate directory under
  724. <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'></ulink>.
  725. Toolchains are available for 32-bit and 64-bit x86 development
  726. systems from the <filename>i686</filename> and
  727. <filename>x86_64</filename> directories, respectively.
  728. The toolchains the Yocto Project provides are based off the
  729. <filename>core-image-sato</filename> image and contain
  730. libraries appropriate for developing against that image.
  731. Each type of development system supports five or more target
  732. architectures.
  733. </para>
  734. <para>
  735. The names of the tarball installer scripts are such that a
  736. string representing the host system appears first in the
  737. filename and then is immediately followed by a string
  738. representing the target architecture.
  739. </para>
  740. <literallayout class='monospaced'>
  741. poky-glibc-<replaceable>host_system</replaceable>-<replaceable>image_type</replaceable>-<replaceable>arch</replaceable>-toolchain-<replaceable>release_version</replaceable>.sh
  742. Where:
  743. <replaceable>host_system</replaceable> is a string representing your development system:
  744. i686 or x86_64.
  745. <replaceable>image_type</replaceable> is a string representing the image you wish to
  746. develop a Software Development Toolkit (SDK) for use against.
  747. The Yocto Project builds toolchain installers using the
  748. following BitBake command:
  749. bitbake core-image-sato -c populate_sdk
  750. <replaceable>arch</replaceable> is a string representing the tuned target architecture:
  751. i586, x86_64, powerpc, mips, armv7a or armv5te
  752. <replaceable>release_version</replaceable> is a string representing the release number of the
  753. Yocto Project:
  754. &DISTRO;, &DISTRO;+snapshot
  755. </literallayout>
  756. <para>
  757. For example, the following toolchain installer is for a 64-bit
  758. development host system and a i586-tuned target architecture
  759. based off the SDK for <filename>core-image-sato</filename>:
  760. <literallayout class='monospaced'>
  761. poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
  762. </literallayout>
  763. </para>
  764. <para>
  765. Toolchains are self-contained and by default are installed into
  766. <filename>/opt/poky</filename>.
  767. However, when you run the toolchain installer, you can choose an
  768. installation directory.
  769. </para>
  770. <para>
  771. The following command shows how to run the installer given a toolchain tarball
  772. for a 64-bit x86 development host system and a 32-bit x86 target architecture.
  773. You must change the permissions on the toolchain
  774. installer script so that it is executable.
  775. </para>
  776. <para>
  777. The example assumes the toolchain installer is located in <filename>~/Downloads/</filename>.
  778. <note>
  779. If you do not have write permissions for the directory into which you are installing
  780. the toolchain, the toolchain installer notifies you and exits.
  781. Be sure you have write permissions in the directory and run the installer again.
  782. </note>
  783. </para>
  784. <para>
  785. <literallayout class='monospaced'>
  786. $ ~/Downloads/poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh
  787. </literallayout>
  788. </para>
  789. <para>
  790. For more information on how to install tarballs, see the
  791. "<ulink url='&YOCTO_DOCS_ADT_URL;#using-an-existing-toolchain-tarball'>Using a Cross-Toolchain Tarball</ulink>" and
  792. "<ulink url='&YOCTO_DOCS_ADT_URL;#using-the-toolchain-from-within-the-build-tree'>Using BitBake and the Build Directory</ulink>" sections in the Yocto Project Application Developer's Guide.
  793. </para>
  794. </section>
  795. <section id='downloading-the-pre-built-linux-kernel'>
  796. <title>Downloading the Pre-Built Linux Kernel</title>
  797. <para>
  798. You can download the pre-built Linux kernel suitable for running in the QEMU emulator from
  799. <ulink url='&YOCTO_QEMU_DL_URL;'></ulink>.
  800. Be sure to use the kernel that matches the architecture you want to simulate.
  801. Download areas exist for the five supported machine architectures:
  802. <filename>qemuarm</filename>, <filename>qemumips</filename>, <filename>qemuppc</filename>,
  803. <filename>qemux86</filename>, and <filename>qemux86-64</filename>.
  804. </para>
  805. <para>
  806. Most kernel files have one of the following forms:
  807. <literallayout class='monospaced'>
  808. *zImage-qemu<replaceable>arch</replaceable>.bin
  809. vmlinux-qemu<replaceable>arch</replaceable>.bin
  810. Where:
  811. <replaceable>arch</replaceable> is a string representing the target architecture:
  812. x86, x86-64, ppc, mips, or arm.
  813. </literallayout>
  814. </para>
  815. <para>
  816. You can learn more about downloading a Yocto Project kernel in the
  817. "<ulink url='&YOCTO_DOCS_DEV_URL;#local-kernel-files'>Yocto Project Kernel</ulink>"
  818. bulleted item in the Yocto Project Development Manual.
  819. </para>
  820. </section>
  821. <section id='downloading-the-filesystem'>
  822. <title>Downloading the Filesystem</title>
  823. <para>
  824. You can also download the filesystem image suitable for your target architecture from
  825. <ulink url='&YOCTO_QEMU_DL_URL;'></ulink>.
  826. Again, be sure to use the filesystem that matches the architecture you want
  827. to simulate.
  828. </para>
  829. <para>
  830. The filesystem image has two tarball forms: <filename>ext3</filename> and
  831. <filename>tar</filename>.
  832. You must use the <filename>ext3</filename> form when booting an image using the
  833. QEMU emulator.
  834. The <filename>tar</filename> form can be flattened out in your host development system
  835. and used for build purposes with the Yocto Project.
  836. <literallayout class='monospaced'>
  837. core-image-<replaceable>profile</replaceable>-qemu<replaceable>arch</replaceable>.ext3
  838. core-image-<replaceable>profile</replaceable>-qemu<replaceable>arch</replaceable>.tar.bz2
  839. Where:
  840. <replaceable>profile</replaceable> is the filesystem image's profile:
  841. lsb, lsb-dev, lsb-sdk, lsb-qt3, minimal, minimal-dev, sato,
  842. sato-dev, or sato-sdk. For information on these types of image
  843. profiles, see the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  844. chapter in the Yocto Project Reference Manual.
  845. <replaceable>arch</replaceable> is a string representing the target architecture:
  846. x86, x86-64, ppc, mips, or arm.
  847. </literallayout>
  848. </para>
  849. </section>
  850. <section id='setting-up-the-environment-and-starting-the-qemu-emulator'>
  851. <title>Setting Up the Environment and Starting the QEMU Emulator</title>
  852. <para>
  853. Before you start the QEMU emulator, you need to set up the emulation environment.
  854. The following command form sets up the emulation environment.
  855. <literallayout class='monospaced'>
  856. $ source &YOCTO_ADTPATH_DIR;/environment-setup-<replaceable>arch</replaceable>-poky-linux-<replaceable>if</replaceable>
  857. Where:
  858. <replaceable>arch</replaceable> is a string representing the target architecture:
  859. i586, x86_64, ppc603e, mips, or armv5te.
  860. <replaceable>if</replaceable> is a string representing an embedded application binary interface.
  861. Not all setup scripts include this string.
  862. </literallayout>
  863. </para>
  864. <para>
  865. Finally, this command form invokes the QEMU emulator
  866. <literallayout class='monospaced'>
  867. $ runqemu <replaceable>qemuarch</replaceable> <replaceable>kernel-image</replaceable> <replaceable>filesystem-image</replaceable>
  868. Where:
  869. <replaceable>qemuarch</replaceable> is a string representing the target architecture: qemux86, qemux86-64,
  870. qemuppc, qemumips, or qemuarm.
  871. <replaceable>kernel-image</replaceable> is the architecture-specific kernel image.
  872. <replaceable>filesystem-image</replaceable> is the .ext3 filesystem image.
  873. </literallayout>
  874. </para>
  875. <para>
  876. Continuing with the example, the following two commands setup the emulation
  877. environment and launch QEMU.
  878. This example assumes the root filesystem (<filename>.ext3</filename> file) and
  879. the pre-built kernel image file both reside in your home directory.
  880. The kernel and filesystem are for a 32-bit target architecture.
  881. <literallayout class='monospaced'>
  882. $ cd $HOME
  883. $ source &YOCTO_ADTPATH_DIR;/environment-setup-i586-poky-linux
  884. $ runqemu qemux86 bzImage-qemux86.bin \
  885. core-image-sato-qemux86.ext3
  886. </literallayout>
  887. </para>
  888. <para>
  889. The environment in which QEMU launches varies depending on the filesystem image and on the
  890. target architecture.
  891. For example, if you source the environment for the ARM target
  892. architecture and then boot the minimal QEMU image, the emulator comes up in a new
  893. shell in command-line mode.
  894. However, if you boot the SDK image, QEMU comes up with a GUI.
  895. <note>Booting the PPC image results in QEMU launching in the same shell in
  896. command-line mode.</note>
  897. </para>
  898. </section>
  899. </section>
  900. </chapter>
  901. <!--
  902. vim: expandtab tw=80 ts=4
  903. -->