dev-manual-start.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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.6 or 2.7).
  67. See "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The 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></listitem>
  120. <listitem id='local-kernel-files'><para><emphasis>Yocto Project Kernel:</emphasis>
  121. If you are going to be making modifications to a supported Yocto Project kernel, you
  122. need to establish local copies of the source.
  123. You can find Git repositories of supported Yocto Project kernels organized under
  124. "Yocto Linux Kernel" in the Yocto Project Source Repositories at
  125. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
  126. <para>This setup can involve creating a bare clone of the Yocto Project kernel and then
  127. copying that cloned repository.
  128. You can create the bare clone and the copy of the bare clone anywhere you like.
  129. For simplicity, it is recommended that you create these structures outside of the
  130. Source Directory, which is usually named <filename>poky</filename>.</para>
  131. <para>As an example, the following transcript shows how to create the bare clone
  132. of the <filename>linux-yocto-3.10</filename> kernel and then create a copy of
  133. that clone.
  134. <note>When you have a local Yocto Project kernel Git repository, you can
  135. reference that repository rather than the upstream Git repository as
  136. part of the <filename>clone</filename> command.
  137. Doing so can speed up the process.</note></para>
  138. <para>In the following example, the bare clone is named
  139. <filename>linux-yocto-3.10.git</filename>, while the
  140. copy is named <filename>my-linux-yocto-3.10-work</filename>:
  141. <literallayout class='monospaced'>
  142. $ git clone --bare git://git.yoctoproject.org/linux-yocto-3.10 linux-yocto-3.10.git
  143. Cloning into bare repository 'linux-yocto-3.10.git'...
  144. remote: Counting objects: 3364487, done.
  145. remote: Compressing objects: 100% (507178/507178), done.
  146. remote: Total 3364487 (delta 2827715), reused 3364481 (delta 2827709)
  147. Receiving objects: 100% (3364487/3364487), 722.95 MiB | 423 KiB/s, done.
  148. Resolving deltas: 100% (2827715/2827715), done.
  149. </literallayout></para>
  150. <para>Now create a clone of the bare clone just created:
  151. <literallayout class='monospaced'>
  152. $ git clone linux-yocto-3.10.git my-linux-yocto-3.10-work
  153. Cloning into 'my-linux-yocto-3.10-work'...
  154. done.
  155. </literallayout></para></listitem>
  156. <listitem id='meta-yocto-kernel-extras-repo'><para><emphasis>
  157. The <filename>meta-yocto-kernel-extras</filename> Git Repository</emphasis>:
  158. The <filename>meta-yocto-kernel-extras</filename> Git repository contains Metadata needed
  159. only if you are modifying and building the kernel image.
  160. In particular, it contains the kernel BitBake append (<filename>.bbappend</filename>)
  161. files that you
  162. edit to point to your locally modified kernel source files and to build the kernel
  163. image.
  164. Pointing to these local files is much more efficient than requiring a download of the
  165. kernel's source files from upstream each time you make changes to the kernel.</para>
  166. <para>You can find the <filename>meta-yocto-kernel-extras</filename> Git Repository in the
  167. "Yocto Metadata Layers" area of the Yocto Project Source Repositories at
  168. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.
  169. It is good practice to create this Git repository inside the Source Directory.</para>
  170. <para>Following is an example that creates the <filename>meta-yocto-kernel-extras</filename> Git
  171. repository inside the Source Directory, which is named <filename>poky</filename>
  172. in this case:
  173. <literallayout class='monospaced'>
  174. $ cd ~/poky
  175. $ git clone git://git.yoctoproject.org/meta-yocto-kernel-extras meta-yocto-kernel-extras
  176. Cloning into 'meta-yocto-kernel-extras'...
  177. remote: Counting objects: 727, done.
  178. remote: Compressing objects: 100% (452/452), done.
  179. remote: Total 727 (delta 260), reused 719 (delta 252)
  180. Receiving objects: 100% (727/727), 536.36 KiB | 240 KiB/s, done.
  181. Resolving deltas: 100% (260/260), done.
  182. </literallayout></para></listitem>
  183. <listitem><para id='supported-board-support-packages-(bsps)'><emphasis>Supported Board Support Packages (BSPs):</emphasis>
  184. The Yocto Project supports many BSPs, which are maintained in
  185. their own layers or in layers designed to contain several
  186. BSPs.
  187. To get an idea of machine support through BSP layers, you can
  188. look at the
  189. <ulink url='&YOCTO_RELEASE_DL_URL;/machines'>index of machines</ulink>
  190. for the release.</para>
  191. <para>The Yocto Project uses the following BSP layer naming
  192. scheme:
  193. <literallayout class='monospaced'>
  194. meta-<replaceable>bsp_name</replaceable>
  195. </literallayout>
  196. where <replaceable>bsp_name</replaceable> is the recognized
  197. BSP name.
  198. Here are some examples:
  199. <literallayout class='monospaced'>
  200. meta-crownbay
  201. meta-emenlow
  202. meta-n450
  203. </literallayout>
  204. See the
  205. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  206. section in the Yocto Project Board Support Package (BSP)
  207. Developer's Guide for more information on BSP Layers.</para>
  208. <para>A useful Git repository released with the Yocto
  209. Project is <filename>meta-intel</filename>, which is a
  210. parent layer that contains many supported
  211. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>.
  212. You can locate the <filename>meta-intel</filename> Git
  213. repository in the "Yocto Metadata Layers" area of the Yocto
  214. Project Source Repositories at
  215. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
  216. <para>Using
  217. <link linkend='git'>Git</link> to create a local clone of the
  218. upstream repository can be helpful if you are working with
  219. BSPs.
  220. Typically, you set up the <filename>meta-intel</filename>
  221. Git repository inside the Source Directory.
  222. For example, the following transcript shows the steps to clone
  223. <filename>meta-intel</filename>.
  224. <note>
  225. Be sure to work in the <filename>meta-intel</filename>
  226. branch that matches your
  227. <link linkend='source-directory'>Source Directory</link>
  228. (i.e. <filename>poky</filename>) branch.
  229. For example, if you have checked out the "master" branch
  230. of <filename>poky</filename> and you are going to use
  231. <filename>meta-intel</filename>, be sure to checkout the
  232. "master" branch of <filename>meta-intel</filename>.
  233. </note>
  234. <literallayout class='monospaced'>
  235. $ cd ~/poky
  236. $ git clone git://git.yoctoproject.org/meta-intel.git
  237. Cloning into 'meta-intel'...
  238. remote: Counting objects: 8844, done.
  239. remote: Compressing objects: 100% (2864/2864), done.
  240. remote: Total 8844 (delta 4931), reused 8780 (delta 4867)
  241. Receiving objects: 100% (8844/8844), 2.48 MiB | 264 KiB/s, done.
  242. Resolving deltas: 100% (4931/4931), done.
  243. </literallayout></para>
  244. <para>The same
  245. <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>wiki page</ulink>
  246. referenced earlier covers how to set up the
  247. <filename>meta-intel</filename> Git repository.
  248. </para></listitem>
  249. <listitem><para><emphasis>Eclipse Yocto Plug-in:</emphasis> If you are developing
  250. applications using the Eclipse Integrated Development Environment (IDE),
  251. you will need this plug-in.
  252. See the
  253. "<link linkend='setting-up-the-eclipse-ide'>Setting up the Eclipse IDE</link>"
  254. section for more information.</para></listitem>
  255. </itemizedlist>
  256. </para>
  257. </section>
  258. <section id='building-images'>
  259. <title>Building Images</title>
  260. <para>
  261. The build process creates an entire Linux distribution, including the toolchain, from source.
  262. For more information on this topic, see the
  263. "<ulink url='&YOCTO_DOCS_QS_URL;#building-image'>Building an Image</ulink>"
  264. section in the Yocto Project Quick Start.
  265. </para>
  266. <para>
  267. The build process is as follows:
  268. <orderedlist>
  269. <listitem><para>Make sure you have set up the Source Directory described in the
  270. previous section.</para></listitem>
  271. <listitem><para>Initialize the build environment by sourcing a build
  272. environment script (i.e.
  273. <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>
  274. or
  275. <ulink url='&YOCTO_DOCS_REF_URL;#structure-memres-core-script'><filename>oe-init-build-env-memres</filename></ulink>).
  276. </para></listitem>
  277. <listitem><para>Optionally ensure the <filename>conf/local.conf</filename> configuration file,
  278. which is found in the
  279. <link linkend='build-directory'>Build Directory</link>,
  280. is set up how you want it.
  281. This file defines many aspects of the build environment including
  282. the target machine architecture through the
  283. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable,
  284. the development machine's processor use through the
  285. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'>BB_NUMBER_THREADS</ulink></filename> and
  286. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'>PARALLEL_MAKE</ulink></filename> variables, and
  287. a centralized tarball download directory through the
  288. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'>DL_DIR</ulink></filename> variable.</para></listitem>
  289. <listitem><para>
  290. Build the image using the <filename>bitbake</filename> command.
  291. If you want information on BitBake, see the
  292. <ulink url='&YOCTO_DOCS_BB_URL;'>BitBake User Manual</ulink>.
  293. </para></listitem>
  294. <listitem><para>Run the image either on the actual hardware or using the QEMU
  295. emulator.</para></listitem>
  296. </orderedlist>
  297. </para>
  298. </section>
  299. <section id='using-pre-built-binaries-and-qemu'>
  300. <title>Using Pre-Built Binaries and QEMU</title>
  301. <para>
  302. Another option you have to get started is to use pre-built binaries.
  303. The Yocto Project provides many types of binaries with each release.
  304. See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  305. chapter in the Yocto Project Reference Manual
  306. for descriptions of the types of binaries that ship with a Yocto Project
  307. release.
  308. </para>
  309. <para>
  310. Using a pre-built binary is ideal for developing software applications to run on your
  311. target hardware.
  312. To do this, you need to be able to access the appropriate cross-toolchain tarball for
  313. the architecture on which you are developing.
  314. If you are using an SDK type image, the image ships with the complete toolchain native to
  315. the architecture.
  316. If you are not using an SDK type image, you need to separately download and
  317. install the stand-alone Yocto Project cross-toolchain tarball.
  318. </para>
  319. <para>
  320. Regardless of the type of image you are using, you need to download the pre-built kernel
  321. that you will boot in the QEMU emulator and then download and extract the target root
  322. filesystem for your target machine’s architecture.
  323. You can get architecture-specific binaries and file systems from
  324. <ulink url='&YOCTO_MACHINES_DL_URL;'>machines</ulink>.
  325. You can get installation scripts for stand-alone toolchains from
  326. <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'>toolchains</ulink>.
  327. Once you have all your files, you set up the environment to emulate the hardware
  328. by sourcing an environment setup script.
  329. Finally, you start the QEMU emulator.
  330. You can find details on all these steps in the
  331. "<ulink url='&YOCTO_DOCS_QS_URL;#using-pre-built'>Using Pre-Built Binaries and QEMU</ulink>"
  332. section of the Yocto Project Quick Start.
  333. You can learn more about using QEMU with the Yocto Project in the
  334. "<link linkend='dev-manual-qemu'>Using the Quick EMUlator (QEMU)</link>"
  335. section.
  336. </para>
  337. <para>
  338. Using QEMU to emulate your hardware can result in speed issues
  339. depending on the target and host architecture mix.
  340. For example, using the <filename>qemux86</filename> image in the emulator
  341. on an Intel-based 32-bit (x86) host machine is fast because the target and
  342. host architectures match.
  343. On the other hand, using the <filename>qemuarm</filename> image on the same Intel-based
  344. host can be slower.
  345. But, you still achieve faithful emulation of ARM-specific issues.
  346. </para>
  347. <para>
  348. To speed things up, the QEMU images support using <filename>distcc</filename>
  349. to call a cross-compiler outside the emulated system.
  350. If you used <filename>runqemu</filename> to start QEMU, and the
  351. <filename>distccd</filename> application is present on the host system, any
  352. BitBake cross-compiling toolchain available from the build system is automatically
  353. used from within QEMU simply by calling <filename>distcc</filename>.
  354. You can accomplish this by defining the cross-compiler variable
  355. (e.g. <filename>export CC="distcc"</filename>).
  356. Alternatively, if you are using a suitable SDK image or the appropriate
  357. stand-alone toolchain is present,
  358. the toolchain is also automatically used.
  359. </para>
  360. <note>
  361. Several mechanisms exist that let you connect to the system running on the
  362. QEMU emulator:
  363. <itemizedlist>
  364. <listitem><para>QEMU provides a framebuffer interface that makes standard
  365. consoles available.</para></listitem>
  366. <listitem><para>Generally, headless embedded devices have a serial port.
  367. If so, you can configure the operating system of the running image
  368. to use that port to run a console.
  369. The connection uses standard IP networking.</para></listitem>
  370. <listitem><para>
  371. SSH servers exist in some QEMU images.
  372. The <filename>core-image-sato</filename> QEMU image has a
  373. Dropbear secure shell (SSH) server that runs with the root
  374. password disabled.
  375. The <filename>core-image-full-cmdline</filename> and
  376. <filename>core-image-lsb</filename> QEMU images
  377. have OpenSSH instead of Dropbear.
  378. Including these SSH servers allow you to use standard
  379. <filename>ssh</filename> and <filename>scp</filename> commands.
  380. The <filename>core-image-minimal</filename> QEMU image,
  381. however, contains no SSH server.
  382. </para></listitem>
  383. <listitem><para>You can use a provided, user-space NFS server to boot the QEMU session
  384. using a local copy of the root filesystem on the host.
  385. In order to make this connection, you must extract a root filesystem tarball by using the
  386. <filename>runqemu-extract-sdk</filename> command.
  387. After running the command, you must then point the <filename>runqemu</filename>
  388. script to the extracted directory instead of a root filesystem image file.</para></listitem>
  389. </itemizedlist>
  390. </note>
  391. </section>
  392. </chapter>
  393. <!--
  394. vim: expandtab tw=80 ts=4
  395. -->