dev-manual-start.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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, which is
  21. referred to as the OpenEmbedded build system in the Yocto Project documentation.
  22. The Yocto Project provides various ancillary tools suitable for the embedded developer
  23. and also features the Sato reference User Interface, which is optimized for
  24. stylus driven, low-resolution screens.
  25. </para>
  26. <para>
  27. You can use the OpenEmbedded build system, which uses
  28. BitBake to develop complete Linux
  29. images and associated user-space applications for architectures based
  30. on ARM, MIPS, PowerPC, x86 and x86-64.
  31. <note>
  32. By default, using the Yocto Project creates a Poky distribution.
  33. However, you can create your own distribution by providing key
  34. <link linkend='metadata'>Metadata</link>.
  35. See the "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>"
  36. section for more information.
  37. </note>
  38. While the Yocto Project does not provide a strict testing framework,
  39. it does provide or generate for you artifacts that let you perform target-level and
  40. emulated testing and debugging.
  41. Additionally, if you are an <trademark class='trade'>Eclipse</trademark>
  42. IDE user, you can install an Eclipse Yocto Plug-in to allow you to
  43. develop within that familiar environment.
  44. </para>
  45. </section>
  46. <section id='getting-setup'>
  47. <title>Getting Set Up</title>
  48. <para>
  49. Here is what you need to get set up to use the Yocto Project:
  50. <itemizedlist>
  51. <listitem><para><emphasis>Host System:</emphasis> You should have a reasonably current
  52. Linux-based host system.
  53. You will have the best results with a recent release of Fedora,
  54. OpenSUSE, Debian, Ubuntu, or CentOS as these releases are frequently tested against the Yocto Project
  55. and officially supported.
  56. For a list of the distributions under validation and their status, see the
  57. "<ulink url='&YOCTO_DOCS_REF_URL;#detailed-supported-distros'>Supported Linux Distributions</ulink>" section
  58. in the Yocto Project Reference Manual and the wiki page at
  59. <ulink url='&YOCTO_WIKI_URL;/wiki/Distribution_Support'>Distribution Support</ulink>.</para>
  60. <para>
  61. You should also have about 100 gigabytes of free disk space for building images.
  62. </para></listitem>
  63. <listitem><para><emphasis>Packages:</emphasis> The OpenEmbedded build system
  64. requires certain packages exist on your development system (e.g. Python 2.6 or 2.7).
  65. See "<ulink url='&YOCTO_DOCS_QS_URL;#packages'>The Packages</ulink>"
  66. section in the Yocto Project Quick Start and the
  67. "<ulink url='&YOCTO_DOCS_REF_URL;#required-packages-for-the-host-development-system'>Required Packages for the Host Development System</ulink>"
  68. section in the Yocto Project Reference Manual for the exact
  69. package requirements and the installation commands to install
  70. them for the supported distributions.
  71. </para></listitem>
  72. <listitem id='local-yp-release'><para><emphasis>Yocto Project Release:</emphasis>
  73. You need a release of the Yocto Project.
  74. You set that up with a local <link linkend='source-directory'>Source Directory</link>
  75. one of two ways depending on whether you
  76. are going to contribute back into the Yocto Project or not.
  77. <note>
  78. Regardless of the method you use, this manual refers to the resulting local
  79. hierarchical set of files as the "Source Directory."
  80. </note>
  81. <itemizedlist>
  82. <listitem><para><emphasis>Tarball Extraction:</emphasis>
  83. If you are not going to contribute back into the Yocto
  84. Project, you can simply go to the
  85. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>,
  86. select the "Downloads" tab, and choose what you want.
  87. Once you have the tarball, just extract it into a
  88. directory of your choice.</para>
  89. <para>For example, the following command extracts the
  90. Yocto Project &DISTRO; release tarball
  91. into the current working directory and sets up the local Source Directory
  92. with a top-level folder named <filename>&YOCTO_POKY;</filename>:
  93. <literallayout class='monospaced'>
  94. $ tar xfj &YOCTO_POKY_TARBALL;
  95. </literallayout></para>
  96. <para>This method does not produce a local Git repository.
  97. Instead, you simply end up with a snapshot of the release.</para></listitem>
  98. <listitem><para><emphasis>Git Repository Method:</emphasis> If you are going to be contributing
  99. back into the Yocto Project or you simply want to keep up
  100. with the latest developments, you should use Git commands to set up a local
  101. Git repository of the upstream <filename>poky</filename> source repository.
  102. Doing so creates a repository with a complete history of changes and allows
  103. you to easily submit your changes upstream to the project.
  104. Because you clone the repository, you have access to all the Yocto Project development
  105. branches and tag names used in the upstream repository.</para>
  106. <note>You can view the Yocto Project Source Repositories at
  107. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink></note>
  108. <para>The following transcript shows how to clone the <filename>poky</filename>
  109. Git repository into the current working directory.
  110. The command creates the local repository in a directory named <filename>poky</filename>.
  111. For information on Git used within the Yocto Project, see the
  112. "<link linkend='git'>Git</link>" section.
  113. <literallayout class='monospaced'>
  114. $ git clone git://git.yoctoproject.org/poky
  115. Cloning into 'poky'...
  116. remote: Counting objects: 183981, done.
  117. remote: Compressing objects: 100% (47428/47428), done.
  118. remote: Total 183981 (delta 132271), reused 183703 (delta 132044)
  119. Receiving objects: 100% (183981/183981), 89.71 MiB | 2.93 MiB/s, done.
  120. Resolving deltas: 100% (132271/132271), done.
  121. </literallayout></para>
  122. <para>For another example of how to set up your own local Git repositories, see this
  123. <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>
  124. wiki page</ulink>, which describes how to create both <filename>poky</filename>
  125. and <filename>meta-intel</filename> Git repositories.</para></listitem>
  126. </itemizedlist></para></listitem>
  127. <listitem id='local-kernel-files'><para><emphasis>Yocto Project Kernel:</emphasis>
  128. If you are going to be making modifications to a supported Yocto Project kernel, you
  129. need to establish local copies of the source.
  130. You can find Git repositories of supported Yocto Project Kernels organized under
  131. "Yocto Linux Kernel" in the Yocto Project Source Repositories at
  132. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
  133. <para>This setup can involve creating a bare clone of the Yocto Project kernel and then
  134. copying that cloned repository.
  135. You can create the bare clone and the copy of the bare clone anywhere you like.
  136. For simplicity, it is recommended that you create these structures outside of the
  137. Source Directory (usually <filename>poky</filename>).</para>
  138. <para>As an example, the following transcript shows how to create the bare clone
  139. of the <filename>linux-yocto-3.8</filename> kernel and then create a copy of
  140. that clone.
  141. <note>When you have a local Yocto Project kernel Git repository, you can
  142. reference that repository rather than the upstream Git repository as
  143. part of the <filename>clone</filename> command.
  144. Doing so can speed up the process.</note></para>
  145. <para>In the following example, the bare clone is named
  146. <filename>linux-yocto-3.8.git</filename>, while the
  147. copy is named <filename>my-linux-yocto-3.8-work</filename>:
  148. <literallayout class='monospaced'>
  149. $ git clone --bare git://git.yoctoproject.org/linux-yocto-3.8 linux-yocto-3.8.git
  150. Cloning into bare repository 'linux-yocto-3.8.git'...
  151. remote: Counting objects: 2847090, done.
  152. remote: Compressing objects: 100% (454675/454675), done.
  153. remote: Total 2847090 (delta 2386170), reused 2825793 (delta 2364886)
  154. Receiving objects: 100% (2847090/2847090), 603.19 MiB | 3.54 MiB/s, done.
  155. Resolving deltas: 100% (2386170/2386170), done. </literallayout></para>
  156. <para>Now create a clone of the bare clone just created:
  157. <literallayout class='monospaced'>
  158. $ git clone linux-yocto-3.8.git my-linux-yocto-3.8-work
  159. Cloning into 'my-linux-yocto-3.8-work'...
  160. done.
  161. </literallayout></para></listitem>
  162. <listitem id='poky-extras-repo'><para><emphasis>
  163. The <filename>poky-extras</filename> Git Repository</emphasis>:
  164. The <filename>poky-extras</filename> Git repository contains Metadata needed
  165. only if you are modifying and building the kernel image.
  166. In particular, it contains the kernel BitBake append (<filename>.bbappend</filename>)
  167. files that you
  168. edit to point to your locally modified kernel source files and to build the kernel
  169. image.
  170. Pointing to these local files is much more efficient than requiring a download of the
  171. kernel's source files from upstream each time you make changes to the kernel.</para>
  172. <para>You can find the <filename>poky-extras</filename> Git Repository in the
  173. "Yocto Metadata Layers" area of the Yocto Project Source Repositories at
  174. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.
  175. It is good practice to create this Git repository inside the Source Directory.</para>
  176. <para>Following is an example that creates the <filename>poky-extras</filename> Git
  177. repository inside the Source Directory, which is named <filename>poky</filename>
  178. in this case:
  179. <literallayout class='monospaced'>
  180. $ cd ~/poky
  181. $ git clone git://git.yoctoproject.org/poky-extras poky-extras
  182. Cloning into 'poky-extras'...
  183. remote: Counting objects: 690, done.
  184. remote: Compressing objects: 100% (431/431), done.
  185. remote: Total 690 (delta 238), reused 690 (delta 238)
  186. Receiving objects: 100% (690/690), 532.60 KiB, done.
  187. Resolving deltas: 100% (238/238), done. </literallayout></para></listitem>
  188. <listitem><para id='supported-board-support-packages-(bsps)'><emphasis>Supported Board
  189. Support Packages (BSPs):</emphasis>
  190. The Yocto Project provides a layer called <filename>meta-intel</filename> and
  191. it is maintained in its own separate Git repository.
  192. The <filename>meta-intel</filename> layer contains many supported
  193. <ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>.</para>
  194. <para>Similar considerations exist for setting up the <filename>meta-intel</filename>
  195. layer.
  196. You can get set up for BSP development one of two ways: tarball extraction or
  197. with a local Git repository.
  198. It is a good idea to use the same method that you used to set up the Source Directory.
  199. Regardless of the method you use, the Yocto Project uses the following BSP layer
  200. naming scheme:
  201. <literallayout class='monospaced'>
  202. meta-&lt;BSP_name&gt;
  203. </literallayout>
  204. where <filename>&lt;BSP_name&gt;</filename> is the recognized BSP name.
  205. Here are some examples:
  206. <literallayout class='monospaced'>
  207. meta-crownbay
  208. meta-emenlow
  209. meta-n450
  210. </literallayout>
  211. See the
  212. "<ulink url='&YOCTO_DOCS_BSP_URL;#bsp-layers'>BSP Layers</ulink>"
  213. section in the Yocto Project Board Support Package (BSP) Developer's Guide for more
  214. information on BSP Layers.
  215. <itemizedlist>
  216. <listitem><para><emphasis>Tarball Extraction:</emphasis> You can download any released
  217. BSP tarball from the same "Downloads" page of the
  218. <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>
  219. to get the Yocto Project release.
  220. Once on the "Download" page, look for "BSP" under the
  221. "Type" heading.</para>
  222. <para>Once you have the tarball, just extract it into a directory of your choice.
  223. Again, this method just produces a snapshot of the BSP layer in the form
  224. of a hierarchical directory structure.</para></listitem>
  225. <listitem><para><emphasis>Git Repository Method:</emphasis> If you are working
  226. with a local Git repository for your Source Directory, you should also use this method
  227. to set up the <filename>meta-intel</filename> Git repository.
  228. You can locate the <filename>meta-intel</filename> Git repository in the
  229. "Yocto Metadata Layers" area of the Yocto Project Source Repositories at
  230. <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>.</para>
  231. <para>Typically, you set up the <filename>meta-intel</filename> Git repository inside
  232. the Source Directory.
  233. For example, the following transcript shows the steps to clone the
  234. <filename>meta-intel</filename>
  235. Git repository inside the local <filename>poky</filename> Git repository.
  236. <literallayout class='monospaced'>
  237. $ cd ~/poky
  238. $ git clone git://git.yoctoproject.org/meta-intel.git
  239. Cloning into 'meta-intel'...
  240. remote: Counting objects: 6264, done.
  241. remote: Compressing objects: 100% (2135/2135), done.
  242. remote: Total 6264 (delta 3321), reused 6235 (delta 3293)
  243. Receiving objects: 100% (6264/6264), 2.17 MiB | 2.63 MiB/s, done.
  244. Resolving deltas: 100% (3321/3321), done.
  245. </literallayout></para>
  246. <para>The same
  247. <ulink url='&YOCTO_WIKI_URL;/wiki/Transcript:_from_git_checkout_to_meta-intel_BSP'>
  248. wiki page</ulink> referenced earlier covers how to
  249. set up the <filename>meta-intel</filename> Git repository.</para></listitem>
  250. </itemizedlist></para></listitem>
  251. <listitem><para><emphasis>Eclipse Yocto Plug-in:</emphasis> If you are developing
  252. applications using the Eclipse Integrated Development Environment (IDE),
  253. you will need this plug-in.
  254. See the
  255. "<link linkend='setting-up-the-eclipse-ide'>Setting up the Eclipse IDE</link>"
  256. section for more information.</para></listitem>
  257. </itemizedlist>
  258. </para>
  259. </section>
  260. <section id='building-images'>
  261. <title>Building Images</title>
  262. <para>
  263. The build process creates an entire Linux distribution, including the toolchain, from source.
  264. For more information on this topic, see the
  265. "<ulink url='&YOCTO_DOCS_QS_URL;#building-image'>Building an Image</ulink>"
  266. section in the Yocto Project Quick Start.
  267. </para>
  268. <para>
  269. The build process is as follows:
  270. <orderedlist>
  271. <listitem><para>Make sure you have set up the Source Directory described in the
  272. previous section.</para></listitem>
  273. <listitem><para>Initialize the build environment by sourcing a build environment
  274. script.</para></listitem>
  275. <listitem><para>Optionally ensure the <filename>conf/local.conf</filename> configuration file,
  276. which is found in the
  277. <link linkend='build-directory'>Build Directory</link>,
  278. is set up how you want it.
  279. This file defines many aspects of the build environment including
  280. the target machine architecture through the
  281. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'>MACHINE</ulink></filename> variable,
  282. the development machine's processor use through the
  283. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'>BB_NUMBER_THREADS</ulink></filename> and
  284. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'>PARALLEL_MAKE</ulink></filename> variables, and
  285. a centralized tarball download directory through the
  286. <filename><ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'>DL_DIR</ulink></filename> variable.</para></listitem>
  287. <listitem><para>Build the image using the <filename>bitbake</filename> command.
  288. If you want information on BitBake, see the user manual included in the
  289. <filename>bitbake/doc/manual</filename> directory of the
  290. <link linkend='source-directory'>Source Directory</link>.</para></listitem>
  291. <listitem><para>Run the image either on the actual hardware or using the QEMU
  292. emulator.</para></listitem>
  293. </orderedlist>
  294. </para>
  295. </section>
  296. <section id='using-pre-built-binaries-and-qemu'>
  297. <title>Using Pre-Built Binaries and QEMU</title>
  298. <para>
  299. Another option you have to get started is to use pre-built binaries.
  300. The Yocto Project provides many types of binaries with each release.
  301. See the "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>"
  302. chapter in the Yocto Project Reference Manual
  303. for descriptions of the types of binaries that ship with a Yocto Project
  304. release.
  305. </para>
  306. <para>
  307. Using a pre-built binary is ideal for developing software applications to run on your
  308. target hardware.
  309. To do this, you need to be able to access the appropriate cross-toolchain tarball for
  310. the architecture on which you are developing.
  311. If you are using an SDK type image, the image ships with the complete toolchain native to
  312. the architecture.
  313. If you are not using an SDK type image, you need to separately download and
  314. install the stand-alone Yocto Project cross-toolchain tarball.
  315. </para>
  316. <para>
  317. Regardless of the type of image you are using, you need to download the pre-built kernel
  318. that you will boot in the QEMU emulator and then download and extract the target root
  319. filesystem for your target machine’s architecture.
  320. You can get architecture-specific binaries and file systems from
  321. <ulink url='&YOCTO_MACHINES_DL_URL;'>machines</ulink>.
  322. You can get installation scripts for stand-alone toolchains from
  323. <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'>toolchains</ulink>.
  324. Once you have all your files, you set up the environment to emulate the hardware
  325. by sourcing an environment setup script.
  326. Finally, you start the QEMU emulator.
  327. You can find details on all these steps in the
  328. "<ulink url='&YOCTO_DOCS_QS_URL;#using-pre-built'>Using Pre-Built Binaries and QEMU</ulink>"
  329. section of the Yocto Project Quick Start.
  330. </para>
  331. <para>
  332. Using QEMU to emulate your hardware can result in speed issues
  333. depending on the target and host architecture mix.
  334. For example, using the <filename>qemux86</filename> image in the emulator
  335. on an Intel-based 32-bit (x86) host machine is fast because the target and
  336. host architectures match.
  337. On the other hand, using the <filename>qemuarm</filename> image on the same Intel-based
  338. host can be slower.
  339. But, you still achieve faithful emulation of ARM-specific issues.
  340. </para>
  341. <para>
  342. To speed things up, the QEMU images support using <filename>distcc</filename>
  343. to call a cross-compiler outside the emulated system.
  344. If you used <filename>runqemu</filename> to start QEMU, and the
  345. <filename>distccd</filename> application is present on the host system, any
  346. BitBake cross-compiling toolchain available from the build system is automatically
  347. used from within QEMU simply by calling <filename>distcc</filename>.
  348. You can accomplish this by defining the cross-compiler variable
  349. (e.g. <filename>export CC="distcc"</filename>).
  350. Alternatively, if you are using a suitable SDK image or the appropriate
  351. stand-alone toolchain is present,
  352. the toolchain is also automatically used.
  353. </para>
  354. <note>
  355. Several mechanisms exist that let you connect to the system running on the
  356. QEMU emulator:
  357. <itemizedlist>
  358. <listitem><para>QEMU provides a framebuffer interface that makes standard
  359. consoles available.</para></listitem>
  360. <listitem><para>Generally, headless embedded devices have a serial port.
  361. If so, you can configure the operating system of the running image
  362. to use that port to run a console.
  363. The connection uses standard IP networking.</para></listitem>
  364. <listitem><para>SSH servers exist in some QEMU images.
  365. The <filename>core-image-sato</filename> QEMU image has a Dropbear secure
  366. shell (SSH) server that runs with the root password disabled.
  367. The <filename>core-image-basic</filename> and <filename>core-image-lsb</filename> QEMU images
  368. have OpenSSH instead of Dropbear.
  369. Including these SSH servers allow you to use standard <filename>ssh</filename> and
  370. <filename>scp</filename> commands.
  371. The <filename>core-image-minimal</filename> QEMU image, however, contains no SSH
  372. server.</para></listitem>
  373. <listitem><para>You can use a provided, user-space NFS server to boot the QEMU session
  374. using a local copy of the root filesystem on the host.
  375. In order to make this connection, you must extract a root filesystem tarball by using the
  376. <filename>runqemu-extract-sdk</filename> command.
  377. After running the command, you must then point the <filename>runqemu</filename>
  378. script to the extracted directory instead of a root filesystem image file.</para></listitem>
  379. </itemizedlist>
  380. </note>
  381. </section>
  382. </chapter>
  383. <!--
  384. vim: expandtab tw=80 ts=4
  385. -->