faq.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ***
  3. FAQ
  4. ***
  5. .. contents::
  6. General questions
  7. =================
  8. How does Poky differ from OpenEmbedded?
  9. ---------------------------------------
  10. The term ``Poky`` refers to the specific reference build
  11. system that the Yocto Project provides. Poky is based on
  12. :term:`OpenEmbedded-Core (OE-Core)` and :term:`BitBake`. Thus, the
  13. generic term used here for the build system is the "OpenEmbedded build
  14. system." Development in the Yocto Project using Poky is closely tied to
  15. OpenEmbedded, with changes always being merged to OE-Core or BitBake
  16. first before being pulled back into Poky. This practice benefits both
  17. projects immediately.
  18. How can you claim Poky / OpenEmbedded-Core is stable?
  19. -----------------------------------------------------
  20. There are three areas that help with stability;
  21. - The Yocto Project team keeps :term:`OpenEmbedded-Core (OE-Core)` small and
  22. focused, containing around 830 recipes as opposed to the thousands
  23. available in other OpenEmbedded community layers. Keeping it small
  24. makes it easy to test and maintain.
  25. - The Yocto Project team runs manual and automated tests using a small,
  26. fixed set of reference hardware as well as emulated targets.
  27. - The Yocto Project uses an :yocto_ab:`autobuilder <>`, which provides
  28. continuous build and integration tests.
  29. Are there any products built using the OpenEmbedded build system?
  30. -----------------------------------------------------------------
  31. See :yocto_wiki:`Products that use the Yocto Project
  32. </Project_Users#Products_that_use_the_Yocto_Project>` in the Yocto Project
  33. Wiki. Don't hesitate to contribute to this page if you know other such
  34. products.
  35. Building environment
  36. ====================
  37. Missing dependencies on the development system?
  38. -----------------------------------------------
  39. If your development system does not meet the required Git, tar, and
  40. Python versions, you can get the required tools on your host development
  41. system in different ways (i.e. building a tarball or downloading a
  42. tarball). See the ":ref:`ref-manual/system-requirements:required git, tar, python, make and gcc versions`"
  43. section for steps on how to update your build tools.
  44. How does OpenEmbedded fetch source code? Will it work through a firewall or proxy server?
  45. -----------------------------------------------------------------------------------------
  46. The way the build system obtains source code is highly
  47. configurable. You can setup the build system to get source code in most
  48. environments if HTTP transport is available.
  49. When the build system searches for source code, it first tries the local
  50. download directory. If that location fails, Poky tries
  51. :term:`PREMIRRORS`, the upstream source, and then
  52. :term:`MIRRORS` in that order.
  53. Assuming your distribution is "poky", the OpenEmbedded build system uses
  54. the Yocto Project source :term:`PREMIRRORS` by default for SCM-based
  55. sources, upstreams for normal tarballs, and then falls back to a number
  56. of other mirrors including the Yocto Project source mirror if those
  57. fail.
  58. As an example, you could add a specific server for the build system to
  59. attempt before any others by adding something like the following to the
  60. ``local.conf`` configuration file::
  61. PREMIRRORS:prepend = "\
  62. git://.*/.* &YOCTO_DL_URL;/mirror/sources/ \
  63. ftp://.*/.* &YOCTO_DL_URL;/mirror/sources/ \
  64. http://.*/.* &YOCTO_DL_URL;/mirror/sources/ \
  65. https://.*/.* &YOCTO_DL_URL;/mirror/sources/"
  66. These changes cause the build system to intercept Git, FTP, HTTP, and
  67. HTTPS requests and direct them to the ``http://`` sources mirror. You
  68. can use ``file://`` URLs to point to local directories or network shares
  69. as well.
  70. Here are other options::
  71. BB_NO_NETWORK = "1"
  72. This statement tells BitBake to issue an error
  73. instead of trying to access the Internet. This technique is useful if
  74. you want to ensure code builds only from local sources.
  75. Here is another technique::
  76. BB_FETCH_PREMIRRORONLY = "1"
  77. This statement limits the build system to pulling source from the
  78. :term:`PREMIRRORS` only. Again, this technique is useful for reproducing
  79. builds.
  80. Here is another technique::
  81. BB_GENERATE_MIRROR_TARBALLS = "1"
  82. This statement tells the build system to generate mirror tarballs. This
  83. technique is useful if you want to create a mirror server. If not,
  84. however, the technique can simply waste time during the build.
  85. Finally, consider an example where you are behind an HTTP-only firewall.
  86. You could make the following changes to the ``local.conf`` configuration
  87. file as long as the :term:`PREMIRRORS` server is current::
  88. PREMIRRORS:prepend = "\
  89. git://.*/.* &YOCTO_DL_URL;/mirror/sources/ \
  90. ftp://.*/.* &YOCTO_DL_URL;/mirror/sources/ \
  91. http://.*/.* &YOCTO_DL_URL;/mirror/sources/ \
  92. https://.*/.* &YOCTO_DL_URL;/mirror/sources/"
  93. BB_FETCH_PREMIRRORONLY = "1"
  94. These changes would cause the build system to successfully fetch source
  95. over HTTP and any network accesses to anything other than the
  96. :term:`PREMIRRORS` would fail.
  97. Most source fetching by the OpenEmbedded build system is done by
  98. ``wget`` and you therefore need to specify the proxy settings in a
  99. ``.wgetrc`` file, which can be in your home directory if you are a
  100. single user or can be in ``/usr/local/etc/wgetrc`` as a global user
  101. file.
  102. Following is the applicable code for setting various proxy types in the
  103. ``.wgetrc`` file. By default, these settings are disabled with comments.
  104. To use them, remove the comments::
  105. # You can set the default proxies for Wget to use for http, https, and ftp.
  106. # They will override the value in the environment.
  107. #https_proxy = http://proxy.yoyodyne.com:18023/
  108. #http_proxy = http://proxy.yoyodyne.com:18023/
  109. #ftp_proxy = http://proxy.yoyodyne.com:18023/
  110. # If you do not want to use proxy at all, set this to off.
  111. #use_proxy = on
  112. The build system also accepts ``http_proxy``, ``ftp_proxy``, ``https_proxy``,
  113. and ``all_proxy`` set as to standard shell environment variables to redirect
  114. requests through proxy servers.
  115. The Yocto Project also includes a
  116. ``meta-poky/conf/templates/default/site.conf.sample`` file that shows
  117. how to configure CVS and Git proxy servers if needed.
  118. .. note::
  119. You can find more information on the
  120. ":yocto_wiki:`Working Behind a Network Proxy </Working_Behind_a_Network_Proxy>`"
  121. Wiki page.
  122. Using the OpenEmbedded Build system
  123. ===================================
  124. How do I use an external toolchain?
  125. -----------------------------------
  126. The toolchain configuration is very flexible and customizable. It
  127. is primarily controlled with the :term:`TCMODE` variable. This variable
  128. controls which ``tcmode-*.inc`` file to include from the
  129. ``meta/conf/distro/include`` directory within the :term:`Source Directory`.
  130. The default value of :term:`TCMODE` is "default", which tells the
  131. OpenEmbedded build system to use its internally built toolchain (i.e.
  132. ``tcmode-default.inc``). However, other patterns are accepted. In
  133. particular, "external-\*" refers to external toolchains. One example is
  134. the Sourcery G++ Toolchain. The support for this toolchain resides in
  135. the separate ``meta-sourcery`` layer at
  136. https://github.com/MentorEmbedded/meta-sourcery/.
  137. In addition to the toolchain configuration, you also need a
  138. corresponding toolchain recipe file. This recipe file needs to package
  139. up any pre-built objects in the toolchain such as ``libgcc``,
  140. ``libstdcc++``, any locales, and ``libc``.
  141. Why do I get chmod permission issues?
  142. -------------------------------------
  143. If you see the error
  144. ``chmod: XXXXX new permissions are r-xrwxrwx, not r-xr-xr-x``,
  145. you are probably running the build on an NTFS filesystem. Instead,
  146. run the build system on a partition with a modern Linux filesystem such as
  147. ``ext4``, ``btrfs`` or ``xfs``.
  148. I see many 404 errors trying to download sources. Is anything wrong?
  149. --------------------------------------------------------------------
  150. Nothing is wrong. The OpenEmbedded build system checks any
  151. configured source mirrors before downloading from the upstream sources.
  152. The build system does this searching for both source archives and
  153. pre-checked out versions of SCM-managed software. These checks help in
  154. large installations because it can reduce load on the SCM servers
  155. themselves. This can also allow builds to continue to work if an
  156. upstream source disappears.
  157. Why do I get random build failures?
  158. -----------------------------------
  159. If the same build is failing in totally different and random
  160. ways, the most likely explanation is:
  161. - The hardware you are running the build on has some problem.
  162. - You are running the build under virtualization, in which case the
  163. virtualization probably has bugs.
  164. The OpenEmbedded build system processes a massive amount of data that
  165. causes lots of network, disk and CPU activity and is sensitive to even
  166. single-bit failures in any of these areas. True random failures have
  167. always been traced back to hardware or virtualization issues.
  168. Why does the build fail with ``iconv.h`` problems?
  169. --------------------------------------------------
  170. When you try to build a native recipe, you may get an error message that
  171. indicates that GNU ``libiconv`` is not in use but ``iconv.h`` has been
  172. included from ``libiconv``::
  173. #error GNU libiconv not in use but included iconv.h is from libiconv
  174. When this happens, you need to check whether you have a previously
  175. installed version of the header file in ``/usr/local/include/``.
  176. If that's the case, you should either uninstall it or temporarily rename
  177. it and try the build again.
  178. This issue is just a single manifestation of "system leakage" issues
  179. caused when the OpenEmbedded build system finds and uses previously
  180. installed files during a native build. This type of issue might not be
  181. limited to ``iconv.h``. Make sure that leakage cannot occur from
  182. ``/usr/local/include`` and ``/opt`` locations.
  183. Why don't other recipes find the files provided by my ``*-native`` recipe?
  184. --------------------------------------------------------------------------
  185. Files provided by your native recipe could be missing from the native
  186. sysroot, your recipe could also be installing to the wrong place, or you
  187. could be getting permission errors during the :ref:`ref-tasks-install`
  188. task in your recipe.
  189. This situation happens when the build system used by a package does not
  190. recognize the environment variables supplied to it by :term:`BitBake`. The
  191. incident that prompted this FAQ entry involved a Makefile that used an
  192. environment variable named ``BINDIR`` instead of the more standard
  193. variable ``bindir``. The makefile's hardcoded default value of
  194. "/usr/bin" worked most of the time, but not for the recipe's ``-native``
  195. variant. For another example, permission errors might be caused by a
  196. Makefile that ignores ``DESTDIR`` or uses a different name for that
  197. environment variable. Check the build system of the package to see if
  198. these kinds of issues exist.
  199. Can I get rid of build output so I can start over?
  200. --------------------------------------------------
  201. Yes --- you can easily do this. When you use BitBake to build an
  202. image, all the build output goes into the directory created when you run
  203. the build environment setup script (i.e. :ref:`structure-core-script`).
  204. By default, this :term:`Build Directory` is named ``build`` but can be named
  205. anything you want.
  206. Within the :term:`Build Directory`, is the ``tmp`` directory. To remove all the
  207. build output yet preserve any source code or downloaded files from
  208. previous builds, simply remove the ``tmp`` directory.
  209. Customizing generated images
  210. ============================
  211. What does the OpenEmbedded build system produce as output?
  212. ----------------------------------------------------------
  213. Because you can use the same set of recipes to create output of
  214. various formats, the output of an OpenEmbedded build depends on how you
  215. start it. Usually, the output is a flashable image ready for the target
  216. device.
  217. How do I make the Yocto Project support my board?
  218. -------------------------------------------------
  219. Support for an additional board is added by creating a Board
  220. Support Package (BSP) layer for it. For more information on how to
  221. create a BSP layer, see the
  222. ":ref:`dev-manual/common-tasks:understanding and creating layers`"
  223. section in the Yocto Project Development Tasks Manual and the
  224. :doc:`/bsp-guide/index`.
  225. Usually, if the board is not completely exotic, adding support in the
  226. Yocto Project is fairly straightforward.
  227. How do I make the Yocto Project support my package?
  228. ---------------------------------------------------
  229. To add a package, you need to create a BitBake recipe. For
  230. information on how to create a BitBake recipe, see the
  231. ":ref:`dev-manual/common-tasks:writing a new recipe`"
  232. section in the Yocto Project Development Tasks Manual.
  233. What do I need to ship for license compliance?
  234. ----------------------------------------------
  235. This is a difficult question and you need to consult your lawyer
  236. for the answer for your specific case. It is worth bearing in mind that
  237. for GPL compliance, there needs to be enough information shipped to
  238. allow someone else to rebuild and produce the same end result you are
  239. shipping. This means sharing the source code, any patches applied to it,
  240. and also any configuration information about how that package was
  241. configured and built.
  242. You can find more information on licensing in the
  243. ":ref:`overview-manual/development-environment:licensing`"
  244. section in the Yocto Project Overview and Concepts Manual and also in the
  245. ":ref:`dev-manual/common-tasks:maintaining open source license compliance during your product's lifecycle`"
  246. section in the Yocto Project Development Tasks Manual.
  247. Do I have to make a full reflash after recompiling one package?
  248. ---------------------------------------------------------------
  249. The OpenEmbedded build system can build packages in various
  250. formats such as IPK for OPKG, Debian package (``.deb``), or RPM. You can
  251. then upgrade only the modified packages using the package tools on the device,
  252. much like on a desktop distribution such as Ubuntu or Fedora. However,
  253. package management on the target is entirely optional.
  254. How to prevent my package from being marked as machine specific?
  255. ----------------------------------------------------------------
  256. If you have machine-specific data in a package for one machine only
  257. but the package is being marked as machine-specific in all cases,
  258. you can set :term:`SRC_URI_OVERRIDES_PACKAGE_ARCH` = "0" in the ``.bb`` file.
  259. However, but make sure the package is manually marked as machine-specific for the
  260. case that needs it. The code that handles :term:`SRC_URI_OVERRIDES_PACKAGE_ARCH`
  261. is in the ``meta/classes-global/base.bbclass`` file.
  262. What's the difference between ``target`` and ``target-native``?
  263. ---------------------------------------------------------------
  264. The ``*-native`` targets are designed to run on the system being
  265. used for the build. These are usually tools that are needed to assist
  266. the build in some way such as ``quilt-native``, which is used to apply
  267. patches. The non-native version is the one that runs on the target
  268. device.
  269. Why do ``${bindir}`` and ``${libdir}`` have strange values for ``-native`` recipes?
  270. -----------------------------------------------------------------------------------
  271. Executables and libraries might need to be used from a directory
  272. other than the directory into which they were initially installed.
  273. Complicating this situation is the fact that sometimes these executables
  274. and libraries are compiled with the expectation of being run from that
  275. initial installation target directory. If this is the case, moving them
  276. causes problems.
  277. This scenario is a fundamental problem for package maintainers of
  278. mainstream Linux distributions as well as for the OpenEmbedded build
  279. system. As such, a well-established solution exists. Makefiles,
  280. Autotools configuration scripts, and other build systems are expected to
  281. respect environment variables such as ``bindir``, ``libdir``, and
  282. ``sysconfdir`` that indicate where executables, libraries, and data
  283. reside when a program is actually run. They are also expected to respect
  284. a ``DESTDIR`` environment variable, which is prepended to all the other
  285. variables when the build system actually installs the files. It is
  286. understood that the program does not actually run from within
  287. ``DESTDIR``.
  288. When the OpenEmbedded build system uses a recipe to build a
  289. target-architecture program (i.e. one that is intended for inclusion on
  290. the image being built), that program eventually runs from the root file
  291. system of that image. Thus, the build system provides a value of
  292. "/usr/bin" for ``bindir``, a value of "/usr/lib" for ``libdir``, and so
  293. forth.
  294. Meanwhile, ``DESTDIR`` is a path within the :term:`Build Directory`.
  295. However, when the recipe builds a native program (i.e. one that is
  296. intended to run on the build machine), that program is never installed
  297. directly to the build machine's root file system. Consequently, the build
  298. system uses paths within the Build Directory for ``DESTDIR``, ``bindir``
  299. and related variables. To better understand this, consider the following
  300. two paths (artificially broken across lines for readability) where the
  301. first is relatively normal and the second is not::
  302. /home/maxtothemax/poky-bootchart2/build/tmp/work/i586-poky-linux/zlib/
  303. 1.2.8-r0/sysroot-destdir/usr/bin
  304. /home/maxtothemax/poky-bootchart2/build/tmp/work/x86_64-linux/
  305. zlib-native/1.2.8-r0/sysroot-destdir/home/maxtothemax/poky-bootchart2/
  306. build/tmp/sysroots/x86_64-linux/usr/bin
  307. Even if the paths look unusual, they both are correct --- the first for
  308. a target and the second for a native recipe. These paths are a consequence
  309. of the ``DESTDIR`` mechanism and while they appear strange, they are correct
  310. and in practice very effective.
  311. How do I create images with more free space?
  312. --------------------------------------------
  313. By default, the OpenEmbedded build system creates images that are
  314. 1.3 times the size of the populated root filesystem. To affect the image
  315. size, you need to set various configurations:
  316. - *Image Size:* The OpenEmbedded build system uses the
  317. :term:`IMAGE_ROOTFS_SIZE` variable to define
  318. the size of the image in Kbytes. The build system determines the size
  319. by taking into account the initial root filesystem size before any
  320. modifications such as requested size for the image and any requested
  321. additional free disk space to be added to the image.
  322. - *Overhead:* Use the
  323. :term:`IMAGE_OVERHEAD_FACTOR` variable
  324. to define the multiplier that the build system applies to the initial
  325. image size, which is 1.3 by default.
  326. - *Additional Free Space:* Use the
  327. :term:`IMAGE_ROOTFS_EXTRA_SPACE`
  328. variable to add additional free space to the image. The build system
  329. adds this space to the image after it determines its
  330. :term:`IMAGE_ROOTFS_SIZE`.
  331. Why aren't spaces in path names supported?
  332. ------------------------------------------
  333. The Yocto Project team has tried to do this before but too many
  334. of the tools the OpenEmbedded build system depends on, such as
  335. ``autoconf``, break when they find spaces in pathnames. Until that
  336. situation changes, the team will not support spaces in pathnames.
  337. I'm adding a binary in a recipe. Why is it different in the image?
  338. ------------------------------------------------------------------
  339. The first most obvious change is the system stripping debug symbols from
  340. it. Setting :term:`INHIBIT_PACKAGE_STRIP` to stop debug symbols being
  341. stripped and/or :term:`INHIBIT_PACKAGE_DEBUG_SPLIT` to stop debug symbols
  342. being split into a separate file will ensure the binary is unchanged.
  343. Issues on the running system
  344. ============================
  345. How do I disable the cursor on my touchscreen device?
  346. -----------------------------------------------------
  347. You need to create a form factor file as described in the
  348. ":ref:`bsp-guide/bsp:miscellaneous bsp-specific recipe files`" section in
  349. the Yocto Project Board Support Packages (BSP) Developer's Guide. Set
  350. the ``HAVE_TOUCHSCREEN`` variable equal to one as follows::
  351. HAVE_TOUCHSCREEN=1
  352. How to always bring up connected network interfaces?
  353. ----------------------------------------------------
  354. The default interfaces file provided by the netbase recipe does
  355. not automatically bring up network interfaces. Therefore, you will need
  356. to add a BSP-specific netbase that includes an interfaces file. See the
  357. ":ref:`bsp-guide/bsp:miscellaneous bsp-specific recipe files`" section in
  358. the Yocto Project Board Support Packages (BSP) Developer's Guide for
  359. information on creating these types of miscellaneous recipe files.
  360. For example, add the following files to your layer::
  361. meta-MACHINE/recipes-bsp/netbase/netbase/MACHINE/interfaces
  362. meta-MACHINE/recipes-bsp/netbase/netbase_5.0.bbappend