dev-manual-start.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <!DOCTYPE chapter 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. <chapter id='dev-manual-start'>
  5. <title>Getting Started with the Yocto Project</title>
  6. <para>
  7. This chapter introduces the Yocto Project and gives you an idea of what you need to get started.
  8. You can find enough information to set up your development host and build or use images for
  9. hardware supported by the Yocto Project by reading the
  10. <ulink url='&YOCTO_DOCS_QS_URL;'>Yocto Project Quick Start</ulink>.
  11. </para>
  12. <para>
  13. The remainder of this chapter summarizes what is in the Yocto Project Quick Start and provides
  14. some higher-level concepts you might want to consider.
  15. </para>
  16. <section id='introducing-the-yocto-project'>
  17. <title>Introducing the Yocto Project</title>
  18. <para>
  19. The Yocto Project is an open-source collaboration project focused on embedded Linux development.
  20. The project currently provides a build system that is
  21. referred to as the
  22. <link linkend='build-system-term'>OpenEmbedded build system</link>
  23. in the Yocto Project documentation.
  24. The Yocto Project provides various ancillary tools for the embedded developer
  25. and also features the Sato reference User Interface, which is optimized for
  26. stylus-driven, low-resolution screens.
  27. </para>
  28. <para>
  29. You can use the OpenEmbedded build system, which uses
  30. <link linkend='bitbake-term'>BitBake</link>, to develop complete Linux
  31. images and associated user-space applications for architectures based
  32. on ARM, MIPS, PowerPC, x86 and x86-64.
  33. <note>
  34. By default, using the Yocto Project creates a Poky distribution.
  35. However, you can create your own distribution by providing key
  36. <link linkend='metadata'>Metadata</link>.
  37. See the "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  38. section for more information.
  39. </note>
  40. While the Yocto Project does not provide a strict testing framework,
  41. it does provide or generate for you artifacts that let you perform target-level and
  42. emulated testing and debugging.
  43. Additionally, if you are an <trademark class='trade'>Eclipse</trademark>
  44. IDE user, you can install an Eclipse Yocto Plug-in to allow you to
  45. develop within that familiar environment.
  46. </para>
  47. </section>
  48. <section id='getting-setup'>
  49. <title>Getting Set Up</title>
  50. <para>
  51. Here is what you need to use the Yocto Project:
  52. <itemizedlist>
  53. <listitem><para><emphasis>Host System:</emphasis> You should have a reasonably current
  54. Linux-based host system.
  55. You will have the best results with a recent release of Fedora,
  56. openSUSE, Debian, Ubuntu, or CentOS as these releases are frequently tested against the Yocto Project
  57. and officially supported.
  58. For a list of the distributions under validation and their status, see the
  59. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" section
  60. in the Yocto Project Reference Manual and the wiki page at
  61. <ulink url='&YOCTO_WIKI_URL;/wiki/Distribution_Support'>Distribution Support</ulink>.</para>
  62. <para>
  63. You should also have about 50 Gbytes of free disk space for building images.
  64. </para></listitem>
  65. <listitem><para><emphasis>Packages:</emphasis> The OpenEmbedded build system
  66. requires that certain packages exist on your development system (e.g. Python 2.7).
  67. See "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Build Host Packages</ulink>"
  68. section in the Yocto Project Quick Start and the
  69. "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>"
  70. section in the Yocto Project Reference Manual for the exact
  71. package requirements and the installation commands to install
  72. them for the supported distributions.
  73. </para></listitem>
  74. <listitem id='local-yp-release'><para><emphasis>Yocto Project Release:</emphasis>
  75. You need a release of the Yocto Project locally installed on
  76. your development system.
  77. The documentation refers to this set of locally installed files
  78. as the <link linkend='source-directory'>Source Directory</link>.
  79. You create your Source Directory by using
  80. <link linkend='git'>Git</link> to clone a local copy
  81. of the upstream <filename>poky</filename> repository,
  82. or by downloading and unpacking a tarball of an official
  83. Yocto Project release.
  84. The preferred method is to create a clone of the repository.
  85. </para>
  86. <para>Working from a copy of the upstream repository allows you
  87. to contribute back into the Yocto Project or simply work with
  88. the latest software on a development branch.
  89. Because Git maintains and creates an upstream repository with
  90. a complete history of changes and you are working with a local
  91. clone of that repository, you have access to all the Yocto
  92. Project development branches and tag names used in the upstream
  93. repository.</para>
  94. <note>You can view the Yocto Project Source Repositories at
  95. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>
  96. </note>
  97. <para>The following transcript shows how to clone the
  98. <filename>poky</filename> Git repository into the current
  99. working directory.
  100. The command creates the local repository in a directory
  101. named <filename>poky</filename>.
  102. For information on Git used within the Yocto Project, see
  103. the "<link linkend='git'>Git</link>" section.
  104. <literallayout class='monospaced'>
  105. $ git clone git://git.yoctoproject.org/poky
  106. Cloning into 'poky'...
  107. remote: Counting objects: 226790, done.
  108. remote: Compressing objects: 100% (57465/57465), done.
  109. remote: Total 226790 (delta 165212), reused 225887 (delta 164327)
  110. Receiving objects: 100% (226790/226790), 100.98 MiB | 263 KiB/s, done.
  111. Resolving deltas: 100% (165212/165212), done.
  112. </literallayout></para>
  113. <para>For another example of how to set up your own local Git
  114. repositories, see this
  115. <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>
  116. wiki page</ulink>, which describes how to create local
  117. Git repositories for both
  118. <filename>poky</filename> and <filename>meta-intel</filename>.
  119. </para>
  120. <para>
  121. You can also get the Yocto Project Files by downloading
  122. Yocto Project releases from the
  123. <ulink url="&YOCTO_HOME_URL;">Yocto Project website</ulink>.
  124. From the website, you just click "Downloads" in the navigation
  125. pane to the left to display all Yocto Project downloads.
  126. Current and archived releases are available for download.
  127. Nightly and developmental builds are also maintained at
  128. <ulink url="&YOCTO_AB_NIGHTLY_URL;"></ulink>.
  129. One final site you can visit for information on Yocto Project
  130. releases is the
  131. <ulink url='&YOCTO_WIKI_URL;/wiki/Releases'>Releases</ulink>
  132. wiki.
  133. </para></listitem>
  134. <listitem id='local-kernel-files'><para><emphasis>Yocto Project Kernel:</emphasis>
  135. If you are going to be making modifications to a supported Yocto Project kernel, you
  136. need to establish local copies of the source.
  137. You can find Git repositories of supported Yocto Project kernels organized under
  138. "Yocto Linux Kernel" in the Yocto Project Source Repositories at
  139. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
  140. <para>This setup can involve creating a bare clone of the Yocto Project kernel and then
  141. copying that cloned repository.
  142. You can create the bare clone and the copy of the bare clone anywhere you like.
  143. For simplicity, it is recommended that you create these structures outside of the
  144. Source Directory, which is usually named <filename>poky</filename>.</para>
  145. <para>As an example, the following transcript shows how to create the bare clone
  146. of the <filename>linux-yocto-3.19</filename> kernel and then create a copy of
  147. that clone.
  148. <note>When you have a local Yocto Project kernel Git repository, you can
  149. reference that repository rather than the upstream Git repository as
  150. part of the <filename>clone</filename> command.
  151. Doing so can speed up the process.</note></para>
  152. <para>In the following example, the bare clone is named
  153. <filename>linux-yocto-3.19.git</filename>, while the
  154. copy is named <filename>my-linux-yocto-3.19-work</filename>:
  155. <literallayout class='monospaced'>
  156. $ git clone --bare git://git.yoctoproject.org/linux-yocto-3.19 linux-yocto-3.19.git
  157. Cloning into bare repository 'linux-yocto-3.19.git'...
  158. remote: Counting objects: 3983256, done.
  159. remote: Compressing objects: 100% (605006/605006), done.
  160. remote: Total 3983256 (delta 3352832), reused 3974503 (delta 3344079)
  161. Receiving objects: 100% (3983256/3983256), 843.66 MiB | 1.07 MiB/s, done.
  162. Resolving deltas: 100% (3352832/3352832), done.
  163. Checking connectivity... done.
  164. </literallayout></para>
  165. <para>Now create a clone of the bare clone just created:
  166. <literallayout class='monospaced'>
  167. $ git clone linux-yocto-3.19.git my-linux-yocto-3.19-work
  168. Cloning into 'my-linux-yocto-3.19-work'...
  169. done.
  170. Checking out files: 100% (48440/48440), done.
  171. </literallayout></para></listitem>
  172. <listitem id='meta-yocto-kernel-extras-repo'><para><emphasis>
  173. The <filename>meta-yocto-kernel-extras</filename> Git Repository</emphasis>:
  174. The <filename>meta-yocto-kernel-extras</filename> Git repository contains Metadata needed
  175. only if you are modifying and building the kernel image.
  176. In particular, it contains the kernel BitBake append (<filename>.bbappend</filename>)
  177. files that you
  178. edit to point to your locally modified kernel source files and to build the kernel
  179. image.
  180. Pointing to these local files is much more efficient than requiring a download of the
  181. kernel's source files from upstream each time you make changes to the kernel.</para>
  182. <para>You can find the <filename>meta-yocto-kernel-extras</filename> Git Repository in the
  183. "Yocto Metadata Layers" area of the Yocto Project Source Repositories at
  184. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.
  185. It is good practice to create this Git repository inside the Source Directory.</para>
  186. <para>Following is an example that creates the <filename>meta-yocto-kernel-extras</filename> Git
  187. repository inside the Source Directory, which is named <filename>poky</filename>
  188. in this case:
  189. <literallayout class='monospaced'>
  190. $ cd ~/poky
  191. $ git clone git://git.yoctoproject.org/meta-yocto-kernel-extras meta-yocto-kernel-extras
  192. Cloning into 'meta-yocto-kernel-extras'...
  193. remote: Counting objects: 727, done.
  194. remote: Compressing objects: 100% (452/452), done.
  195. remote: Total 727 (delta 260), reused 719 (delta 252)
  196. Receiving objects: 100% (727/727), 536.36 KiB | 240 KiB/s, done.
  197. Resolving deltas: 100% (260/260), done.
  198. </literallayout></para></listitem>
  199. <listitem><para id='supported-board-support-packages-(bsps)'><emphasis>Supported Board Support Packages (BSPs):</emphasis>
  200. The Yocto Project supports many BSPs, which are maintained in
  201. their own layers or in layers designed to contain several
  202. BSPs.
  203. To get an idea of machine support through BSP layers, you can
  204. look at the
  205. <ulink url='&YOCTO_RELEASE_DL_URL;/machines'>index of machines</ulink>
  206. for the release.</para>
  207. <para>The Yocto Project uses the following BSP layer naming
  208. scheme:
  209. <literallayout class='monospaced'>
  210. meta-<replaceable>bsp_name</replaceable>
  211. </literallayout>
  212. where <replaceable>bsp_name</replaceable> is the recognized
  213. BSP name.
  214. Here is an example:
  215. <literallayout class='monospaced'>
  216. meta-raspberrypi
  217. </literallayout>
  218. See the
  219. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  220. section in the Yocto Project Board Support Package (BSP)
  221. Developer's Guide for more information on BSP Layers.</para>
  222. <para>A useful Git repository released with the Yocto
  223. Project is <filename>meta-intel</filename>, which is a
  224. parent layer that contains many supported
  225. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>.
  226. You can locate the <filename>meta-intel</filename> Git
  227. repository in the "Yocto Metadata Layers" area of the Yocto
  228. Project Source Repositories at
  229. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
  230. <para>Using
  231. <link linkend='git'>Git</link> to create a local clone of the
  232. upstream repository can be helpful if you are working with
  233. BSPs.
  234. Typically, you set up the <filename>meta-intel</filename>
  235. Git repository inside the Source Directory.
  236. For example, the following transcript shows the steps to clone
  237. <filename>meta-intel</filename>.
  238. <note>
  239. Be sure to work in the <filename>meta-intel</filename>
  240. branch that matches your
  241. <link linkend='source-directory'>Source Directory</link>
  242. (i.e. <filename>poky</filename>) branch.
  243. For example, if you have checked out the "master" branch
  244. of <filename>poky</filename> and you are going to use
  245. <filename>meta-intel</filename>, be sure to checkout the
  246. "master" branch of <filename>meta-intel</filename>.
  247. </note>
  248. <literallayout class='monospaced'>
  249. $ cd ~/poky
  250. $ git clone git://git.yoctoproject.org/meta-intel.git
  251. Cloning into 'meta-intel'...
  252. remote: Counting objects: 11917, done.
  253. remote: Compressing objects: 100% (3842/3842), done.
  254. remote: Total 11917 (delta 6840), reused 11699 (delta 6622)
  255. Receiving objects: 100% (11917/11917), 2.92 MiB | 2.88 MiB/s, done.
  256. Resolving deltas: 100% (6840/6840), done.
  257. Checking connectivity... done.
  258. </literallayout></para>
  259. <para>The same
  260. <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>wiki page</ulink>
  261. referenced earlier covers how to set up the
  262. <filename>meta-intel</filename> Git repository.
  263. </para></listitem>
  264. <listitem><para><emphasis>Eclipse Yocto Plug-in:</emphasis> If you are developing
  265. applications using the Eclipse Integrated Development Environment (IDE),
  266. you will need this plug-in.
  267. See the
  268. "<ulink url='&YOCTO_DOCS_SDK_URL;#setting-up-the-eclipse-ide'>Setting up the Eclipse IDE</ulink>"
  269. section in the Yocto Project Software Development Kit (SDK)
  270. Developer's Guide for more information.</para></listitem>
  271. </itemizedlist>
  272. </para>
  273. </section>
  274. <section id='building-images'>
  275. <title>Building Images</title>
  276. <para>
  277. The build process creates an entire Linux distribution, including the toolchain, from source.
  278. For more information on this topic, see the
  279. "<ulink url='&YOCTO_DOCS_QS_URL;#qs-building-images'>Building Images</ulink>"
  280. section in the Yocto Project Quick Start.
  281. </para>
  282. <para>
  283. The build process is as follows:
  284. <orderedlist>
  285. <listitem><para>Make sure you have set up the Source Directory described in the
  286. previous section.</para></listitem>
  287. <listitem><para>Initialize the build environment by sourcing a build
  288. environment script (i.e.
  289. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  290. or
  291. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>).
  292. </para></listitem>
  293. <listitem><para>Optionally ensure the <filename>conf/local.conf</filename> configuration file,
  294. which is found in the
  295. <link linkend='build-directory'>Build Directory</link>,
  296. is set up how you want it.
  297. This file defines many aspects of the build environment including
  298. the target machine architecture through the
  299. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable,
  300. the packaging format used during the build
  301. (<ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>),
  302. and a centralized tarball download directory through the
  303. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'>DL_DIR</ulink></filename> variable.</para></listitem>
  304. <listitem><para>
  305. Build the image using the <filename>bitbake</filename> command.
  306. If you want information on BitBake, see the
  307. <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
  308. </para></listitem>
  309. <listitem><para>Run the image either on the actual hardware or using the QEMU
  310. emulator.</para></listitem>
  311. </orderedlist>
  312. </para>
  313. </section>
  314. <section id='using-pre-built-binaries-and-qemu'>
  315. <title>Using Pre-Built Binaries and QEMU</title>
  316. <para>
  317. Another option you have to get started is to use pre-built binaries.
  318. The Yocto Project provides many types of binaries with each release.
  319. See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  320. chapter in the Yocto Project Reference Manual
  321. for descriptions of the types of binaries that ship with a Yocto Project
  322. release.
  323. </para>
  324. <para>
  325. Using a pre-built binary is ideal for developing software
  326. applications to run on your target hardware.
  327. To do this, you need to be able to access the appropriate
  328. cross-toolchain tarball for the architecture on which you are
  329. developing.
  330. If you are using an SDK type image, the image ships with the complete
  331. toolchain native to the architecture (i.e. a toolchain designed to
  332. run on the
  333. <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>).
  334. If you are not using an SDK type image, you need to separately download
  335. and install the stand-alone Yocto Project cross-toolchain tarball.
  336. </para>
  337. <para>
  338. Regardless of the type of image you are using, you need to download the pre-built kernel
  339. that you will boot in the QEMU emulator and then download and extract the target root
  340. filesystem for your target machine’s architecture.
  341. You can get architecture-specific binaries and file systems from
  342. <ulink url='&YOCTO_MACHINES_DL_URL;'>machines</ulink>.
  343. You can get installation scripts for stand-alone toolchains from
  344. <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'>toolchains</ulink>.
  345. Once you have all your files, you set up the environment to emulate the hardware
  346. by sourcing an environment setup script.
  347. Finally, you start the QEMU emulator.
  348. You can find details on all these steps in the
  349. <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>.
  350. You can learn more about using QEMU with the Yocto Project in the
  351. "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
  352. section.
  353. </para>
  354. <para>
  355. Using QEMU to emulate your hardware can result in speed issues
  356. depending on the target and host architecture mix.
  357. For example, using the <filename>qemux86</filename> image in the emulator
  358. on an Intel-based 32-bit (x86) host machine is fast because the target and
  359. host architectures match.
  360. On the other hand, using the <filename>qemuarm</filename> image on the same Intel-based
  361. host can be slower.
  362. But, you still achieve faithful emulation of ARM-specific issues.
  363. </para>
  364. <para>
  365. To speed things up, the QEMU images support using <filename>distcc</filename>
  366. to call a cross-compiler outside the emulated system.
  367. If you used <filename>runqemu</filename> to start QEMU, and the
  368. <filename>distccd</filename> application is present on the host system, any
  369. BitBake cross-compiling toolchain available from the build system is automatically
  370. used from within QEMU simply by calling <filename>distcc</filename>.
  371. You can accomplish this by defining the cross-compiler variable
  372. (e.g. <filename>export CC="distcc"</filename>).
  373. Alternatively, if you are using a suitable SDK image or the appropriate
  374. stand-alone toolchain is present,
  375. the toolchain is also automatically used.
  376. </para>
  377. <note>
  378. Several mechanisms exist that let you connect to the system running on the
  379. QEMU emulator:
  380. <itemizedlist>
  381. <listitem><para>QEMU provides a framebuffer interface that makes standard
  382. consoles available.</para></listitem>
  383. <listitem><para>Generally, headless embedded devices have a serial port.
  384. If so, you can configure the operating system of the running image
  385. to use that port to run a console.
  386. The connection uses standard IP networking.</para></listitem>
  387. <listitem><para>
  388. SSH servers exist in some QEMU images.
  389. The <filename>core-image-sato</filename> QEMU image has a
  390. Dropbear secure shell (SSH) server that runs with the root
  391. password disabled.
  392. The <filename>core-image-full-cmdline</filename> and
  393. <filename>core-image-lsb</filename> QEMU images
  394. have OpenSSH instead of Dropbear.
  395. Including these SSH servers allow you to use standard
  396. <filename>ssh</filename> and <filename>scp</filename> commands.
  397. The <filename>core-image-minimal</filename> QEMU image,
  398. however, contains no SSH server.
  399. </para></listitem>
  400. <listitem><para>You can use a provided, user-space NFS server to boot the QEMU session
  401. using a local copy of the root filesystem on the host.
  402. In order to make this connection, you must extract a root filesystem tarball by using the
  403. <filename>runqemu-extract-sdk</filename> command.
  404. After running the command, you must then point the <filename>runqemu</filename>
  405. script to the extracted directory instead of a root filesystem image file.</para></listitem>
  406. </itemizedlist>
  407. </note>
  408. </section>
  409. </chapter>
  410. <!--
  411. vim: expandtab tw=80 ts=4
  412. -->