faq.rst 22 KB

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