extensible.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ************************
  3. Using the Extensible SDK
  4. ************************
  5. This chapter describes the extensible SDK and how to install it.
  6. Information covers the pieces of the SDK, how to install it, and
  7. presents a look at using the ``devtool`` functionality. The extensible
  8. SDK makes it easy to add new applications and libraries to an image,
  9. modify the source for an existing component, test changes on the target
  10. hardware, and ease integration into the rest of the
  11. :term:`OpenEmbedded Build System`.
  12. .. note::
  13. For a side-by-side comparison of main features supported for an
  14. extensible SDK as compared to a standard SDK, see the
  15. :ref:`sdk-manual/intro:introduction` section.
  16. In addition to the functionality available through ``devtool``, you can
  17. alternatively make use of the toolchain directly, for example from
  18. Makefile and Autotools. See the
  19. ":ref:`sdk-manual/working-projects:using the sdk toolchain directly`" chapter
  20. for more information.
  21. Why use the Extensible SDK and What is in It?
  22. =============================================
  23. The extensible SDK provides a cross-development toolchain and libraries
  24. tailored to the contents of a specific image. You would use the
  25. Extensible SDK if you want a toolchain experience supplemented with the
  26. powerful set of ``devtool`` commands tailored for the Yocto Project
  27. environment.
  28. The installed extensible SDK consists of several files and directories.
  29. Basically, it contains an SDK environment setup script, some
  30. configuration files, an internal build system, and the ``devtool``
  31. functionality.
  32. Installing the Extensible SDK
  33. =============================
  34. Two ways to install the Extensible SDK
  35. --------------------------------------
  36. Extensible SDK can be installed in two different ways, and both have
  37. their own pros and cons:
  38. #. *Setting up the Extensible SDK environment directly in a Yocto build*. This
  39. avoids having to produce, test, distribute and maintain separate SDK
  40. installer archives, which can get very large. There is only one environment
  41. for the regular Yocto build and the SDK and less code paths where things can
  42. go not according to plan. It's easier to update the SDK: it simply means
  43. updating the Yocto layers with git fetch or layer management tooling. The
  44. SDK extensibility is better than in the second option: just run ``bitbake``
  45. again to add more things to the sysroot, or add layers if even more things
  46. are required.
  47. #. *Setting up the Extensible SDK from a standalone installer*. This has the
  48. benefit of having a single, self-contained archive that includes all the
  49. needed binary artifacts. So nothing needs to be rebuilt, and there is no
  50. need to provide a well-functioning binary artefact cache over the network
  51. for developers with underpowered laptops.
  52. .. _setting_up_ext_sdk_in_build:
  53. Setting up the Extensible SDK environment directly in a Yocto build
  54. -------------------------------------------------------------------
  55. #. Set up all the needed layers and a Yocto :term:`Build Directory`, e.g. a regular Yocto
  56. build where ``bitbake`` can be executed.
  57. #. Run::
  58. $ bitbake meta-ide-support
  59. $ bitbake -c populate_sysroot gtk+3
  60. # or any other target or native item that the application developer would need
  61. $ bitbake build-sysroots -c build_native_sysroot && bitbake build-sysroots -c build_target_sysroot
  62. Setting up the Extensible SDK from a standalone installer
  63. ---------------------------------------------------------
  64. The first thing you need to do is install the SDK on your :term:`Build
  65. Host` by running the ``*.sh`` installation script.
  66. You can download a tarball installer, which includes the pre-built
  67. toolchain, the ``runqemu`` script, the internal build system,
  68. ``devtool``, and support files from the appropriate
  69. :yocto_dl:`toolchain </releases/yocto/&DISTRO_REL_LATEST_TAG;/toolchain/>` directory within the Index of
  70. Releases. Toolchains are available for several 32-bit and 64-bit
  71. architectures with the ``x86_64`` directories, respectively. The
  72. toolchains the Yocto Project provides are based off the
  73. ``core-image-sato`` and ``core-image-minimal`` images and contain
  74. libraries appropriate for developing against that image.
  75. The names of the tarball installer scripts are such that a string
  76. representing the host system appears first in the filename and then is
  77. immediately followed by a string representing the target architecture.
  78. An extensible SDK has the string "-ext" as part of the name. Following
  79. is the general form::
  80. poky-glibc-host_system-image_type-arch-toolchain-ext-release_version.sh
  81. Where:
  82. host_system is a string representing your development system:
  83. i686 or x86_64.
  84. image_type is the image for which the SDK was built:
  85. core-image-sato or core-image-minimal
  86. arch is a string representing the tuned target architecture:
  87. aarch64, armv5e, core2-64, i586, mips32r2, mips64, ppc7400, or cortexa8hf-neon
  88. release_version is a string representing the release number of the Yocto Project:
  89. &DISTRO;, &DISTRO;+snapshot
  90. For example, the following SDK installer is for a 64-bit
  91. development host system and a i586-tuned target architecture based off
  92. the SDK for ``core-image-sato`` and using the current &DISTRO; snapshot::
  93. poky-glibc-x86_64-core-image-sato-i586-toolchain-ext-&DISTRO;.sh
  94. .. note::
  95. As an alternative to downloading an SDK, you can build the SDK
  96. installer. For information on building the installer, see the
  97. :ref:`sdk-manual/appendix-obtain:building an sdk installer`
  98. section.
  99. The SDK and toolchains are self-contained and by default are installed
  100. into the ``poky_sdk`` folder in your home directory. You can choose to
  101. install the extensible SDK in any location when you run the installer.
  102. However, because files need to be written under that directory during
  103. the normal course of operation, the location you choose for installation
  104. must be writable for whichever users need to use the SDK.
  105. The following command shows how to run the installer given a toolchain
  106. tarball for a 64-bit x86 development host system and a 64-bit x86 target
  107. architecture. The example assumes the SDK installer is located in
  108. ``~/Downloads/`` and has execution rights::
  109. $ ./Downloads/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.5.sh
  110. Poky (Yocto Project Reference Distro) Extensible SDK installer version 2.5
  111. ==========================================================================
  112. Enter target directory for SDK (default: poky_sdk):
  113. You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y
  114. Extracting SDK..............done
  115. Setting it up...
  116. Extracting buildtools...
  117. Preparing build system...
  118. Parsing recipes: 100% |##################################################################| Time: 0:00:52
  119. Initialising tasks: 100% |###############################################################| Time: 0:00:00
  120. Checking sstate mirror object availability: 100% |#######################################| Time: 0:00:00
  121. Loading cache: 100% |####################################################################| Time: 0:00:00
  122. Initialising tasks: 100% |###############################################################| Time: 0:00:00
  123. done
  124. SDK has been successfully set up and is ready to be used.
  125. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
  126. $ . /home/scottrif/poky_sdk/environment-setup-core2-64-poky-linux
  127. .. note::
  128. If you do not have write permissions for the directory into which you
  129. are installing the SDK, the installer notifies you and exits. For
  130. that case, set up the proper permissions in the directory and run the
  131. installer again.
  132. .. _running_the_ext_sdk_env:
  133. Running the Extensible SDK Environment Setup Script
  134. ===================================================
  135. Once you have the SDK installed, you must run the SDK environment setup
  136. script before you can actually use the SDK.
  137. When using an SDK directly in a Yocto build, you will find the script in
  138. ``tmp/deploy/images/qemux86-64/`` in your :term:`Build Directory`.
  139. When using a standalone SDK installer, this setup script resides in
  140. the directory you chose when you installed the SDK, which is either the
  141. default ``poky_sdk`` directory or the directory you chose during
  142. installation.
  143. Before running the script, be sure it is the one that matches the
  144. architecture for which you are developing. Environment setup scripts
  145. begin with the string "``environment-setup``" and include as part of
  146. their name the tuned target architecture. As an example, the following
  147. commands set the working directory to where the SDK was installed and
  148. then source the environment setup script. In this example, the setup
  149. script is for an IA-based target machine using i586 tuning::
  150. $ cd /home/scottrif/poky_sdk
  151. $ source environment-setup-core2-64-poky-linux
  152. SDK environment now set up; additionally you may now run devtool to perform development tasks.
  153. Run devtool --help for further details.
  154. When using the environment script directly in a Yocto build, it can
  155. be run similarly::
  156. $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux
  157. Running the setup script defines many environment variables needed in order to
  158. use the SDK (e.g. ``PATH``, :term:`CC`, :term:`LD`, and so forth). If you want
  159. to see all the environment variables the script exports, examine the
  160. installation file itself.
  161. .. _using_devtool:
  162. Using ``devtool`` in Your SDK Workflow
  163. ======================================
  164. The cornerstone of the extensible SDK is a command-line tool called
  165. ``devtool``. This tool provides a number of features that help you
  166. build, test and package software within the extensible SDK, and
  167. optionally integrate it into an image built by the OpenEmbedded build
  168. system.
  169. .. note::
  170. The use of ``devtool`` is not limited to the extensible SDK. You can use
  171. ``devtool`` to help you easily develop any project whose build output must be
  172. part of an image built using the build system.
  173. The ``devtool`` command line is organized similarly to
  174. :ref:`overview-manual/development-environment:git` in that it has a number of
  175. sub-commands for each function. You can run ``devtool --help`` to see
  176. all the commands.
  177. .. note::
  178. See the ":doc:`/ref-manual/devtool-reference`"
  179. section in the Yocto Project Reference Manual.
  180. ``devtool`` subcommands provide entry-points into development:
  181. - *devtool add*: Assists in adding new software to be built.
  182. - *devtool modify*: Sets up an environment to enable you to modify
  183. the source of an existing component.
  184. - *devtool ide-sdk*: Generates a configuration for an IDE.
  185. - *devtool upgrade*: Updates an existing recipe so that you can
  186. build it for an updated set of source files.
  187. As with the build system, "recipes" represent software packages within
  188. ``devtool``. When you use ``devtool add``, a recipe is automatically
  189. created. When you use ``devtool modify``, the specified existing recipe
  190. is used in order to determine where to get the source code and how to
  191. patch it. In both cases, an environment is set up so that when you build
  192. the recipe a source tree that is under your control is used in order to
  193. allow you to make changes to the source as desired. By default, new
  194. recipes and the source go into a "workspace" directory under the SDK.
  195. To learn how to use ``devtool`` to add, modify, upgrade recipes and more, see
  196. the :ref:`dev-manual/devtool:Using the \`\`devtool\`\` command-line tool`
  197. section of the Yocto Project Development Tasks Manual.
  198. Installing Additional Items Into the Extensible SDK
  199. ===================================================
  200. Out of the box the extensible SDK typically only comes with a small
  201. number of tools and libraries. A minimal SDK starts mostly empty and is
  202. populated on-demand. Sometimes you must explicitly install extra items
  203. into the SDK. If you need these extra items, you can first search for
  204. the items using the ``devtool search`` command. For example, suppose you
  205. need to link to libGL but you are not sure which recipe provides libGL.
  206. You can use the following command to find out::
  207. $ devtool search libGL mesa
  208. A free implementation of the OpenGL API
  209. Once you know the recipe
  210. (i.e. ``mesa`` in this example), you can install it.
  211. When using the extensible SDK directly in a Yocto build
  212. -------------------------------------------------------
  213. In this scenario, the Yocto build tooling, e.g. ``bitbake``
  214. is directly accessible to build additional items, and it
  215. can simply be executed directly::
  216. $ bitbake curl-native
  217. # Add newly built native items to native sysroot
  218. $ bitbake build-sysroots -c build_native_sysroot
  219. $ bitbake mesa
  220. # Add newly built target items to target sysroot
  221. $ bitbake build-sysroots -c build_target_sysroot
  222. When using a standalone installer for the Extensible SDK
  223. --------------------------------------------------------
  224. ::
  225. $ devtool sdk-install mesa
  226. By default, the ``devtool sdk-install`` command assumes
  227. the item is available in pre-built form from your SDK provider. If the
  228. item is not available and it is acceptable to build the item from
  229. source, you can add the "-s" option as follows::
  230. $ devtool sdk-install -s mesa
  231. It is important to remember that building the item from source
  232. takes significantly longer than installing the pre-built artifact. Also,
  233. if there is no recipe for the item you want to add to the SDK, you must
  234. instead add the item using the ``devtool add`` command.
  235. Applying Updates to an Installed Extensible SDK
  236. ===============================================
  237. If you are working with an installed extensible SDK that gets
  238. occasionally updated (e.g. a third-party SDK), then you will need to
  239. manually "pull down" the updates into the installed SDK.
  240. To update your installed SDK, use ``devtool`` as follows::
  241. $ devtool sdk-update
  242. The previous command assumes your SDK provider has set the default update URL
  243. for you through the :term:`SDK_UPDATE_URL` variable as described in the
  244. ":ref:`sdk-manual/appendix-customizing:Providing Updates to the Extensible SDK After Installation`"
  245. section. If the SDK provider has not set that default URL, you need to
  246. specify it yourself in the command as follows::
  247. $ devtool sdk-update path_to_update_directory
  248. .. note::
  249. The URL needs to point specifically to a published SDK and not to an
  250. SDK installer that you would download and install.
  251. Creating a Derivative SDK With Additional Components
  252. ====================================================
  253. You might need to produce an SDK that contains your own custom
  254. libraries. A good example would be if you were a vendor with customers
  255. that use your SDK to build their own platform-specific software and
  256. those customers need an SDK that has custom libraries. In such a case,
  257. you can produce a derivative SDK based on the currently installed SDK
  258. fairly easily by following these steps:
  259. #. If necessary, install an extensible SDK that you want to use as a
  260. base for your derivative SDK.
  261. #. Source the environment script for the SDK.
  262. #. Add the extra libraries or other components you want by using the
  263. ``devtool add`` command.
  264. #. Run the ``devtool build-sdk`` command.
  265. The previous steps take the recipes added to the workspace and construct
  266. a new SDK installer that contains those recipes and the resulting binary
  267. artifacts. The recipes go into their own separate layer in the
  268. constructed derivative SDK, which leaves the workspace clean and ready
  269. for users to add their own recipes.