sdk-appendix-obtain.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. *****************
  3. Obtaining the SDK
  4. *****************
  5. .. _sdk-locating-pre-built-sdk-installers:
  6. Locating Pre-Built SDK Installers
  7. =================================
  8. You can use existing, pre-built toolchains by locating and running an
  9. SDK installer script that ships with the Yocto Project. Using this
  10. method, you select and download an architecture-specific SDK installer
  11. and then run the script to hand-install the toolchain.
  12. Follow these steps to locate and hand-install the toolchain:
  13. 1. *Go to the Installers Directory:* Go to
  14. :yocto_dl:`/releases/yocto/yocto-3.1.2/toolchain/`
  15. 2. *Open the Folder for Your Build Host:* Open the folder that matches
  16. your :term:`Build Host` (i.e.
  17. ``i686`` for 32-bit machines or ``x86_64`` for 64-bit machines).
  18. 3. *Locate and Download the SDK Installer:* You need to find and
  19. download the installer appropriate for your build host, target
  20. hardware, and image type.
  21. The installer files (``*.sh``) follow this naming convention:
  22. ::
  23. poky-glibc-host_system-core-image-type-arch-toolchain[-ext]-release.sh
  24. Where:
  25. host_system is a string representing your development system:
  26. "i686" or "x86_64"
  27. type is a string representing the image:
  28. "sato" or "minimal"
  29. arch is a string representing the target architecture:
  30. "aarch64", "armv5e", "core2-64", "coretexa8hf-neon", "i586", "mips32r2",
  31. "mips64", or "ppc7400"
  32. release is the version of Yocto Project.
  33. NOTE:
  34. The standard SDK installer does not have the "-ext" string as
  35. part of the filename.
  36. The toolchains provided by the Yocto
  37. Project are based off of the ``core-image-sato`` and
  38. ``core-image-minimal`` images and contain libraries appropriate for
  39. developing against those images.
  40. For example, if your build host is a 64-bit x86 system and you need
  41. an extended SDK for a 64-bit core2 target, go into the ``x86_64``
  42. folder and download the following installer:
  43. ::
  44. poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-DISTRO.sh
  45. 4. *Run the Installer:* Be sure you have execution privileges and run
  46. the installer. Following is an example from the ``Downloads``
  47. directory:
  48. ::
  49. $ ~/Downloads/poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-DISTRO.sh
  50. During execution of the script, you choose the root location for the
  51. toolchain. See the "`Installed Standard SDK Directory
  52. Structure <#sdk-installed-standard-sdk-directory-structure>`__"
  53. section and the "`Installed Extensible SDK Directory
  54. Structure <#sdk-installed-extensible-sdk-directory-structure>`__"
  55. section for more information.
  56. Building an SDK Installer
  57. =========================
  58. As an alternative to locating and downloading an SDK installer, you can
  59. build the SDK installer. Follow these steps:
  60. 1. *Set Up the Build Environment:* Be sure you are set up to use BitBake
  61. in a shell. See the ":ref:`dev-manual/dev-manual-start:preparing the build host`" section
  62. in the Yocto Project Development Tasks Manual for information on how
  63. to get a build host ready that is either a native Linux machine or a
  64. machine that uses CROPS.
  65. 2. *Clone the ``poky`` Repository:* You need to have a local copy of the
  66. Yocto Project :term:`Source Directory`
  67. (i.e. a local
  68. ``poky`` repository). See the ":ref:`dev-manual/dev-manual-start:cloning the \`\`poky\`\` repository`" and
  69. possibly the ":ref:`dev-manual/dev-manual-start:checking out by branch in poky`" and
  70. ":ref:`checkout-out-by-tag-in-poky`" sections
  71. all in the Yocto Project Development Tasks Manual for information on
  72. how to clone the ``poky`` repository and check out the appropriate
  73. branch for your work.
  74. 3. *Initialize the Build Environment:* While in the root directory of
  75. the Source Directory (i.e. ``poky``), run the
  76. :ref:`structure-core-script` environment
  77. setup script to define the OpenEmbedded build environment on your
  78. build host.
  79. ::
  80. $ source oe-init-build-env
  81. Among other things, the script
  82. creates the :term:`Build Directory`,
  83. which is
  84. ``build`` in this case and is located in the Source Directory. After
  85. the script runs, your current working directory is set to the
  86. ``build`` directory.
  87. 4. *Make Sure You Are Building an Installer for the Correct Machine:*
  88. Check to be sure that your
  89. :term:`MACHINE` variable in the
  90. ``local.conf`` file in your Build Directory matches the architecture
  91. for which you are building.
  92. 5. *Make Sure Your SDK Machine is Correctly Set:* If you are building a
  93. toolchain designed to run on an architecture that differs from your
  94. current development host machine (i.e. the build host), be sure that
  95. the :term:`SDKMACHINE` variable
  96. in the ``local.conf`` file in your Build Directory is correctly set.
  97. .. note::
  98. If you are building an SDK installer for the Extensible SDK, the
  99. SDKMACHINE
  100. value must be set for the architecture of the machine you are
  101. using to build the installer. If
  102. SDKMACHINE
  103. is not set appropriately, the build fails and provides an error
  104. message similar to the following:
  105. ::
  106. The extensible SDK can currently only be built for the same architecture as the machine being built on - SDK_ARCH is
  107. set to i686 (likely via setting SDKMACHINE) which is different from the architecture of the build machine (x86_64).
  108. Unable to continue.
  109. 6. *Build the SDK Installer:* To build the SDK installer for a standard
  110. SDK and populate the SDK image, use the following command form. Be
  111. sure to replace image with an image (e.g. "core-image-sato"): $
  112. bitbake image -c populate_sdk You can do the same for the extensible
  113. SDK using this command form:
  114. ::
  115. $ bitbake image -c populate_sdk_ext
  116. These commands produce an SDK installer that contains the sysroot
  117. that matches your target root filesystem.
  118. When the ``bitbake`` command completes, the SDK installer will be in
  119. ``tmp/deploy/sdk`` in the Build Directory.
  120. .. note::
  121. - By default, the previous BitBake command does not build static
  122. binaries. If you want to use the toolchain to build these types
  123. of libraries, you need to be sure your SDK has the appropriate
  124. static development libraries. Use the
  125. :term:`TOOLCHAIN_TARGET_TASK`
  126. variable inside your ``local.conf`` file before building the
  127. SDK installer. Doing so ensures that the eventual SDK
  128. installation process installs the appropriate library packages
  129. as part of the SDK. Following is an example using ``libc``
  130. static development libraries: TOOLCHAIN_TARGET_TASK_append = "
  131. libc-staticdev"
  132. 7. *Run the Installer:* You can now run the SDK installer from
  133. ``tmp/deploy/sdk`` in the Build Directory. Following is an example:
  134. ::
  135. $ cd ~/poky/build/tmp/deploy/sdk
  136. $ ./poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-DISTRO.sh
  137. During execution of the script, you choose the root location for the
  138. toolchain. See the "`Installed Standard SDK Directory
  139. Structure <#sdk-installed-standard-sdk-directory-structure>`__"
  140. section and the "`Installed Extensible SDK Directory
  141. Structure <#sdk-installed-extensible-sdk-directory-structure>`__"
  142. section for more information.
  143. Extracting the Root Filesystem
  144. ==============================
  145. After installing the toolchain, for some use cases you might need to
  146. separately extract a root filesystem:
  147. - You want to boot the image using NFS.
  148. - You want to use the root filesystem as the target sysroot.
  149. - You want to develop your target application using the root filesystem
  150. as the target sysroot.
  151. Follow these steps to extract the root filesystem:
  152. 1. *Locate and Download the Tarball for the Pre-Built Root Filesystem
  153. Image File:* You need to find and download the root filesystem image
  154. file that is appropriate for your target system. These files are kept
  155. in machine-specific folders in the
  156. :yocto_dl:`Index of Releases </releases/yocto/yocto-3.1.2/machines/>`
  157. in the "machines" directory.
  158. The machine-specific folders of the "machines" directory contain
  159. tarballs (``*.tar.bz2``) for supported machines. These directories
  160. also contain flattened root filesystem image files (``*.ext4``),
  161. which you can use with QEMU directly.
  162. The pre-built root filesystem image files follow these naming
  163. conventions:
  164. ::
  165. core-image-profile-arch.tar.bz2
  166. Where:
  167. profile is the filesystem image's profile:
  168. lsb, lsb-dev, lsb-sdk, minimal, minimal-dev, minimal-initramfs,
  169. sato, sato-dev, sato-sdk, sato-sdk-ptest. For information on
  170. these types of image profiles, see the "Images" chapter in
  171. the Yocto Project Reference Manual.
  172. arch is a string representing the target architecture:
  173. beaglebone-yocto, beaglebone-yocto-lsb, edgerouter, edgerouter-lsb,
  174. genericx86, genericx86-64, genericx86-64-lsb, genericx86-lsb and qemu*.
  175. The root filesystems
  176. provided by the Yocto Project are based off of the
  177. ``core-image-sato`` and ``core-image-minimal`` images.
  178. For example, if you plan on using a BeagleBone device as your target
  179. hardware and your image is a ``core-image-sato-sdk`` image, you can
  180. download the following file:
  181. ::
  182. core-image-sato-sdk-beaglebone-yocto.tar.bz2
  183. 2. *Initialize the Cross-Development Environment:* You must ``source``
  184. the cross-development environment setup script to establish necessary
  185. environment variables.
  186. This script is located in the top-level directory in which you
  187. installed the toolchain (e.g. ``poky_sdk``).
  188. Following is an example based on the toolchain installed in the
  189. ":ref:`sdk-locating-pre-built-sdk-installers`" section:
  190. ::
  191. $ source ~/poky_sdk/environment-setup-core2-64-poky-linux
  192. 3. *Extract the Root Filesystem:* Use the ``runqemu-extract-sdk``
  193. command and provide the root filesystem image.
  194. Following is an example command that extracts the root filesystem
  195. from a previously built root filesystem image that was downloaded
  196. from the :yocto_dl:`Index of Releases </releases/yocto/yocto-3.1.2/machines/>`.
  197. This command extracts the root filesystem into the ``core2-64-sato``
  198. directory:
  199. ::
  200. $ runqemu-extract-sdk ~/Downloads/core-image-sato-sdk-beaglebone-yocto.tar.bz2 ~/beaglebone-sato
  201. You could now point to the target sysroot at ``beablebone-sato``.
  202. Installed Standard SDK Directory Structure
  203. ==========================================
  204. The following figure shows the resulting directory structure after you
  205. install the Standard SDK by running the ``*.sh`` SDK installation
  206. script:
  207. .. image:: figures/sdk-installed-standard-sdk-directory.png
  208. :scale: 80%
  209. :align: center
  210. The installed SDK consists of an environment setup script for the SDK, a
  211. configuration file for the target, a version file for the target, and
  212. the root filesystem (``sysroots``) needed to develop objects for the
  213. target system.
  214. Within the figure, italicized text is used to indicate replaceable
  215. portions of the file or directory name. For example, install_dir/version
  216. is the directory where the SDK is installed. By default, this directory
  217. is ``/opt/poky/``. And, version represents the specific snapshot of the
  218. SDK (e.g. 3.1.2). Furthermore, target represents the target architecture
  219. (e.g. ``i586``) and host represents the development system's
  220. architecture (e.g. ``x86_64``). Thus, the complete names of the two
  221. directories within the ``sysroots`` could be ``i586-poky-linux`` and
  222. ``x86_64-pokysdk-linux`` for the target and host, respectively.
  223. Installed Extensible SDK Directory Structure
  224. ============================================
  225. The following figure shows the resulting directory structure after you
  226. install the Extensible SDK by running the ``*.sh`` SDK installation
  227. script:
  228. .. image:: figures/sdk-installed-extensible-sdk-directory.png
  229. :scale: 80%
  230. :align: center
  231. The installed directory structure for the extensible SDK is quite
  232. different than the installed structure for the standard SDK. The
  233. extensible SDK does not separate host and target parts in the same
  234. manner as does the standard SDK. The extensible SDK uses an embedded
  235. copy of the OpenEmbedded build system, which has its own sysroots.
  236. Of note in the directory structure are an environment setup script for
  237. the SDK, a configuration file for the target, a version file for the
  238. target, and log files for the OpenEmbedded build system preparation
  239. script run by the installer and BitBake.
  240. Within the figure, italicized text is used to indicate replaceable
  241. portions of the file or directory name. For example, install_dir is the
  242. directory where the SDK is installed, which is ``poky_sdk`` by default,
  243. and target represents the target architecture (e.g. ``i586``).