sdk-appendix-obtain.xml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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. <appendix id='sdk-appendix-obtain'>
  5. <title>Obtaining the SDK</title>
  6. <section id='sdk-locating-pre-built-sdk-installers'>
  7. <title>Locating Pre-Built SDK Installers</title>
  8. <para>
  9. You can use existing, pre-built toolchains by locating and running
  10. an SDK installer script that ships with the Yocto Project.
  11. Using this method, you select and download an architecture-specific
  12. SDK installer and then run the script to hand-install the
  13. toolchain.
  14. </para>
  15. <para>
  16. Follow these steps to locate and hand-install the toolchain:
  17. <orderedlist>
  18. <listitem><para>
  19. <emphasis>Go to the Installers Directory:</emphasis>
  20. Go to <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'></ulink>
  21. </para></listitem>
  22. <listitem><para>
  23. <emphasis>Open the Folder for Your Build Host:</emphasis>
  24. Open the folder that matches your
  25. <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>build host</ulink>
  26. (i.e. <filename>i686</filename> for 32-bit machines or
  27. <filename>x86_64</filename> for 64-bit machines).
  28. </para></listitem>
  29. <listitem><para>
  30. <emphasis>Locate and Download the SDK Installer:</emphasis>
  31. You need to find and download the installer appropriate for
  32. your build host, target hardware, and image type.
  33. </para>
  34. <para>The installer files (<filename>*.sh</filename>) follow
  35. this naming convention:
  36. <literallayout class='monospaced'>
  37. poky-glibc-<replaceable>host_system</replaceable>-core-image-<replaceable>type</replaceable>-<replaceable>arch</replaceable>-toolchain[-ext]-<replaceable>release</replaceable>.sh
  38. Where:
  39. <replaceable>host_system</replaceable> is a string representing your development system:
  40. "i686" or "x86_64"
  41. <replaceable>type</replaceable> is a string representing the image:
  42. "sato" or "minimal"
  43. <replaceable>arch</replaceable> is a string representing the target architecture:
  44. "aarch64", "armv5e", "core2-64", "coretexa8hf-neon", "i586", "mips32r2",
  45. "mips64", or "ppc7400"
  46. <replaceable>release</replaceable> is the version of Yocto Project.
  47. NOTE:
  48. The standard SDK installer does not have the "-ext" string as
  49. part of the filename.
  50. </literallayout>
  51. The toolchains provided by the Yocto Project are based off of
  52. the <filename>core-image-sato</filename> and
  53. <filename>core-image-minimal</filename> images and contain
  54. libraries appropriate for developing against those images.
  55. </para>
  56. <para>For example, if your build host is a 64-bit x86 system
  57. and you need an extended SDK for a 64-bit core2 target, go
  58. into the <filename>x86_64</filename> folder and download the
  59. following installer:
  60. <literallayout class='monospaced'>
  61. poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh
  62. </literallayout>
  63. </para></listitem>
  64. <listitem><para>
  65. <emphasis>Run the Installer:</emphasis>
  66. Be sure you have execution privileges and run the installer.
  67. Following is an example from the <filename>Downloads</filename>
  68. directory:
  69. <literallayout class='monospaced'>
  70. $ ~/Downloads/poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh
  71. </literallayout>
  72. During execution of the script, you choose the root location
  73. for the toolchain.
  74. See the
  75. "<link linkend='sdk-installed-standard-sdk-directory-structure'>Installed Standard SDK Directory Structure</link>"
  76. section and the
  77. "<link linkend='sdk-installed-extensible-sdk-directory-structure'>Installed Extensible SDK Directory Structure</link>"
  78. section for more information.
  79. </para></listitem>
  80. </orderedlist>
  81. </para>
  82. </section>
  83. <section id='sdk-building-an-sdk-installer'>
  84. <title>Building an SDK Installer</title>
  85. <para>
  86. As an alternative to locating and downloading an SDK installer,
  87. you can build the SDK installer.
  88. Follow these steps:
  89. <orderedlist>
  90. <listitem><para>
  91. <emphasis>Set Up the Build Environment:</emphasis>
  92. Be sure you are set up to use BitBake in a shell.
  93. See the
  94. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-preparing-the-build-host'>Preparing the Build Host</ulink>"
  95. section in the Yocto Project Development Tasks Manual for
  96. information on how to get a build host ready that is either a
  97. native Linux machine or a machine that uses CROPS.
  98. </para></listitem>
  99. <listitem><para>
  100. <emphasis>Clone the <filename>poky</filename> Repository:</emphasis>
  101. You need to have a local copy of the Yocto Project
  102. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>
  103. (i.e. a local <filename>poky</filename> repository).
  104. See the
  105. "<ulink url='&YOCTO_DOCS_DEV_URL;#cloning-the-poky-repository'>Cloning the <filename>poky</filename> Repository</ulink>"
  106. and possibly the
  107. "<ulink url='&YOCTO_DOCS_DEV_URL;#checking-out-by-branch-in-poky'>Checking Out by Branch in Poky</ulink>"
  108. and
  109. "<ulink url='&YOCTO_DOCS_DEV_URL;#checkout-out-by-tag-in-poky'>Checking Out by Tag in Poky</ulink>"
  110. sections all in the Yocto Project Development Tasks Manual for
  111. information on how to clone the <filename>poky</filename>
  112. repository and check out the appropriate branch for your work.
  113. </para></listitem>
  114. <listitem><para>
  115. <emphasis>Initialize the Build Environment:</emphasis>
  116. While in the root directory of the Source Directory (i.e.
  117. <filename>poky</filename>), run the
  118. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  119. environment setup script to define the OpenEmbedded
  120. build environment on your build host.
  121. <literallayout class='monospaced'>
  122. $ source &OE_INIT_FILE;
  123. </literallayout>
  124. Among other things, the script creates the
  125. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  126. which is <filename>build</filename> in this case
  127. and is located in the Source Directory.
  128. After the script runs, your current working directory
  129. is set to the <filename>build</filename> directory.
  130. </para></listitem>
  131. <listitem><para>
  132. <emphasis>Make Sure You Are Building an Installer for the Correct Machine:</emphasis>
  133. Check to be sure that your
  134. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  135. variable in the <filename>local.conf</filename> file in your
  136. Build Directory matches the architecture for which you are
  137. building.
  138. </para></listitem>
  139. <listitem><para>
  140. <emphasis>Make Sure Your SDK Machine is Correctly Set:</emphasis>
  141. If you are building a toolchain designed to run on an
  142. architecture that differs from your current development host
  143. machine (i.e. the build host), be sure that the
  144. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>
  145. variable in the <filename>local.conf</filename> file in your
  146. Build Directory is correctly set.
  147. <note>
  148. If you are building an SDK installer for the Extensible
  149. SDK, the <filename>SDKMACHINE</filename> value must be
  150. set for the architecture of the machine you are using to
  151. build the installer.
  152. If <filename>SDKMACHINE</filename> is not set appropriately,
  153. the build fails and provides an error message similar to
  154. the following:
  155. <literallayout class='monospaced'>
  156. The extensible SDK can currently only be built for the same architecture as the machine being built on - SDK_ARCH is
  157. set to i686 (likely via setting SDKMACHINE) which is different from the architecture of the build machine (x86_64).
  158. Unable to continue.
  159. </literallayout>
  160. </note>
  161. </para></listitem>
  162. <listitem><para>
  163. <emphasis>Build the SDK Installer:</emphasis>
  164. To build the SDK installer for a standard SDK and populate
  165. the SDK image, use the following command form.
  166. Be sure to replace <replaceable>image</replaceable> with
  167. an image (e.g. "core-image-sato"):
  168. <literallayout class='monospaced'>
  169. $ bitbake <replaceable>image</replaceable> -c populate_sdk
  170. </literallayout>
  171. You can do the same for the extensible SDK using this command
  172. form:
  173. <literallayout class='monospaced'>
  174. $ bitbake <replaceable>image</replaceable> -c populate_sdk_ext
  175. </literallayout>
  176. These commands produce an SDK installer that contains the
  177. sysroot that matches your target root filesystem.</para>
  178. <para>When the <filename>bitbake</filename> command completes,
  179. the SDK installer will be in
  180. <filename>tmp/deploy/sdk</filename> in the Build Directory.
  181. <note><title>Notes</title>
  182. <itemizedlist>
  183. <listitem><para>
  184. By default, the previous BitBake command does not
  185. build static binaries.
  186. If you want to use the toolchain to build these
  187. types of libraries, you need to be sure your SDK
  188. has the appropriate static development libraries.
  189. Use the
  190. <ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></ulink>
  191. variable inside your <filename>local.conf</filename>
  192. file before building the SDK installer.
  193. Doing so ensures that the eventual SDK installation
  194. process installs the appropriate library packages
  195. as part of the SDK.
  196. Following is an example using
  197. <filename>libc</filename> static development
  198. libraries:
  199. <literallayout class='monospaced'>
  200. TOOLCHAIN_TARGET_TASK_append = " libc-staticdev"
  201. </literallayout>
  202. </para></listitem>
  203. <listitem><para>
  204. For additional information on building the
  205. installer, see the
  206. <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>Cookbook guide to Making an <trademark class='trade'>Eclipse</trademark> Debug Capable Image</ulink>
  207. wiki page.
  208. </para></listitem>
  209. </itemizedlist>
  210. </note>
  211. </para></listitem>
  212. <listitem><para>
  213. <emphasis>Run the Installer:</emphasis>
  214. You can now run the SDK installer from
  215. <filename>tmp/deploy/sdk</filename> in the Build Directory.
  216. Following is an example:
  217. <literallayout class='monospaced'>
  218. $ cd ~/poky/build/tmp/deploy/sdk
  219. $ ./poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh
  220. </literallayout>
  221. During execution of the script, you choose the root location
  222. for the toolchain.
  223. See the
  224. "<link linkend='sdk-installed-standard-sdk-directory-structure'>Installed Standard SDK Directory Structure</link>"
  225. section and the
  226. "<link linkend='sdk-installed-extensible-sdk-directory-structure'>Installed Extensible SDK Directory Structure</link>"
  227. section for more information.
  228. </para></listitem>
  229. </orderedlist>
  230. </para>
  231. </section>
  232. <section id='sdk-extracting-the-root-filesystem'>
  233. <title>Extracting the Root Filesystem</title>
  234. <para>
  235. After installing the toolchain, for some use cases you
  236. might need to separately extract a root filesystem:
  237. <itemizedlist>
  238. <listitem><para>
  239. You want to boot the image using NFS.
  240. </para></listitem>
  241. <listitem><para>
  242. You want to use the root filesystem as the
  243. target sysroot.
  244. For example, the Eclipse IDE environment with the Eclipse
  245. Yocto Plug-in installed allows you to use QEMU to boot
  246. under NFS.
  247. </para></listitem>
  248. <listitem><para>
  249. You want to develop your target application
  250. using the root filesystem as the target sysroot.
  251. </para></listitem>
  252. </itemizedlist>
  253. </para>
  254. <para>
  255. Follow these steps to extract the root filesystem:
  256. <orderedlist>
  257. <listitem><para>
  258. <emphasis>Locate and Download the Tarball for the Pre-Built
  259. Root Filesystem Image File:</emphasis>
  260. You need to find and download the root filesystem image
  261. file that is appropriate for your target system.
  262. These files are kept in machine-specific folders in the
  263. <ulink url='&YOCTO_DL_URL;/releases/yocto/yocto-&DISTRO;/machines/'>Index of Releases</ulink>
  264. in the "machines" directory.</para>
  265. <para>The machine-specific folders of the "machines" directory
  266. contain tarballs (<filename>*.tar.bz2</filename>) for supported
  267. machines.
  268. These directories also contain flattened root filesystem
  269. image files (<filename>*.ext4</filename>), which you can use
  270. with QEMU directly.</para>
  271. <para>The pre-built root filesystem image files
  272. follow these naming conventions:
  273. <literallayout class='monospaced'>
  274. <!--
  275. core-image-<replaceable>profile</replaceable>-<replaceable>arch</replaceable>-<replaceable>date_time</replaceable>.rootfs.tar.bz2
  276. -->
  277. core-image-<replaceable>profile</replaceable>-<replaceable>arch</replaceable>.tar.bz2
  278. Where:
  279. <replaceable>profile</replaceable> is the filesystem image's profile:
  280. lsb, lsb-dev, lsb-sdk, minimal, minimal-dev, minimal-initramfs,
  281. sato, sato-dev, sato-sdk, sato-sdk-ptest. For information on
  282. these types of image profiles, see the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" chapter in
  283. the Yocto Project Reference Manual.
  284. <replaceable>arch</replaceable> is a string representing the target architecture:
  285. beaglebone-yocto, beaglebone-yocto-lsb, edgerouter, edgerouter-lsb,
  286. genericx86, genericx86-64, genericx86-64-lsb, genericx86-lsb,
  287. mpc8315e-rdb, mpc8315e-rdb-lsb, and qemu*.
  288. <!-->
  289. <replaceable>date_time</replaceable> is a date and time stamp.
  290. -->
  291. </literallayout>
  292. The root filesystems provided by the Yocto Project are based
  293. off of the <filename>core-image-sato</filename> and
  294. <filename>core-image-minimal</filename> images.
  295. </para>
  296. <para>For example, if you plan on using a BeagleBone device
  297. as your target hardware and your image is a
  298. <filename>core-image-sato-sdk</filename>
  299. image, you can download the following file:
  300. <literallayout class='monospaced'>
  301. core-image-sato-sdk-beaglebone-yocto.tar.bz2
  302. </literallayout>
  303. </para></listitem>
  304. <listitem><para>
  305. <emphasis>Initialize the Cross-Development Environment:</emphasis>
  306. You must <filename>source</filename> the cross-development
  307. environment setup script to establish necessary environment
  308. variables.</para>
  309. <para>This script is located in the top-level directory in
  310. which you installed the toolchain (e.g.
  311. <filename>poky_sdk</filename>).</para>
  312. <para>Following is an example based on the toolchain installed
  313. in the
  314. "<link linkend='sdk-locating-pre-built-sdk-installers'>Locating Pre-Built SDK Installers</link>"
  315. section:
  316. <literallayout class='monospaced'>
  317. $ source ~/poky_sdk/environment-setup-core2-64-poky-linux
  318. </literallayout>
  319. </para></listitem>
  320. <listitem><para>
  321. <emphasis>Extract the Root Filesystem:</emphasis>
  322. Use the <filename>runqemu-extract-sdk</filename> command
  323. and provide the root filesystem image.</para>
  324. <para>Following is an example command that extracts the root
  325. filesystem from a previously built root filesystem image that
  326. was downloaded from the
  327. <ulink url='&YOCTO_DOCS_OM_URL;#index-downloads'>Index of Releases</ulink>.
  328. This command extracts the root filesystem into the
  329. <filename>core2-64-sato</filename> directory:
  330. <literallayout class='monospaced'>
  331. $ runqemu-extract-sdk ~/Downloads/core-image-sato-sdk-beaglebone-yocto.tar.bz2 ~/beaglebone-sato
  332. </literallayout>
  333. You could now point to the target sysroot at
  334. <filename>beablebone-sato</filename>.
  335. </para></listitem>
  336. </orderedlist>
  337. </para>
  338. </section>
  339. <section id='sdk-installed-standard-sdk-directory-structure'>
  340. <title>Installed Standard SDK Directory Structure</title>
  341. <para>
  342. The following figure shows the resulting directory structure after
  343. you install the Standard SDK by running the <filename>*.sh</filename>
  344. SDK installation script:
  345. </para>
  346. <para>
  347. <imagedata fileref="figures/sdk-installed-standard-sdk-directory.png" scale="80" align="center" />
  348. </para>
  349. <para>
  350. The installed SDK consists of an environment setup script for the SDK,
  351. a configuration file for the target, a version file for the target,
  352. and the root filesystem (<filename>sysroots</filename>) needed to
  353. develop objects for the target system.
  354. </para>
  355. <para>
  356. Within the figure, italicized text is used to indicate replaceable
  357. portions of the file or directory name.
  358. For example,
  359. <replaceable>install_dir</replaceable>/<replaceable>version</replaceable>
  360. is the directory where the SDK is installed.
  361. By default, this directory is <filename>/opt/poky/</filename>.
  362. And, <replaceable>version</replaceable> represents the specific
  363. snapshot of the SDK (e.g. <filename>&DISTRO;</filename>).
  364. Furthermore, <replaceable>target</replaceable> represents the target
  365. architecture (e.g. <filename>i586</filename>) and
  366. <replaceable>host</replaceable> represents the development system's
  367. architecture (e.g. <filename>x86_64</filename>).
  368. Thus, the complete names of the two directories within the
  369. <filename>sysroots</filename> could be
  370. <filename>i586-poky-linux</filename> and
  371. <filename>x86_64-pokysdk-linux</filename> for the target and host,
  372. respectively.
  373. </para>
  374. </section>
  375. <section id='sdk-installed-extensible-sdk-directory-structure'>
  376. <title>Installed Extensible SDK Directory Structure</title>
  377. <para>
  378. The following figure shows the resulting directory structure after
  379. you install the Extensible SDK by running the <filename>*.sh</filename>
  380. SDK installation script:
  381. </para>
  382. <para>
  383. <imagedata fileref="figures/sdk-installed-extensible-sdk-directory.png" scale="80" align="center" />
  384. </para>
  385. <para>
  386. The installed directory structure for the extensible SDK is quite
  387. different than the installed structure for the standard SDK.
  388. The extensible SDK does not separate host and target parts in the
  389. same manner as does the standard SDK.
  390. The extensible SDK uses an embedded copy of the OpenEmbedded
  391. build system, which has its own sysroots.
  392. </para>
  393. <para>
  394. Of note in the directory structure are an environment setup script
  395. for the SDK, a configuration file for the target, a version file for
  396. the target, and log files for the OpenEmbedded build system
  397. preparation script run by the installer and BitBake.
  398. </para>
  399. <para>
  400. Within the figure, italicized text is used to indicate replaceable
  401. portions of the file or directory name.
  402. For example,
  403. <replaceable>install_dir</replaceable> is the directory where the SDK
  404. is installed, which is <filename>poky_sdk</filename> by default, and
  405. <replaceable>target</replaceable> represents the target
  406. architecture (e.g. <filename>i586</filename>).
  407. </para>
  408. </section>
  409. </appendix>
  410. <!--
  411. vim: expandtab tw=80 ts=4
  412. -->