brief-yoctoprojectqs.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <!DOCTYPE article 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. <article id='brief-yocto-project-qs-intro'>
  5. <articleinfo>
  6. <title>Yocto Project Quick Build</title>
  7. <copyright>
  8. <year>&COPYRIGHT_YEAR;</year>
  9. <holder>Linux Foundation</holder>
  10. </copyright>
  11. <legalnotice>
  12. <para>
  13. Permission is granted to copy, distribute and/or modify this document under
  14. the terms of the <ulink type="http" url="http://creativecommons.org/licenses/by-sa/2.0/uk/">Creative Commons Attribution-Share Alike 2.0 UK: England &amp; Wales</ulink> as published by Creative Commons.
  15. </para>
  16. </legalnotice>
  17. <abstract>
  18. <imagedata fileref="figures/yocto-project-transp.png"
  19. width="6in" depth="1in"
  20. align="right" scale="25" />
  21. </abstract>
  22. </articleinfo>
  23. <section id='brief-welcome'>
  24. <title>Welcome!</title>
  25. <para>
  26. Welcome!
  27. This short document steps you through the process for a typical
  28. image build using the Yocto Project.
  29. The document also introduces how to configure a build for specific
  30. hardware.
  31. You will use Yocto Project to build a reference embedded OS
  32. called Poky.
  33. <note><title>Notes</title>
  34. <itemizedlist>
  35. <listitem><para>
  36. The examples in this paper assume you are using a
  37. native Linux system running a recent Ubuntu Linux
  38. distribution.
  39. If the machine you want to use Yocto Project on to
  40. build an image
  41. (<ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>)
  42. is not a native Linux system, you can
  43. still perform these steps by using CROss PlatformS
  44. (CROPS) and setting up a Poky container.
  45. See the
  46. <ulink url='&YOCTO_DOCS_DEV_URL;#setting-up-to-use-crops'>Setting Up to Use CROss PlatformS (CROPS)</ulink>"
  47. section in the Yocto Project Development Tasks Manual for more
  48. information.
  49. </para></listitem>
  50. <listitem><para>
  51. You cannot use a build host that is using the
  52. <ulink url='https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux'>Windows Subsystem for Linux</ulink>
  53. (WSL).
  54. The Yocto Project is not compatible with WSL.
  55. </para></listitem>
  56. </itemizedlist>
  57. </note>
  58. </para>
  59. <para>
  60. If you want more conceptual or background information on the
  61. Yocto Project, see the
  62. <ulink url='&YOCTO_DOCS_OM_URL;'>Yocto Project Overview and Concepts Manual</ulink>.
  63. </para>
  64. </section>
  65. <section id='brief-compatible-distro'>
  66. <title>Compatible Linux Distribution</title>
  67. <para>
  68. Make sure your
  69. <ulink url='&YOCTO_DOCS_REF_URL;#hardware-build-system-term'>build host</ulink>
  70. meets the following requirements:
  71. <itemizedlist>
  72. <listitem><para>
  73. 50 Gbytes of free disk space
  74. </para></listitem>
  75. <listitem><para>
  76. Runs a supported Linux distribution (i.e. recent releases of
  77. Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of
  78. Linux distributions that support the Yocto Project, see the
  79. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>"
  80. section in the Yocto Project Reference Manual.
  81. For detailed information on preparing your build host, see
  82. the
  83. "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-preparing-the-build-host'>Preparing the Build Host</ulink>"
  84. section in the Yocto Project Development Tasks Manual.
  85. </para></listitem>
  86. <listitem><para>
  87. <itemizedlist>
  88. <listitem><para>
  89. Git 1.8.3.1 or greater
  90. </para></listitem>
  91. <listitem><para>
  92. tar 1.27 or greater
  93. </para></listitem>
  94. <listitem><para>
  95. Python 3.4.0 or greater.
  96. </para></listitem>
  97. </itemizedlist>
  98. If your build host does not meet any of these three listed
  99. version requirements, you can take steps to prepare the
  100. system so that you can still use the Yocto Project.
  101. See the
  102. "<ulink url='&YOCTO_DOCS_REF_URL;#required-git-tar-and-python-versions'>Required Git, tar, and Python Versions</ulink>"
  103. section in the Yocto Project Reference Manual for information.
  104. </para></listitem>
  105. </itemizedlist>
  106. </para>
  107. </section>
  108. <section id='brief-build-system-packages'>
  109. <title>Build Host Packages</title>
  110. <para>
  111. You must install essential host packages on your
  112. build host.
  113. The following command installs the host packages based on an
  114. Ubuntu distribution:
  115. <note>
  116. For host package requirements on all supported Linux
  117. distributions, see the
  118. "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-build-host'>Required Packages for the Build Host</ulink>"
  119. section in the Yocto Project Reference Manual.
  120. </note>
  121. <literallayout class='monospaced'>
  122. $ sudo apt-get install &UBUNTU_HOST_PACKAGES_ESSENTIAL; libsdl1.2-dev xterm
  123. </literallayout>
  124. </para>
  125. </section>
  126. <section id='brief-use-git-to-clone-poky'>
  127. <title>Use Git to Clone Poky</title>
  128. <para>
  129. Once you complete the setup instructions for your machine,
  130. you need to get a copy of the Poky repository on your build
  131. host.
  132. Use the following commands to clone the Poky
  133. repository.
  134. <literallayout class='monospaced'>
  135. $ git clone git://git.yoctoproject.org/poky
  136. Cloning into 'poky'...
  137. remote: Counting objects: 445141, done.
  138. remote: Compressing objects: 100% (105214/105214), done.
  139. remote: Total 445141 (delta 333098), reused 444745 (delta 332720)
  140. Receiving objects: 100% (445141/445141), 156.60 MiB | 5.13 MiB/s, done.
  141. Resolving deltas: 100% (333098/333098), done.
  142. Checking connectivity... done.
  143. </literallayout>
  144. Move to the <filename>poky</filename> directory and take a look
  145. at the tags:
  146. <literallayout class='monospaced'>
  147. $ cd poky
  148. $ git fetch --tags
  149. $ git tag
  150. 1.1_M1.final
  151. 1.1_M1.rc1
  152. 1.1_M1.rc2
  153. 1.1_M2.final
  154. 1.1_M2.rc1
  155. .
  156. .
  157. .
  158. yocto-2.5
  159. yocto-2.5.1
  160. yocto-2.5.2
  161. yocto-2.5.3
  162. yocto-2.6
  163. yocto-2.6.1
  164. yocto-2.6.2
  165. yocto-2.6.3
  166. yocto-2.7
  167. yocto_1.5_M5.rc8
  168. </literallayout>
  169. For this example, check out the branch based on the
  170. &DISTRO_REL_TAG; release:
  171. <literallayout class='monospaced'>
  172. $ git checkout tags/&DISTRO_REL_TAG; -b my-&DISTRO_REL_TAG;
  173. Switched to a new branch 'my-&DISTRO_REL_TAG;'
  174. </literallayout>
  175. The previous Git checkout command creates a local branch
  176. named my-&DISTRO_REL_TAG;. The files available to you in that
  177. branch exactly match the repository's files in the
  178. "&DISTRO_NAME_NO_CAP;" development branch at the time of the
  179. Yocto Project &DISTRO_REL_TAG; release.
  180. </para>
  181. <para>
  182. For more options and information about accessing Yocto
  183. Project related repositories, see the
  184. "<ulink url='&YOCTO_DOCS_DEV_URL;#locating-yocto-project-source-files'>Locating Yocto Project Source Files</ulink>"
  185. section in the Yocto Project Development Tasks Manual.
  186. </para>
  187. </section>
  188. <section id='brief-building-your-image'>
  189. <title>Building Your Image</title>
  190. <para>
  191. Use the following steps to build your image.
  192. The build process creates an entire Linux distribution, including
  193. the toolchain, from source.
  194. <note>
  195. <itemizedlist>
  196. <listitem><para>
  197. If you are working behind a firewall and your build
  198. host is not set up for proxies, you could encounter
  199. problems with the build process when fetching source
  200. code (e.g. fetcher failures or Git failures).
  201. </para></listitem>
  202. <listitem><para>
  203. If you do not know your proxy settings, consult your
  204. local network infrastructure resources and get that
  205. information.
  206. A good starting point could also be to check your
  207. web browser settings.
  208. Finally, you can find more information on the
  209. "<ulink url='https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy'>Working Behind a Network Proxy</ulink>"
  210. page of the Yocto Project Wiki.
  211. </para></listitem>
  212. </itemizedlist>
  213. </note>
  214. </para>
  215. <para>
  216. <orderedlist>
  217. <listitem><para>
  218. <emphasis>Initialize the Build Environment:</emphasis>
  219. From within the <filename>poky</filename> directory, run the
  220. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  221. environment setup script to define Yocto Project's
  222. build environment on your build host.
  223. <literallayout class='monospaced'>
  224. $ cd ~/poky
  225. $ source &OE_INIT_FILE;
  226. You had no conf/local.conf file. This configuration file has therefore been
  227. created for you with some default values. You may wish to edit it to, for
  228. example, select a different MACHINE (target hardware). See conf/local.conf
  229. for more information as common configuration options are commented.
  230. You had no conf/bblayers.conf file. This configuration file has therefore been
  231. created for you with some default values. To add additional metadata layers
  232. into your configuration please add entries to conf/bblayers.conf.
  233. The Yocto Project has extensive documentation about OE including a reference
  234. manual which can be found at:
  235. http://yoctoproject.org/documentation
  236. For more information about OpenEmbedded see their website:
  237. http://www.openembedded.org/
  238. ### Shell environment set up for builds. ###
  239. You can now run 'bitbake &lt;target&gt;'
  240. Common targets are:
  241. core-image-minimal
  242. core-image-sato
  243. meta-toolchain
  244. meta-ide-support
  245. You can also run generated qemu images with a command like 'runqemu qemux86'
  246. </literallayout>
  247. Among other things, the script creates the
  248. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>,
  249. which is <filename>build</filename> in this case
  250. and is located in the
  251. <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>.
  252. After the script runs, your current working directory
  253. is set to the Build Directory.
  254. Later, when the build completes, the Build Directory
  255. contains all the files created during the build.
  256. </para></listitem>
  257. <listitem><para id='conf-file-step'>
  258. <emphasis>Examine Your Local Configuration File:</emphasis>
  259. When you set up the build environment, a local
  260. configuration file named
  261. <filename>local.conf</filename> becomes available in
  262. a <filename>conf</filename> subdirectory of the
  263. Build Directory.
  264. For this example, the defaults are set to build
  265. for a <filename>qemux86</filename> target, which is
  266. suitable for emulation.
  267. The package manager used is set to the RPM package
  268. manager.
  269. <tip>
  270. You can significantly speed up your build and guard
  271. against fetcher failures by using mirrors.
  272. To use mirrors, add these lines to your
  273. <filename>local.conf</filename> file in the Build
  274. directory:
  275. <literallayout class='monospaced'>
  276. SSTATE_MIRRORS = "\
  277. file://.* http://sstate.yoctoproject.org/dev/PATH;downloadfilename=PATH \n \
  278. file://.* http://sstate.yoctoproject.org/&YOCTO_DOC_VERSION_MINUS_ONE;/PATH;downloadfilename=PATH \n \
  279. file://.* http://sstate.yoctoproject.org/&YOCTO_DOC_VERSION;/PATH;downloadfilename=PATH \n \
  280. "
  281. </literallayout>
  282. The previous examples showed how to add sstate
  283. paths for Yocto Project &YOCTO_DOC_VERSION_MINUS_ONE;,
  284. &YOCTO_DOC_VERSION;, and a development area.
  285. For a complete index of sstate locations, see
  286. <ulink url='http://sstate.yoctoproject.org/'></ulink>.
  287. </tip>
  288. </para></listitem>
  289. <listitem><para>
  290. <emphasis>Start the Build:</emphasis>
  291. Continue with the following command to build an OS image
  292. for the target, which is
  293. <filename>core-image-sato</filename> in this example:
  294. <literallayout class='monospaced'>
  295. $ bitbake core-image-sato
  296. </literallayout>
  297. For information on using the
  298. <filename>bitbake</filename> command, see the
  299. "<ulink url='&YOCTO_DOCS_OM_URL;#usingpoky-components-bitbake'>BitBake</ulink>"
  300. section in the Yocto Project Overview and Concepts Manual,
  301. or see the
  302. "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-command'>BitBake Command</ulink>"
  303. section in the BitBake User Manual.
  304. </para></listitem>
  305. <listitem><para>
  306. <emphasis>Simulate Your Image Using QEMU:</emphasis>
  307. Once this particular image is built, you can start
  308. QEMU, which is a Quick EMUlator that ships with
  309. the Yocto Project:
  310. <literallayout class='monospaced'>
  311. $ runqemu qemux86
  312. </literallayout>
  313. If you want to learn more about running QEMU, see the
  314. "<ulink url="&YOCTO_DOCS_DEV_URL;#dev-manual-qemu">Using the Quick EMUlator (QEMU)</ulink>"
  315. chapter in the Yocto Project Development Tasks Manual.
  316. </para></listitem>
  317. <listitem><para>
  318. <emphasis>Exit QEMU:</emphasis>
  319. Exit QEMU by either clicking on the shutdown icon or by
  320. typing <filename>Ctrl-C</filename> in the QEMU
  321. transcript window from which you evoked QEMU.
  322. </para></listitem>
  323. </orderedlist>
  324. </para>
  325. </section>
  326. <section id='customizing-your-build-for-specific-hardware'>
  327. <title>Customizing Your Build for Specific Hardware</title>
  328. <para>
  329. So far, all you have done is quickly built an image suitable
  330. for emulation only.
  331. This section shows you how to customize your build for specific
  332. hardware by adding a hardware layer into the Yocto Project
  333. development environment.
  334. </para>
  335. <para>
  336. In general, layers are repositories that contain related sets of
  337. instructions and configurations that tell the Yocto Project what
  338. to do.
  339. Isolating related metadata into functionally specific layers
  340. facilitates modular development and makes it easier to reuse the
  341. layer metadata.
  342. <note>
  343. By convention, layer names start with the string "meta-".
  344. </note>
  345. </para>
  346. <para>
  347. Follow these steps to add a hardware layer:
  348. <orderedlist>
  349. <listitem><para>
  350. <emphasis>Find a Layer:</emphasis>
  351. Lots of hardware layers exist.
  352. The Yocto Project
  353. <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink>
  354. has many hardware layers.
  355. This example adds the
  356. <ulink url='https://github.com/kraj/meta-altera'>meta-altera</ulink>
  357. hardware layer.
  358. </para></listitem>
  359. <listitem><para>
  360. <emphasis>Clone the Layer</emphasis>
  361. Use Git to make a local copy of the layer on your machine.
  362. You can put the copy in the top level of the copy of the
  363. Poky repository created earlier:
  364. <literallayout class='monospaced'>
  365. $ git clone https://github.com/kraj/meta-altera.git
  366. Cloning into 'meta-altera'...
  367. remote: Enumerating objects: 219, done.
  368. remote: Counting objects: 100% (219/219), done.
  369. remote: Compressing objects: 100% (116/116), done.
  370. remote: Total 1463 (delta 111), reused 172 (delta 79), pack-reused 1244
  371. Receiving objects: 100% (1463/1463), 211.60 KiB | 0 bytes/s, done.
  372. Resolving deltas: 100% (706/706), done.
  373. Checking connectivity... done. </literallayout>
  374. The hardware layer now exists with other layers inside
  375. the Poky reference repository on your build host as
  376. <filename>meta-altera</filename> and contains all the
  377. metadata needed to support hardware from Altera, which
  378. is owned by Intel.
  379. </para></listitem>
  380. <listitem><para>
  381. <emphasis>Change the Configuration to Build for a Specific Machine:</emphasis>
  382. The
  383. <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>
  384. variable in the <filename>local.conf</filename> file
  385. specifies the machine for the build.
  386. For this example, set the <filename>MACHINE</filename>
  387. variable to "cyclone5".
  388. These configurations are used:
  389. <ulink url='https://github.com/kraj/meta-altera/blob/master/conf/machine/cyclone5.conf'></ulink>.
  390. <note>
  391. See the
  392. "<link linkend='conf-file-step'>Examine Your Local Configuration File</link>"
  393. step earlier for more information on configuring the
  394. build.
  395. </note>
  396. </para></listitem>
  397. <listitem><para>
  398. <emphasis>Add Your Layer to the Layer Configuration File:</emphasis>
  399. Before you can use a layer during a build, you must add it
  400. to your <filename>bblayers.conf</filename> file, which
  401. is found in the
  402. <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory's</ulink>
  403. <filename>conf</filename> directory.</para>
  404. <para>Use the <filename>bitbake-layers add-layer</filename>
  405. command to add the layer to the configuration file:
  406. <literallayout class='monospaced'>
  407. $ cd ~/poky/build
  408. $ bitbake-layers add-layer ../meta-altera
  409. NOTE: Starting bitbake server...
  410. </literallayout>
  411. You can find more information on adding layers in the
  412. "<ulink url='&YOCTO_DOCS_DEV_URL;#adding-a-layer-using-the-bitbake-layers-script'>Adding a Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  413. section.
  414. </para></listitem>
  415. </orderedlist>
  416. Completing these steps has added the
  417. <filename>meta-altera</filename> layer to your Yocto Project
  418. development environment and configured it to build for the
  419. "cyclone5" machine.
  420. <note>
  421. The previous steps are for demonstration purposes only.
  422. If you were to attempt to build an image for the
  423. "cyclone5" build, you should read the Altera
  424. <filename>README</filename>.
  425. </note>
  426. </para>
  427. </section>
  428. <section id='creating-your-own-general-layer'>
  429. <title>Creating Your Own General Layer</title>
  430. <para>
  431. Maybe you have an application or specific set of behaviors you
  432. need to isolate.
  433. You can create your own general layer using the
  434. <filename>bitbake-layers create-layer</filename> command.
  435. The tool automates layer creation by setting up a
  436. subdirectory with a <filename>layer.conf</filename>
  437. configuration file, a <filename>recipes-example</filename>
  438. subdirectory that contains an <filename>example.bb</filename>
  439. recipe, a licensing file, and a <filename>README</filename>.
  440. </para>
  441. <para>
  442. The following commands run the tool to create a layer named
  443. <filename>meta-mylayer</filename> in the
  444. <filename>poky</filename> directory:
  445. <literallayout class='monospaced'>
  446. $ cd ~/poky
  447. $ bitbake-layers create-layer meta-mylayer
  448. NOTE: Starting bitbake server...
  449. Add your new layer with 'bitbake-layers add-layer meta-mylayer'
  450. </literallayout>
  451. For more information on layers and how to create them, see the
  452. "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-general-layer-using-the-bitbake-layers-script'>Creating a General Layer Using the <filename>bitbake-layers</filename> Script</ulink>"
  453. section in the Yocto Project Development Tasks Manual.
  454. </para>
  455. </section>
  456. <section id='brief-where-to-go-next'>
  457. <title>Where To Go Next</title>
  458. <para>
  459. Now that you have experienced using the Yocto Project, you might
  460. be asking yourself "What now?"
  461. The Yocto Project has many sources of information including
  462. the website, wiki pages, and user manuals:
  463. <itemizedlist>
  464. <listitem><para>
  465. <emphasis>Website:</emphasis>
  466. The
  467. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>
  468. provides background information, the latest builds,
  469. breaking news, full development documentation, and
  470. access to a rich Yocto Project Development Community
  471. into which you can tap.
  472. </para></listitem>
  473. <listitem><para>
  474. <emphasis>Developer Screencast:</emphasis>
  475. The
  476. <ulink url='http://vimeo.com/36450321'>Getting Started with the Yocto Project - New Developer Screencast Tutorial</ulink>
  477. provides a 30-minute video created for users unfamiliar
  478. with the Yocto Project but familiar with Linux build
  479. hosts.
  480. While this screencast is somewhat dated, the
  481. introductory and fundamental concepts are useful for
  482. the beginner.
  483. </para></listitem>
  484. <listitem><para>
  485. <emphasis>Yocto Project Overview and Concepts Manual:</emphasis>
  486. The
  487. <ulink url='&YOCTO_DOCS_OM_URL;'>Yocto Project Overview and Concepts Manual</ulink>
  488. is a great place to start to learn about the
  489. Yocto Project.
  490. This manual introduces you to the Yocto Project and its
  491. development environment.
  492. The manual also provides conceptual information for
  493. various aspects of the Yocto Project.
  494. </para></listitem>
  495. <listitem><para>
  496. <emphasis>Yocto Project Wiki:</emphasis>
  497. The
  498. <ulink url='&YOCTO_WIKI_URL;'>Yocto Project Wiki</ulink>
  499. provides additional information on where to go next
  500. when ramping up with the Yocto Project, release
  501. information, project planning, and QA information.
  502. </para></listitem>
  503. <listitem><para>
  504. <emphasis>Yocto Project Mailing Lists:</emphasis>
  505. Related mailing lists provide a forum for discussion,
  506. patch submission and announcements.
  507. Several mailing lists exist and are grouped according
  508. to areas of concern.
  509. See the
  510. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-mailinglist'>Mailing lists</ulink>"
  511. section in the Yocto Project Reference Manual for a
  512. complete list of Yocto Project mailing lists.
  513. </para></listitem>
  514. <listitem><para>
  515. <emphasis>Comprehensive List of Links and Other Documentation:</emphasis>
  516. The
  517. "<ulink url='&YOCTO_DOCS_REF_URL;#resources-links-and-related-documentation'>Links and Related Documentation</ulink>"
  518. section in the Yocto Project Reference Manual provides a
  519. comprehensive list of all related links and other
  520. user documentation.
  521. </para></listitem>
  522. </itemizedlist>
  523. </para>
  524. </section>
  525. </article>
  526. <!--
  527. vim: expandtab tw=80 ts=4
  528. -->