start.rst 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. ***********************************
  3. Setting Up to Use the Yocto Project
  4. ***********************************
  5. This chapter provides guidance on how to prepare to use the Yocto
  6. Project. You can learn about creating a team environment to develop
  7. using the Yocto Project, how to set up a :ref:`build
  8. host <dev-manual/start:preparing the build host>`, how to locate
  9. Yocto Project source repositories, and how to create local Git
  10. repositories.
  11. Creating a Team Development Environment
  12. =======================================
  13. It might not be immediately clear how you can use the Yocto Project in a
  14. team development environment, or how to scale it for a large team of
  15. developers. You can adapt the Yocto Project to many different use cases
  16. and scenarios; however, this flexibility could cause difficulties if you
  17. are trying to create a working setup that scales effectively.
  18. To help you understand how to set up this type of environment, this
  19. section presents a procedure that gives you information that can help
  20. you get the results you want. The procedure is high-level and presents
  21. some of the project's most successful experiences, practices, solutions,
  22. and available technologies that have proved to work well in the past;
  23. however, keep in mind, the procedure here is simply a starting point.
  24. You can build off these steps and customize the procedure to fit any
  25. particular working environment and set of practices.
  26. #. *Determine Who is Going to be Developing:* You first need to
  27. understand who is going to be doing anything related to the Yocto
  28. Project and determine their roles. Making this determination is
  29. essential to completing subsequent steps, which are to get your
  30. equipment together and set up your development environment's
  31. hardware topology.
  32. Possible roles are:
  33. - *Application Developer:* This type of developer does application
  34. level work on top of an existing software stack.
  35. - *Core System Developer:* This type of developer works on the
  36. contents of the operating system image itself.
  37. - *Build Engineer:* This type of developer manages Autobuilders and
  38. releases. Depending on the specifics of the environment, not all
  39. situations might need a Build Engineer.
  40. - *Test Engineer:* This type of developer creates and manages
  41. automated tests that are used to ensure all application and core
  42. system development meets desired quality standards.
  43. #. *Gather the Hardware:* Based on the size and make-up of the team,
  44. get the hardware together. Ideally, any development, build, or test
  45. engineer uses a system that runs a supported Linux distribution.
  46. These systems, in general, should be high performance (e.g. dual,
  47. six-core Xeons with 24 Gbytes of RAM and plenty of disk space). You
  48. can help ensure efficiency by having any machines used for testing
  49. or that run Autobuilders be as high performance as possible.
  50. .. note::
  51. Given sufficient processing power, you might also consider
  52. building Yocto Project development containers to be run under
  53. Docker, which is described later.
  54. #. *Understand the Hardware Topology of the Environment:* Once you
  55. understand the hardware involved and the make-up of the team, you
  56. can understand the hardware topology of the development environment.
  57. You can get a visual idea of the machines and their roles across the
  58. development environment.
  59. #. *Use Git as Your Source Control Manager (SCM):* Keeping your
  60. :term:`Metadata` (i.e. recipes,
  61. configuration files, classes, and so forth) and any software you are
  62. developing under the control of an SCM system that is compatible
  63. with the OpenEmbedded build system is advisable. Of all of the SCMs
  64. supported by BitBake, the Yocto Project team strongly recommends using
  65. :ref:`overview-manual/development-environment:git`.
  66. Git is a distributed system
  67. that is easy to back up, allows you to work remotely, and then
  68. connects back to the infrastructure.
  69. .. note::
  70. For information about BitBake, see the
  71. :doc:`bitbake:index`.
  72. It is relatively easy to set up Git services and create infrastructure like
  73. :yocto_git:`/`, which is based on server software called
  74. `Gitolite <https://gitolite.com>`__
  75. with `cgit <https://git.zx2c4.com/cgit/about/>`__ being used to
  76. generate the web interface that lets you view the repositories.
  77. ``gitolite`` identifies users using SSH keys and allows
  78. branch-based access controls to repositories that you can control as
  79. little or as much as necessary.
  80. #. *Set up the Application Development Machines:* As mentioned earlier,
  81. application developers are creating applications on top of existing
  82. software stacks. Here are some best practices for setting up
  83. machines used for application development:
  84. - Use a pre-built toolchain that contains the software stack
  85. itself. Then, develop the application code on top of the stack.
  86. This method works well for small numbers of relatively isolated
  87. applications.
  88. - Keep your cross-development toolchains updated. You can do this
  89. through provisioning either as new toolchain downloads or as
  90. updates through a package update mechanism using ``opkg`` to
  91. provide updates to an existing toolchain. The exact mechanics of
  92. how and when to do this depend on local policy.
  93. - Use multiple toolchains installed locally into different
  94. locations to allow development across versions.
  95. #. *Set up the Core Development Machines:* As mentioned earlier, core
  96. developers work on the contents of the operating system itself.
  97. Here are some best practices for setting up machines used for
  98. developing images:
  99. - Have the :term:`OpenEmbedded Build System` available on
  100. the developer workstations so developers can run their own builds
  101. and directly rebuild the software stack.
  102. - Keep the core system unchanged as much as possible and do your
  103. work in layers on top of the core system. Doing so gives you a
  104. greater level of portability when upgrading to new versions of
  105. the core system or Board Support Packages (BSPs).
  106. - Share layers amongst the developers of a particular project and
  107. contain the policy configuration that defines the project.
  108. #. *Set up an Autobuilder:* Autobuilders are often the core of the
  109. development environment. It is here that changes from individual
  110. developers are brought together and centrally tested. Based on this
  111. automated build and test environment, subsequent decisions about
  112. releases can be made. Autobuilders also allow for "continuous
  113. integration" style testing of software components and regression
  114. identification and tracking.
  115. See ":yocto_ab:`Yocto Project Autobuilder <>`" for more
  116. information and links to buildbot. The Yocto Project team has found
  117. this implementation works well in this role. A public example of
  118. this is the Yocto Project Autobuilders, which the Yocto Project team
  119. uses to test the overall health of the project.
  120. The features of this system are:
  121. - Highlights when commits break the build.
  122. - Populates an :ref:`sstate
  123. cache <overview-manual/concepts:shared state cache>` from which
  124. developers can pull rather than requiring local builds.
  125. - Allows commit hook triggers, which trigger builds when commits
  126. are made.
  127. - Allows triggering of automated image booting and testing under
  128. the QuickEMUlator (QEMU).
  129. - Supports incremental build testing and from-scratch builds.
  130. - Shares output that allows developer testing and historical
  131. regression investigation.
  132. - Creates output that can be used for releases.
  133. - Allows scheduling of builds so that resources can be used
  134. efficiently.
  135. #. *Set up Test Machines:* Use a small number of shared, high
  136. performance systems for testing purposes. Developers can use these
  137. systems for wider, more extensive testing while they continue to
  138. develop locally using their primary development system.
  139. #. *Document Policies and Change Flow:* The Yocto Project uses a
  140. hierarchical structure and a pull model. There are scripts to create and
  141. send pull requests (i.e. ``create-pull-request`` and
  142. ``send-pull-request``). This model is in line with other open source
  143. projects where maintainers are responsible for specific areas of the
  144. project and a single maintainer handles the final "top-of-tree"
  145. merges.
  146. .. note::
  147. You can also use a more collective push model. The ``gitolite``
  148. software supports both the push and pull models quite easily.
  149. As with any development environment, it is important to document the
  150. policy used as well as any main project guidelines so they are
  151. understood by everyone. It is also a good idea to have
  152. well-structured commit messages, which are usually a part of a
  153. project's guidelines. Good commit messages are essential when
  154. looking back in time and trying to understand why changes were made.
  155. If you discover that changes are needed to the core layer of the
  156. project, it is worth sharing those with the community as soon as
  157. possible. Chances are if you have discovered the need for changes,
  158. someone else in the community needs them also.
  159. #. *Development Environment Summary:* Aside from the previous steps,
  160. here are best practices within the Yocto Project development
  161. environment:
  162. - Use :ref:`overview-manual/development-environment:git` as the source control
  163. system.
  164. - Maintain your Metadata in layers that make sense for your
  165. situation. See the ":ref:`overview-manual/yp-intro:the yocto project layer model`"
  166. section in the Yocto Project Overview and Concepts Manual and the
  167. ":ref:`dev-manual/layers:understanding and creating layers`"
  168. section for more information on layers.
  169. - Separate the project's Metadata and code by using separate Git
  170. repositories. See the ":ref:`overview-manual/development-environment:yocto project source repositories`"
  171. section in the Yocto Project Overview and Concepts Manual for
  172. information on these repositories. See the
  173. ":ref:`dev-manual/start:locating yocto project source files`"
  174. section for information on how to set up local Git repositories
  175. for related upstream Yocto Project Git repositories.
  176. - Set up the directory for the shared state cache
  177. (:term:`SSTATE_DIR`) where
  178. it makes sense. For example, set up the sstate cache on a system
  179. used by developers in the same organization and share the same
  180. source directories on their machines.
  181. - Set up an Autobuilder and have it populate the sstate cache and
  182. source directories.
  183. - The Yocto Project community encourages you to send patches to the
  184. project to fix bugs or add features. If you do submit patches,
  185. follow the project commit guidelines for writing good commit
  186. messages. See the ":doc:`../contributor-guide/submit-changes`"
  187. section in the Yocto Project and OpenEmbedded Contributor Guide.
  188. - Send changes to the core sooner than later as others are likely
  189. to run into the same issues. For some guidance on mailing lists
  190. to use, see the lists in the
  191. ":ref:`contributor-guide/submit-changes:finding a suitable mailing list`"
  192. section. For a description
  193. of the available mailing lists, see the ":ref:`resources-mailinglist`" section in
  194. the Yocto Project Reference Manual.
  195. Preparing the Build Host
  196. ========================
  197. This section provides procedures to set up a system to be used as your
  198. :term:`Build Host` for
  199. development using the Yocto Project. Your build host can be a native
  200. Linux machine (recommended), it can be a machine (Linux, Mac, or
  201. Windows) that uses `CROPS <https://github.com/crops/poky-container>`__,
  202. which leverages `Docker Containers <https://www.docker.com/>`__ or it
  203. can be a Windows machine capable of running version 2 of Windows Subsystem
  204. For Linux (WSL 2).
  205. .. note::
  206. The Yocto Project is not compatible with version 1 of
  207. :wikipedia:`Windows Subsystem for Linux <Windows_Subsystem_for_Linux>`.
  208. It is compatible but neither officially supported nor validated with
  209. WSL 2. If you still decide to use WSL please upgrade to
  210. `WSL 2 <https://learn.microsoft.com/en-us/windows/wsl/install>`__.
  211. Once your build host is set up to use the Yocto Project, further steps
  212. are necessary depending on what you want to accomplish. See the
  213. following references for information on how to prepare for Board Support
  214. Package (BSP) development and kernel development:
  215. - *BSP Development:* See the ":ref:`bsp-guide/bsp:preparing your build host to work with bsp layers`"
  216. section in the Yocto Project Board Support Package (BSP) Developer's
  217. Guide.
  218. - *Kernel Development:* See the ":ref:`kernel-dev/common:preparing the build host to work on the kernel`"
  219. section in the Yocto Project Linux Kernel Development Manual.
  220. Setting Up a Native Linux Host
  221. ------------------------------
  222. Follow these steps to prepare a native Linux machine as your Yocto
  223. Project Build Host:
  224. #. *Use a Supported Linux Distribution:* You should have a reasonably
  225. current Linux-based host system. You will have the best results with
  226. a recent release of Fedora, openSUSE, Debian, Ubuntu, RHEL or CentOS
  227. as these releases are frequently tested against the Yocto Project and
  228. officially supported. For a list of the distributions under
  229. validation and their status, see the ":ref:`Supported Linux
  230. Distributions <system-requirements-supported-distros>`"
  231. section in the Yocto Project Reference Manual and the wiki page at
  232. :yocto_wiki:`Distribution Support </Distribution_Support>`.
  233. #. *Have Enough Free Memory:* Your system should have at least 50 Gbytes
  234. of free disk space for building images.
  235. #. *Meet Minimal Version Requirements:* The OpenEmbedded build system
  236. should be able to run on any modern distribution that has the
  237. following versions for Git, tar, Python, gcc and make.
  238. - Git &MIN_GIT_VERSION; or greater
  239. - tar &MIN_TAR_VERSION; or greater
  240. - Python &MIN_PYTHON_VERSION; or greater.
  241. - gcc &MIN_GCC_VERSION; or greater.
  242. - GNU make &MIN_MAKE_VERSION; or greater
  243. If your build host does not meet any of these listed version
  244. requirements, you can take steps to prepare the system so that you
  245. can still use the Yocto Project. See the
  246. ":ref:`ref-manual/system-requirements:required git, tar, python, make and gcc versions`"
  247. section in the Yocto Project Reference Manual for information.
  248. #. *Install Development Host Packages:* Required development host
  249. packages vary depending on your build host and what you want to do
  250. with the Yocto Project. Collectively, the number of required packages
  251. is large if you want to be able to cover all cases.
  252. For lists of required packages for all scenarios, see the
  253. ":ref:`ref-manual/system-requirements:required packages for the build host`"
  254. section in the Yocto Project Reference Manual.
  255. Once you have completed the previous steps, you are ready to continue
  256. using a given development path on your native Linux machine. If you are
  257. going to use BitBake, see the
  258. ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
  259. section. If you are going
  260. to use the Extensible SDK, see the ":doc:`/sdk-manual/extensible`" Chapter in the Yocto
  261. Project Application Development and the Extensible Software Development
  262. Kit (eSDK) manual. If you want to work on the kernel, see the :doc:`/kernel-dev/index`. If you are going to use
  263. Toaster, see the ":doc:`/toaster-manual/setup-and-use`"
  264. section in the Toaster User Manual. If you are a VSCode user, you can configure
  265. the `Yocto Project BitBake
  266. <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`__
  267. extension accordingly.
  268. Setting Up to Use CROss PlatformS (CROPS)
  269. -----------------------------------------
  270. With `CROPS <https://github.com/crops/poky-container>`__, which
  271. leverages `Docker Containers <https://www.docker.com/>`__, you can
  272. create a Yocto Project development environment that is operating system
  273. agnostic. You can set up a container in which you can develop using the
  274. Yocto Project on a Windows, Mac, or Linux machine.
  275. Follow these general steps to prepare a Windows, Mac, or Linux machine
  276. as your Yocto Project build host:
  277. #. *Determine What Your Build Host Needs:*
  278. `Docker <https://www.docker.com/what-docker>`__ is a software
  279. container platform that you need to install on the build host.
  280. Depending on your build host, you might have to install different
  281. software to support Docker containers. Go to the Docker installation
  282. page and read about the platform requirements in "`Supported
  283. Platforms <https://docs.docker.com/engine/install/#supported-platforms>`__"
  284. your build host needs to run containers.
  285. #. *Choose What To Install:* Depending on whether or not your build host
  286. meets system requirements, you need to install "Docker CE Stable" or
  287. the "Docker Toolbox". Most situations call for Docker CE. However, if
  288. you have a build host that does not meet requirements (e.g.
  289. Pre-Windows 10 or Windows 10 "Home" version), you must install Docker
  290. Toolbox instead.
  291. #. *Go to the Install Site for Your Platform:* Click the link for the
  292. Docker edition associated with your build host's native software. For
  293. example, if your build host is running Microsoft Windows Version 10
  294. and you want the Docker CE Stable edition, click that link under
  295. "Supported Platforms".
  296. #. *Install the Software:* Once you have understood all the
  297. pre-requisites, you can download and install the appropriate
  298. software. Follow the instructions for your specific machine and the
  299. type of the software you need to install:
  300. - Install `Docker Desktop on
  301. Windows <https://docs.docker.com/docker-for-windows/install/#install-docker-desktop-on-windows>`__
  302. for Windows build hosts that meet requirements.
  303. - Install `Docker Desktop on
  304. MacOs <https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-desktop-on-mac>`__
  305. for Mac build hosts that meet requirements.
  306. - Install `Docker Engine on
  307. CentOS <https://docs.docker.com/engine/install/centos/>`__
  308. for Linux build hosts running the CentOS distribution.
  309. - Install `Docker Engine on
  310. Debian <https://docs.docker.com/engine/install/debian/>`__
  311. for Linux build hosts running the Debian distribution.
  312. - Install `Docker Engine for
  313. Fedora <https://docs.docker.com/engine/install/fedora/>`__
  314. for Linux build hosts running the Fedora distribution.
  315. - Install `Docker Engine for
  316. Ubuntu <https://docs.docker.com/engine/install/ubuntu/>`__
  317. for Linux build hosts running the Ubuntu distribution.
  318. #. *Optionally Orient Yourself With Docker:* If you are unfamiliar with
  319. Docker and the container concept, you can learn more here -
  320. https://docs.docker.com/get-started/.
  321. #. *Launch Docker or Docker Toolbox:* You should be able to launch
  322. Docker or the Docker Toolbox and have a terminal shell on your
  323. development host.
  324. #. *Set Up the Containers to Use the Yocto Project:* Go to
  325. https://github.com/crops/docker-win-mac-docs/wiki and follow
  326. the directions for your particular build host (i.e. Linux, Mac, or
  327. Windows).
  328. Once you complete the setup instructions for your machine, you have
  329. the Poky, Extensible SDK, and Toaster containers available. You can
  330. click those links from the page and learn more about using each of
  331. those containers.
  332. Once you have a container set up, everything is in place to develop just
  333. as if you were running on a native Linux machine. If you are going to
  334. use the Poky container, see the
  335. ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
  336. section. If you are going to use the Extensible SDK container, see the
  337. ":doc:`/sdk-manual/extensible`" Chapter in the Yocto
  338. Project Application Development and the Extensible Software Development
  339. Kit (eSDK) manual. If you are going to use the Toaster container, see
  340. the ":doc:`/toaster-manual/setup-and-use`"
  341. section in the Toaster User Manual. If you are a VSCode user, you can configure
  342. the `Yocto Project BitBake
  343. <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`__
  344. extension accordingly.
  345. Setting Up to Use Windows Subsystem For Linux (WSL 2)
  346. -----------------------------------------------------
  347. With `Windows Subsystem for Linux (WSL 2)
  348. <https://learn.microsoft.com/en-us/windows/wsl/>`__,
  349. you can create a Yocto Project development environment that allows you
  350. to build on Windows. You can set up a Linux distribution inside Windows
  351. in which you can develop using the Yocto Project.
  352. Follow these general steps to prepare a Windows machine using WSL 2 as
  353. your Yocto Project build host:
  354. #. *Make sure your Windows machine is capable of running WSL 2:*
  355. While all Windows 11 and Windows Server 2022 builds support WSL 2,
  356. the first versions of Windows 10 and Windows Server 2019 didn't.
  357. Check the minimum build numbers for `Windows 10
  358. <https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-2---check-requirements-for-running-wsl-2>`__
  359. and for `Windows Server 2019
  360. <https://learn.microsoft.com/en-us/windows/wsl/install-on-server>`__.
  361. To check which build version you are running, you may open a command
  362. prompt on Windows and execute the command "ver"::
  363. C:\Users\myuser> ver
  364. Microsoft Windows [Version 10.0.19041.153]
  365. #. *Install the Linux distribution of your choice inside WSL 2:*
  366. Once you know your version of Windows supports WSL 2, you can
  367. install the distribution of your choice from the Microsoft Store.
  368. Open the Microsoft Store and search for Linux. While there are
  369. several Linux distributions available, the assumption is that your
  370. pick will be one of the distributions supported by the Yocto Project
  371. as stated on the instructions for using a native Linux host. After
  372. making your selection, simply click "Get" to download and install the
  373. distribution.
  374. #. *Check which Linux distribution WSL 2 is using:* Open a Windows
  375. PowerShell and run::
  376. C:\WINDOWS\system32> wsl -l -v
  377. NAME STATE VERSION
  378. *Ubuntu Running 2
  379. Note that WSL 2 supports running as many different Linux distributions
  380. as you want to install.
  381. #. *Optionally Get Familiar with WSL:* You can learn more on
  382. https://docs.microsoft.com/en-us/windows/wsl/wsl2-about.
  383. #. *Launch your WSL Distibution:* From the Windows start menu simply
  384. launch your WSL distribution just like any other application.
  385. #. *Optimize your WSL 2 storage often:* Due to the way storage is
  386. handled on WSL 2, the storage space used by the underlying Linux
  387. distribution is not reflected immediately, and since BitBake heavily
  388. uses storage, after several builds, you may be unaware you are
  389. running out of space. As WSL 2 uses a VHDX file for storage, this issue
  390. can be easily avoided by regularly optimizing this file in a manual way:
  391. 1. *Find the location of your VHDX file:*
  392. First you need to find the distro app package directory, to achieve this
  393. open a Windows Powershell as Administrator and run::
  394. C:\WINDOWS\system32> Get-AppxPackage -Name "*Ubuntu*" | Select PackageFamilyName
  395. PackageFamilyName
  396. -----------------
  397. CanonicalGroupLimited.UbuntuonWindows_79abcdefgh
  398. You should now
  399. replace the PackageFamilyName and your user on the following path
  400. to find your VHDX file::
  401. ls C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\
  402. Mode LastWriteTime Length Name
  403. -a---- 3/14/2020 9:52 PM 57418973184 ext4.vhdx
  404. Your VHDX file path is:
  405. ``C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx``
  406. 2a. *Optimize your VHDX file using Windows Powershell:*
  407. To use the ``optimize-vhd`` cmdlet below, first install the Hyper-V
  408. option on Windows. Then, open a Windows Powershell as Administrator to
  409. optimize your VHDX file, shutting down WSL first::
  410. C:\WINDOWS\system32> wsl --shutdown
  411. C:\WINDOWS\system32> optimize-vhd -Path C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx -Mode full
  412. A progress bar should be shown while optimizing the
  413. VHDX file, and storage should now be reflected correctly on the
  414. Windows Explorer.
  415. 2b. *Optimize your VHDX file using DiskPart:*
  416. The ``optimize-vhd`` cmdlet noted in step 2a above is provided by
  417. Hyper-V. Not all SKUs of Windows can install Hyper-V. As an alternative,
  418. use the DiskPart tool. To start, open a Windows command prompt as
  419. Administrator to optimize your VHDX file, shutting down WSL first::
  420. C:\WINDOWS\system32> wsl --shutdown
  421. C:\WINDOWS\system32> diskpart
  422. DISKPART> select vdisk file="<path_to_VHDX_file>"
  423. DISKPART> attach vdisk readonly
  424. DISKPART> compact vdisk
  425. DISKPART> exit
  426. .. note::
  427. The current implementation of WSL 2 does not have out-of-the-box
  428. access to external devices such as those connected through a USB
  429. port, but it automatically mounts your ``C:`` drive on ``/mnt/c/``
  430. (and others), which you can use to share deploy artifacts to be later
  431. flashed on hardware through Windows, but your :term:`Build Directory`
  432. should not reside inside this mountpoint.
  433. Once you have WSL 2 set up, everything is in place to develop just as if
  434. you were running on a native Linux machine. If you are going to use the
  435. Extensible SDK container, see the ":doc:`/sdk-manual/extensible`" Chapter in the Yocto
  436. Project Application Development and the Extensible Software Development
  437. Kit (eSDK) manual. If you are going to use the Toaster container, see
  438. the ":doc:`/toaster-manual/setup-and-use`"
  439. section in the Toaster User Manual. If you are a VSCode user, you can configure
  440. the `Yocto Project BitBake
  441. <https://marketplace.visualstudio.com/items?itemName=yocto-project.yocto-bitbake>`__
  442. extension accordingly.
  443. Locating Yocto Project Source Files
  444. ===================================
  445. This section shows you how to locate, fetch and configure the source
  446. files you'll need to work with the Yocto Project.
  447. .. note::
  448. - For concepts and introductory information about Git as it is used
  449. in the Yocto Project, see the ":ref:`overview-manual/development-environment:git`"
  450. section in the Yocto Project Overview and Concepts Manual.
  451. - For concepts on Yocto Project source repositories, see the
  452. ":ref:`overview-manual/development-environment:yocto project source repositories`"
  453. section in the Yocto Project Overview and Concepts Manual."
  454. Accessing Source Repositories
  455. -----------------------------
  456. Working from a copy of the upstream :ref:`dev-manual/start:accessing source repositories` is the
  457. preferred method for obtaining and using a Yocto Project release. You
  458. can view the Yocto Project Source Repositories at
  459. :yocto_git:`/`. In particular, you can find the ``poky``
  460. repository at :yocto_git:`/poky`.
  461. Use the following procedure to locate the latest upstream copy of the
  462. ``poky`` Git repository:
  463. #. *Access Repositories:* Open a browser and go to
  464. :yocto_git:`/` to access the GUI-based interface into the
  465. Yocto Project source repositories.
  466. #. *Select the Repository:* Click on the repository in which you are
  467. interested (e.g. ``poky``).
  468. #. *Find the URL Used to Clone the Repository:* At the bottom of the
  469. page, note the URL used to clone that repository
  470. (e.g. :yocto_git:`/poky`).
  471. .. note::
  472. For information on cloning a repository, see the
  473. ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`" section.
  474. Accessing Source Archives
  475. -------------------------
  476. The Yocto Project also provides source archives of its releases, which
  477. are available on :yocto_dl:`/releases/yocto/`. Then, choose the subdirectory
  478. containing the release you wish to use, for example
  479. :yocto_dl:`&DISTRO_REL_LATEST_TAG; </releases/yocto/&DISTRO_REL_LATEST_TAG;/>`.
  480. You will find there source archives of individual components (if you wish
  481. to use them individually), and of the corresponding Poky release bundling
  482. a selection of these components.
  483. .. note::
  484. The recommended method for accessing Yocto Project components is to
  485. use Git to clone the upstream repository and work from within that
  486. locally cloned repository.
  487. Using the Downloads Page
  488. ------------------------
  489. The :yocto_home:`Yocto Project Website <>` uses a "RELEASES" page
  490. from which you can locate and download tarballs of any Yocto Project
  491. release. Rather than Git repositories, these files represent snapshot
  492. tarballs similar to the tarballs located in the Index of Releases
  493. described in the ":ref:`dev-manual/start:accessing source archives`" section.
  494. #. *Go to the Yocto Project Website:* Open The
  495. :yocto_home:`Yocto Project Website <>` in your browser.
  496. #. *Get to the Downloads Area:* Select the "RELEASES" item from the
  497. pull-down "DEVELOPMENT" tab menu near the top of the page.
  498. #. *Select a Yocto Project Release:* On the top of the "RELEASE" page currently
  499. supported releases are displayed, further down past supported Yocto Project
  500. releases are visible. The "Download" links in the rows of the table there
  501. will lead to the download tarballs for the release.
  502. .. note::
  503. For a "map" of Yocto Project releases to version numbers, see the
  504. :yocto_wiki:`Releases </Releases>` wiki page.
  505. You can use the "RELEASE ARCHIVE" link to reveal a menu of all Yocto
  506. Project releases.
  507. #. *Download Tools or Board Support Packages (BSPs):* Next to the tarballs you
  508. will find download tools or BSPs as well. Just select a Yocto Project
  509. release and look for what you need.
  510. Cloning and Checking Out Branches
  511. =================================
  512. To use the Yocto Project for development, you need a release locally
  513. installed on your development system. This locally installed set of
  514. files is referred to as the :term:`Source Directory`
  515. in the Yocto Project documentation.
  516. The preferred method of creating your Source Directory is by using
  517. :ref:`overview-manual/development-environment:git` to clone a local copy of the upstream
  518. ``poky`` repository. Working from a cloned copy of the upstream
  519. repository allows you to contribute back into the Yocto Project or to
  520. simply work with the latest software on a development branch. Because
  521. Git maintains and creates an upstream repository with a complete history
  522. of changes and you are working with a local clone of that repository,
  523. you have access to all the Yocto Project development branches and tag
  524. names used in the upstream repository.
  525. Cloning the ``poky`` Repository
  526. -------------------------------
  527. Follow these steps to create a local version of the upstream
  528. :term:`Poky` Git repository.
  529. #. *Set Your Directory:* Change your working directory to where you want
  530. to create your local copy of ``poky``.
  531. #. *Clone the Repository:* The following example command clones the
  532. ``poky`` repository and uses the default name "poky" for your local
  533. repository::
  534. $ git clone git://git.yoctoproject.org/poky
  535. Cloning into 'poky'...
  536. remote: Counting objects: 432160, done.
  537. remote: Compressing objects: 100% (102056/102056), done.
  538. remote: Total 432160 (delta 323116), reused 432037 (delta 323000)
  539. Receiving objects: 100% (432160/432160), 153.81 MiB | 8.54 MiB/s, done.
  540. Resolving deltas: 100% (323116/323116), done.
  541. Checking connectivity... done.
  542. Unless you
  543. specify a specific development branch or tag name, Git clones the
  544. "master" branch, which results in a snapshot of the latest
  545. development changes for "master". For information on how to check out
  546. a specific development branch or on how to check out a local branch
  547. based on a tag name, see the
  548. ":ref:`dev-manual/start:checking out by branch in poky`" and
  549. ":ref:`dev-manual/start:checking out by tag in poky`" sections, respectively.
  550. Once the local repository is created, you can change to that
  551. directory and check its status. The ``master`` branch is checked out
  552. by default::
  553. $ cd poky
  554. $ git status
  555. On branch master
  556. Your branch is up-to-date with 'origin/master'.
  557. nothing to commit, working directory clean
  558. $ git branch
  559. * master
  560. Your local repository of poky is identical to the
  561. upstream poky repository at the time from which it was cloned. As you
  562. work with the local branch, you can periodically use the
  563. ``git pull --rebase`` command to be sure you are up-to-date
  564. with the upstream branch.
  565. Checking Out by Branch in Poky
  566. ------------------------------
  567. When you clone the upstream poky repository, you have access to all its
  568. development branches. Each development branch in a repository is unique
  569. as it forks off the "master" branch. To see and use the files of a
  570. particular development branch locally, you need to know the branch name
  571. and then specifically check out that development branch.
  572. .. note::
  573. Checking out an active development branch by branch name gives you a
  574. snapshot of that particular branch at the time you check it out.
  575. Further development on top of the branch that occurs after check it
  576. out can occur.
  577. #. *Switch to the Poky Directory:* If you have a local poky Git
  578. repository, switch to that directory. If you do not have the local
  579. copy of poky, see the
  580. ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
  581. section.
  582. #. *Determine Existing Branch Names:*
  583. ::
  584. $ git branch -a
  585. * master
  586. remotes/origin/1.1_M1
  587. remotes/origin/1.1_M2
  588. remotes/origin/1.1_M3
  589. remotes/origin/1.1_M4
  590. remotes/origin/1.2_M1
  591. remotes/origin/1.2_M2
  592. remotes/origin/1.2_M3
  593. . . .
  594. remotes/origin/thud
  595. remotes/origin/thud-next
  596. remotes/origin/warrior
  597. remotes/origin/warrior-next
  598. remotes/origin/zeus
  599. remotes/origin/zeus-next
  600. ... and so on ...
  601. #. *Check out the Branch:* Check out the development branch in which you
  602. want to work. For example, to access the files for the Yocto Project
  603. &DISTRO; Release (&DISTRO_NAME;), use the following command::
  604. $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP;
  605. Branch &DISTRO_NAME_NO_CAP; set up to track remote branch &DISTRO_NAME_NO_CAP; from origin.
  606. Switched to a new branch '&DISTRO_NAME_NO_CAP;'
  607. The previous command checks out the "&DISTRO_NAME_NO_CAP;" development
  608. branch and reports that the branch is tracking the upstream
  609. "origin/&DISTRO_NAME_NO_CAP;" branch.
  610. The following command displays the branches that are now part of your
  611. local poky repository. The asterisk character indicates the branch
  612. that is currently checked out for work::
  613. $ git branch
  614. master
  615. * &DISTRO_NAME_NO_CAP;
  616. Checking Out by Tag in Poky
  617. ---------------------------
  618. Similar to branches, the upstream repository uses tags to mark specific
  619. commits associated with significant points in a development branch (i.e.
  620. a release point or stage of a release). You might want to set up a local
  621. branch based on one of those points in the repository. The process is
  622. similar to checking out by branch name except you use tag names.
  623. .. note::
  624. Checking out a branch based on a tag gives you a stable set of files
  625. not affected by development on the branch above the tag.
  626. #. *Switch to the Poky Directory:* If you have a local poky Git
  627. repository, switch to that directory. If you do not have the local
  628. copy of poky, see the
  629. ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
  630. section.
  631. #. *Fetch the Tag Names:* To checkout the branch based on a tag name,
  632. you need to fetch the upstream tags into your local repository::
  633. $ git fetch --tags
  634. $
  635. #. *List the Tag Names:* You can list the tag names now::
  636. $ git tag
  637. 1.1_M1.final
  638. 1.1_M1.rc1
  639. 1.1_M1.rc2
  640. 1.1_M2.final
  641. 1.1_M2.rc1
  642. .
  643. .
  644. .
  645. yocto-2.5
  646. yocto-2.5.1
  647. yocto-2.5.2
  648. yocto-2.5.3
  649. yocto-2.6
  650. yocto-2.6.1
  651. yocto-2.6.2
  652. yocto-2.7
  653. yocto_1.5_M5.rc8
  654. #. *Check out the Branch:*
  655. ::
  656. $ git checkout tags/yocto-&DISTRO; -b my_yocto_&DISTRO;
  657. Switched to a new branch 'my_yocto_&DISTRO;'
  658. $ git branch
  659. master
  660. * my_yocto_&DISTRO;
  661. The previous command creates and
  662. checks out a local branch named "my_yocto_&DISTRO;", which is based on
  663. the commit in the upstream poky repository that has the same tag. In
  664. this example, the files you have available locally as a result of the
  665. ``checkout`` command are a snapshot of the "&DISTRO_NAME_NO_CAP;"
  666. development branch at the point where Yocto Project &DISTRO; was
  667. released.
  668. Initializing the Build Environment
  669. ==================================
  670. Before you can use Yocto you need to setup the build environment.
  671. From within the ``poky`` directory, source the :ref:`ref-manual/structure:``oe-init-build-env``` environment
  672. setup script to define Yocto Project's build environment on your build host::
  673. $ source oe-init-build-env
  674. Note, that this step will have to be repeated every time you open a new shell.