diff options
Diffstat (limited to 'documentation/dev-manual/dev-manual-start.rst')
-rw-r--r-- | documentation/dev-manual/dev-manual-start.rst | 873 |
1 files changed, 873 insertions, 0 deletions
diff --git a/documentation/dev-manual/dev-manual-start.rst b/documentation/dev-manual/dev-manual-start.rst new file mode 100644 index 0000000000..9ddd29c664 --- /dev/null +++ b/documentation/dev-manual/dev-manual-start.rst | |||
@@ -0,0 +1,873 @@ | |||
1 | *********************************** | ||
2 | Setting Up to Use the Yocto Project | ||
3 | *********************************** | ||
4 | |||
5 | This chapter provides guidance on how to prepare to use the Yocto | ||
6 | Project. You can learn about creating a team environment that develops | ||
7 | using the Yocto Project, how to set up a `build | ||
8 | host <&YOCTO_DOCS_REF_URL;#hardware-build-system-term>`__, how to locate | ||
9 | Yocto Project source repositories, and how to create local Git | ||
10 | repositories. | ||
11 | |||
12 | .. _usingpoky-changes-collaborate: | ||
13 | |||
14 | Creating a Team Development Environment | ||
15 | ======================================= | ||
16 | |||
17 | It might not be immediately clear how you can use the Yocto Project in a | ||
18 | team development environment, or how to scale it for a large team of | ||
19 | developers. You can adapt the Yocto Project to many different use cases | ||
20 | and scenarios; however, this flexibility could cause difficulties if you | ||
21 | are trying to create a working setup that scales effectively. | ||
22 | |||
23 | To help you understand how to set up this type of environment, this | ||
24 | section presents a procedure that gives you information that can help | ||
25 | you get the results you want. The procedure is high-level and presents | ||
26 | some of the project's most successful experiences, practices, solutions, | ||
27 | and available technologies that have proved to work well in the past; | ||
28 | however, keep in mind, the procedure here is simply a starting point. | ||
29 | You can build off these steps and customize the procedure to fit any | ||
30 | particular working environment and set of practices. | ||
31 | |||
32 | 1. *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 | |||
39 | The following roles exist: | ||
40 | |||
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 | |||
55 | 2. *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 | |||
69 | 3. *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 | |||
75 | 4. *Use Git as Your Source Control Manager (SCM):* Keeping your | ||
76 | `Metadata <&YOCTO_DOCS_REF_URL;#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 | ||
81 | using `Git <&YOCTO_DOCS_OM_URL;#git>`__. Git is a distributed system | ||
82 | that is easy to back up, allows you to work remotely, and then | ||
83 | connects back to the infrastructure. | ||
84 | |||
85 | .. note:: | ||
86 | |||
87 | For information about BitBake, see the | ||
88 | BitBake User Manual | ||
89 | . | ||
90 | |||
91 | It is relatively easy to set up Git services and create | ||
92 | infrastructure like | ||
93 | `http://git.yoctoproject.org <&YOCTO_GIT_URL;>`__, which is based on | ||
94 | server software called ``gitolite`` with ``cgit`` being used to | ||
95 | generate the web interface that lets you view the repositories. The | ||
96 | ``gitolite`` software identifies users using SSH keys and allows | ||
97 | branch-based access controls to repositories that you can control as | ||
98 | little or as much as necessary. | ||
99 | |||
100 | .. note:: | ||
101 | |||
102 | The setup of these services is beyond the scope of this manual. | ||
103 | However, sites such as the following exist that describe how to | ||
104 | perform setup: | ||
105 | |||
106 | - `Git documentation <http://git-scm.com/book/ch4-8.html>`__: | ||
107 | Describes how to install ``gitolite`` on the server. | ||
108 | |||
109 | - `Gitolite <http://gitolite.com>`__: Information for | ||
110 | ``gitolite``. | ||
111 | |||
112 | - `Interfaces, frontends, and | ||
113 | tools <https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools>`__: | ||
114 | Documentation on how to create interfaces and frontends for | ||
115 | Git. | ||
116 | |||
117 | 5. *Set up the Application Development Machines:* As mentioned earlier, | ||
118 | application developers are creating applications on top of existing | ||
119 | software stacks. Following are some best practices for setting up | ||
120 | machines used for application development: | ||
121 | |||
122 | - Use a pre-built toolchain that contains the software stack | ||
123 | itself. Then, develop the application code on top of the stack. | ||
124 | This method works well for small numbers of relatively isolated | ||
125 | applications. | ||
126 | |||
127 | - Keep your cross-development toolchains updated. You can do this | ||
128 | through provisioning either as new toolchain downloads or as | ||
129 | updates through a package update mechanism using ``opkg`` to | ||
130 | provide updates to an existing toolchain. The exact mechanics of | ||
131 | how and when to do this depend on local policy. | ||
132 | |||
133 | - Use multiple toolchains installed locally into different | ||
134 | locations to allow development across versions. | ||
135 | |||
136 | 6. *Set up the Core Development Machines:* As mentioned earlier, core | ||
137 | developers work on the contents of the operating system itself. | ||
138 | Following are some best practices for setting up machines used for | ||
139 | developing images: | ||
140 | |||
141 | - Have the `OpenEmbedded build | ||
142 | system <&YOCTO_DOCS_REF_URL;#build-system-term>`__ available on | ||
143 | the developer workstations so developers can run their own builds | ||
144 | and directly rebuild the software stack. | ||
145 | |||
146 | - Keep the core system unchanged as much as possible and do your | ||
147 | work in layers on top of the core system. Doing so gives you a | ||
148 | greater level of portability when upgrading to new versions of | ||
149 | the core system or Board Support Packages (BSPs). | ||
150 | |||
151 | - Share layers amongst the developers of a particular project and | ||
152 | contain the policy configuration that defines the project. | ||
153 | |||
154 | 7. *Set up an Autobuilder:* Autobuilders are often the core of the | ||
155 | development environment. It is here that changes from individual | ||
156 | developers are brought together and centrally tested. Based on this | ||
157 | automated build and test environment, subsequent decisions about | ||
158 | releases can be made. Autobuilders also allow for "continuous | ||
159 | integration" style testing of software components and regression | ||
160 | identification and tracking. | ||
161 | |||
162 | See "`Yocto Project | ||
163 | Autobuilder <http://autobuilder.yoctoproject.org>`__" for more | ||
164 | information and links to buildbot. The Yocto Project team has found | ||
165 | this implementation works well in this role. A public example of | ||
166 | this is the Yocto Project Autobuilders, which the Yocto Project team | ||
167 | uses to test the overall health of the project. | ||
168 | |||
169 | The features of this system are: | ||
170 | |||
171 | - Highlights when commits break the build. | ||
172 | |||
173 | - Populates an `sstate | ||
174 | cache <&YOCTO_DOCS_OM_URL;#shared-state-cache>`__ from which | ||
175 | developers can pull rather than requiring local builds. | ||
176 | |||
177 | - Allows commit hook triggers, which trigger builds when commits | ||
178 | are made. | ||
179 | |||
180 | - Allows triggering of automated image booting and testing under | ||
181 | the QuickEMUlator (QEMU). | ||
182 | |||
183 | - Supports incremental build testing and from-scratch builds. | ||
184 | |||
185 | - Shares output that allows developer testing and historical | ||
186 | regression investigation. | ||
187 | |||
188 | - Creates output that can be used for releases. | ||
189 | |||
190 | - Allows scheduling of builds so that resources can be used | ||
191 | efficiently. | ||
192 | |||
193 | 8. *Set up Test Machines:* Use a small number of shared, high | ||
194 | performance systems for testing purposes. Developers can use these | ||
195 | systems for wider, more extensive testing while they continue to | ||
196 | develop locally using their primary development system. | ||
197 | |||
198 | 9. *Document Policies and Change Flow:* The Yocto Project uses a | ||
199 | hierarchical structure and a pull model. Scripts exist to create and | ||
200 | send pull requests (i.e. ``create-pull-request`` and | ||
201 | ``send-pull-request``). This model is in line with other open source | ||
202 | projects where maintainers are responsible for specific areas of the | ||
203 | project and a single maintainer handles the final "top-of-tree" | ||
204 | merges. | ||
205 | |||
206 | .. note:: | ||
207 | |||
208 | You can also use a more collective push model. The | ||
209 | gitolite | ||
210 | software supports both the push and pull models quite easily. | ||
211 | |||
212 | As with any development environment, it is important to document the | ||
213 | policy used as well as any main project guidelines so they are | ||
214 | understood by everyone. It is also a good idea to have | ||
215 | well-structured commit messages, which are usually a part of a | ||
216 | project's guidelines. Good commit messages are essential when | ||
217 | looking back in time and trying to understand why changes were made. | ||
218 | |||
219 | If you discover that changes are needed to the core layer of the | ||
220 | project, it is worth sharing those with the community as soon as | ||
221 | possible. Chances are if you have discovered the need for changes, | ||
222 | someone else in the community needs them also. | ||
223 | |||
224 | 10. *Development Environment Summary:* Aside from the previous steps, | ||
225 | some best practices exist within the Yocto Project development | ||
226 | environment. Consider the following: | ||
227 | |||
228 | - Use `Git <&YOCTO_DOCS_OM_URL;#git>`__ as the source control | ||
229 | system. | ||
230 | |||
231 | - Maintain your Metadata in layers that make sense for your | ||
232 | situation. See the "`The Yocto Project Layer | ||
233 | Model <&YOCTO_DOCS_OM_URL;#the-yocto-project-layer-model>`__" | ||
234 | section in the Yocto Project Overview and Concepts Manual and the | ||
235 | "`Understanding and Creating | ||
236 | Layers <#understanding-and-creating-layers>`__" section for more | ||
237 | information on layers. | ||
238 | |||
239 | - Separate the project's Metadata and code by using separate Git | ||
240 | repositories. See the "`Yocto Project Source | ||
241 | Repositories <&YOCTO_DOCS_OM_URL;#yocto-project-repositories>`__" | ||
242 | section in the Yocto Project Overview and Concepts Manual for | ||
243 | information on these repositories. See the "`Locating Yocto | ||
244 | Project Source Files <#locating-yocto-project-source-files>`__" | ||
245 | section for information on how to set up local Git repositories | ||
246 | for related upstream Yocto Project Git repositories. | ||
247 | |||
248 | - Set up the directory for the shared state cache | ||
249 | (```SSTATE_DIR`` <&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR>`__) where | ||
250 | it makes sense. For example, set up the sstate cache on a system | ||
251 | used by developers in the same organization and share the same | ||
252 | source directories on their machines. | ||
253 | |||
254 | - Set up an Autobuilder and have it populate the sstate cache and | ||
255 | source directories. | ||
256 | |||
257 | - The Yocto Project community encourages you to send patches to the | ||
258 | project to fix bugs or add features. If you do submit patches, | ||
259 | follow the project commit guidelines for writing good commit | ||
260 | messages. See the "`Submitting a Change to the Yocto | ||
261 | Project <#how-to-submit-a-change>`__" section. | ||
262 | |||
263 | - Send changes to the core sooner than later as others are likely | ||
264 | to run into the same issues. For some guidance on mailing lists | ||
265 | to use, see the list in the "`Submitting a Change to the Yocto | ||
266 | Project <#how-to-submit-a-change>`__" section. For a description | ||
267 | of the available mailing lists, see the "`Mailing | ||
268 | Lists <&YOCTO_DOCS_REF_URL;#resources-mailinglist>`__" section in | ||
269 | the Yocto Project Reference Manual. | ||
270 | |||
271 | .. _dev-preparing-the-build-host: | ||
272 | |||
273 | Preparing the Build Host | ||
274 | ======================== | ||
275 | |||
276 | This section provides procedures to set up a system to be used as your | ||
277 | `build host <&YOCTO_DOCS_REF_URL;#hardware-build-system-term>`__ for | ||
278 | development using the Yocto Project. Your build host can be a native | ||
279 | Linux machine (recommended), it can be a machine (Linux, Mac, or | ||
280 | Windows) that uses `CROPS <https://github.com/crops/poky-container>`__, | ||
281 | which leverages `Docker Containers <https://www.docker.com/>`__ or it | ||
282 | can be a Windows machine capable of running Windows Subsystem For Linux | ||
283 | v2 (WSL). | ||
284 | |||
285 | .. note:: | ||
286 | |||
287 | The Yocto Project is not compatible with | ||
288 | Windows Subsystem for Linux v1 | ||
289 | . It is compatible but not officially supported nor validated with | ||
290 | WSLv2. If you still decide to use WSL please upgrade to | ||
291 | WSLv2 | ||
292 | . | ||
293 | |||
294 | Once your build host is set up to use the Yocto Project, further steps | ||
295 | are necessary depending on what you want to accomplish. See the | ||
296 | following references for information on how to prepare for Board Support | ||
297 | Package (BSP) development and kernel development: | ||
298 | |||
299 | - *BSP Development:* See the "`Preparing Your Build Host to Work With | ||
300 | BSP | ||
301 | Layers <&YOCTO_DOCS_BSP_URL;#preparing-your-build-host-to-work-with-bsp-layers>`__" | ||
302 | section in the Yocto Project Board Support Package (BSP) Developer's | ||
303 | Guide. | ||
304 | |||
305 | - *Kernel Development:* See the "`Preparing the Build Host to Work on | ||
306 | the | ||
307 | Kernel <&YOCTO_DOCS_KERNEL_DEV_URL;#preparing-the-build-host-to-work-on-the-kernel>`__" | ||
308 | section in the Yocto Project Linux Kernel Development Manual. | ||
309 | |||
310 | Setting Up a Native Linux Host | ||
311 | ------------------------------ | ||
312 | |||
313 | Follow these steps to prepare a native Linux machine as your Yocto | ||
314 | Project Build Host: | ||
315 | |||
316 | 1. *Use a Supported Linux Distribution:* You should have a reasonably | ||
317 | current Linux-based host system. You will have the best results with | ||
318 | a recent release of Fedora, openSUSE, Debian, Ubuntu, RHEL or CentOS | ||
319 | as these releases are frequently tested against the Yocto Project and | ||
320 | officially supported. For a list of the distributions under | ||
321 | validation and their status, see the "`Supported Linux | ||
322 | Distributions <&YOCTO_DOCS_REF_URL;#detailed-supported-distros>`__" | ||
323 | section in the Yocto Project Reference Manual and the wiki page at | ||
324 | `Distribution | ||
325 | Support <&YOCTO_WIKI_URL;/wiki/Distribution_Support>`__. | ||
326 | |||
327 | 2. *Have Enough Free Memory:* Your system should have at least 50 Gbytes | ||
328 | of free disk space for building images. | ||
329 | |||
330 | 3. *Meet Minimal Version Requirements:* The OpenEmbedded build system | ||
331 | should be able to run on any modern distribution that has the | ||
332 | following versions for Git, tar, Python and gcc. | ||
333 | |||
334 | - Git 1.8.3.1 or greater | ||
335 | |||
336 | - tar 1.28 or greater | ||
337 | |||
338 | - Python 3.5.0 or greater. | ||
339 | |||
340 | - gcc 5.0 or greater. | ||
341 | |||
342 | If your build host does not meet any of these three listed version | ||
343 | requirements, you can take steps to prepare the system so that you | ||
344 | can still use the Yocto Project. See the "`Required Git, tar, Python | ||
345 | and gcc | ||
346 | Versions <&YOCTO_DOCS_REF_URL;#required-git-tar-python-and-gcc-versions>`__" | ||
347 | section in the Yocto Project Reference Manual for information. | ||
348 | |||
349 | 4. *Install Development Host Packages:* Required development host | ||
350 | packages vary depending on your build host and what you want to do | ||
351 | with the Yocto Project. Collectively, the number of required packages | ||
352 | is large if you want to be able to cover all cases. | ||
353 | |||
354 | For lists of required packages for all scenarios, see the "`Required | ||
355 | Packages for the Build | ||
356 | Host <&YOCTO_DOCS_REF_URL;#required-packages-for-the-build-host>`__" | ||
357 | section in the Yocto Project Reference Manual. | ||
358 | |||
359 | Once you have completed the previous steps, you are ready to continue | ||
360 | using a given development path on your native Linux machine. If you are | ||
361 | going to use BitBake, see the "`Cloning the ``poky`` | ||
362 | Repository <#cloning-the-poky-repository>`__" section. If you are going | ||
363 | to use the Extensible SDK, see the "`Using the Extensible | ||
364 | SDK <&YOCTO_DOCS_SDK_URL;#sdk-extensible>`__" Chapter in the Yocto | ||
365 | Project Application Development and the Extensible Software Development | ||
366 | Kit (eSDK) manual. If you want to work on the kernel, see the `Yocto | ||
367 | Project Linux Kernel Development | ||
368 | Manual <&YOCTO_DOCS_KERNEL_DEV_URL;>`__. If you are going to use | ||
369 | Toaster, see the "`Setting Up and Using | ||
370 | Toaster <&YOCTO_DOCS_TOAST_URL;#toaster-manual-setup-and-use>`__" | ||
371 | section in the Toaster User Manual. | ||
372 | |||
373 | .. _setting-up-to-use-crops: | ||
374 | |||
375 | Setting Up to Use CROss PlatformS (CROPS) | ||
376 | ----------------------------------------- | ||
377 | |||
378 | With `CROPS <https://github.com/crops/poky-container>`__, which | ||
379 | leverages `Docker Containers <https://www.docker.com/>`__, you can | ||
380 | create a Yocto Project development environment that is operating system | ||
381 | agnostic. You can set up a container in which you can develop using the | ||
382 | Yocto Project on a Windows, Mac, or Linux machine. | ||
383 | |||
384 | Follow these general steps to prepare a Windows, Mac, or Linux machine | ||
385 | as your Yocto Project build host: | ||
386 | |||
387 | 1. *Determine What Your Build Host Needs:* | ||
388 | `Docker <https://www.docker.com/what-docker>`__ is a software | ||
389 | container platform that you need to install on the build host. | ||
390 | Depending on your build host, you might have to install different | ||
391 | software to support Docker containers. Go to the Docker installation | ||
392 | page and read about the platform requirements in "`Supported | ||
393 | Platforms <https://docs.docker.com/install/#supported-platforms>`__" | ||
394 | your build host needs to run containers. | ||
395 | |||
396 | 2. *Choose What To Install:* Depending on whether or not your build host | ||
397 | meets system requirements, you need to install "Docker CE Stable" or | ||
398 | the "Docker Toolbox". Most situations call for Docker CE. However, if | ||
399 | you have a build host that does not meet requirements (e.g. | ||
400 | Pre-Windows 10 or Windows 10 "Home" version), you must install Docker | ||
401 | Toolbox instead. | ||
402 | |||
403 | 3. *Go to the Install Site for Your Platform:* Click the link for the | ||
404 | Docker edition associated with your build host's native software. For | ||
405 | example, if your build host is running Microsoft Windows Version 10 | ||
406 | and you want the Docker CE Stable edition, click that link under | ||
407 | "Supported Platforms". | ||
408 | |||
409 | 4. *Install the Software:* Once you have understood all the | ||
410 | pre-requisites, you can download and install the appropriate | ||
411 | software. Follow the instructions for your specific machine and the | ||
412 | type of the software you need to install: | ||
413 | |||
414 | - Install `Docker CE for | ||
415 | Windows <https://docs.docker.com/docker-for-windows/install/#install-docker-for-windows-desktop-app>`__ | ||
416 | for Windows build hosts that meet requirements. | ||
417 | |||
418 | - Install `Docker CE for | ||
419 | Macs <https://docs.docker.com/docker-for-mac/install/#install-and-run-docker-for-mac>`__ | ||
420 | for Mac build hosts that meet requirements. | ||
421 | |||
422 | - Install `Docker Toolbox for | ||
423 | Windows <https://docs.docker.com/toolbox/toolbox_install_windows/>`__ | ||
424 | for Windows build hosts that do not meet Docker requirements. | ||
425 | |||
426 | - Install `Docker Toolbox for | ||
427 | MacOS <https://docs.docker.com/toolbox/toolbox_install_mac/>`__ | ||
428 | for Mac build hosts that do not meet Docker requirements. | ||
429 | |||
430 | - Install `Docker CE for | ||
431 | CentOS <https://docs.docker.com/install/linux/docker-ce/centos/>`__ | ||
432 | for Linux build hosts running the CentOS distribution. | ||
433 | |||
434 | - Install `Docker CE for | ||
435 | Debian <https://docs.docker.com/install/linux/docker-ce/debian/>`__ | ||
436 | for Linux build hosts running the Debian distribution. | ||
437 | |||
438 | - Install `Docker CE for | ||
439 | Fedora <https://docs.docker.com/install/linux/docker-ce/fedora/>`__ | ||
440 | for Linux build hosts running the Fedora distribution. | ||
441 | |||
442 | - Install `Docker CE for | ||
443 | Ubuntu <https://docs.docker.com/install/linux/docker-ce/ubuntu/>`__ | ||
444 | for Linux build hosts running the Ubuntu distribution. | ||
445 | |||
446 | 5. *Optionally Orient Yourself With Docker:* If you are unfamiliar with | ||
447 | Docker and the container concept, you can learn more here - | ||
448 | ` <https://docs.docker.com/get-started/>`__. | ||
449 | |||
450 | 6. *Launch Docker or Docker Toolbox:* You should be able to launch | ||
451 | Docker or the Docker Toolbox and have a terminal shell on your | ||
452 | development host. | ||
453 | |||
454 | 7. *Set Up the Containers to Use the Yocto Project:* Go to | ||
455 | ` <https://github.com/crops/docker-win-mac-docs/wiki>`__ and follow | ||
456 | the directions for your particular build host (i.e. Linux, Mac, or | ||
457 | Windows). | ||
458 | |||
459 | Once you complete the setup instructions for your machine, you have | ||
460 | the Poky, Extensible SDK, and Toaster containers available. You can | ||
461 | click those links from the page and learn more about using each of | ||
462 | those containers. | ||
463 | |||
464 | Once you have a container set up, everything is in place to develop just | ||
465 | as if you were running on a native Linux machine. If you are going to | ||
466 | use the Poky container, see the "`Cloning the ``poky`` | ||
467 | Repository <#cloning-the-poky-repository>`__" section. If you are going | ||
468 | to use the Extensible SDK container, see the "`Using the Extensible | ||
469 | SDK <&YOCTO_DOCS_SDK_URL;#sdk-extensible>`__" Chapter in the Yocto | ||
470 | Project Application Development and the Extensible Software Development | ||
471 | Kit (eSDK) manual. If you are going to use the Toaster container, see | ||
472 | the "`Setting Up and Using | ||
473 | Toaster <&YOCTO_DOCS_TOAST_URL;#toaster-manual-setup-and-use>`__" | ||
474 | section in the Toaster User Manual. | ||
475 | |||
476 | .. _setting-up-to-use-wsl: | ||
477 | |||
478 | Setting Up to Use Windows Subsystem For Linux (WSLv2) | ||
479 | ----------------------------------------------------- | ||
480 | |||
481 | With `Windows Subsystem for Linux | ||
482 | (WSLv2) <https://docs.microsoft.com/en-us/windows/wsl/wsl2-about>`__, | ||
483 | you can create a Yocto Project development environment that allows you | ||
484 | to build on Windows. You can set up a Linux distribution inside Windows | ||
485 | in which you can develop using the Yocto Project. | ||
486 | |||
487 | Follow these general steps to prepare a Windows machine using WSLv2 as | ||
488 | your Yocto Project build host: | ||
489 | |||
490 | 1. *Make sure your Windows 10 machine is capable of running WSLv2:* | ||
491 | WSLv2 is only available for Windows 10 builds > 18917. To check which | ||
492 | build version you are running, you may open a command prompt on | ||
493 | Windows and execute the command "ver". C:\Users\myuser> ver Microsoft | ||
494 | Windows [Version 10.0.19041.153] If your build is capable of running | ||
495 | WSLv2 you may continue, for more information on this subject or | ||
496 | instructions on how to upgrade to WSLv2 visit `Windows 10 | ||
497 | WSLv2 <https://docs.microsoft.com/en-us/windows/wsl/wsl2-install>`__ | ||
498 | |||
499 | 2. *Install the Linux distribution of your choice inside Windows 10:* | ||
500 | Once you know your version of Windows 10 supports WSLv2, you can | ||
501 | install the distribution of your choice from the Microsoft Store. | ||
502 | Open the Microsoft Store and search for Linux. While there are | ||
503 | several Linux distributions available, the assumption is that your | ||
504 | pick will be one of the distributions supported by the Yocto Project | ||
505 | as stated on the instructions for using a native Linux host. After | ||
506 | making your selection, simply click "Get" to download and install the | ||
507 | distribution. | ||
508 | |||
509 | 3. *Check your Linux distribution is using WSLv2:* Open a Windows | ||
510 | PowerShell and run: C:\WINDOWS\system32> wsl -l -v NAME STATE VERSION | ||
511 | \*Ubuntu Running 2 Note the version column which says the WSL version | ||
512 | being used by your distribution, on compatible systems, this can be | ||
513 | changed back at any point in time. | ||
514 | |||
515 | 4. *Optionally Orient Yourself on WSL:* If you are unfamiliar with WSL, | ||
516 | you can learn more here - | ||
517 | ` <https://docs.microsoft.com/en-us/windows/wsl/wsl2-about>`__. | ||
518 | |||
519 | 5. *Launch your WSL Distibution:* From the Windows start menu simply | ||
520 | launch your WSL distribution just like any other application. | ||
521 | |||
522 | 6. *Optimize your WSLv2 storage often:* Due to the way storage is | ||
523 | handled on WSLv2, the storage space used by the undelying Linux | ||
524 | distribution is not reflected immedately, and since bitbake heavily | ||
525 | uses storage, after several builds, you may be unaware you are | ||
526 | running out of space. WSLv2 uses a VHDX file for storage, this issue | ||
527 | can be easily avoided by manually optimizing this file often, this | ||
528 | can be done in the following way: | ||
529 | |||
530 | 1. *Find the location of your VHDX file:* First you need to find the | ||
531 | distro app package directory, to achieve this open a Windows | ||
532 | Powershell as Administrator and run: C:\WINDOWS\system32> | ||
533 | Get-AppxPackage -Name "*Ubuntu*" \| Select PackageFamilyName | ||
534 | PackageFamilyName ----------------- | ||
535 | CanonicalGroupLimited.UbuntuonWindows_79abcdefgh You should now | ||
536 | replace the PackageFamilyName and your user on the following path | ||
537 | to find your VHDX file: | ||
538 | ``C:\Users\user\AppData\Local\Packages\PackageFamilyName\LocalState\`` | ||
539 | For example: ls | ||
540 | C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\\ | ||
541 | Mode LastWriteTime Length Name -a---- 3/14/2020 9:52 PM | ||
542 | 57418973184 ext4.vhdx Your VHDX file path is: | ||
543 | ``C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx`` | ||
544 | |||
545 | 2. *Optimize your VHDX file:* Open a Windows Powershell as | ||
546 | Administrator to optimize your VHDX file, shutting down WSL first: | ||
547 | C:\WINDOWS\system32> wsl --shutdown C:\WINDOWS\system32> | ||
548 | optimize-vhd -Path | ||
549 | C:\Users\myuser\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79abcdefgh\LocalState\ext4.vhdx | ||
550 | -Mode full A progress bar should be shown while optimizing the | ||
551 | VHDX file, and storage should now be reflected correctly on the | ||
552 | Windows Explorer. | ||
553 | |||
554 | .. note:: | ||
555 | |||
556 | The current implementation of WSLv2 does not have out-of-the-box | ||
557 | access to external devices such as those connected through a USB | ||
558 | port, but it automatically mounts your | ||
559 | C: | ||
560 | drive on | ||
561 | /mnt/c/ | ||
562 | (and others), which you can use to share deploy artifacts to be later | ||
563 | flashed on hardware through Windows, but your build directory should | ||
564 | not reside inside this mountpoint. | ||
565 | |||
566 | Once you have WSLv2 set up, everything is in place to develop just as if | ||
567 | you were running on a native Linux machine. If you are going to use the | ||
568 | Extensible SDK container, see the "`Using the Extensible | ||
569 | SDK <&YOCTO_DOCS_SDK_URL;#sdk-extensible>`__" Chapter in the Yocto | ||
570 | Project Application Development and the Extensible Software Development | ||
571 | Kit (eSDK) manual. If you are going to use the Toaster container, see | ||
572 | the "`Setting Up and Using | ||
573 | Toaster <&YOCTO_DOCS_TOAST_URL;#toaster-manual-setup-and-use>`__" | ||
574 | section in the Toaster User Manual. | ||
575 | |||
576 | Locating Yocto Project Source Files | ||
577 | =================================== | ||
578 | |||
579 | This section shows you how to locate, fetch and configure the source | ||
580 | files you'll need to work with the Yocto Project. | ||
581 | |||
582 | .. note:: | ||
583 | |||
584 | - For concepts and introductory information about Git as it is used | ||
585 | in the Yocto Project, see the "`Git <&YOCTO_DOCS_OM_URL;#git>`__" | ||
586 | section in the Yocto Project Overview and Concepts Manual. | ||
587 | |||
588 | - For concepts on Yocto Project source repositories, see the "`Yocto | ||
589 | Project Source | ||
590 | Repositories <&YOCTO_DOCS_OM_URL;#yocto-project-repositories>`__" | ||
591 | section in the Yocto Project Overview and Concepts Manual." | ||
592 | |||
593 | Accessing Source Repositories | ||
594 | ----------------------------- | ||
595 | |||
596 | Working from a copy of the upstream Yocto Project `Source | ||
597 | Repositories <&YOCTO_DOCS_OM_URL;#source-repositories>`__ is the | ||
598 | preferred method for obtaining and using a Yocto Project release. You | ||
599 | can view the Yocto Project Source Repositories at | ||
600 | ` <&YOCTO_GIT_URL;>`__. In particular, you can find the ``poky`` | ||
601 | repository at ` <http://git.yoctoproject.org/cgit/cgit.cgi/poky/>`__. | ||
602 | |||
603 | Use the following procedure to locate the latest upstream copy of the | ||
604 | ``poky`` Git repository: | ||
605 | |||
606 | 1. *Access Repositories:* Open a browser and go to | ||
607 | ` <&YOCTO_GIT_URL;>`__ to access the GUI-based interface into the | ||
608 | Yocto Project source repositories. | ||
609 | |||
610 | 2. *Select the Repository:* Click on the repository in which you are | ||
611 | interested (e.g. ``poky``). | ||
612 | |||
613 | 3. *Find the URL Used to Clone the Repository:* At the bottom of the | ||
614 | page, note the URL used to | ||
615 | `clone <&YOCTO_DOCS_OM_URL;#git-commands-clone>`__ that repository | ||
616 | (e.g. ``YOCTO_GIT_URL/poky``). | ||
617 | |||
618 | .. note:: | ||
619 | |||
620 | For information on cloning a repository, see the " | ||
621 | Cloning the | ||
622 | poky | ||
623 | Repository | ||
624 | " section. | ||
625 | |||
626 | Accessing Index of Releases | ||
627 | --------------------------- | ||
628 | |||
629 | Yocto Project maintains an Index of Releases area that contains related | ||
630 | files that contribute to the Yocto Project. Rather than Git | ||
631 | repositories, these files are tarballs that represent snapshots in time | ||
632 | of a given component. | ||
633 | |||
634 | .. note:: | ||
635 | |||
636 | The recommended method for accessing Yocto Project components is to | ||
637 | use Git to clone the upstream repository and work from within that | ||
638 | locally cloned repository. The procedure in this section exists | ||
639 | should you desire a tarball snapshot of any given component. | ||
640 | |||
641 | Follow these steps to locate and download a particular tarball: | ||
642 | |||
643 | 1. *Access the Index of Releases:* Open a browser and go to | ||
644 | ` <&YOCTO_DL_URL;/releases>`__ to access the Index of Releases. The | ||
645 | list represents released components (e.g. ``bitbake``, ``sato``, and | ||
646 | so on). | ||
647 | |||
648 | .. note:: | ||
649 | |||
650 | The | ||
651 | yocto | ||
652 | directory contains the full array of released Poky tarballs. The | ||
653 | poky | ||
654 | directory in the Index of Releases was historically used for very | ||
655 | early releases and exists now only for retroactive completeness. | ||
656 | |||
657 | 2. *Select a Component:* Click on any released component in which you | ||
658 | are interested (e.g. ``yocto``). | ||
659 | |||
660 | 3. *Find the Tarball:* Drill down to find the associated tarball. For | ||
661 | example, click on ``yocto-DISTRO`` to view files associated with the | ||
662 | Yocto Project DISTRO release (e.g. | ||
663 | ``poky-DISTRO_NAME_NO_CAP-POKYVERSION.tar.bz2``, which is the | ||
664 | released Poky tarball). | ||
665 | |||
666 | 4. *Download the Tarball:* Click the tarball to download and save a | ||
667 | snapshot of the given component. | ||
668 | |||
669 | Using the Downloads Page | ||
670 | ------------------------ | ||
671 | |||
672 | The `Yocto Project Website <&YOCTO_HOME_URL;>`__ uses a "DOWNLOADS" page | ||
673 | from which you can locate and download tarballs of any Yocto Project | ||
674 | release. Rather than Git repositories, these files represent snapshot | ||
675 | tarballs similar to the tarballs located in the Index of Releases | ||
676 | described in the "`Accessing Index of | ||
677 | Releases <#accessing-index-of-releases>`__" section. | ||
678 | |||
679 | .. note:: | ||
680 | |||
681 | The recommended method for accessing Yocto Project components is to | ||
682 | use Git to clone a repository and work from within that local | ||
683 | repository. The procedure in this section exists should you desire a | ||
684 | tarball snapshot of any given component. | ||
685 | |||
686 | 1. *Go to the Yocto Project Website:* Open The `Yocto Project | ||
687 | Website <&YOCTO_HOME_URL;>`__ in your browser. | ||
688 | |||
689 | 2. *Get to the Downloads Area:* Select the "DOWNLOADS" item from the | ||
690 | pull-down "SOFTWARE" tab menu near the top of the page. | ||
691 | |||
692 | 3. *Select a Yocto Project Release:* Use the menu next to "RELEASE" to | ||
693 | display and choose a recent or past supported Yocto Project release | ||
694 | (e.g. DISTRO_NAME_NO_CAP, DISTRO_NAME_NO_CAP_MINUS_ONE, and so | ||
695 | forth). | ||
696 | |||
697 | .. note:: | ||
698 | |||
699 | For a "map" of Yocto Project releases to version numbers, see the | ||
700 | Releases | ||
701 | wiki page. | ||
702 | |||
703 | You can use the "RELEASE ARCHIVE" link to reveal a menu of all Yocto | ||
704 | Project releases. | ||
705 | |||
706 | 4. *Download Tools or Board Support Packages (BSPs):* From the | ||
707 | "DOWNLOADS" page, you can download tools or BSPs as well. Just scroll | ||
708 | down the page and look for what you need. | ||
709 | |||
710 | Accessing Nightly Builds | ||
711 | ------------------------ | ||
712 | |||
713 | Yocto Project maintains an area for nightly builds that contains tarball | ||
714 | releases at ` <&YOCTO_AB_NIGHTLY_URL;>`__. These builds include Yocto | ||
715 | Project releases ("poky"), toolchains, and builds for supported | ||
716 | machines. | ||
717 | |||
718 | Should you ever want to access a nightly build of a particular Yocto | ||
719 | Project component, use the following procedure: | ||
720 | |||
721 | 1. *Locate the Index of Nightly Builds:* Open a browser and go to | ||
722 | ` <&YOCTO_AB_NIGHTLY_URL;>`__ to access the Nightly Builds. | ||
723 | |||
724 | 2. *Select a Date:* Click on the date in which you are interested. If | ||
725 | you want the latest builds, use "CURRENT". | ||
726 | |||
727 | 3. *Select a Build:* Choose the area in which you are interested. For | ||
728 | example, if you are looking for the most recent toolchains, select | ||
729 | the "toolchain" link. | ||
730 | |||
731 | 4. *Find the Tarball:* Drill down to find the associated tarball. | ||
732 | |||
733 | 5. *Download the Tarball:* Click the tarball to download and save a | ||
734 | snapshot of the given component. | ||
735 | |||
736 | Cloning and Checking Out Branches | ||
737 | ================================= | ||
738 | |||
739 | To use the Yocto Project for development, you need a release locally | ||
740 | installed on your development system. This locally installed set of | ||
741 | files is referred to as the `Source | ||
742 | Directory <&YOCTO_DOCS_REF_URL;#source-directory>`__ in the Yocto | ||
743 | Project documentation. | ||
744 | |||
745 | The preferred method of creating your Source Directory is by using | ||
746 | `Git <&YOCTO_DOCS_OM_URL;#git>`__ to clone a local copy of the upstream | ||
747 | ``poky`` repository. Working from a cloned copy of the upstream | ||
748 | repository allows you to contribute back into the Yocto Project or to | ||
749 | simply work with the latest software on a development branch. Because | ||
750 | Git maintains and creates an upstream repository with a complete history | ||
751 | of changes and you are working with a local clone of that repository, | ||
752 | you have access to all the Yocto Project development branches and tag | ||
753 | names used in the upstream repository. | ||
754 | |||
755 | Cloning the ``poky`` Repository | ||
756 | ------------------------------- | ||
757 | |||
758 | Follow these steps to create a local version of the upstream | ||
759 | ```poky`` <&YOCTO_DOCS_REF_URL;#poky>`__ Git repository. | ||
760 | |||
761 | 1. *Set Your Directory:* Change your working directory to where you want | ||
762 | to create your local copy of ``poky``. | ||
763 | |||
764 | 2. *Clone the Repository:* The following example command clones the | ||
765 | ``poky`` repository and uses the default name "poky" for your local | ||
766 | repository: $ git clone git://git.yoctoproject.org/poky Cloning into | ||
767 | 'poky'... remote: Counting objects: 432160, done. remote: Compressing | ||
768 | objects: 100% (102056/102056), done. remote: Total 432160 (delta | ||
769 | 323116), reused 432037 (delta 323000) Receiving objects: 100% | ||
770 | (432160/432160), 153.81 MiB \| 8.54 MiB/s, done. Resolving deltas: | ||
771 | 100% (323116/323116), done. Checking connectivity... done. Unless you | ||
772 | specify a specific development branch or tag name, Git clones the | ||
773 | "master" branch, which results in a snapshot of the latest | ||
774 | development changes for "master". For information on how to check out | ||
775 | a specific development branch or on how to check out a local branch | ||
776 | based on a tag name, see the "`Checking Out By Branch in | ||
777 | Poky <#checking-out-by-branch-in-poky>`__" and `Checking Out By Tag | ||
778 | in Poky <#checkout-out-by-tag-in-poky>`__" sections, respectively. | ||
779 | |||
780 | Once the local repository is created, you can change to that | ||
781 | directory and check its status. Here, the single "master" branch | ||
782 | exists on your system and by default, it is checked out: $ cd ~/poky | ||
783 | $ git status On branch master Your branch is up-to-date with | ||
784 | 'origin/master'. nothing to commit, working directory clean $ git | ||
785 | branch \* master Your local repository of poky is identical to the | ||
786 | upstream poky repository at the time from which it was cloned. As you | ||
787 | work with the local branch, you can periodically use the | ||
788 | ``git pull DASHDASHrebase`` command to be sure you are up-to-date | ||
789 | with the upstream branch. | ||
790 | |||
791 | Checking Out by Branch in Poky | ||
792 | ------------------------------ | ||
793 | |||
794 | When you clone the upstream poky repository, you have access to all its | ||
795 | development branches. Each development branch in a repository is unique | ||
796 | as it forks off the "master" branch. To see and use the files of a | ||
797 | particular development branch locally, you need to know the branch name | ||
798 | and then specifically check out that development branch. | ||
799 | |||
800 | .. note:: | ||
801 | |||
802 | Checking out an active development branch by branch name gives you a | ||
803 | snapshot of that particular branch at the time you check it out. | ||
804 | Further development on top of the branch that occurs after check it | ||
805 | out can occur. | ||
806 | |||
807 | 1. *Switch to the Poky Directory:* If you have a local poky Git | ||
808 | repository, switch to that directory. If you do not have the local | ||
809 | copy of poky, see the "`Cloning the ``poky`` | ||
810 | Repository <#cloning-the-poky-repository>`__" section. | ||
811 | |||
812 | 2. *Determine Existing Branch Names:* $ git branch -a \* master | ||
813 | remotes/origin/1.1_M1 remotes/origin/1.1_M2 remotes/origin/1.1_M3 | ||
814 | remotes/origin/1.1_M4 remotes/origin/1.2_M1 remotes/origin/1.2_M2 | ||
815 | remotes/origin/1.2_M3 . . . remotes/origin/thud | ||
816 | remotes/origin/thud-next remotes/origin/warrior | ||
817 | remotes/origin/warrior-next remotes/origin/zeus | ||
818 | remotes/origin/zeus-next ... and so on ... | ||
819 | |||
820 | 3. *Check out the Branch:* Check out the development branch in which you | ||
821 | want to work. For example, to access the files for the Yocto Project | ||
822 | DISTRO Release (DISTRO_NAME), use the following command: $ git | ||
823 | checkout -b DISTRO_NAME_NO_CAP origin/DISTRO_NAME_NO_CAP Branch | ||
824 | DISTRO_NAME_NO_CAP set up to track remote branch DISTRO_NAME_NO_CAP | ||
825 | from origin. Switched to a new branch 'DISTRO_NAME_NO_CAP' The | ||
826 | previous command checks out the "DISTRO_NAME_NO_CAP" development | ||
827 | branch and reports that the branch is tracking the upstream | ||
828 | "origin/DISTRO_NAME_NO_CAP" branch. | ||
829 | |||
830 | The following command displays the branches that are now part of your | ||
831 | local poky repository. The asterisk character indicates the branch | ||
832 | that is currently checked out for work: $ git branch master \* | ||
833 | DISTRO_NAME_NO_CAP | ||
834 | |||
835 | .. _checkout-out-by-tag-in-poky: | ||
836 | |||
837 | Checking Out by Tag in Poky | ||
838 | --------------------------- | ||
839 | |||
840 | Similar to branches, the upstream repository uses tags to mark specific | ||
841 | commits associated with significant points in a development branch (i.e. | ||
842 | a release point or stage of a release). You might want to set up a local | ||
843 | branch based on one of those points in the repository. The process is | ||
844 | similar to checking out by branch name except you use tag names. | ||
845 | |||
846 | .. note:: | ||
847 | |||
848 | Checking out a branch based on a tag gives you a stable set of files | ||
849 | not affected by development on the branch above the tag. | ||
850 | |||
851 | 1. *Switch to the Poky Directory:* If you have a local poky Git | ||
852 | repository, switch to that directory. If you do not have the local | ||
853 | copy of poky, see the "`Cloning the ``poky`` | ||
854 | Repository <#cloning-the-poky-repository>`__" section. | ||
855 | |||
856 | 2. *Fetch the Tag Names:* To checkout the branch based on a tag name, | ||
857 | you need to fetch the upstream tags into your local repository: $ git | ||
858 | fetch --tags $ | ||
859 | |||
860 | 3. *List the Tag Names:* You can list the tag names now: $ git tag | ||
861 | 1.1_M1.final 1.1_M1.rc1 1.1_M1.rc2 1.1_M2.final 1.1_M2.rc1 . . . | ||
862 | yocto-2.5 yocto-2.5.1 yocto-2.5.2 yocto-2.5.3 yocto-2.6 yocto-2.6.1 | ||
863 | yocto-2.6.2 yocto-2.7 yocto_1.5_M5.rc8 | ||
864 | |||
865 | 4. *Check out the Branch:* $ git checkout tags/DISTRO_REL_TAG -b | ||
866 | my_yocto_DISTRO Switched to a new branch 'my_yocto_DISTRO' $ git | ||
867 | branch master \* my_yocto_DISTRO The previous command creates and | ||
868 | checks out a local branch named "my_yocto_DISTRO", which is based on | ||
869 | the commit in the upstream poky repository that has the same tag. In | ||
870 | this example, the files you have available locally as a result of the | ||
871 | ``checkout`` command are a snapshot of the "DISTRO_NAME_NO_CAP" | ||
872 | development branch at the point where Yocto Project DISTRO was | ||
873 | released. | ||