blob: 9c7dde8cf2a8edc9b025684b8ef423e0bbe41bde [file] [log] [blame]
Andrew Geisslerf0343792020-11-18 10:42:21 -06001.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
Andrew Geisslerc9f78652020-09-18 14:11:35 -05002
3***********************************
4Setting Up to Use the Yocto Project
5***********************************
6
7This chapter provides guidance on how to prepare to use the Yocto
8Project. You can learn about creating a team environment to develop
9using the Yocto Project, how to set up a :ref:`build
Andrew Geissler09209ee2020-12-13 08:44:15 -060010host <dev-manual/start:preparing the build host>`, how to locate
Andrew Geisslerc9f78652020-09-18 14:11:35 -050011Yocto Project source repositories, and how to create local Git
12repositories.
13
Andrew Geisslerc9f78652020-09-18 14:11:35 -050014Creating a Team Development Environment
15=======================================
16
17It might not be immediately clear how you can use the Yocto Project in a
18team development environment, or how to scale it for a large team of
19developers. You can adapt the Yocto Project to many different use cases
20and scenarios; however, this flexibility could cause difficulties if you
21are trying to create a working setup that scales effectively.
22
23To help you understand how to set up this type of environment, this
24section presents a procedure that gives you information that can help
25you get the results you want. The procedure is high-level and presents
26some of the project's most successful experiences, practices, solutions,
27and available technologies that have proved to work well in the past;
28however, keep in mind, the procedure here is simply a starting point.
29You can build off these steps and customize the procedure to fit any
30particular working environment and set of practices.
31
321. *Determine Who is Going to be Developing:* You first need to
33 understand who is going to be doing anything related to the Yocto
34 Project and determine their roles. Making this determination is
35 essential to completing subsequent steps, which are to get your
36 equipment together and set up your development environment's
37 hardware topology.
38
William A. Kennington IIIac69b482021-06-02 12:28:27 -070039 Here are possible roles:
Andrew Geisslerc9f78652020-09-18 14:11:35 -050040
41 - *Application Developer:* This type of developer does application
42 level work on top of an existing software stack.
43
44 - *Core System Developer:* This type of developer works on the
45 contents of the operating system image itself.
46
47 - *Build Engineer:* This type of developer manages Autobuilders and
48 releases. Depending on the specifics of the environment, not all
49 situations might need a Build Engineer.
50
51 - *Test Engineer:* This type of developer creates and manages
52 automated tests that are used to ensure all application and core
53 system development meets desired quality standards.
54
552. *Gather the Hardware:* Based on the size and make-up of the team,
56 get the hardware together. Ideally, any development, build, or test
57 engineer uses a system that runs a supported Linux distribution.
58 These systems, in general, should be high performance (e.g. dual,
59 six-core Xeons with 24 Gbytes of RAM and plenty of disk space). You
60 can help ensure efficiency by having any machines used for testing
61 or that run Autobuilders be as high performance as possible.
62
63 .. note::
64
65 Given sufficient processing power, you might also consider
66 building Yocto Project development containers to be run under
67 Docker, which is described later.
68
693. *Understand the Hardware Topology of the Environment:* Once you
70 understand the hardware involved and the make-up of the team, you
71 can understand the hardware topology of the development environment.
72 You can get a visual idea of the machines and their roles across the
73 development environment.
74
754. *Use Git as Your Source Control Manager (SCM):* Keeping your
76 :term:`Metadata` (i.e. recipes,
77 configuration files, classes, and so forth) and any software you are
78 developing under the control of an SCM system that is compatible
79 with the OpenEmbedded build system is advisable. Of all of the SCMs
80 supported by BitBake, the Yocto Project team strongly recommends using
Andrew Geissler09209ee2020-12-13 08:44:15 -060081 :ref:`overview-manual/development-environment:git`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050082 Git is a distributed system
83 that is easy to back up, allows you to work remotely, and then
84 connects back to the infrastructure.
85
86 .. note::
87
88 For information about BitBake, see the
Andrew Geissler4c19ea12020-10-27 13:52:24 -050089 :doc:`bitbake:index`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -050090
91 It is relatively easy to set up Git services and create
Andrew Geissler4c19ea12020-10-27 13:52:24 -050092 infrastructure like :yocto_git:`/`, which is based on
Andrew Geisslerc9f78652020-09-18 14:11:35 -050093 server software called ``gitolite`` with ``cgit`` being used to
94 generate the web interface that lets you view the repositories. The
95 ``gitolite`` software identifies users using SSH keys and allows
96 branch-based access controls to repositories that you can control as
97 little or as much as necessary.
98
99 .. note::
100
101 The setup of these services is beyond the scope of this manual.
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700102 However, here are sites describing how to perform setup:
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500103
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500104 - `Gitolite <https://gitolite.com>`__: Information for
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500105 ``gitolite``.
106
107 - `Interfaces, frontends, and
108 tools <https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools>`__:
109 Documentation on how to create interfaces and frontends for
110 Git.
111
1125. *Set up the Application Development Machines:* As mentioned earlier,
113 application developers are creating applications on top of existing
114 software stacks. Following are some best practices for setting up
115 machines used for application development:
116
117 - Use a pre-built toolchain that contains the software stack
118 itself. Then, develop the application code on top of the stack.
119 This method works well for small numbers of relatively isolated
120 applications.
121
122 - Keep your cross-development toolchains updated. You can do this
123 through provisioning either as new toolchain downloads or as
124 updates through a package update mechanism using ``opkg`` to
125 provide updates to an existing toolchain. The exact mechanics of
126 how and when to do this depend on local policy.
127
128 - Use multiple toolchains installed locally into different
129 locations to allow development across versions.
130
1316. *Set up the Core Development Machines:* As mentioned earlier, core
132 developers work on the contents of the operating system itself.
133 Following are some best practices for setting up machines used for
134 developing images:
135
136 - Have the :term:`OpenEmbedded Build System` available on
137 the developer workstations so developers can run their own builds
138 and directly rebuild the software stack.
139
140 - Keep the core system unchanged as much as possible and do your
141 work in layers on top of the core system. Doing so gives you a
142 greater level of portability when upgrading to new versions of
143 the core system or Board Support Packages (BSPs).
144
145 - Share layers amongst the developers of a particular project and
146 contain the policy configuration that defines the project.
147
1487. *Set up an Autobuilder:* Autobuilders are often the core of the
149 development environment. It is here that changes from individual
150 developers are brought together and centrally tested. Based on this
151 automated build and test environment, subsequent decisions about
152 releases can be made. Autobuilders also allow for "continuous
153 integration" style testing of software components and regression
154 identification and tracking.
155
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500156 See ":yocto_ab:`Yocto Project Autobuilder <>`" for more
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500157 information and links to buildbot. The Yocto Project team has found
158 this implementation works well in this role. A public example of
159 this is the Yocto Project Autobuilders, which the Yocto Project team
160 uses to test the overall health of the project.
161
162 The features of this system are:
163
164 - Highlights when commits break the build.
165
166 - Populates an :ref:`sstate
Andrew Geissler09209ee2020-12-13 08:44:15 -0600167 cache <overview-manual/concepts:shared state cache>` from which
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500168 developers can pull rather than requiring local builds.
169
170 - Allows commit hook triggers, which trigger builds when commits
171 are made.
172
173 - Allows triggering of automated image booting and testing under
174 the QuickEMUlator (QEMU).
175
176 - Supports incremental build testing and from-scratch builds.
177
178 - Shares output that allows developer testing and historical
179 regression investigation.
180
181 - Creates output that can be used for releases.
182
183 - Allows scheduling of builds so that resources can be used
184 efficiently.
185
1868. *Set up Test Machines:* Use a small number of shared, high
187 performance systems for testing purposes. Developers can use these
188 systems for wider, more extensive testing while they continue to
189 develop locally using their primary development system.
190
1919. *Document Policies and Change Flow:* The Yocto Project uses a
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700192 hierarchical structure and a pull model. There are scripts to create and
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500193 send pull requests (i.e. ``create-pull-request`` and
194 ``send-pull-request``). This model is in line with other open source
195 projects where maintainers are responsible for specific areas of the
196 project and a single maintainer handles the final "top-of-tree"
197 merges.
198
199 .. note::
200
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500201 You can also use a more collective push model. The ``gitolite``
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500202 software supports both the push and pull models quite easily.
203
204 As with any development environment, it is important to document the
205 policy used as well as any main project guidelines so they are
206 understood by everyone. It is also a good idea to have
207 well-structured commit messages, which are usually a part of a
208 project's guidelines. Good commit messages are essential when
209 looking back in time and trying to understand why changes were made.
210
211 If you discover that changes are needed to the core layer of the
212 project, it is worth sharing those with the community as soon as
213 possible. Chances are if you have discovered the need for changes,
214 someone else in the community needs them also.
215
21610. *Development Environment Summary:* Aside from the previous steps,
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700217 here are best practices within the Yocto Project development
218 environment:
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500219
Andrew Geissler09209ee2020-12-13 08:44:15 -0600220 - Use :ref:`overview-manual/development-environment:git` as the source control
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500221 system.
222
223 - Maintain your Metadata in layers that make sense for your
Andrew Geissler09209ee2020-12-13 08:44:15 -0600224 situation. See the ":ref:`overview-manual/yp-intro:the yocto project layer model`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500225 section in the Yocto Project Overview and Concepts Manual and the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600226 ":ref:`dev-manual/common-tasks:understanding and creating layers`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500227 section for more information on layers.
228
229 - Separate the project's Metadata and code by using separate Git
Andrew Geissler09209ee2020-12-13 08:44:15 -0600230 repositories. See the ":ref:`overview-manual/development-environment:yocto project source repositories`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500231 section in the Yocto Project Overview and Concepts Manual for
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500232 information on these repositories. See the
233 ":ref:`dev-manual/start:locating yocto project source files`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500234 section for information on how to set up local Git repositories
235 for related upstream Yocto Project Git repositories.
236
237 - Set up the directory for the shared state cache
238 (:term:`SSTATE_DIR`) where
239 it makes sense. For example, set up the sstate cache on a system
240 used by developers in the same organization and share the same
241 source directories on their machines.
242
243 - Set up an Autobuilder and have it populate the sstate cache and
244 source directories.
245
246 - The Yocto Project community encourages you to send patches to the
247 project to fix bugs or add features. If you do submit patches,
248 follow the project commit guidelines for writing good commit
249 messages. See the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600250 ":ref:`dev-manual/common-tasks:submitting a change to the yocto project`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500251 section.
252
253 - Send changes to the core sooner than later as others are likely
254 to run into the same issues. For some guidance on mailing lists
255 to use, see the list in the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600256 ":ref:`dev-manual/common-tasks:submitting a change to the yocto project`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500257 section. For a description
258 of the available mailing lists, see the ":ref:`resources-mailinglist`" section in
259 the Yocto Project Reference Manual.
260
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500261Preparing the Build Host
262========================
263
264This section provides procedures to set up a system to be used as your
265:term:`Build Host` for
266development using the Yocto Project. Your build host can be a native
267Linux machine (recommended), it can be a machine (Linux, Mac, or
268Windows) that uses `CROPS <https://github.com/crops/poky-container>`__,
269which leverages `Docker Containers <https://www.docker.com/>`__ or it
270can be a Windows machine capable of running Windows Subsystem For Linux
271v2 (WSL).
272
273.. note::
274
275 The Yocto Project is not compatible with
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500276 `Windows Subsystem for Linux v1 <https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux>`__.
277 It is compatible but not officially supported nor validated with
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500278 WSLv2. If you still decide to use WSL please upgrade to
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500279 `WSLv2 <https://docs.microsoft.com/en-us/windows/wsl/install-win10>`__.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500280
281Once your build host is set up to use the Yocto Project, further steps
282are necessary depending on what you want to accomplish. See the
283following references for information on how to prepare for Board Support
284Package (BSP) development and kernel development:
285
286- *BSP Development:* See the ":ref:`bsp-guide/bsp:preparing your build host to work with bsp layers`"
287 section in the Yocto Project Board Support Package (BSP) Developer's
288 Guide.
289
Andrew Geissler09209ee2020-12-13 08:44:15 -0600290- *Kernel Development:* See the ":ref:`kernel-dev/common:preparing the build host to work on the kernel`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500291 section in the Yocto Project Linux Kernel Development Manual.
292
293Setting Up a Native Linux Host
294------------------------------
295
296Follow these steps to prepare a native Linux machine as your Yocto
297Project Build Host:
298
2991. *Use a Supported Linux Distribution:* You should have a reasonably
300 current Linux-based host system. You will have the best results with
301 a recent release of Fedora, openSUSE, Debian, Ubuntu, RHEL or CentOS
302 as these releases are frequently tested against the Yocto Project and
303 officially supported. For a list of the distributions under
304 validation and their status, see the ":ref:`Supported Linux
305 Distributions <detailed-supported-distros>`"
306 section in the Yocto Project Reference Manual and the wiki page at
Andrew Geissler09209ee2020-12-13 08:44:15 -0600307 :yocto_wiki:`Distribution Support </Distribution_Support>`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500308
3092. *Have Enough Free Memory:* Your system should have at least 50 Gbytes
310 of free disk space for building images.
311
3123. *Meet Minimal Version Requirements:* The OpenEmbedded build system
313 should be able to run on any modern distribution that has the
314 following versions for Git, tar, Python and gcc.
315
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500316 - Git &MIN_GIT_VERSION; or greater
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500317
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500318 - tar &MIN_TAR_VERSION; or greater
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500319
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500320 - Python &MIN_PYTHON_VERSION; or greater.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500321
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500322 - gcc &MIN_GCC_VERSION; or greater.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500323
Andrew Geissler5199d832021-09-24 16:47:35 -0500324 If your build host does not meet any of these listed version
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500325 requirements, you can take steps to prepare the system so that you
326 can still use the Yocto Project. See the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600327 ":ref:`ref-manual/system-requirements:required git, tar, python and gcc versions`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500328 section in the Yocto Project Reference Manual for information.
329
3304. *Install Development Host Packages:* Required development host
331 packages vary depending on your build host and what you want to do
332 with the Yocto Project. Collectively, the number of required packages
333 is large if you want to be able to cover all cases.
334
335 For lists of required packages for all scenarios, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600336 ":ref:`ref-manual/system-requirements:required packages for the build host`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500337 section in the Yocto Project Reference Manual.
338
339Once you have completed the previous steps, you are ready to continue
340using a given development path on your native Linux machine. If you are
341going to use BitBake, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600342":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500343section. If you are going
Andrew Geissler09209ee2020-12-13 08:44:15 -0600344to use the Extensible SDK, see the ":doc:`/sdk-manual/extensible`" Chapter in the Yocto
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500345Project Application Development and the Extensible Software Development
Andrew Geissler09209ee2020-12-13 08:44:15 -0600346Kit (eSDK) manual. If you want to work on the kernel, see the :doc:`/kernel-dev/index`. If you are going to use
347Toaster, see the ":doc:`/toaster-manual/setup-and-use`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500348section in the Toaster User Manual.
349
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500350Setting Up to Use CROss PlatformS (CROPS)
351-----------------------------------------
352
353With `CROPS <https://github.com/crops/poky-container>`__, which
354leverages `Docker Containers <https://www.docker.com/>`__, you can
355create a Yocto Project development environment that is operating system
356agnostic. You can set up a container in which you can develop using the
357Yocto Project on a Windows, Mac, or Linux machine.
358
359Follow these general steps to prepare a Windows, Mac, or Linux machine
360as your Yocto Project build host:
361
3621. *Determine What Your Build Host Needs:*
363 `Docker <https://www.docker.com/what-docker>`__ is a software
364 container platform that you need to install on the build host.
365 Depending on your build host, you might have to install different
366 software to support Docker containers. Go to the Docker installation
367 page and read about the platform requirements in "`Supported
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500368 Platforms <https://docs.docker.com/engine/install/#supported-platforms>`__"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500369 your build host needs to run containers.
370
3712. *Choose What To Install:* Depending on whether or not your build host
372 meets system requirements, you need to install "Docker CE Stable" or
373 the "Docker Toolbox". Most situations call for Docker CE. However, if
374 you have a build host that does not meet requirements (e.g.
375 Pre-Windows 10 or Windows 10 "Home" version), you must install Docker
376 Toolbox instead.
377
3783. *Go to the Install Site for Your Platform:* Click the link for the
379 Docker edition associated with your build host's native software. For
380 example, if your build host is running Microsoft Windows Version 10
381 and you want the Docker CE Stable edition, click that link under
382 "Supported Platforms".
383
3844. *Install the Software:* Once you have understood all the
385 pre-requisites, you can download and install the appropriate
386 software. Follow the instructions for your specific machine and the
387 type of the software you need to install:
388
Andrew Geisslerc926e172021-05-07 16:11:35 -0500389 - Install `Docker Desktop on
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500390 Windows <https://docs.docker.com/docker-for-windows/install/#install-docker-desktop-on-windows>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500391 for Windows build hosts that meet requirements.
392
Andrew Geisslerc926e172021-05-07 16:11:35 -0500393 - Install `Docker Desktop on
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500394 MacOs <https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-desktop-on-mac>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500395 for Mac build hosts that meet requirements.
396
Andrew Geisslerc926e172021-05-07 16:11:35 -0500397 - Install `Docker Engine on
398 CentOS <https://docs.docker.com/engine/install/centos/>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500399 for Linux build hosts running the CentOS distribution.
400
Andrew Geisslerc926e172021-05-07 16:11:35 -0500401 - Install `Docker Engine on
402 Debian <https://docs.docker.com/engine/install/debian/>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500403 for Linux build hosts running the Debian distribution.
404
Andrew Geisslerc926e172021-05-07 16:11:35 -0500405 - Install `Docker Engine for
406 Fedora <https://docs.docker.com/engine/install/fedora/>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500407 for Linux build hosts running the Fedora distribution.
408
Andrew Geisslerc926e172021-05-07 16:11:35 -0500409 - Install `Docker Engine for
410 Ubuntu <https://docs.docker.com/engine/install/ubuntu/>`__
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500411 for Linux build hosts running the Ubuntu distribution.
412
4135. *Optionally Orient Yourself With Docker:* If you are unfamiliar with
414 Docker and the container concept, you can learn more here -
415 https://docs.docker.com/get-started/.
416
4176. *Launch Docker or Docker Toolbox:* You should be able to launch
418 Docker or the Docker Toolbox and have a terminal shell on your
419 development host.
420
4217. *Set Up the Containers to Use the Yocto Project:* Go to
422 https://github.com/crops/docker-win-mac-docs/wiki and follow
423 the directions for your particular build host (i.e. Linux, Mac, or
424 Windows).
425
426 Once you complete the setup instructions for your machine, you have
427 the Poky, Extensible SDK, and Toaster containers available. You can
428 click those links from the page and learn more about using each of
429 those containers.
430
431Once you have a container set up, everything is in place to develop just
432as if you were running on a native Linux machine. If you are going to
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500433use the Poky container, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600434":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500435section. If you are going to use the Extensible SDK container, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600436":doc:`/sdk-manual/extensible`" Chapter in the Yocto
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500437Project Application Development and the Extensible Software Development
438Kit (eSDK) manual. If you are going to use the Toaster container, see
Andrew Geissler09209ee2020-12-13 08:44:15 -0600439the ":doc:`/toaster-manual/setup-and-use`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500440section in the Toaster User Manual.
441
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500442Setting Up to Use Windows Subsystem For Linux (WSLv2)
443-----------------------------------------------------
444
445With `Windows Subsystem for Linux
446(WSLv2) <https://docs.microsoft.com/en-us/windows/wsl/wsl2-about>`__,
447you can create a Yocto Project development environment that allows you
448to build on Windows. You can set up a Linux distribution inside Windows
449in which you can develop using the Yocto Project.
450
451Follow these general steps to prepare a Windows machine using WSLv2 as
452your Yocto Project build host:
453
4541. *Make sure your Windows 10 machine is capable of running WSLv2:*
455 WSLv2 is only available for Windows 10 builds > 18917. To check which
456 build version you are running, you may open a command prompt on
457 Windows and execute the command "ver".
458 ::
459
460 C:\Users\myuser> ver
461
462 Microsoft Windows [Version 10.0.19041.153]
463
464 If your build is capable of running
465 WSLv2 you may continue, for more information on this subject or
466 instructions on how to upgrade to WSLv2 visit `Windows 10
467 WSLv2 <https://docs.microsoft.com/en-us/windows/wsl/wsl2-install>`__
468
4692. *Install the Linux distribution of your choice inside Windows 10:*
470 Once you know your version of Windows 10 supports WSLv2, you can
471 install the distribution of your choice from the Microsoft Store.
472 Open the Microsoft Store and search for Linux. While there are
473 several Linux distributions available, the assumption is that your
474 pick will be one of the distributions supported by the Yocto Project
475 as stated on the instructions for using a native Linux host. After
476 making your selection, simply click "Get" to download and install the
477 distribution.
478
4793. *Check your Linux distribution is using WSLv2:* Open a Windows
Andrew Geisslerc926e172021-05-07 16:11:35 -0500480 PowerShell and run::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500481
482 C:\WINDOWS\system32> wsl -l -v
483 NAME STATE VERSION
484 *Ubuntu Running 2
485
486 Note the version column which says the WSL version
487 being used by your distribution, on compatible systems, this can be
488 changed back at any point in time.
489
4904. *Optionally Orient Yourself on WSL:* If you are unfamiliar with WSL,
491 you can learn more here -
492 https://docs.microsoft.com/en-us/windows/wsl/wsl2-about.
493
4945. *Launch your WSL Distibution:* From the Windows start menu simply
495 launch your WSL distribution just like any other application.
496
4976. *Optimize your WSLv2 storage often:* Due to the way storage is
498 handled on WSLv2, the storage space used by the undelying Linux
499 distribution is not reflected immedately, and since bitbake heavily
500 uses storage, after several builds, you may be unaware you are
501 running out of space. WSLv2 uses a VHDX file for storage, this issue
502 can be easily avoided by manually optimizing this file often, this
503 can be done in the following way:
504
505 1. *Find the location of your VHDX file:* First you need to find the
506 distro app package directory, to achieve this open a Windows
Andrew Geisslerc926e172021-05-07 16:11:35 -0500507 Powershell as Administrator and run::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500508
509 C:\WINDOWS\system32> Get-AppxPackage -Name "*Ubuntu*" | Select PackageFamilyName
510 PackageFamilyName
511 -----------------
512 CanonicalGroupLimited.UbuntuonWindows_79abcdefgh
513
514
515 You should now
516 replace the PackageFamilyName and your user on the following path
Andrew Geisslerc926e172021-05-07 16:11:35 -0500517 to find your VHDX file::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500518
519 ls C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\
520 Mode LastWriteTime Length Name
521 -a---- 3/14/2020 9:52 PM 57418973184 ext4.vhdx
522
523 Your VHDX file path is:
524 ``C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx``
525
526 2. *Optimize your VHDX file:* Open a Windows Powershell as
Andrew Geisslerc926e172021-05-07 16:11:35 -0500527 Administrator to optimize your VHDX file, shutting down WSL first::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500528
529 C:\WINDOWS\system32> wsl --shutdown
530 C:\WINDOWS\system32> optimize-vhd -Path C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx -Mode full
531
532 A progress bar should be shown while optimizing the
533 VHDX file, and storage should now be reflected correctly on the
534 Windows Explorer.
535
536.. note::
537
538 The current implementation of WSLv2 does not have out-of-the-box
539 access to external devices such as those connected through a USB
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500540 port, but it automatically mounts your ``C:`` drive on ``/mnt/c/``
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500541 (and others), which you can use to share deploy artifacts to be later
542 flashed on hardware through Windows, but your build directory should
543 not reside inside this mountpoint.
544
545Once you have WSLv2 set up, everything is in place to develop just as if
546you were running on a native Linux machine. If you are going to use the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600547Extensible SDK container, see the ":doc:`/sdk-manual/extensible`" Chapter in the Yocto
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500548Project Application Development and the Extensible Software Development
549Kit (eSDK) manual. If you are going to use the Toaster container, see
Andrew Geissler09209ee2020-12-13 08:44:15 -0600550the ":doc:`/toaster-manual/setup-and-use`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500551section in the Toaster User Manual.
552
553Locating Yocto Project Source Files
554===================================
555
556This section shows you how to locate, fetch and configure the source
557files you'll need to work with the Yocto Project.
558
559.. note::
560
561 - For concepts and introductory information about Git as it is used
Andrew Geissler09209ee2020-12-13 08:44:15 -0600562 in the Yocto Project, see the ":ref:`overview-manual/development-environment:git`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500563 section in the Yocto Project Overview and Concepts Manual.
564
565 - For concepts on Yocto Project source repositories, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600566 ":ref:`overview-manual/development-environment:yocto project source repositories`"
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500567 section in the Yocto Project Overview and Concepts Manual."
568
569Accessing Source Repositories
570-----------------------------
571
Andrew Geissler09209ee2020-12-13 08:44:15 -0600572Working from a copy of the upstream :ref:`dev-manual/start:accessing source repositories` is the
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500573preferred method for obtaining and using a Yocto Project release. You
574can view the Yocto Project Source Repositories at
575:yocto_git:`/`. In particular, you can find the ``poky``
Andrew Geissler09209ee2020-12-13 08:44:15 -0600576repository at :yocto_git:`/poky`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500577
578Use the following procedure to locate the latest upstream copy of the
579``poky`` Git repository:
580
5811. *Access Repositories:* Open a browser and go to
582 :yocto_git:`/` to access the GUI-based interface into the
583 Yocto Project source repositories.
584
5852. *Select the Repository:* Click on the repository in which you are
586 interested (e.g. ``poky``).
587
5883. *Find the URL Used to Clone the Repository:* At the bottom of the
589 page, note the URL used to clone that repository
Andrew Geissler09209ee2020-12-13 08:44:15 -0600590 (e.g. :yocto_git:`/poky`).
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500591
592 .. note::
593
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500594 For information on cloning a repository, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600595 ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`" section.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500596
597Accessing Index of Releases
598---------------------------
599
600Yocto Project maintains an Index of Releases area that contains related
601files that contribute to the Yocto Project. Rather than Git
602repositories, these files are tarballs that represent snapshots in time
603of a given component.
604
605.. note::
606
607 The recommended method for accessing Yocto Project components is to
608 use Git to clone the upstream repository and work from within that
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700609 locally cloned repository. However, this section documents how to
610 use a tarball snapshot of any given component.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500611
612Follow these steps to locate and download a particular tarball:
613
6141. *Access the Index of Releases:* Open a browser and go to
Andrew Geisslerc3d88e42020-10-02 09:45:00 -0500615 :yocto_dl:`Index of Releases </releases>`. The
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500616 list represents released components (e.g. ``bitbake``, ``sato``, and
617 so on).
618
619 .. note::
620
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500621 The ``yocto`` directory contains the full array of released Poky
622 tarballs. The ``poky`` directory in the Index of Releases was
623 historically used for very early releases and exists now only for
624 retroactive completeness.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500625
6262. *Select a Component:* Click on any released component in which you
627 are interested (e.g. ``yocto``).
628
6293. *Find the Tarball:* Drill down to find the associated tarball. For
630 example, click on ``yocto-&DISTRO;`` to view files associated with the
631 Yocto Project &DISTRO; release (e.g.
632 ``&YOCTO_POKY;.tar.bz2``, which is the
633 released Poky tarball).
634
6354. *Download the Tarball:* Click the tarball to download and save a
636 snapshot of the given component.
637
638Using the Downloads Page
639------------------------
640
641The :yocto_home:`Yocto Project Website <>` uses a "DOWNLOADS" page
642from which you can locate and download tarballs of any Yocto Project
643release. Rather than Git repositories, these files represent snapshot
644tarballs similar to the tarballs located in the Index of Releases
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500645described in the ":ref:`dev-manual/start:accessing index of releases`" section.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500646
Andrew Geisslerc9f78652020-09-18 14:11:35 -05006471. *Go to the Yocto Project Website:* Open The
648 :yocto_home:`Yocto Project Website <>` in your browser.
649
6502. *Get to the Downloads Area:* Select the "DOWNLOADS" item from the
651 pull-down "SOFTWARE" tab menu near the top of the page.
652
6533. *Select a Yocto Project Release:* Use the menu next to "RELEASE" to
654 display and choose a recent or past supported Yocto Project release
655 (e.g. &DISTRO_NAME_NO_CAP;, &DISTRO_NAME_NO_CAP_MINUS_ONE;, and so forth).
656
657 .. note::
658
659 For a "map" of Yocto Project releases to version numbers, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600660 :yocto_wiki:`Releases </Releases>` wiki page.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500661
662 You can use the "RELEASE ARCHIVE" link to reveal a menu of all Yocto
663 Project releases.
664
6654. *Download Tools or Board Support Packages (BSPs):* From the
666 "DOWNLOADS" page, you can download tools or BSPs as well. Just scroll
667 down the page and look for what you need.
668
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500669Cloning and Checking Out Branches
670=================================
671
672To use the Yocto Project for development, you need a release locally
673installed on your development system. This locally installed set of
674files is referred to as the :term:`Source Directory`
675in the Yocto Project documentation.
676
677The preferred method of creating your Source Directory is by using
Andrew Geissler09209ee2020-12-13 08:44:15 -0600678:ref:`overview-manual/development-environment:git` to clone a local copy of the upstream
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500679``poky`` repository. Working from a cloned copy of the upstream
680repository allows you to contribute back into the Yocto Project or to
681simply work with the latest software on a development branch. Because
682Git maintains and creates an upstream repository with a complete history
683of changes and you are working with a local clone of that repository,
684you have access to all the Yocto Project development branches and tag
685names used in the upstream repository.
686
687Cloning the ``poky`` Repository
688-------------------------------
689
690Follow these steps to create a local version of the upstream
691:term:`Poky` Git repository.
692
6931. *Set Your Directory:* Change your working directory to where you want
694 to create your local copy of ``poky``.
695
6962. *Clone the Repository:* The following example command clones the
697 ``poky`` repository and uses the default name "poky" for your local
Andrew Geisslerc926e172021-05-07 16:11:35 -0500698 repository::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500699
700 $ git clone git://git.yoctoproject.org/poky
701 Cloning into 'poky'...
702 remote: Counting objects: 432160, done.
703 remote: Compressing objects: 100% (102056/102056), done.
704 remote: Total 432160 (delta 323116), reused 432037 (delta 323000)
705 Receiving objects: 100% (432160/432160), 153.81 MiB | 8.54 MiB/s, done.
706 Resolving deltas: 100% (323116/323116), done.
707 Checking connectivity... done.
708
709 Unless you
710 specify a specific development branch or tag name, Git clones the
711 "master" branch, which results in a snapshot of the latest
712 development changes for "master". For information on how to check out
713 a specific development branch or on how to check out a local branch
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500714 based on a tag name, see the
715 ":ref:`dev-manual/start:checking out by branch in poky`" and
716 ":ref:`dev-manual/start:checking out by tag in poky`" sections, respectively.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500717
718 Once the local repository is created, you can change to that
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700719 directory and check its status. The ``master`` branch is checked out
720 by default::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500721
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500722 $ cd poky
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500723 $ git status
724 On branch master
725 Your branch is up-to-date with 'origin/master'.
726 nothing to commit, working directory clean
727 $ git branch
728 * master
729
730 Your local repository of poky is identical to the
731 upstream poky repository at the time from which it was cloned. As you
732 work with the local branch, you can periodically use the
733 ``git pull --rebase`` command to be sure you are up-to-date
734 with the upstream branch.
735
736Checking Out by Branch in Poky
737------------------------------
738
739When you clone the upstream poky repository, you have access to all its
740development branches. Each development branch in a repository is unique
741as it forks off the "master" branch. To see and use the files of a
742particular development branch locally, you need to know the branch name
743and then specifically check out that development branch.
744
745.. note::
746
747 Checking out an active development branch by branch name gives you a
748 snapshot of that particular branch at the time you check it out.
749 Further development on top of the branch that occurs after check it
750 out can occur.
751
7521. *Switch to the Poky Directory:* If you have a local poky Git
753 repository, switch to that directory. If you do not have the local
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500754 copy of poky, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600755 ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500756 section.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500757
7582. *Determine Existing Branch Names:*
759 ::
760
761 $ git branch -a
762 * master
763 remotes/origin/1.1_M1
764 remotes/origin/1.1_M2
765 remotes/origin/1.1_M3
766 remotes/origin/1.1_M4
767 remotes/origin/1.2_M1
768 remotes/origin/1.2_M2
769 remotes/origin/1.2_M3
770 . . .
771 remotes/origin/thud
772 remotes/origin/thud-next
773 remotes/origin/warrior
774 remotes/origin/warrior-next
775 remotes/origin/zeus
776 remotes/origin/zeus-next
777 ... and so on ...
778
7793. *Check out the Branch:* Check out the development branch in which you
780 want to work. For example, to access the files for the Yocto Project
Andrew Geisslerc926e172021-05-07 16:11:35 -0500781 &DISTRO; Release (&DISTRO_NAME;), use the following command::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500782
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500783 $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP;
784 Branch &DISTRO_NAME_NO_CAP; set up to track remote branch &DISTRO_NAME_NO_CAP; from origin.
785 Switched to a new branch '&DISTRO_NAME_NO_CAP;'
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500786
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500787 The previous command checks out the "&DISTRO_NAME_NO_CAP;" development
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500788 branch and reports that the branch is tracking the upstream
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500789 "origin/&DISTRO_NAME_NO_CAP;" branch.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500790
791 The following command displays the branches that are now part of your
792 local poky repository. The asterisk character indicates the branch
Andrew Geisslerc926e172021-05-07 16:11:35 -0500793 that is currently checked out for work::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500794
795 $ git branch
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500796 master
797 * &DISTRO_NAME_NO_CAP;
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500798
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500799Checking Out by Tag in Poky
800---------------------------
801
802Similar to branches, the upstream repository uses tags to mark specific
803commits associated with significant points in a development branch (i.e.
804a release point or stage of a release). You might want to set up a local
805branch based on one of those points in the repository. The process is
806similar to checking out by branch name except you use tag names.
807
808.. note::
809
810 Checking out a branch based on a tag gives you a stable set of files
811 not affected by development on the branch above the tag.
812
8131. *Switch to the Poky Directory:* If you have a local poky Git
814 repository, switch to that directory. If you do not have the local
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500815 copy of poky, see the
Andrew Geissler09209ee2020-12-13 08:44:15 -0600816 ":ref:`dev-manual/start:cloning the \`\`poky\`\` repository`"
Andrew Geissler4c19ea12020-10-27 13:52:24 -0500817 section.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500818
8192. *Fetch the Tag Names:* To checkout the branch based on a tag name,
Andrew Geisslerc926e172021-05-07 16:11:35 -0500820 you need to fetch the upstream tags into your local repository::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500821
822 $ git fetch --tags
823 $
824
Andrew Geisslerc926e172021-05-07 16:11:35 -05008253. *List the Tag Names:* You can list the tag names now::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500826
827 $ git tag
828 1.1_M1.final
829 1.1_M1.rc1
830 1.1_M1.rc2
831 1.1_M2.final
832 1.1_M2.rc1
833 .
834 .
835 .
836 yocto-2.5
837 yocto-2.5.1
838 yocto-2.5.2
839 yocto-2.5.3
840 yocto-2.6
841 yocto-2.6.1
842 yocto-2.6.2
843 yocto-2.7
844 yocto_1.5_M5.rc8
845
846
8474. *Check out the Branch:*
848 ::
849
850 $ git checkout tags/yocto-&DISTRO; -b my_yocto_&DISTRO;
851 Switched to a new branch 'my_yocto_&DISTRO;'
852 $ git branch
853 master
854 * my_yocto_&DISTRO;
855
856 The previous command creates and
857 checks out a local branch named "my_yocto_&DISTRO;", which is based on
858 the commit in the upstream poky repository that has the same tag. In
859 this example, the files you have available locally as a result of the
860 ``checkout`` command are a snapshot of the "&DISTRO_NAME_NO_CAP;"
861 development branch at the point where Yocto Project &DISTRO; was
862 released.