blob: 6dba2e6f62f69c881bf8d540be1cc16bfdab2672 [file] [log] [blame] [view]
Satoru Takabayashi803fd1b2018-05-25 02:29:321# Chromium OS Developer Guide
2
Mike Frysinger05bebd52021-01-27 18:48:113*** note
4**Warning: This document is old & has moved. Please update any links:**<br>
5https://chromium.googlesource.com/chromiumos/docs/+/HEAD/developer_guide.md
6***
7
Satoru Takabayashi803fd1b2018-05-25 02:29:328## Introduction
9
10This guide describes how to work on Chromium OS. If you want to help develop
11Chromium OS and you're looking for detailed information about how to get
12started, you're in the right place. You can also use the [quick-start guide]
13instead, which gives just the basic steps that work for most people.
14
15[TOC]
16
17### Target audience
18
19The target audience of this guide is anyone who wants to obtain, build, or
20contribute to Chromium OS. That includes new developers who are interested in
21the project and who simply want to browse through the Chromium OS code, as well
22as developers who have been working on Chromium OS for a long time.
23
24### Organization & content
25
26This guide describes the common tasks required to develop Chromium OS. The guide
27is organized linearly, so that developers who are new to Chromium OS can follow
28the tasks in sequence. The tasks are grouped into the following sections:
29
30* [Prerequisites]
31* [Getting the source code]
32* [Building Chromium OS]
33* [Installing Chromium OS on your Device]
34* [Making changes to packages whose source code is checked into Chromium OS git repositories]
35* [Making changes to non-cros_workon-able packages]
36* [Using Clang to get better compiler diagnostics]
37* [Local Debugging]
38* [Remote Debugging]
39* [Troubleshooting]
40* [Running Tests]
41* [Additional information]
42
43### Typography conventions
44
Satoru Takabayashif3075092018-05-25 05:12:2245* **Commands** are shown with different labels to indicate whether they apply
46 to (1) your build computer (the computer on which you're doing development),
Josie Nordrumc4b63aa2020-04-03 17:46:4347 (2) the [chroot] (Chrome OS SDK) on your build computer, or (3) your Chromium OS computer (the
Satoru Takabayashif3075092018-05-25 05:12:2248 device on which you run the images you build):
Satoru Takabayashi803fd1b2018-05-25 02:29:3249
Conor McNamaracab29c02019-12-06 23:18:5550Label | Commands
51--- | ---
52`(outside)` | on your build computer, outside the chroot
53`(inside)` | inside the chroot on your build computer
54`(in/out)` | on your build computer, either inside or outside the chroot
55`(device)` | on your Chromium OS computer
Satoru Takabayashi803fd1b2018-05-25 02:29:3256
57* **Notes** are shown using the following conventions:
58 * **IMPORTANT NOTE** describes required actions and critical information
59 * **SIDE NOTE** describes explanations, related information, and
60 alternative options
61* **TODO** describes questions or work that is needed on this document
62
63### Modifying this document
64
Satoru Takabayashi803fd1b2018-05-25 02:29:3265If you're a Chromium OS developer, **YOU SHOULD UPDATE THIS DOCUMENT** and fix
Satoru Takabayashif3075092018-05-25 05:12:2266things as appropriate. See [README.md] for how to update this document. Bias
67towards action:
Satoru Takabayashi803fd1b2018-05-25 02:29:3268
Satoru Takabayashif3075092018-05-25 05:12:2269* If you see a TODO and you know the right answer, fix it!
Satoru Takabayashi803fd1b2018-05-25 02:29:3270* If you see something wrong, fix it.
Satoru Takabayashif3075092018-05-25 05:12:2271* If you're not sure of the perfect answer, still fix it. Stick in a TODO
Satoru Takabayashi803fd1b2018-05-25 02:29:3272 noting your uncertainty if you aren't sure, but don't let anything you know
73 to be wrong stick around.
74
75Please try to abide by the following guidelines when you modify this document:
76
77* Put all general "getting started" information directly on this page. It's OK
78 if this document grows big.
79* If some information is also relevant for other documents, put the
80 information in this document and add links from the other documents to this
81 document. If you do not have a choice and must put information relevant to
82 getting started in other documents, add links in this document to discrete
83 chunks of information in the other documents. Following a web of links can
84 be very confusing, especially for people who are new to a project, so it's
85 very important to maintain a linear flow as much as possible.
86* Where possible, describe a single way of doing things. If you specify
87 multiple options, provide a clear explanation why someone following the
88 instructions would pick one option over the others. If there is disagreement
89 about how to do things, consider listing alternative options in a SIDE NOTE.
90* Keep Google-specific references to a minimum. A large number of the people
91 working on Chromium OS work at Google, and this document may occasionally
92 contain references that are only relevant to engineers at Google. Google
93 engineers, please keep such references to a minimum – Chromium OS is an open
94 source project that should stay as open as possible.
95
96### More information
97
98This document provides an overview of the tasks required to develop Chromium
99OS. After you've learned the basics, check out the links in the [Additional
100information] section at the end of this document for tips and tricks, FAQs, and
101important details (e.g., the Chromium OS directory structure, using the dev
102server, etc.).
103
104Finally, if you build a Chromium OS image, please read this important note about
105[Attribution requirements].
106
107## Prerequisites
108
109You must have Linux to develop Chromium OS. Any recent or up-to-date
110distribution should work. However, we can't support everyone and their dog's
111Linux distro, so the only official supported environment is listed below. If you
112encounter issues with other setups, patches are generally welcomed, but please
113do not expect us to figure out your distro.
114
Mike Frysingerff3f4e12019-02-05 21:23:44115* [Ubuntu] Linux (version 16.04 - Xenial)
Satoru Takabayashi803fd1b2018-05-25 02:29:32116
Mike Frysingerff3f4e12019-02-05 21:23:44117 Most developers working on Chromium OS are using Xenial (the LTS version of
118 Ubuntu) and Debian testing. It is possible that things will work if you're
119 running a different Linux distribution, but you will probably find life
120 easier if you're on one of these.
Satoru Takabayashi803fd1b2018-05-25 02:29:32121
122* an x86_64 64-bit system for performing the build
123
124* an account with `sudo` access
125
126 You need root access to run the `chroot` command and to modify the mount
127 table. **NOTE:** Do not run any of the commands listed in this document as
128 root – the commands themselves will run sudo to get root access when needed.
129
130* many gigabytes of RAM
131
132 Per [this thread][RAM-thread], linking Chrome requires somewhere between 8
133 GB and 28 GB of RAM as of March 2017; you may be able to get by with less at
134 the cost of slower builds with adequate swap space. Seeing an error like
135 `error: ld terminated with signal 9 [Killed]` while building the
136 `chromeos-chrome` package indicates that you need more RAM. If you are not
137 building your own copy of Chrome, the RAM requirements will be substantially
138 lower.
139
140You will have a much nicer time if you also have:
141
142* a fast multi-processor machine with lots of memory
143
144 The build system is optimized to make good use of all processors, and an 8
145 core machine will build nearly 8x faster than a single core machine.
146
147* a good Internet connection
148
149 This will help for the initial download (minimum of about 2 GB) and any
150 further updates.
151
152### Install git and curl
153
154Install the git revision control system, the curl download helper, and lvm
Daniel Ng7efd91c2020-09-24 02:16:29155tools. On Ubuntu 16.04, the magic incantation to do this is (all on one line):
Satoru Takabayashi803fd1b2018-05-25 02:29:32156
Tom Hughese6f05112019-08-06 15:35:38157```bash
Satoru Takabayashif3075092018-05-25 05:12:22158(outside)
Pawit Pornkitprasan8a2f2352018-07-01 00:57:06159sudo apt-get install git-core gitk git-gui curl lvm2 thin-provisioning-tools \
Mike Frysingerc4bdf292020-02-27 23:29:51160 python-pkg-resources python-virtualenv python-oauth2client xz-utils \
161 python3.6
Daniel Ng7efd91c2020-09-24 02:16:29162```
Mike Frysingerc4bdf292020-02-27 23:29:51163
Daniel Ng7efd91c2020-09-24 02:16:29164More recent Debian-based distributions (such as Googlers' workstations)
165might qualify the Python package names and you'll need to run this instead:
Stephane Belmon3aa40b12020-07-23 23:51:50166
Daniel Ng7efd91c2020-09-24 02:16:29167```bash
168(outside)
169sudo apt-get install git-core gitk git-gui curl lvm2 thin-provisioning-tools \
170 python3-pkg-resources python3-virtualenv python3-oauth2client xz-utils \
171 python3.6
172```
173
174These command also installs git's graphical front end (`git gui`) and revision
175history browser (`gitk`).
176
177If Python 3.5 is the default, switch it to at least Python 3.6. You can check what
178version you're using with:
179
180```bash
181(outside)
Mike Frysingerc4bdf292020-02-27 23:29:51182python3 --version
Daniel Ng7efd91c2020-09-24 02:16:29183```
184
185If the above says 3.5, or below, you'll need to switch it to 3.6+ (Googlers
186should be wary of modifying any python configurations). This can be done with:
187
188```bash
189(outside)
Mike Frysingerc4bdf292020-02-27 23:29:51190sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
191sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
192sudo update-alternatives --config python3
Satoru Takabayashi803fd1b2018-05-25 02:29:32193```
194
Satoru Takabayashi803fd1b2018-05-25 02:29:32195### Install depot_tools
196
197To get started, follow the instructions at [install depot_tools]. This step is
198required so that you can use the repo command to get/sync the source code.
199
200### Tweak your sudoers configuration
201
202You must tweak your sudoers configuration to turn off the tty_tickets option as
203described in [Making sudo a little more permissive]. This is required for using
204`cros_sdk`.
205
Andrew de los Reyes5d4f4b32020-07-15 18:41:09206### Set locale
207
208These may not be needed if you are building on a system that you
209already use, however if you have a clean instance on GCE, you'll need
210to set a better locale. For example, on Debian Buster on GCE, do:
211
212```bash
213(outside)
214sudo apt-get install locales
215sudo dpkg-reconfigure locales
216```
217
218When running `dpkg-reconfigure locales`, choose a language with UTF-8,
219e.g. `en_US.UTF-8`. For this change to take effect, you will need to
220log out and back in (closing all term windows, tmux/screen sessions,
221etc.).
222
Satoru Takabayashi803fd1b2018-05-25 02:29:32223### Configure git
224
225Setup git now. If you don't do this, you may run into errors/issues
226later. Replace `[email protected]` and `Your Name` with your information:
227
Tom Hughese6f05112019-08-06 15:35:38228```bash
Satoru Takabayashif3075092018-05-25 05:12:22229(outside)
Satoru Takabayashi803fd1b2018-05-25 02:29:32230git config --global user.email "[email protected]"
231git config --global user.name "Your Name"
232```
233
234### Preparations to submit changes
235
236**IMPORTANT NOTE:** If you are new to Chromium OS, you can skip this step (go to
237"[Decide where your source will live]"). This is only for people who wish to
238make changes to the tree. Remember: anyone can post changes to Gerrit for
239review.
240
241Follow the instructions [here][gerrit-guide] to setup your code review
242account(s) and machine access credentials for the source repos. Remember a
243@chromium.org account is not required to submit code for review.
244
245### Double-check that you are running a 64-bit architecture
246
247Run the following command:
248
Tom Hughese6f05112019-08-06 15:35:38249```bash
Satoru Takabayashif3075092018-05-25 05:12:22250(outside) uname -m
Satoru Takabayashi803fd1b2018-05-25 02:29:32251```
252
253You should see the result: `x86_64`
254
255If you see something else (for example, `i686`, which means you are on a 32-bit
256machine or a 64-bit machine running a 32-bit OS) then you won't be able to build
257Chromium OS. The project would happily welcome patches to fix this.
258
259### Verify that your default file permissions (umask) setting is correct
260
261Sources need to be world-readable to properly function inside the chroot
262(described later). For that reason, the last digit of your umask should not be
263higher than 2, eg. '002' or '022'. Many distros have this by default, Ubuntu,
264for instance, does not. It is essential to put the following line into your
265`~/.bashrc` file before you checkout or sync your sources.
266
Tom Hughese6f05112019-08-06 15:35:38267```bash
Satoru Takabayashif3075092018-05-25 05:12:22268(outside) umask 022
Satoru Takabayashi803fd1b2018-05-25 02:29:32269```
270
271You can verify that this works by creating any file and checking if its
272permissions are correct.
273
Tom Hughese6f05112019-08-06 15:35:38274```bash
Satoru Takabayashif3075092018-05-25 05:12:22275(outside)
276touch ~/foo
277ls -la ~/foo
Satoru Takabayashi803fd1b2018-05-25 02:29:32278-rw-r--r-- 1 user group 0 2012-08-30 23:09 /home/user/foo
279```
280
281## Get the Source
282
283### Decide where your source will live
284
285Chromium OS developers commonly put their source code in
Conor McNamaracab29c02019-12-06 23:18:55286`~/chromiumos`. If you feel strongly, put your own source elsewhere, but
Satoru Takabayashi803fd1b2018-05-25 02:29:32287note that **all commands in this document assume that your source code is in**
Conor McNamaracab29c02019-12-06 23:18:55288`~/chromiumos`.
Satoru Takabayashi803fd1b2018-05-25 02:29:32289
290Create the directory for your source code with this command:
291
Tom Hughese6f05112019-08-06 15:35:38292```bash
Conor McNamaracab29c02019-12-06 23:18:55293(outside) mkdir -p ~/chromiumos
Satoru Takabayashi803fd1b2018-05-25 02:29:32294```
295
296**IMPORTANT NOTE:** If your home directory is on NFS, you **must** place your
297code somewhere else. Not only is it a bad idea to build directly from NFS for
298performance reasons, but builds won't actually work (builds use sudo, and root
299doesn't have access to your NFS mount, unless your NFS server has the
300`no_root_squash` option). Wherever you place your source, you can still add a
301symbolic link to it from your home directory (this is suggested), like so:
302
Tom Hughese6f05112019-08-06 15:35:38303```bash
Satoru Takabayashif3075092018-05-25 05:12:22304(outside)
305mkdir -p /usr/local/path/to/source/chromiumos
Conor McNamaracab29c02019-12-06 23:18:55306ln -s /usr/local/path/to/source/chromiumos ~/chromiumos
Satoru Takabayashi803fd1b2018-05-25 02:29:32307```
308
309### Get the source code
310
311Chromium OS uses [repo] to sync down source code. `repo` is a wrapper for the
312[git] that helps deal with a large number of `git` repositories. You already
313installed `repo` when you [installed `depot_tools` above][install depot_tools].
314
315**Make sure you have followed the gerrit credentials setup instructions
316[here][gerrit-guide].**
317
Tom Hughescd215342019-08-06 00:44:37318**Public:**
Tom Hughese6f05112019-08-06 15:35:38319```bash
Satoru Takabayashif3075092018-05-25 05:12:22320(outside)
Conor McNamaracab29c02019-12-06 23:18:55321cd ~/chromiumos
Tom Hughescd215342019-08-06 00:44:37322repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git
Satoru Takabayashi803fd1b2018-05-25 02:29:32323repo sync -j4
324```
325
Tom Hughescd215342019-08-06 00:44:37326**Googlers/internal manifest:**
327```shell
328(outside)
Conor McNamaracab29c02019-12-06 23:18:55329cd ~/chromiumos
Jason D. Clintone5435d72019-10-15 01:57:50330repo init -u https://chrome-internal.googlesource.com/chromeos/manifest-internal.git --repo-url https://chromium.googlesource.com/external/repo.git -b stable
Tom Hughescd215342019-08-06 00:44:37331repo sync -j4
332```
333
Jason D. Clintone5435d72019-10-15 01:57:50334For Googlers: the instructions above add `-b stable` to the init instructions vs
335the external version without. This feature is known as "sync-to-green"; the
336version of the source that you will sync to is 5-10 hours old but is guaranteed
337to be verified by our CI system and have prebuilt binaries available. For more
338information about this see [Sync to Green].
339
Tom Hughescd215342019-08-06 00:44:37340*** note
341**Note:** `-j4` tells `repo` to concurrently sync up to 4 repositories at once.
342You can adjust the number based on how fast your internet connection is. For
343the initial sync, it's generally requested that you use no more than 8
344concurrent jobs. (For later syncs, when you already have the majority of the
345source local, using -j16 or so is generally okay.)
346***
347
348*** note
349**Note:** If you are on a slow network connection or have low disk space, you
350can use the `-g minilayout` option. This starts you out with a minimum
351amount of source code. This isn't a particularly well tested configuration and
352has been known to break from time-to-time, so we usually recommend against it.
353***
354
Satoru Takabayashi803fd1b2018-05-25 02:29:32355#### Optionally add Google API keys
356
357Secondly, decide whether you need to use features of Chromium that access Google
358APIs from the image you are building (**signing in**, translating web pages,
Nick Petersonb5cbc6a2018-10-24 17:24:48359geolocation, etc). If the answer is yes, you will need to have keys (see
Satoru Takabayashi803fd1b2018-05-25 02:29:32360[API Keys]) either in your include.gypi, or in a file in your home directory
361called ".googleapikeys". If either of these file are present for step 1 of
362building (below) they will be included automatically. If you don't have these
363keys, these features of chromium will be quietly disabled.
364
365#### Branch Builds
366
367If you want to build on a branch, pass the branch name to repo init (e.g: `repo
Ben Pastene96c25a82020-06-18 00:05:19368init -u <URL> [-g minilayout] -b release-R80-12739.B`).
Satoru Takabayashi803fd1b2018-05-25 02:29:32369
370When you use `repo init` you will be asked to confirm your name, email address,
371and whether you want color in your terminal. This command runs quickly. The
372`repo sync` command takes a lot longer.
373
374More info can be found in the [working on a branch page].
375
David Pursehouseb3b7da12019-06-17 12:23:39376### Make sure you are authorized to access Google Storage (GS) buckets
Andrew McRae4f3e97c2019-05-30 06:07:35377
378Building and testing Chromium OS requires access to Google Storage.
David Pursehouseb3b7da12019-06-17 12:23:39379This is done via [gsutil]. Once configured, an authorization key is placed in `~/.boto`.
380Every time you access the [chroot] via `cros_sdk`, the `.boto` file is copied to the [chroot].
Andrew McRae4f3e97c2019-05-30 06:07:35381If you run [gsutil] inside the chroot, it will configure the key in the chroot version of `~/.boto`,
382but every time you re-run `cros_sdk`, it will overwrite the `~/.boto` file in the chroot.
383
Satoru Takabayashi803fd1b2018-05-25 02:29:32384## Building Chromium OS
385
386### Create a chroot
387
388To make sure everyone uses the same exact environment and tools to build
389Chromium OS, all building is done inside a [chroot]. This chroot is its own
390little world: it contains its own compiler, its own tools (its own copy of bash,
391its own copy of sudo), etc. Now that you've synced down the source code, you
Conor McNamaracab29c02019-12-06 23:18:55392need to create this chroot. Assuming you're already in `~/chromiumos` (or
Satoru Takabayashi803fd1b2018-05-25 02:29:32393wherever your source lives), the command to download and install the chroot is:
394
Tom Hughese6f05112019-08-06 15:35:38395```bash
Satoru Takabayashif3075092018-05-25 05:12:22396(outside) cros_sdk
Satoru Takabayashi803fd1b2018-05-25 02:29:32397```
398
399If this does not work, make sure you've added the depot_tools directory to your
400PATH already (as was needed above with using `repo`).
401
402This will download and setup a prebuilt chroot from Chromium OS mirrors (under
403400M). If you prefer to rather build it from source, or have trouble accessing
404the servers, use `cros_sdk --bootstrap`. Note that this will also enter the
405chroot. If you prefer to build only, use `--download`.
406
407The command with `--bootstrap` takes about half an hour to run on a four core
408machine. It compiles quite a bit of software, which it installs into your
409chroot, and downloads some additional items (around 300MB). While it is building
410you will see a regular update of the number of packages left to build. Once the
411command finishes, the chroot will take up total disk space of a little over 3GB.
412
Conor McNamaracab29c02019-12-06 23:18:55413The chroot lives by default at `~/chromiumos/chroot`. Inside that
Satoru Takabayashi803fd1b2018-05-25 02:29:32414directory you will find system directories like `/usr/bin` and `/etc`. These are
415local to the chroot and are separate from the system directories on your
416machine. For example, the chroot has its own version of the `ls` utility. It
417will be very similar, but it is actually a different binary than the normal one
418you use on your machine.
419
420**SIDE NOTES:**
421
422* You shouldn't have to create the chroot very often. Most developers create
423 it once and never touch it again unless someone explicitly sends out an
424 email telling them to recreate their chroot.
425* The `cros_sdk` command currently doesn't work behind a proxy server, but
426 there is a [workaround][crosbug/10048].
Satoru Takabayashi803fd1b2018-05-25 02:29:32427
428### Enter the chroot
429
430Most of the commands that Chromium OS developers use on a day-to-day basis
431(including the commands to build a Chromium OS image) expect to be run from
432within the chroot. You can enter the chroot by calling:
433
Tom Hughese6f05112019-08-06 15:35:38434```bash
Satoru Takabayashif3075092018-05-25 05:12:22435(outside) cros_sdk
Satoru Takabayashi803fd1b2018-05-25 02:29:32436```
437
438This is the same command used to create the chroot, but if the chroot already
439exists, it will just enter.
440
441NOTE: if you want to run a single command in the chroot (rather than entering
442the chroot), prefix that command with `cros_sdk -- `.
443
444This command will probably prompt you for your password for the `sudo` command
445(entering the chroot requires root privileges). Once the command finishes, that
446terminal is in the chroot and you'll be in the `~/trunk/src/scripts` directory,
447where most build commands live. In the chroot you can only see a subset of the
448filesystem on your machine. However, through some trickery (bind mounts), you
449will have access to the whole `src` directory from within the chroot – this is
450so that you can build the software within the chroot.
451
452Note in particular that the `src/scripts` directory is the same `src/scripts`
453directory found within the Chromium OS directory you were in before you entered
454the chroot, even though it looks like a different location. That's because when
455you enter the chroot, the `~/trunk` directory in the chroot is mounted such that
Conor McNamaracab29c02019-12-06 23:18:55456it points to the main Chromium OS directory `~/chromiumos`. That means
Satoru Takabayashi803fd1b2018-05-25 02:29:32457that changes that you make to the source code outside of the chroot immediately
458take effect inside the chroot.
459
460Calling this will also install a chroot, if you don't have one yet, for example
461by not following the above.
462
Nick Petersonb5cbc6a2018-10-24 17:24:48463While in the chroot you will see a special "(cr)" prompt to remind you
Satoru Takabayashi803fd1b2018-05-25 02:29:32464that you are there:
465
Tom Hughese6f05112019-08-06 15:35:38466```bash
Nick Petersonb5cbc6a2018-10-24 17:24:48467(cr) ((...)) johnnyrotten@flyingkite ~/trunk/src/scripts $
Satoru Takabayashi803fd1b2018-05-25 02:29:32468```
469
470You generally cannot run programs on your filesystem from within the chroot. For
471example, if you are using eclipse as an IDE, or gedit to edit a text file, you
472will need to run those programs outside the chroot. As a consolation, you can
473use vim. If you are desperate for emacs, try typing `sudo emerge emacs`. Of
474course this command will build emacs from source so allow 5-10mins.
475
476**IMPORTANT NOTES**:
477
Satoru Takabayashi803fd1b2018-05-25 02:29:32478* **If you need to delete your chroot**, use `cros_sdk --delete` to delete it
479 properly. Using `rm -rf` could end up deleting your source tree due to the
480 active bind mounts.
481
482**SIDE NOTES:**
483
484* If you need to share lots of files inside and outside chroot (for example,
485 settings for your favorite editor / tools, or files downloaded by browser
486 outside chroot, etc.), read [Tips and Tricks].
487* There is a file system loop because inside `~/trunk` you will find the
488 chroot again. Don't think about this for too long. If you try to use `du -s
Conor McNamaracab29c02019-12-06 23:18:55489 ~/chromiumos/chroot/home` you might get a message about a corrupted
Satoru Takabayashi803fd1b2018-05-25 02:29:32490 file system. This is nothing to worry about, and just means that your
491 computer doesn't understand this loop either. (If you _can_ understand this
492 loop, try [something harder].)
493
494### Select a board
495
496Building Chromium OS produces a disk image (usually just called an "image") that
497can be copied directly onto the boot disk of a computer intended to run Chromium
498OS. Depending on the specifics of that computer, you may want different files in
499the disk image. For example, if your computer has an ARM processor, you'll want
500to make sure that all executables in the image are compiled for the ARM
501instruction set. Similarly, if your computer has special hardware, you'll want
502to include a matching set of device drivers.
503
504Different classes of computers are referred to by Chromium OS as different
Thiemo Nagel39096e62019-06-18 12:20:51505target "boards". The following are some example boards:
Satoru Takabayashi803fd1b2018-05-25 02:29:32506
Thiemo Nagel39096e62019-06-18 12:20:51507* **amd64-generic** - builds a generic image suitable for computers with an
508 x86_64-compatible CPU (64 bit) or for running in a VM
Satoru Takabayashi803fd1b2018-05-25 02:29:32509* **arm-generic** - builds a generic image suitable for computers with an ARM
510 CPU (32 bit)
Thiemo Nagel39096e62019-06-18 12:20:51511* **arm64-generic** - builds a generic image suitable for computers with an
512 ARM CPU (64 bit)
513* **samus, eve, \<your board name>** - builds an image specific to the chosen
514 device (find your board name [here][Chrome OS Devices]); recommended for
515 deploying to official hardware
516* **betty** - (Googlers only) builds an ARC++-enabled image for running in a
517 VM
Satoru Takabayashi803fd1b2018-05-25 02:29:32518
Thiemo Nagel39096e62019-06-18 12:20:51519You need to choose a board for your first build. Be aware that the generic
520images may not work well (or not at all) when run on official hardware. Don't
521worry too much about this choice, though – you can always build for another
522board later. If you want a list of known boards, you can look in
523`~/trunk/src/overlays`.
Satoru Takabayashi803fd1b2018-05-25 02:29:32524
525Each command in the build processes takes a `--board` parameter. To facilitate
526this, it can be helpful to keep the name of the board in a shell variable. This
527is not strictly necessary, but if you do this, you can simply copy and paste the
528commands below into your terminal program. Enter the following inside your
Thiemo Nagel39096e62019-06-18 12:20:51529chroot:
Satoru Takabayashi803fd1b2018-05-25 02:29:32530
Tom Hughese6f05112019-08-06 15:35:38531```bash
Thiemo Nagel39096e62019-06-18 12:20:51532(inside) export BOARD=<your pick of board>
Satoru Takabayashi803fd1b2018-05-25 02:29:32533```
534
535This setting only holds while you stay in the chroot. If you leave and come
Matthew Duggan472da132020-08-18 01:05:32536back, you need to specify this setting again.
Satoru Takabayashi803fd1b2018-05-25 02:29:32537
538**SIDE NOTES:**
539
540* If you look at `~/trunk/src/overlays`, you may notice two different naming
541 patterns: `overlay-BOARD` and `overlay-variant-BOARD-VARIANT` (note the dash
542 here). If you intend to build for particular board variant, you'll want to
543 use `BOARD_VARIANT` pair (note the underscore here) as your board
544 name. E.g. for overlay-variant-peach-pi the correct value for `BOARD` would
545 be `peach_pi`.
546
547### Initialize the build for a board
548
549To start building for a given board, issue the following command inside your
550chroot (you should be in the `~/trunk/src/scripts` directory):
551
Tom Hughese6f05112019-08-06 15:35:38552```bash
Alex Klein841bc6d2019-01-14 17:40:11553(inside) setup_board --board=${BOARD}
Satoru Takabayashi803fd1b2018-05-25 02:29:32554```
555
556This command sets up the board target with a default sysroot of
557`/build/${BOARD}`. The command downloads a small amount of stuff and takes a few
558minutes to complete.
Evan Benn8fe69b12019-11-05 04:45:59559`setup_board` also calls `update_chroot`, which will update the toolchain if
560`repo sync` has been run and the toolchain is out of date.
Satoru Takabayashi803fd1b2018-05-25 02:29:32561
562**SIDE NOTES:**
563
564* If you pass the `--default` flag to `setup_board`, the command writes the
565 board name in the file `~/trunk/src/scripts/.default_board` (it does the
566 same thing as `echo ${BOARD} > ~/trunk/src/scripts/.default_board`). This
567 makes it so that you don't need to specify a `--board` argument to
568 subsequent commands. These instructions do not use the `--default` flag so
569 that you can explicitly see what commands are board-specific.
Evan Benn8fe69b12019-11-05 04:45:59570* If you want to clobber your old board files and start fresh,
Satoru Takabayashi803fd1b2018-05-25 02:29:32571 try passing the `--force` flag, which deletes the old `/build/${BOARD}`
572 directory for you. Like `cros_sdk`, most people only re-run `setup_board`
573 when told to (they don't re-run it even after a `repo sync`).
574* You can delete the board sysroot at any time with: `sudo rm -rf
575 /build/${BOARD}`
576
577### Set the chronos user password
578
579On a Chromium OS computer, you can get command line access (and root access
580through the `sudo` command) by logging in with the shared user account
581`"chronos"`. You should set a password for the `chronos` user by entering the
582command below from inside the `~/trunk/src/scripts` directory:
583
Tom Hughese6f05112019-08-06 15:35:38584```bash
Satoru Takabayashif3075092018-05-25 05:12:22585(inside) ./set_shared_user_password.sh
Satoru Takabayashi803fd1b2018-05-25 02:29:32586```
587
588You will be prompted for a password, which will be stored in encrypted form in
589`/etc/shared_user_passwd.txt`.
590
591**SIDE NOTES:**
592
593* The encrypted password is stored inside chroot. That means that if you
594 recreate your chroot, you have to run this command again.
595* If you don't set a shared user password, the password for the chronos
596 account may end up being any number of things depending on some complicated
597 (and constantly evolving) formula that includes whether you build a
Tom Hughes9ae6c932019-08-14 17:00:49598 developer image, whether you boot into [Developer Mode], and the current
599 state of the scripts. The password might be empty, or a well-known string
600 (such as `"test0000"` on test images), or it might be impossible to login
601 with chronos. It is strongly recommended that you simply set a shared user
Satoru Takabayashi803fd1b2018-05-25 02:29:32602 password. TODO: put a link to some place with more info about this.
603
604### Build the packages for your board
605
606To build all the packages for your board, run the following command from inside
607the `~/trunk/src/scripts` directory:
608
Tom Hughese6f05112019-08-06 15:35:38609```bash
Satoru Takabayashif3075092018-05-25 05:12:22610(inside) ./build_packages --board=${BOARD}
Satoru Takabayashi803fd1b2018-05-25 02:29:32611```
612
613This step is the rough equivalent of `make all` in a standard Makefile
614system. This command handles incremental builds; you should run it whenever you
615change something and need to rebuild it (or after you run `repo sync`).
616
617Normally, the build_packages command builds the stable version of a package
618(i.e. from committed git sources), unless you are working on a package (with
619`cros_workon`). If you are working on a package, build_packages will build using
620your local sources. See below for information about `cros_workon`.
621
622**SIDE NOTES:**
623
Evan Benn8fe69b12019-11-05 04:45:59624* Like `setup_board`, `build_packages` also calls `update_chroot`, which will
625 update the toolchain if `repo sync` has been run and the toolchain is
626 out of date.
Satoru Takabayashi803fd1b2018-05-25 02:29:32627* Even though there are some flags that can optimize your build (like
628 `--nowithdev`, --nowithautotest, etc), you **should not** use these flags
629 (even if you don't plan on building a developer / test image). There are
630 some [issues with virtual packages] that can cause some hard-to-debug
631 differences if you use one of these flags.
632* The `--nowithdebug` flag is an exception to the previous point. By default,
633 packages other than Chrome will be compiled in debug mode; that is, with
634 `NDEBUG` undefined and with debugging constructs like `DCHECK`, `DLOG`, and
635 the red "Debug image" message present. If you supply `--nowithdebug`, then
636 `NDEBUG` will be defined and the debugging constructs will be removed.
637
638* The first time you run the `build_packages` command, it will take a long
639 time (around 90 minutes on a four core machine), as it must build every
640 package, and also download about 1.7GB of source packages and 1.3GB of
641 binary packages. [See here][What does build_packages actually do?] for more
642 information about what the build_packages command actually does. In short,
643 it tries to download existing binary packages to avoid building anything
644 (and puts them in `/build/${BOARD}/packages` for subsequent builds). Failing
645 that, it downloads source packages, puts them in
646 `/var/lib/portage/distfiles-target`, and builds them.
647
648### Build a disk image for your board
649
650Once the `build_packages` step is finished, you can build a Chromium OS-base
651developer image by running the command below from inside the
652`~/trunk/src/scripts` directory:
653
Tom Hughese6f05112019-08-06 15:35:38654```bash
Satoru Takabayashif3075092018-05-25 05:12:22655(inside) ./build_image --board=${BOARD} --noenable_rootfs_verification test
Satoru Takabayashi803fd1b2018-05-25 02:29:32656```
657
Oleg Davydov21f1b172019-01-03 16:56:07658The args for `build_image` specify what type of build you want.
659A test image (in the example above) has additional test-specific packages and
660also accepts incoming ssh connections.
661It is more convenient to use test images, but developers could
662also build developer images. A developer image provides a Chromium OS-based
663image with additional developer packages.
664To build it use `dev` instead of `test`.
665If building a test image, the password set using
Satoru Takabayashi803fd1b2018-05-25 02:29:32666`set_shared_user_password.sh` will be ignored and `"test0000"` will be the
667password instead. The `--noenable_rootfs_verification` turns off verified boot
668allowing you to freely modify the root file system. The system is less secure
669using this flag, however, for rapid development you may want to set this
670flag. If you would like a more secure, locked-down version of Chromium OS, then
671simply remove the `--noenable_rootfs_verification` flag. Finally if you want
672just the pristine Chromium OS-based image (closest to Chrome OS but not quite
Oleg Davydov21f1b172019-01-03 16:56:07673the same), pass in `base` rather than `test` or `dev`. Use `build_image --help`
674for more information.
Satoru Takabayashi803fd1b2018-05-25 02:29:32675
676The image produced by build_image will be located in
677`~/trunk/src/build/images/${BOARD}/versionNum/` (where `versionNum` will
678actually be a version number). The most recent image produced for a given board
679will be symlinked to `~/trunk/src/build/images/${BOARD}/latest`.
680
681**IMPORTANT NOTE:** It's up to you to delete old builds that you don't
682need. Every time you run `build_image`, the command creates files that take up
Gwendal Grignoud1575b72020-02-18 02:38:53683to **8GB of space(!)**.
Satoru Takabayashi803fd1b2018-05-25 02:29:32684
Satoru Takabayashi803fd1b2018-05-25 02:29:32685### Look at your disk image (optional)
686
687The preferred way to mount the image you just built to look at its contents is:
688
Tom Hughese6f05112019-08-06 15:35:38689```bash
Conor McNamaracab29c02019-12-06 23:18:55690(inside) ./mount_gpt_image.sh --board=${BOARD} --safe --most_recent
Satoru Takabayashi803fd1b2018-05-25 02:29:32691```
692
693If you built a test image, also make sure to add `-i chromiumos_test_image.bin`
694to this command.
695
696The `--safe` option ensures you do not make accidental changes to the Root FS.
697
698Again, don't forget to unmount the root filesystem when you're done:
699
Tom Hughese6f05112019-08-06 15:35:38700```bash
Satoru Takabayashif3075092018-05-25 05:12:22701(inside) ./mount_gpt_image.sh --board=${BOARD} -u
Satoru Takabayashi803fd1b2018-05-25 02:29:32702```
703
704Optionally, you can unpack the partition as separate files and mount them
705directly:
706
Tom Hughese6f05112019-08-06 15:35:38707```bash
Satoru Takabayashif3075092018-05-25 05:12:22708(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:32709cd ~/trunk/src/build/images/${BOARD}/latest
710./unpack_partitions.sh chromiumos_image.bin
711mkdir -p rootfs
712sudo mount -o loop,ro part_3 rootfs
713```
714
715This will do a loopback mount of the rootfs from your image to the location
716`~/trunk/src/build/images/${BOARD}/latest/rootfs` in your chroot.
717
718If you built with `"--noenable_rootfs_verification"` you can omit the "ro"
719option to mount it read write.
720
721If you built an x86 Chromium OS image, you can probably even try chrooting into
722the image:
723
Tom Hughese6f05112019-08-06 15:35:38724```bash
Satoru Takabayashif3075092018-05-25 05:12:22725(inside) sudo chroot ~/trunk/src/build/images/${BOARD}/latest/rootfs
Satoru Takabayashi803fd1b2018-05-25 02:29:32726```
727
728This is a little hacky (the Chromium OS rootfs isn't really designed to be a
729chroot for your host machine), but it seems to work pretty well. Don't forget to
730`exit` this chroot when you're done.
731
732When you're done, unmount the root filesystem:
733
Tom Hughese6f05112019-08-06 15:35:38734```bash
Satoru Takabayashif3075092018-05-25 05:12:22735(inside) sudo umount ~/trunk/src/build/images/${BOARD}/latest/rootfs
Satoru Takabayashi803fd1b2018-05-25 02:29:32736```
737
738## Installing Chromium OS on your Device
739
740### Put your image on a USB disk
741
742The easiest way to get your image running on your target computer is to put the
743image on a USB flash disk (sometimes called a USB key), and boot the target
Fletcher Woodruff5eb8b602018-09-18 17:50:20744computer from the flash disk.
745
746The first step is to disable auto-mounting of USB devices on your build computer
Justin TerAvest809370c2019-12-26 18:14:28747as it may corrupt the disk image while it's being written. On systems that use
748GNOME or Cinnamon, run the following:
749```bash
750gsettings set org.gnome.desktop.media-handling automount false
751gsettings set org.gnome.desktop.media-handling automount-open false
752gsettings set org.cinnamon.desktop.media-handling automount false
753gsettings set org.cinnamon.desktop.media-handling automount-open false
754```
755
Gwendal Grignoud1575b72020-02-18 02:38:53756Next, insert a USB flash disk (8GB or bigger) into your build computer. **This
Justin TerAvest809370c2019-12-26 18:14:28757disk will be completely erased, so make sure it doesn't have anything important
758on it**. Wait ~10 seconds for the USB disk to register, then type the following
759command:
Satoru Takabayashi803fd1b2018-05-25 02:29:32760
Tom Hughese6f05112019-08-06 15:35:38761```bash
Satoru Takabayashif3075092018-05-25 05:12:22762(inside) cros flash usb:// ${BOARD}/latest
Satoru Takabayashi803fd1b2018-05-25 02:29:32763```
764
Fletcher Woodruff5eb8b602018-09-18 17:50:20765For more details on using this tool, see the [Cros Flash page].
Satoru Takabayashi803fd1b2018-05-25 02:29:32766
767When the `cros flash` command finishes, you can simply unplug your USB key and
768it's ready to boot from.
769
770**IMPORTANT NOTE:** To emphasize again, `cros flash` completely replaces the
771contents of your USB disk. Make sure there is nothing important on your USB disk
772before you run this command.
773
774**SIDE NOTES:**
775
Daniel Erat756631d2018-12-13 02:27:15776* If you want to create a test image (used for integration testing), see the
777 [Running Tests] section.
Satoru Takabayashi803fd1b2018-05-25 02:29:32778
Tom Hughes9ae6c932019-08-14 17:00:49779### Enter Developer Mode
Satoru Takabayashi803fd1b2018-05-25 02:29:32780
Tom Hughes9ae6c932019-08-14 17:00:49781See the [Developer Mode] documentation.
Satoru Takabayashi803fd1b2018-05-25 02:29:32782
783### Boot from your USB disk
784
Tom Hughes9ae6c932019-08-14 17:00:49785After enabling [Developer Mode], you should set your system to boot from USB.
Satoru Takabayashi803fd1b2018-05-25 02:29:32786
Tom Hughes9ae6c932019-08-14 17:00:49787Let the device boot, login and open a shell (or switch to terminal 2 via
788Ctrl+Alt+F2).
Satoru Takabayashi803fd1b2018-05-25 02:29:32789
Tom Hughes9ae6c932019-08-14 17:00:49790Run the following command:
Satoru Takabayashi803fd1b2018-05-25 02:29:32791
Tom Hughese6f05112019-08-06 15:35:38792```bash
Satoru Takabayashif3075092018-05-25 05:12:22793(device) sudo crossystem
Satoru Takabayashi803fd1b2018-05-25 02:29:32794```
795
796You should see `"dev_boot_usb"` equal to 0. Set it to 1 to enable USB boot:
797
Tom Hughese6f05112019-08-06 15:35:38798```bash
Satoru Takabayashif3075092018-05-25 05:12:22799(device) sudo crossystem dev_boot_usb=1
Satoru Takabayashi803fd1b2018-05-25 02:29:32800```
801
Tom Hughes9ae6c932019-08-14 17:00:49802Now reboot. On the white screen (indicating [Developer Mode] is enabled),
803plug-in the USB disk and press `Ctrl+U` ([Debug Button Shortcuts]).
Satoru Takabayashi803fd1b2018-05-25 02:29:32804
805### Installing your Chromium OS image to your hard disk
806
807Once you've booted from your USB key and gotten to the command prompt, you can
808install your Chromium OS image to the hard disk on your computer with this
809command:
810
Tom Hughese6f05112019-08-06 15:35:38811```bash
Satoru Takabayashif3075092018-05-25 05:12:22812(device) /usr/sbin/chromeos-install
Satoru Takabayashi803fd1b2018-05-25 02:29:32813```
814
815**IMPORTANT NOTE:** Installing Chromium OS onto your hard disk will **WIPE YOUR
816HARD DISK CLEAN**.
817
818### Getting to a command prompt on Chromium OS
819
820Since you set the shared user password (with `set_shared_user_password.sh`) when
821you built your image, you have the ability to login as the chronos user:
822
8231. After your computer has booted to the Chromium OS login screen, press `[
824 Ctrl ] [ Alt ] [ F2 ]` to get a text-based login prompt. ( `[ F2 ]` may
825 appear as `[ → ]` on your Notebook keyboard.)
8262. Login with the chronos user and enter the password you set earlier.
827
828Because you built an image with developer tools, you also have an alternate way
829to get a terminal prompt. The alternate shell is a little nicer (in the very
830least, it keeps your screen from dimming on you), even if it is a little harder
831to get to. To use this alternate shell:
832
8331. Go through the standard Chromium OS login screen (you'll need to setup a
834 network, etc.) and get to the web browser. It's OK to login as guest.
8352. Press `[ Ctrl ] [ Alt ] [ T ]` to get the [crosh] shell.
8363. Use the `shell` command to get the shell prompt. NOTE: you **don't** need to
837 enter the `chronos` password here, though you will still need the password
838 if you want to use the `sudo` command.
839
Satoru Takabayashi803fd1b2018-05-25 02:29:32840### Building an image to run in a virtual machine
841
842Many times it is easier to simply run Chromium OS in a virtual machine like
843kvm. You can adapt the previously built Chromium OS image so that it is usable
844by `kvm` (which uses qemu images) by entering this command from the
845`~/trunk/src/scripts` directory:
846
Tom Hughese6f05112019-08-06 15:35:38847```bash
Satoru Takabayashif3075092018-05-25 05:12:22848(inside) ./image_to_vm.sh --board=${BOARD}
Satoru Takabayashi803fd1b2018-05-25 02:29:32849```
850
851This command creates the file
852`~/trunk/src/build/images/${BOARD}/latest/chromiumos_qemu_image.bin`.
853
854**SIDE NOTES:**
855
856* WARNING: After [crbug/710629], 'betty' is the only board regularly run
857 through pre-CQ and CQ VMTest and so is the most likely to work at
858 ToT. 'betty' is based on 'amd64-generic', though, so 'amd64-generic' is
859 likely to also work.
860* Only KVM/QEMU VM's are actively supported at the moment.
Jeff Carpenterb3d4b352019-03-06 23:30:56861* If you built a `test` image, you also need to add the `--test` flag.
Satoru Takabayashi803fd1b2018-05-25 02:29:32862* You can specify source/destination paths with the `--from` and `--to`
863 parameters.
Daniel Erat756631d2018-12-13 02:27:15864* If you're interested in creating a test image (used for integration
865 testing), see the [Running Tests] section.
Satoru Takabayashi803fd1b2018-05-25 02:29:32866
867## Making changes to packages whose source code is checked into Chromium OS git repositories
868
869Now that you can build and run Chromium OS, you're ready to start making changes
870to the code.
871
872**NOTE:** If you skipped to this section without building your own system image,
Brian Norris406b15b2019-04-24 16:50:53873you may run into hard-to-fix dependency problems if you build your own versions
874of system packages and try to deploy them to a system image that was built by a
Satoru Takabayashi803fd1b2018-05-25 02:29:32875builder. If you run into trouble, try going through the full [Building Chromium
876OS] process first and installing your own system image.
877
878### Keep the tree green
879
880Before you start, take a moment to understand Chromium's source management
881strategy of "keeping the tree green". For the Chromium OS project, **keeping the
882tree green** means:
883
8841. Any new commits should not destabilize the build:
885 * Images built from the tree should always have basic functionality
886 working.
887 * There may be minor functionality not working, and it may be the case,
888 for example, that you will need to use Terminal to fix or work around
889 some of the problems.
8902. If you must introduce unstable changes to the tree (which should happen
891 infrequently), you should use parameterization to hide new, unstable
892 functionality behind a flag that's turned off by default. The Chromium OS
893 team leaders may need to develop mechanisms for parameterizing different
894 parts of the system (such as the init script).
8953. Internal "dev channel" releases will be produced directly from the tree,
896 with a quick branch to check-point the release version. Any fixes required
897 for a release will be pulled from the tree, avoiding merges back to tree.
898
899This strategy has many benefits, including avoiding separate build trains for
900parallel development (and the cost of supporting such development), as well as
901avoiding large, costly merges from forked branches.
902
903**SIDE NOTE**: "Keep the tree green" means something a bit different for
904Chromium OS than for Chromium, which is much further along in its life cycle.
905
906The steps in this section describe how to make changes to a Chromium OS package
907whose source is checked into the Chromium OS source control
908system. Specifically, this is a package where:
909
910* The `**ebuild**` for the package lives in the
911 `src/third_party/chromiumos-overlay` or `src/overlays/overlay-${BOARD}`
912 directories.
913* There is an ebuild for the package that ends with `9999.ebuild`.
914* The ebuild inherits from the `cros-workon` class.
915* The ebuild has a `KEYWORDS` in the ebuild containing this architecture name
916 (like "`x86`").
917
918You can see a list of all such packages by running the following command from
919inside the `~/trunk/src/scripts` directory:
920
Tom Hughese6f05112019-08-06 15:35:38921```bash
Satoru Takabayashif3075092018-05-25 05:12:22922(inside) cros_workon --board=${BOARD} --all list
Satoru Takabayashi803fd1b2018-05-25 02:29:32923```
924
925### Run cros_workon start
926
927The first thing you need to do is to mark the package as active. Use the command
928below, replacing `${PACKAGE_NAME}` with your package name (e.g., `chromeos-wm`):
929
Tom Hughese6f05112019-08-06 15:35:38930```bash
Satoru Takabayashif3075092018-05-25 05:12:22931(inside) cros_workon --board=${BOARD} start ${PACKAGE_NAME}
Satoru Takabayashi803fd1b2018-05-25 02:29:32932```
933
934This command:
935
936* Indicates that you'd like to build the `9999` version of the `ebuild`
937 instead of the stable, committed version.
938* Indicates that you'd like to build from source every time.
939* If you specified that you wanted the `minilayout` when you did your `repo
940 init`, this command adds a clause to your `.repo/local_manifest.xml` to tell
941 `repo` to sync down the source code for this package next time you do a
942 `repo sync`.
943
944### Run repo sync
945
946After running `cros_workon`, sync down the sources. This is critical if you're
947using the `minilayout`, but is probably a good idea in any case to make sure
948that you're working with the latest code (it'll help avoid merge conflicts
Conor McNamaracab29c02019-12-06 23:18:55949later). Run the command below anywhere under your `~/chromiumos` directory:
Satoru Takabayashi803fd1b2018-05-25 02:29:32950
Tom Hughese6f05112019-08-06 15:35:38951```bash
Conor McNamaracab29c02019-12-06 23:18:55952(in/out) repo sync
Satoru Takabayashi803fd1b2018-05-25 02:29:32953```
954
955### Find out which ebuilds map to which directories
956
957The `cros_workon` tool can help you find out what ebuilds map to each
958directory. You can view a full list of ebuilds and directories using the
959following command:
960
Tom Hughese6f05112019-08-06 15:35:38961```bash
Satoru Takabayashif3075092018-05-25 05:12:22962(inside) cros_workon --board=${BOARD} --all info
Satoru Takabayashi803fd1b2018-05-25 02:29:32963```
964
965If you want to find out which ebuilds use source code from a specific directory,
966you can use grep to find them. For example:
967
Tom Hughese6f05112019-08-06 15:35:38968```bash
Satoru Takabayashif3075092018-05-25 05:12:22969(inside) cros_workon --board=${BOARD} --all info | grep platform/ec
Satoru Takabayashi803fd1b2018-05-25 02:29:32970```
971
972This returns the following output:
973
Tom Hughese6f05112019-08-06 15:35:38974```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:32975chromeos-base/ec-utils chromiumos/platform/ec src/platform/ec
976```
977
978This tells you the following information:
979
9801. The name of the ebuild is `chromeos-base/ec-utils`
9812. The path to the git repository on the server is `chromiumos/platform/ec`
9823. The path to the source code on your system is `src/platform/ec`
983
984You can similarly find what source code is associated with a given ebuild by
985grepping for the ebuild name in the list.
986
987To find out where the ebuild lives:
988
Tom Hughese6f05112019-08-06 15:35:38989```bash
Satoru Takabayashif3075092018-05-25 05:12:22990(inside) equery-${BOARD} which ${PACKAGE_NAME}
Satoru Takabayashi803fd1b2018-05-25 02:29:32991```
992
993As an example, for `PACKAGE_NAME=ec-utils`, the above command might display:
994
Tom Hughese6f05112019-08-06 15:35:38995```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:32996/home/.../trunk/src/third_party/chromiumos-overlay/chromeos-base/ec-utils/ec-utils-9999.ebuild
997```
998
999**SIDE NOTE:** If you run the same command **without** running `cros_workon`
1000first, you can see the difference:
1001
Tom Hughese6f05112019-08-06 15:35:381002```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321003/home/.../trunk/src/third_party/chromiumos-overlay/chromeos-base/ec-utils/ec-utils-0.0.1-r134.ebuild
1004```
1005
1006### Create a branch for your changes
1007
1008Since Chromium OS uses `repo`/`git`, you should always create a local branch
1009whenever you make changes.
1010
1011First, find the source directory for the project you just used `cros_workon`
1012on. This isn't directly related to the project name you used with
1013`cros_workon`. (This isn't very helpful - someone with more experience, actually
1014tell us how to find it reliably? --Meredydd)
1015
1016cd into that directory, in particular the `"files/"` directory in which the
1017actual source resides. In the command below, replace `${BRANCH_NAME}` with a
1018name that is meaningful to you and that describes your changes (nobody else will
1019see this name):
1020
Tom Hughese6f05112019-08-06 15:35:381021```bash
Conor McNamaracab29c02019-12-06 23:18:551022(in/out) repo start ${BRANCH_NAME} .
Satoru Takabayashi803fd1b2018-05-25 02:29:321023```
1024
1025The branch that this creates will be based on the remote branch (which one?
1026--Meredydd). If you've made any other local changes, they will not be present in
1027this branch.
1028
1029### Make your changes
1030
1031You should be able to make your changes to the source code now. To incrementally
Jesse Schettler93ca29f2018-11-26 22:48:301032compile your changes, use either `cros_workon_make` or `emerge-${BOARD}`. To use
1033`cros_workon_make`, run
Satoru Takabayashi803fd1b2018-05-25 02:29:321034
Tom Hughese6f05112019-08-06 15:35:381035```bash
Satoru Takabayashif3075092018-05-25 05:12:221036(inside) cros_workon_make --board=${BOARD} ${PACKAGE_NAME}
Satoru Takabayashi803fd1b2018-05-25 02:29:321037```
1038
1039This will build your package inside your source directory. Change a single file,
1040and it will rebuild only that file and re-link. If your package contains test
1041binaries, using
1042
Tom Hughese6f05112019-08-06 15:35:381043```bash
Satoru Takabayashif3075092018-05-25 05:12:221044(inside) cros_workon_make --board=${BOARD} ${PACKAGE_NAME} --test
Satoru Takabayashi803fd1b2018-05-25 02:29:321045```
1046
1047will build and run those binaries as well. Call `cros_workon_make --help` to see
1048other options that are supported.
1049
1050You probably want to get your changes onto your device now. You need to install
1051the changes you made by using
1052
Tom Hughese6f05112019-08-06 15:35:381053```bash
Satoru Takabayashif3075092018-05-25 05:12:221054(inside) cros_workon_make --board=${BOARD} ${PACKAGE_NAME} --install
Satoru Takabayashi803fd1b2018-05-25 02:29:321055```
1056
Jesse Schettler93ca29f2018-11-26 22:48:301057You can then rebuild an image with `build_image` and reimage your device.
1058
1059Alternatively, you can build your package using `emerge-${BOARD}` and quickly
1060install it to the device by using [cros deploy].
1061
1062For example, if you want to build `ec-utils` to test on your device, use
1063
Tom Hughese6f05112019-08-06 15:35:381064```bash
Jesse Schettler93ca29f2018-11-26 22:48:301065(inside) emerge-${BOARD} ec-utils
1066```
1067
1068To install the package to the device, use
1069
Tom Hughese6f05112019-08-06 15:35:381070```bash
Jesse Schettler93ca29f2018-11-26 22:48:301071(inside) cros deploy ${IP} ec-utils
1072```
Satoru Takabayashi803fd1b2018-05-25 02:29:321073
1074### Set your editor
1075
1076Many of the commands below (in particular `git`) open up an editor. You probably
1077want to run one of the three commands below depending on your favorite editor.
1078
1079If you're not a *nix expert, `nano` is a reasonable editor:
1080
Tom Hughese6f05112019-08-06 15:35:381081```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321082export EDITOR='nano'
1083```
1084If you love `vi`:
1085
Tom Hughese6f05112019-08-06 15:35:381086```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321087export EDITOR='vi'
1088```
1089
1090If you love `emacs` (and don't want an X window to open up every time you do
1091something):
1092
Tom Hughese6f05112019-08-06 15:35:381093```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321094export EDITOR='emacs -nw'
1095```
1096
1097You should probably add one of those lines to your `.bashrc` (or similar file)
1098too.
1099
1100### Submit changes locally
1101
1102When your changes look good, commit them to your local branch using `git`. Full
1103documentation of how to use git is beyond the scope of this guide, but you might
1104be able to commit your changes by running something like the command below from
1105the project directory:
1106
Tom Hughese6f05112019-08-06 15:35:381107```bash
Conor McNamaracab29c02019-12-06 23:18:551108(in/out) git commit -a
Satoru Takabayashi803fd1b2018-05-25 02:29:321109```
1110
1111The git commit command brings up a text editor. You should describe your
1112changes, save, and exit the editor. Note that the description you provide is
1113only for your own use. When you upload your changes for code review, the repo
1114upload command grabs all of your previous descriptions, and gives you a chance
1115to edit them.
1116
1117### Upload your changes and get a code review
1118
Mike Frysingercb52c092018-09-25 03:51:071119Check out our [Gerrit Workflow] guide for details on our review process.
Satoru Takabayashi803fd1b2018-05-25 02:29:321120
1121### Clean up after you're done with your changes
1122
1123After you're done with your changes, you're ready to clean up. The most
1124important thing to do is to tell `cros_workon` that you're done by running the
1125following command:
1126
Tom Hughese6f05112019-08-06 15:35:381127```bash
Satoru Takabayashif3075092018-05-25 05:12:221128(inside) cros_workon --board=${BOARD} stop ${PACKAGE_NAME}
Satoru Takabayashi803fd1b2018-05-25 02:29:321129```
1130
1131This command tells `cros_workon` to stop forcing the `-9999.ebuild` and to stop
1132forcing a build from source every time.
1133
Mike Frysingercb52c092018-09-25 03:51:071134If you're using the `minilayout`, doing a `cros_workon` stop **will not** remove
1135your source code. The code will continue to stay on your hard disk and get
1136synced down.
Satoru Takabayashi803fd1b2018-05-25 02:29:321137
1138## Making changes to non-cros_workon-able packages
1139
Andrew62b7d4c2019-11-08 17:26:541140If you want to make changes to something other than packages which source is
Satoru Takabayashi803fd1b2018-05-25 02:29:321141checked into the Chromium OS source control system, you can follow the
1142instructions in the previous section, but skip the `cros_workon` step. Note
1143specifically that you still need to run `repo start` to [Create a branch for
1144your changes].
1145
1146The types of changes that fall into this category include:
1147
1148* changes to build scripts (pretty much anything in `src/scripts`)
1149* changes to `ebuild` files themselves (like the ones in
1150 `src/third_party/chromiumos-overlay`)
1151 * To change these files, you need to "manually uprev" the package. For
1152 example, if we're making a modification to for the Pixel overlay (link),
1153 then
1154 * `cd src/overlays/overlay-link/chromeos-base/chromeos-bsp-link`
1155 * `mv chromeos-bsp-link-0.0.2-r29.ebuild chromeos-bsp-link-0.0.2-r30.ebuild`
1156 * `chromeos-bsp-link-0.0.2-r29.ebuild` is a symlink that points to
1157 `chromeos-bsp-link-0.0.2.ebuild`. To uprev the package, simply increment the
1158 revision (r29) number.
Andrew62b7d4c2019-11-08 17:26:541159 * Note: Upreving should not be done when there is an ebuild for the
1160 package that ends with `9999.ebuild`. Changes to the ebuild should
1161 usually be done in the `9999.ebuild` file.
Satoru Takabayashi803fd1b2018-05-25 02:29:321162* adding small patches to existing packages whose source code is NOT checked
1163 into Chromium OS git repositories
1164* changes to `eclass` files (like the ones in
1165 `src/third_party/chromiumos-overlay/eclass`)
1166* changes to the buildbot infrastructure (in `crostools`)
Abe Levkoy97226482018-10-02 16:15:161167* changes to Chromium OS project documentation (in `docs`)
Satoru Takabayashi803fd1b2018-05-25 02:29:321168* TODO: anything else?
1169
1170### Adding small patches to existing packages
1171
1172When you need to add small patches to existing packages whose source code is not
1173checked into a Chromium OS git repository (e.g. it comes from portage, and is
1174not a `cros_workon`-able package), you need to do the following:
1175
1176First, find the package ebuild file under `third_party/chromiumos-overlay`.
1177
Robert Brandte3556172020-04-13 16:44:291178Then, [create a patch file](portage/how_to_patch_an_ebuild.md) from the exact
1179version of the package that is used by the current ebuild. If other patches
1180are already in the ebuild, you'll want to add your patch LAST, and build the
1181patch off of the source that has already had the existing patches applied
1182(either do it by hand, or set `FEATURES=noclean` and build your patch off of
1183the temp source). Note that patch order is significant, since the ebuild
1184expects each patch line number to be accurate after the previous patch is
1185applied.
Satoru Takabayashi803fd1b2018-05-25 02:29:321186
1187Place your patch in the "files" subdir of the directory that contains the ebuild
1188file
1189(e.g. `third_party/chromiumos-overlay/dev-libs/mypackage/files/mypackage-1.0.0-my-little-patch.patch`).
1190
1191Then, in the `prepare()` section of the ebuild (create one if it doesn't exist),
1192add an epatch line:
1193
Tom Hughese6f05112019-08-06 15:35:381194```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321195epatch "${FILESDIR}"/${P}-my-little-patch.patch
1196```
1197
1198Lastly, you'll need to bump the revision number in the name of the ebuild file
1199(or symlink) so the build system picks up the change. The current wisdom is that
1200the ebuild file should be symlinked instead of being renamed. For example, if
1201the original ebuild file is `"mypackage-1.0.0.ebuild"`, you should create a
1202`"mypackage-1.0.0-r1.ebuild"` symbolic link that points at the original ebuild
1203file. If that symlink already exists, create the next higher "rN" symlink.
1204
1205### Making changes to the way that the chroot is constructed
1206
1207TODO: This section is currently a placeholder, waiting for someone to fill it
1208in. However, a few notes:
1209
1210* Many of the commands that take a `--board=${BOARD}` parameter also take a
1211 `--host` parameter, which makes the commands affect the host (i.e. the
1212 chroot) rather than the board.
1213 * Most notably, `cros_workon --host` says that you want to build a package
1214 used in the chroot from source.
1215
1216### Building an individual package
1217
1218TODO: Document this better, and add the new `cros_workon_make`.
1219
1220**SIDE NOTE:** To build an individual portage package, for a particular board,
1221use `emerge-${BOARD}`.
1222
1223For example, if you want to build dash to test on your device:
1224
Tom Hughese6f05112019-08-06 15:35:381225```bash
Satoru Takabayashif3075092018-05-25 05:12:221226(inside) emerge-${BOARD} dash
Satoru Takabayashi803fd1b2018-05-25 02:29:321227```
1228
1229To install the package to the device, see [cros deploy].
1230
David Stevens8e88c702019-10-21 06:38:191231**SIDE NOTE:**
1232
1233* Typically, when building a package with `emerge-${BOARD}`, the dependencies have
1234 already been built. However, in some situations dependencies will need to be built
1235 as well. When that happens, `-jN` can be passed to `emerge-${BOARD}` to build
1236 different packages in parallel.
1237
Satoru Takabayashi803fd1b2018-05-25 02:29:321238### Making changes to the Chromium web browser on Chromium OS
1239
1240If you just want to make modifications to the Chromium web browser and quickly
1241deploy your changes to an already-built Chromium OS image, see [Making changes
1242to the Chromium web browser on Chromium OS].
1243
1244To use your local checkout of the Chromium source code when building a Chromium
1245OS image, set the `--chrome_root` flag appropriately when entering the chroot,
1246e.g.
1247
Tom Hughese6f05112019-08-06 15:35:381248```bash
Conor McNamaracab29c02019-12-06 23:18:551249(outside) cros_sdk --chrome_root=~/chrome
Satoru Takabayashi803fd1b2018-05-25 02:29:321250```
1251
1252Within the chroot, you'll also need to either start working on the
Jeroen Dhollander0eca9672020-04-17 17:00:291253`chromeos-chrome` and `chrome-icu` packages:
Satoru Takabayashi803fd1b2018-05-25 02:29:321254
Tom Hughese6f05112019-08-06 15:35:381255```bash
Jeroen Dhollander0eca9672020-04-17 17:00:291256(inside) cros_workon --board=${BOARD} start chromeos-chrome chrome-icu
Satoru Takabayashi803fd1b2018-05-25 02:29:321257```
1258
1259or set the `CHROME_ORIGIN` environment variable appropriately:
1260
Tom Hughese6f05112019-08-06 15:35:381261```bash
Satoru Takabayashif3075092018-05-25 05:12:221262(inside) export CHROME_ORIGIN=LOCAL_SOURCE
Satoru Takabayashi803fd1b2018-05-25 02:29:321263```
1264
1265See
1266`src/third_party/chromiumos-overlay/chromeos-base/chromeos-chrome/chromeos-chrome-9999.ebuild`
1267for additional possible values for the `CHROME_ORIGIN` variable.
1268
1269If you have an internal checkout of the Google Chrome source and want to build
1270the browser with official branding, export `USE=chrome_internal`.
1271
1272## Using Clang to get better compiler diagnostics
1273
1274### Description
1275
1276The ChromeOS toolchain provides a feature to get Clang syntax-only compiler
1277diagnostics without having to do a separate build with the Clang compiler. To
1278enable this feature, add `-clang` to the `C[XX]FLAGS` used by the package for
1279its build.
1280
1281Addition of the `-clang` option to the build is interpreted by the compiler
1282driver wrapper script, which then invokes Clang with -fsyntax-only option, and
1283after a successful Clang run, invokes the gcc compiler. Any errors generated by
1284Clang will stop compilation just like a regular build does. In addition to Clang
1285warnings, you will also see warning from gcc, in some cases for the same source
1286construct.
1287
1288The presence of a few specific gcc options, for example, `-print-*` or `-E`
1289will disable a clang run, even if `-clang` is specified. This is to allow
1290package configure scripts to run correctly even in the presence of the
1291`-clang` option.
1292
1293### Wrapper Options
1294
1295The wrapper script also interprets a few other options. All options specific to
1296the wrapper only are tabulated below:
1297
1298* `-clang`: Invoke Clang front-end with `-fsyntax-only` and all other
1299 options specified on the command line. On successful completion of Clang
1300 compile, continue the build with gcc or `g++`. The presence of
1301 `-print-*`, `-dump*`, `@*`, `-E`, `-` or `-M` will disable
1302 clang invocation.
1303* `-Xclang-only=<option>`: This is a special option that can be used to pass
1304 `<option>` to Clang and not to `gcc` or `g++`. This can be used, for
1305 example, to turn off a specific Clang warning. Example:
1306 `-Xclang-only=-Wno-c++11-extension`s will add `-Wno-c++11-extensions` to the
1307 Clang invocation.
1308* `-print-cmdline`: In addition to doing the builds, print the exact
1309 command-line used for both Clang and gcc.
1310
1311### Testing
1312
1313You can test your package with Clang before adding `-clang` to your ebuild or
1314Makefiles using the `CFLAGS` or `CXXFLAGS` variable. While using this, you need
1315to be careful not to overwrite existing `CFLAGS` or `CXXFLAGS`. Here's an
1316example:
1317
Tom Hughese6f05112019-08-06 15:35:381318```bash
Satoru Takabayashif3075092018-05-25 05:12:221319(inside)
1320$ CFLAGS="$(portageq-$board envvar CFLAGS) -clang" \
1321 CXXFLAGS="$(portageq-$board envvar CXXFLAG) -clang" \
1322 emerge-$board chromeos-chrome
Satoru Takabayashi803fd1b2018-05-25 02:29:321323```
1324
1325After your package builds cleanly with Clang, you can add `-clang` to your
1326ebuild.
1327
Trent Begin028fb542018-10-10 20:40:401328## Local Debugging
Satoru Takabayashi803fd1b2018-05-25 02:29:321329
1330### Debugging both x86 and non-x86 binaries on your workstation.
1331
1332If you build your projects incrementally, write unit tests and use them to drive
1333your development, you may want to debug your code without shipping it over to a
1334running device or VM.
1335
1336`gdb-${BOARD}` sets up gdb in your board sysroot and ensures that gdb is using
1337the proper libraries, debug files, etc. for debugging, allowing you to run your
1338target-compiled binaries.
1339
1340It should already be installed in your chroot. If you do not have the script,
1341update your repository to get the latest changes, then re-build your packages:
1342
Tom Hughese6f05112019-08-06 15:35:381343```bash
Conor McNamaracab29c02019-12-06 23:18:551344(in/out) repo sync
Satoru Takabayashi803fd1b2018-05-25 02:29:321345
Satoru Takabayashif3075092018-05-25 05:12:221346(inside) ./build_packages --board=...
Satoru Takabayashi803fd1b2018-05-25 02:29:321347```
1348
1349This should install `gdb-${BOARD}` in the `/usr/local/bin` directory inside the
1350chroot. These board-specific gdb wrapper scripts correctly handle _both local
1351and remote debugging_ (see next section for more information on remote
1352debugging). When used for local debugging, these scripts will run inside a
1353special chroot-inside-your-chroot, rooted in the board's sysroot. For example if
1354you are using `gdb-lumpy`, it will run inside a chroot based entirely in your
1355`/build/lumpy` sysroot. _The libraries that it will load and use are the
1356libraries in the sysroot,_ i.e. the target libraries for the board; the gdb
1357binary it will use is the gdb binary in that tree. While debugging with
1358`gdb-lumpy` (for local debugging), you will not be able to see/access any files
1359outside of the `/build/lumpy` tree. While for the most part this is very good,
1360as it ensures the correct debugging environment, it does mean that if you want
1361to use this script to debug a lumpy binary, such as a unit test, that you built
1362outside of the `/build/lumpy` tree, you will need to copy the binary to the
1363`/build/lumpy` tree first. Also, if you want the debugger to be able to see the
1364source files when debugging, you will need to make sure they exist inside the
1365`/build/lumpy` tree as well (see example below).
1366
1367**IMPORTANT NOTE 1**: Local and remote debugging functionality are combined in
1368this single script. Some of the options shown below only work for remote
1369debugging.
1370
1371**IMPORTANT NOTE 2**: When doing local debugging of x86 binaries, they will try
1372to execute on your desktop machine (using the appropriate libraries and gdb
1373binaries). It is possible that for some x86 boards, the binaries may use
1374instructions not understood by your hardware (particularly some vector
1375instructions), in which case you will need to do remote debugging with the
1376actual hardware instead.
1377
1378**IMPORTANT NOTE 3**: You can use this script with \*some\* debugging
1379functionality for local debugging of non-x86 binaries. The script loads qemu and
1380runs the non-x86 binaries in qemu. However qemu has some unfortunate
1381limitations. For example you can "set" breakpoints in the binary (to see what
1382addresses correspond to locations in the source), examine the source or assembly
1383code, and execute the program. But qemu does not actually hit the breakpoints,
1384so you cannot suspend execution in the middle when running under qemu. For full
1385debugging functionality with non-x86 binaries, you must debug them remotely
1386running on the correct hardware (see next section on remote debugging). You can
1387see this in the example below, where gdb-daisy does not actually stop at the
1388breakpoint it appears to set, although it does correctly execute the program.
1389
Tom Hughese6f05112019-08-06 15:35:381390```bash
Satoru Takabayashif3075092018-05-25 05:12:221391(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321392(cr) $ gdb-daisy -h
1393
1394usage: cros_gdb [-h]
1395 [--log-level {fatal,critical,error,warning,notice,info,debug}]
1396 [--log_format LOG_FORMAT] [--debug] [--nocolor]
1397 [--board BOARD] [-g GDB_ARGS] [--remote REMOTE] [--pid PID]
1398 [--remote_pid PID] [--no-ping] [--attach ATTACH_NAME] [--cgdb]
1399 [binary-to-be-debugged] [args-for-binary-being-debugged]
1400
1401Wrapper for running gdb.
1402
1403This handles the fun details like running against the right sysroot, via
1404qemu, bind mounts, etc...
1405
1406positional arguments:
1407 inf_args Arguments for gdb to pass to the program being
1408 debugged. These are positional and must come at the
1409 end of the command line. This will not work if
1410 attaching to an already running program.
1411...
1412
1413(cr) $ gdb-daisy /bin/grep shebang /bin/ls
Mike Frysinger92694c02019-12-17 22:12:40141415:51:06: INFO: run: file /build/daisy/bin/grep
Satoru Takabayashi803fd1b2018-05-25 02:29:321415Reading symbols from /bin/grep...Reading symbols from /usr/lib/debug/bin/grep.debug...done.
1416done.
1417(daisy-gdb) b main
1418Breakpoint 1 at 0x2814: file grep.c, line 2111.
1419(daisy-gdb) disass main
1420Dump of assembler code for function main:
1421 0x00002814 <+0>: ldr.w r2, [pc, #3408] ; 0x3568 <main+3412>
1422 0x00002818 <+4>: str.w r4, [sp, #-36]!
1423 0x0000281c <+8>: movs r4, #0
1424 0x0000281e <+10>: strd r5, r6, [sp, #4]
1425 0x00002822 <+14>: ldr.w r3, [pc, #3400] ; 0x356c <main+3416>
1426 0x00002826 <+18>: movs r5, #2
1427 0x00002828 <+20>: strd r7, r8, [sp, #12]
1428...
1429(daisy-gdb) run
1430Starting program: /bin/grep shebang /bin/ls
1431qemu: Unsupported syscall: 26
1432#!/usr/bin/coreutils --coreutils-prog-shebang=ls
1433qemu: Unsupported syscall: 26
1434During startup program exited normally.
1435(daisy-gdb) quit
1436```
1437
1438Note in the example above that, like "regular" gdb when given `--args`, you can
1439pass the arguments for the program being debugged to the gdb wrapper script just
1440by adding them to the command line after the name of the program being debugged
1441(except that `--args` isn't needed).
1442
1443The commands below show how to copy your incrementally-compiled unit test binary
1444and source file(s) to the appropriate sysroot and then start gdb with that
1445binary (using the correct libraries, etc).
1446
Tom Hughese6f05112019-08-06 15:35:381447```bash
Satoru Takabayashif3075092018-05-25 05:12:221448(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321449(cr) $ cd /build/lumpy/tmp/portage
1450(cr) $ mkdir shill-test
1451(cr) $ cd shill-test
1452(cr) $ cp <path-to-binary>/shill_unittest .
Satoru Takabayashif3075092018-05-25 05:12:221453(cr) $ cp <path-to-src>/shill_unittest.cc .
Satoru Takabayashi803fd1b2018-05-25 02:29:321454(cr) $ gdb-lumpy
1455(gdb-lumpy) directory /tmp/portage/shill-test # Tell gdb to add /tmp/portage/shill-test to the paths it searches for source files
1456(gdb-lumpy) file ./shill_unittest
1457```
1458
1459If gdb is still looking for the source file in the wrong directory path, you can
1460use `set substitute-path <from> <to>` inside gdb to help it find the right path
1461(inside your sysroot) for searching for source files.
1462
Eliot Courtneyaf7edf32020-06-16 05:49:501463### Printing stack traces at runtime.
1464
1465See [./stack_traces.md] for how to print stack traces at runtime.
1466
Satoru Takabayashi803fd1b2018-05-25 02:29:321467## Remote Debugging
1468
1469### Setting up remote debugging by hand.
1470
1471If you want to manually run through all the steps necessary to set up your
1472system for remote debugging and start the debugger, see [Remote Debugging in
1473Chromium OS].
1474
1475### Automated remote debugging using gdb-${BOARD} script (gdb-lumpy, gdb-daisy, gdb-parrot, etc).
1476
1477`gdb-${BOARD}` is a script that automates many of the steps necessary for
1478setting up remote debugging with gdb. It should already be installed in your
1479chroot. If you do not have the script, update your repository to get the latest
1480changes, then re-build your packages:
1481
Tom Hughese6f05112019-08-06 15:35:381482```bash
Conor McNamaracab29c02019-12-06 23:18:551483(in/out) repo sync
Satoru Takabayashi803fd1b2018-05-25 02:29:321484
Satoru Takabayashif3075092018-05-25 05:12:221485(inside) ./build_packages --board=...
Satoru Takabayashi803fd1b2018-05-25 02:29:321486```
1487
1488This should install `gdb_remote` in the `/usr/bin` directory inside the
1489chroot. The `gdb-${BOARD}` script takes several options. The most important ones
1490are mentioned below.
1491
1492`--gdb_args` (`-g`) are arguments to be passed to gdb itself (rather than to the
1493program gdb is debugging). If multiple arguments are passed, each argument
1494requires a separate -g flag.
1495
1496E.g `gdb-lumpy --remote=123.45.67.765 -g "-core=/tmp/core" -g "-directory=/tmp/source"`
1497
1498`--remote` is the ip_address or name for your chromebook, if you are doing
1499remote debugging. If you omit this argument, the assumption is you are doing
1500local debugging in the sysroot on your desktop (see section above). if you are
1501debugging in the VM, then you need to specify either `:vm:` or `localhost:9222`.
1502
1503`--pid` is the pid of a running process on the remote device to which you want
1504gdb/gdbserver to attach.
1505
1506`--attach` is the name of the running process on the remote device to which you
1507want gdb/gdbserver to attach. If you want to attach to the Chrome browser
1508itself, there are three special names you can use: `browser` will attach to the
1509main browser process; `gpu-process` will attach to the GPU process; and
1510`renderer` will attach to the renderer process if there is only one. If there is
1511more than one renderer process `--attach=renderer` will return a list of the
1512renderer pids and stop.
1513
1514To have gdb/gdbserver start and attach to a new (not already running) binary,
1515give the name of the binary, followed by any arguments for the binary, at the
1516end of the command line:
1517
Tom Hughese6f05112019-08-06 15:35:381518```bash
Satoru Takabayashif3075092018-05-25 05:12:221519(inside) $ gdb-daisy --remote=123.45.67.809 /bin/grep "test" /tmp/myfile
Satoru Takabayashi803fd1b2018-05-25 02:29:321520```
1521
1522When doing remote debugging you \*must\* use the `--pid` or the `--attach`
1523option, or specify the name of a new binary to start. You cannot start a remote
1524debugging session without having specified the program to debug in one of these
1525three ways.
1526
1527When you invoke `gdb-${BOARD} --remote=...`, it will connect to the notebook or
1528VM (automatically setting up port-forwarding on the VM), make sure the port is
1529entered into the iptables, and start up gdbserver, using the correct port and
1530binary, either attaching to the binary (if a remote pid or name was specified)
1531or starting up the binary. It will also start the appropriate version of gdb
1532(for whichever type of board you are debugging) on your desktop and connect the
1533gdb on your desktop to the gdbserver on the remote device.
1534
1535### Edit/Debug cycle
1536
1537If you want to edit code and debug it on the DUT you can follow this procedure
1538
Tom Hughese6f05112019-08-06 15:35:381539```bash
Conor McNamaracab29c02019-12-06 23:18:551540(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321541$ CFLAGS="-ggdb" FEATURES="noclean" emerge-${BOARD} -v sys-apps/mosys
1542$ cros deploy --board=${BOARD} ${IP} sys-apps/mosys
1543$ gdb-${BOARD} --cgdb --remote "${IP}" \
Raul E Rangel4b6fa602018-05-30 15:13:071544 -g "--eval-command=directory /build/${BOARD}/tmp/portage/sys-apps/mosys-9999/work/" \
Satoru Takabayashi803fd1b2018-05-25 02:29:321545 /usr/sbin/mosys -V
1546```
1547
1548This will build your package with debug symbols (assuming your package respects
1549`CFLAGS`). We need to use the `noclean` feature so that we have access to the
1550original sourcecode that was used to build the package. Some packages will
1551generate build artifacts and have different directory structures then the
1552tar/git repo. This ensures all the paths line up correctly and the source code
1553can be located. Ideally we would use the `installsources` feature, but we don't
1554have support for the debugedit package (yet!). Portage by default will strip the
1555symbols and install the debug symbols in `/usr/lib/debug/`. `gdb-${BOARD}` will
1556handle setting up the correct debug symbol path. cros deploy will then update
1557the rootfs on the DUT. We pass the work directory into `gdb-${BOARD}` so that
1558[cgdb] can display the sourcecode inline.
1559
1560Quick primer on cgdb:
1561
1562* ESC: moves to the source window.
1563* i: moves from source window to gdb window.
1564
1565### Examples of debugging using the gdb-${BOARD} script.
1566
1567Below are three examples of using the board-specific gdb wrapper scripts to
1568start up debugging sessions. The first two examples show connecting to a remote
1569chromebook. The first one automatically finds the browser's running GPU process,
1570attaches gdbserver to the running process, starts gdb on the desktop, and
1571connects the local gdb to gdbserver. It also shows the user running the `bt`
1572(backtrace) command after gdb comes up. The second example shows the user
1573specifying the pid of a process on the chromebook. Again the script attaches
1574gdbserver to the process, starts gdb on the desktop, and connects the two. The
1575third example shows the user connecting to the main browser process in ChromeOS
1576running in a VM on the user's desktop. For debugging the VM, you can use either
1577`--remote=:vm:` or `--remote=localhost:9222` (`:vm:` gets translated into
1578`localhost:9222`).
1579
1580Example 1:
1581
Tom Hughese6f05112019-08-06 15:35:381582```bash
Satoru Takabayashif3075092018-05-25 05:12:221583(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321584$ gdb-lumpy --remote=123.45.67.809 --attach=gpu-process
1585
Mike Frysinger92694c02019-12-17 22:12:40158614:50:07: INFO: run: ping -c 1 -w 20 123.45.67.809
158714:50:09: INFO: run: file /build/lumpy/opt/google/chrome/chrome
158814:50:10: INFO: run: x86_64-cros-linux-gnu-gdb --quiet '--eval-command=set sysroot /build/lumpy' '--eval-command=set solib-absolute-prefix /build/lumpy' '--eval-command=set solib-search-path /build/lumpy' '--eval-command=set debug-file-directory /build/lumpy/usr/lib/debug' '--eval-command=set prompt (lumpy-gdb) ' '--eval-command=file /build/lumpy/opt/google/chrome/chrome' '--eval-command=target remote localhost:38080'
Satoru Takabayashi803fd1b2018-05-25 02:29:321589Reading symbols from /build/lumpy/opt/google/chrome/chrome...Reading symbols from/build/lumpy/usr/lib/debug/opt/google/chrome/chrome.debug...done.
1590(lumpy-gdb) bt
1591#0 0x00007f301fad56ad in poll () at ../sysdeps/unix/syscall-template.S:81
1592#1 0x00007f3020d5787c in g_main_context_poll (priority=2147483647, n_fds=3, fds=0xdce10719840, timeout=-1, context=0xdce1070ddc0) at gmain.c:3584
1593#2 g_main_context_iterate (context=context@entry=0xdce1070ddc0,block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3285
1594#3 0x00007f3020d5798c in g_main_context_iteration (context=0xdce1070ddc0may_block=1) at gmain.c:3351
1595#4 0x00007f30226a4c1a in base::MessagePumpGlib::Run (this=0xdce10718580, delegate=<optimized out>) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/base/message_loop/message_pump_glib.cc:309
1596#5 0x00007f30226666ef in base::RunLoop::Run (this=this@entry=0x7fff72271af0) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/base/run_loop.cc:55
1597#6 0x00007f302264e165 in base::MessageLoop::Run (this=this@entry=0x7fff72271db0) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/base/message_loop/message_loop.cc:307
1598#7 0x00007f30266bc847 in content::GpuMain (parameters=...) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/content/gpu/gpu_main.cc:365
1599#8 0x00007f30225cedee in content::RunNamedProcessTypeMain (process_type=..., main_function_params=..., delegate=0x7fff72272380 at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/content/app/content_main_runner.cc:385
1600#9 0x00007f30225cef3a in content::ContentMainRunnerImpl::Run (this=0xdce106fef50) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/content/app/content_main_runner.cc:763
1601#10 0x00007f30225cd551 in content::ContentMain (params=...) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/content/app/content_main.cc:19
1602#11 0x00007f3021fef02a in ChromeMain (argc=21, argv=0x7fff722724b8) at ../../../../../chromeos-cache/distfiles/target/chrome-src-internal/src/chrome/app/chrome_main.cc:66
1603#12 0x00007f301fa0bf40 in __libc_start_main (main=0x7f3021fee760 <main(int, char const**)>, argc=21, argv=0x7fff722724b8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,stack_end=0x7fff722724a8) at libc-start.c:292
1604#13 0x00007f3021feee95 in _start ()
1605(lumpy-gdb)
1606```
1607
1608Example 2:
1609
Tom Hughese6f05112019-08-06 15:35:381610```bash
Satoru Takabayashif3075092018-05-25 05:12:221611(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321612$ gdb-daisy --pid=626 --remote=123.45.98.765
Mike Frysinger92694c02019-12-17 22:12:40161314:50:07: INFO: run: ping -c 1 -w 20 123.45.98.765
161414:50:09: INFO: run: file /build/daisy/usr/sbin/cryptohomed
161514:50:10: INFO: run: armv7a-cros-linux-gnueabi-gdb --quiet '--eval-command=set sysroot /build/daisy' '--eval-command=set solib-absolute-prefix /build/daisy' '--eval-command=set solib-search-path /build/daisy' '--eval-command=set debug-file-directory /build/daisy/usr/lib/debug' '--eval-command=set prompt (daisy-gdb) ' '--eval-command=file /build/daisy/usr/sbin/cryptohomed' '--eval-command=target remote localhost:38080'
Satoru Takabayashi803fd1b2018-05-25 02:29:321616Reading symbols from /build/daisy/usr/sbin/cryptohomed...Reading symbols from/build/daisy/usr/lib/debug/usr/bin/cryptohomed.debug...done.
1617(daisy-gdb)
1618```
1619
1620Example 3:
1621
Tom Hughese6f05112019-08-06 15:35:381622```bash
Satoru Takabayashif3075092018-05-25 05:12:221623(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321624$ gdb-lumpy --remote=:vm: --attach=browser
Mike Frysinger92694c02019-12-17 22:12:40162515:18:28: INFO: run: ping -c 1 -w 20 localhost
162615:18:31: INFO: run: file /build/lumpy/opt/google/chrome/chrome
162715:18:33: INFO: run: x86_64-cros-linux-gnu-gdb --quiet '--eval-command=setsysroot /build/lumpy' '--eval-command=set solib-absolute-prefix /build/lumpy' '--eval-command=set solib-search-path /build/lumpy' '--eval-command=set debug-file-directory /build/lumpy/usr/lib/debug' '--eval-command=set prompt (lumpy-gdb) ' '--eval-command=file /build/lumpy/opt/google/chrome/chrome' '--eval-command=target remote localhost:48062'
Satoru Takabayashi803fd1b2018-05-25 02:29:321628Reading symbols from /build/lumpy/opt/google/chrome/chrome...Reading symbols from /build/lumpy/usr/lib/debug/opt/google/chrome/chrome.debug...done.
1629done.
1630Remote debugging using localhost:48062
1631...
1632(lumpy-gdb)
1633```
1634
1635If you find problems with the board-specific gdb scripts, please file a bug
1636([crbug.com/new]) and add 'build-toolchain' as one of the labels in the
1637bug.
1638
Steven Bennetts7f08b002018-06-29 23:28:441639## Building Chrome for Chromium OS
1640
1641See [Simple Chrome Workflow].
1642
Satoru Takabayashi803fd1b2018-05-25 02:29:321643## Troubleshooting
1644
1645### I lost my developer tools on the stateful partition, can I get them back?
1646
1647This happens sometimes because the security system likes to wipe out the
1648stateful partition and a lot of developer tools are in /usr/local/bin. But all
1649is not lost because there is a tool for updating the stateful partition from an
1650image created by the auto-update part of the dev_server. Sadly, it is normally
1651found in /usr/local so will have been lost too and you need to copy it over
1652manually. This works for me:
1653
Tom Hughese6f05112019-08-06 15:35:381654```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321655$ cd /tmp
1656$ scp me@myworkstation:/path/to/chromiumos/chroot/build/x86-whatever/usr/bin/stateful_update .
1657$ sudo sh stateful_update
1658$ sudo reboot
1659```
1660
1661Note you can clobber the stateful partition (remove user accounts etc and force
1662OOBE) as part of this process by using a flag:
1663
Tom Hughese6f05112019-08-06 15:35:381664```bash
Satoru Takabayashi803fd1b2018-05-25 02:29:321665$ cd /tmp
1666$ scp me@myworkstation:/path/to/chromiumos/chroot/build/x86-whatever/usr/bin/stateful_update .
1667$ sudo sh stateful_update --stateful_change=clean
1668$ sudo reboot
1669```
1670
Tom Hughes4c99d072019-11-08 18:31:011671### Disabling Enterprise Enrollment
1672
1673Some devices may be configured with a policy that only allows logging in with
1674enterprise credentials, which will prevent you from logging in with a
1675non-enterprise Google account (e.g., `[email protected]`). To disable the enterprise
1676enrollment setting:
1677
1678* Enable [Developer Mode].
1679* Disable the enterprise enrollment check:
1680
1681 ```bash
Miriam Polzer353b8d02020-11-09 08:24:161682 (dut) $ vpd -i RW_VPD -check_enrollment=0
Tom Hughes4c99d072019-11-08 18:31:011683 (dut) $ dump_vpd_log --force
1684 (dut) $ crossystem clear_tpm_owner_request=1
1685 (dut) $ reboot
1686 ```
1687
1688***note
1689**NOTE:** The enterprise policy can also prevent transitioning to
1690[Developer Mode], in which case you won't be able to perform the above commands.
1691***
1692
Satoru Takabayashi803fd1b2018-05-25 02:29:321693## Running Tests
1694
Daniel Erat756631d2018-12-13 02:27:151695Chromium OS integration (or "functional") tests are written using the [Tast] or
1696[Autotest] frameworks.
Satoru Takabayashi803fd1b2018-05-25 02:29:321697
Daniel Erat756631d2018-12-13 02:27:151698### Tast
Satoru Takabayashi803fd1b2018-05-25 02:29:321699
Daniel Erat756631d2018-12-13 02:27:151700[Tast] is a Go-based integration testing framework with a focus on speed,
1701ease-of-use, and maintainability. Existing Autotest-based tests that run on the
1702Chrome OS Commit Queue are being ported to Tast and decommissioned as of 2018
1703Q4. Please strongly consider using Tast when writing new integration tests (but
1704be aware that not all functionality provided by Autotest is available in Tast;
1705for example, tests that use multiple devices simultaneously when running are not
1706currently supported).
1707
1708Here are some starting points for learning more about Tast:
1709
1710* [Tast Quickstart]
1711* [Tast: Running Tests]
1712* [Tast: Writing Tests]
1713* [Tast Overview]
1714
1715Please contact the public [tast-users mailing list] if you have questions.
1716
1717### Autotest
1718
1719[Autotest] is a Python-based integration testing framework; the codebase is also
1720responsible for managing the [Chrome OS lab] that is used for hardware testing.
1721Chromium-OS-specific Autotest information is available in the [Autotest User
1722Documentation].
1723
1724Additional Autotest documentation:
1725
1726* [Creating a new Autotest test]
1727* [Running Autotest Smoke Suite On a VM Image]
1728* [Seeing which Autotest tests are implemented by an ebuild]
1729
1730### Creating a normal image that has been modified for test
1731
1732See [Creating an image that has been modified for test] for information about
1733modifying a normal system image so that integration tests can be run on it.
1734
1735### Creating a VM image that has been modified for test
Satoru Takabayashi803fd1b2018-05-25 02:29:321736
Pranav Batra0ccdf1e2020-09-18 06:27:291737If you wish to produce a VM image instead, make sure to include the --test flag
1738when running build_image and run `./image_to_vm.sh` with the --test_image flag:
Satoru Takabayashi803fd1b2018-05-25 02:29:321739
Tom Hughese6f05112019-08-06 15:35:381740```bash
Mike Wiitalaff7b1ce2019-07-24 22:22:491741(inside) ./image_to_vm.sh --board=${BOARD} --test_image
Satoru Takabayashi803fd1b2018-05-25 02:29:321742```
1743
1744Note: this difference between `cros flash` and `./image_to_vm.sh` arises because
1745`./image_to_vm.sh` does not yet support the `--image_name` flag and by default
1746looks for `chromiumos_image.bin`. We expect this to change in the future.
1747
Satoru Takabayashi803fd1b2018-05-25 02:29:321748### Creating a recovery image that has been modified for test
1749
Daniel Erat756631d2018-12-13 02:27:151750After building a test image using `./build_image test` as described above, you
1751may wish to encapsulate it within a recovery image:
Satoru Takabayashi803fd1b2018-05-25 02:29:321752
Tom Hughese6f05112019-08-06 15:35:381753```bash
Satoru Takabayashif3075092018-05-25 05:12:221754(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321755./mod_image_for_recovery.sh \
1756 --board=${BOARD} \
1757 --nominimize_image \
1758 --image ~/trunk/src/build/images/${BOARD}/latest/chromiumos_test_image.bin \
1759 --to ~/trunk/src/build/images/${BOARD}/latest/recovery_test_image.bin
1760```
1761
1762If desired, you may specify a custom kernel with `--kernel_image
1763${RECOVERY_KERNEL}`.
1764
1765You can write this recovery image out to the USB device like so:
1766
Tom Hughese6f05112019-08-06 15:35:381767```bash
Satoru Takabayashif3075092018-05-25 05:12:221768(inside)
Satoru Takabayashi803fd1b2018-05-25 02:29:321769cros flash usb:// ~/trunk/src/build/images/${BOARD}/latest/recovery_test_image.bin
1770```
1771
1772Note that there are some **downsides** to this approach which you should keep in
1773mind.
1774
1775* Your USB image will be a recovery mode/test image, but the ordinary image in
1776 your directory will be a non-test image.
1777* If you use devserver, this will serve the non-test image not the test-image.
1778* This means a machine installed with a test-enabled USB image will update to
1779 a non-test-enabled one.
Thiemo Nagel39096e62019-06-18 12:20:511780* As the `*-generic` boards set `USE=tpm`, recovery images built for
1781 `*-generic` don't work on devices with H1 chips (which requires `USE=tpm2`).
Satoru Takabayashi803fd1b2018-05-25 02:29:321782
1783## Additional information
1784
Kirtika Ruchandani6ce690a2019-02-26 01:12:021785### Updating the chroot
1786
Evan Benn8fe69b12019-11-05 04:45:591787You should run `update_chroot` after `repo sync`.
1788`repo sync` only updates the source code, `update_chroot` is required to apply
1789those changes to the chroot.
1790`update_chroot` can be run manually, alternatively it is run as part of
1791`setup_board` and `build_packages`.
Kirtika Ruchandani6ce690a2019-02-26 01:12:021792
Tom Hughese6f05112019-08-06 15:35:381793```bash
Evan Benn8fe69b12019-11-05 04:45:591794(inside) ./update_chroot
Kirtika Ruchandani6ce690a2019-02-26 01:12:021795```
1796
Satoru Takabayashi803fd1b2018-05-25 02:29:321797### Toolchain Compilers
1798
1799At any given time in the chroot, to see what cross-compiler version is the
1800current default one, do:
1801
1802* For ARM: `armv7a-cros-linux-gnueabi-gcc -v`
1803* For x86: `i686-pc-linux-gnu-gcc -v`
1804* For amd64: `x86_64-cros-linux-gnu-gcc -v`
1805
Jason D. Clintone5435d72019-10-15 01:57:501806### Sync to Green
1807
1808Googlers/internal users may work from either the stable ref or from tip-of-tree
1809(ToT) like external contributors; both are fully supported.
1810
1811It's always the case that `repo sync` could sync to a broken tree in ChromeOS.
1812There's been many bug reports of this happening to folks over the years. There
1813are two structural sources of this: chumped CL's and mutually incompatible CL's
1814landing at the same time.
1815
1816If you have previously run `repo init` without the `-b stable`, you can convert an
Avery Musbache29deda2020-09-11 16:58:311817existing checkout to stable:
Jason D. Clintone5435d72019-10-15 01:57:501818
Conor McNamaracab29c02019-12-06 23:18:551819```shell
1820(in/out)
Jason D. Clintone5435d72019-10-15 01:57:501821repo init -b stable
1822repo sync
1823```
1824
1825This stable ref is updated anytime that postsubmit-orchestrator passes all build
1826and unit test stages (it ignores hardware tests so that the stables updates are
1827more frequent). It should vary from 5-10 hours old, so long as ToT is not broken
1828(which is rare).
1829
Avery Musbache29deda2020-09-11 16:58:311830You can continue to use master (switch back with `repo init -b master`), if you
1831prefer. You would want to do this if you want to see a change that just landed
1832on ToT and don't want to wait for the stable ref to be updated to include the
1833change you are interested in building off of. On the downside, master may be
1834broken and may not have all binaries available, including Chrome (which
1835typically takes 45 minutes to build).
Jason D. Clintone5435d72019-10-15 01:57:501836
1837We guarantee that binary prebuilt packages are available for everything at the
1838stable ref including Chrome. Conversely, we don't guarantee Chrome binary
Mike Frysinger2db7b852020-09-10 08:37:441839prebuilts are available at ToT (they will be available there about 85% of
Jason D. Clintone5435d72019-10-15 01:57:501840the time). When building from stable, this should result in <10 min
1841`build_packages && build_image` times in most cases.
1842
1843In summary:
1844
1845* Stable pros: binaries always available; never broken
1846* Stable cons: 5-10 hours old
1847* Master pros: always has ToT changes
1848* Master cons: more frequently broken, may need to build packages in the
1849 depgraph including Chrome which could add ~1 hours to build times
1850
Satoru Takabayashi803fd1b2018-05-25 02:29:321851### Attribution requirements
1852
1853When you produce a Chromium OS image, you need to fulfill various attribution
1854requirements of third party licenses. Currently, the images generated by a build
1855don't do this for you automatically. You must modify [about_os_credits.html].
1856
1857### Documentation on this site
1858
1859You now understand the basics of building, running, modifying, and testing
1860Chromium OS, but you've still got a lot to learn. Here are links to a few other
1861pages on the chromium.org site that you are likely to find helpful (somewhat
1862ordered by relevance):
1863
1864* The [Tips And Tricks] page has a lot of useful
1865 information to help you optimize your workflow.
1866* If you haven't read the page about the [devserver] already, read it now.
1867* Learn about the Chromium OS [directory structure].
1868* [The Chromium OS developer FAQ]
1869* [Chromium OS Portage Build FAQ] is useful for portage-specific questions.
1870* If you have questions about the `--noenable_rootfs_verification` option, you
1871 might find answers on this [thread on chromium-os-dev][rootfs-thread].
1872* [Running Smoke Suite on a VM Image] has good information about how to get up
1873 and running with autotest tests and VMs.
1874* [Debugging Tips] contains information about how to debug the Chromium
1875 browser on your Chromium OS device.
1876* [Working on a Branch] has tips for working on branches.
1877* [Git server-side information] talks about adding new git repositories.
1878* The [Portage Package Upgrade Process] documents how our Portage
1879 packages can be upgraded when they fall out of date with respect to
1880 upstream.
1881* The [Chromium OS Sandboxing] page describes the mechanisms and tools used to
1882 sandbox (or otherwise restrict the privileges of) Chromium OS system
1883 services.
1884* The [Go in Chromium OS] page provides information on using [Go] in Chromium
1885 OS, including recommendations for project organization, importing and
1886 managing third party packages, and writing ebuilds.
Evan Benn6a6383b2019-10-31 23:01:071887* The [SELinux](security/selinux.md) page provides information on SELinux in Chrome
David Pursehouseb3b7da12019-06-17 12:23:391888 OS, including overview, writing policies, and troubleshooting.
Satoru Takabayashi803fd1b2018-05-25 02:29:321889
1890### External documentation
1891
1892Below are a few links to external sites that you might also find helpful
1893(somewhat ordered by relevance):
1894
1895* **Definitely** look at the [Chromium OS dev group] to see what people are
1896 talking about.
Matthew Duggan472da132020-08-18 01:05:321897* Check out the [Chromium bug tracker] to report bugs, look for known
Satoru Takabayashi803fd1b2018-05-25 02:29:321898 issues, or look for things to fix.
1899* Get an idea of what's actively happening by looking at the [Chromium Gerrit]
1900 site. (Note that this is no longer the same site that Chromium uses)
1901* Browse the source code on the [Chromium OS gitweb].
1902* Check the current status of the builds by looking at the
1903 [Chromium OS build waterfall].
1904* Check out the [#chromium-os channel] on freenode.net (this is the IRC
1905 channel that Chromium OS developers like to hang out on).
1906* If you're learning git, check out [Git for Computer Scientists],
1907 [Git Magic], or the [Git Manual].
1908* Gentoo has several useful documentation resources
1909 * [Gentoo Development Guide] is a useful resource for Portage, which is
1910 the underlying packaging system we use.
1911 * [Gentoo Embedded Handbook]
1912 * [Gentoo Cross Development Guide]
1913 * [Gentoo Wiki on Cross-Compiling]
1914 * [Gentoo Package Manager Specification]
1915* The [repo user docs] might help you if you're curious about repo.
1916* The [repo-discuss group] is a good place to talk about repo.
1917
1918
Mike Frysinger9fc0fc02020-09-05 05:18:571919[quick-start guide]: https://dev.chromium.org/chromium-os/quick-start-guide
Satoru Takabayashif3075092018-05-25 05:12:221920[README.md]: README.md
Satoru Takabayashi803fd1b2018-05-25 02:29:321921[Prerequisites]: #Prerequisites
1922[Getting the source code]: #Getting-the-source-code
1923[Building Chromium OS]: #Building-Chromium-OS
1924[Installing Chromium OS on your Device]: #Installing-Chromium-OS-on-your-Device
1925[Making changes to packages whose source code is checked into Chromium OS git repositories]: #Making-changes-to-packages-whose-source-code-is-checked-into-Chromium-OS-git-repositories
Ben Pasteneff8c9e92020-03-19 00:21:301926[Making changes to non-cros_workon-able packages]: #Making-changes-to-non_cros_workon_able-packages
Satoru Takabayashi803fd1b2018-05-25 02:29:321927[Using Clang to get better compiler diagnostics]: #Using-Clang-to-get-better-compiler-diagnostics
1928[Local Debugging]: #Local-Debugging
1929[Remote Debugging]: #Remote-Debugging
1930[Troubleshooting]: #Troubleshooting
1931[Running Tests]: #Running-Tests
1932[Additional information]: #Additional-information
Satoru Takabayashi803fd1b2018-05-25 02:29:321933[Attribution requirements]: #Attribution-requirements
Mike Frysinger9fc0fc02020-09-05 05:18:571934[Ubuntu]: https://www.ubuntu.com/
Satoru Takabayashi803fd1b2018-05-25 02:29:321935[RAM-thread]: https://groups.google.com/a/chromium.org/d/topic/chromium-os-dev/ZcbP-33Smiw/discussion
Mike Frysinger9fc0fc02020-09-05 05:18:571936[install depot_tools]: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
Brian Norrise7fb7012019-11-07 22:37:541937[Sync to Green]: #Sync-to-Green
Allen Webb22bbd9b2020-07-16 12:06:321938[Making sudo a little more permissive]: tips-and-tricks.md#How-to-make-sudo-a-little-more-permissive
Nick Petersonb5cbc6a2018-10-24 17:24:481939[Decide where your source will live]: #Decide-where-your-source-will-live
Mike Frysinger9fc0fc02020-09-05 05:18:571940[gerrit-guide]: https://www.chromium.org/chromium-os/developer-guide/gerrit-guide
Satoru Takabayashi803fd1b2018-05-25 02:29:321941[repo]: https://code.google.com/p/git-repo/
Mike Frysinger9fc0fc02020-09-05 05:18:571942[git]: https://git-scm.com/
Satoru Takabayashi803fd1b2018-05-25 02:29:321943[goto/chromeos-building]: http://goto/chromeos-building
Mike Frysinger9fc0fc02020-09-05 05:18:571944[API Keys]: https://www.chromium.org/developers/how-tos/api-keys
Evan Benn6a6383b2019-10-31 23:01:071945[working on a branch page]: work_on_branch.md
Mike Frysinger9fc0fc02020-09-05 05:18:571946[chroot]: https://en.wikipedia.org/wiki/Chroot
Andrew McRae4f3e97c2019-05-30 06:07:351947[gsutil]: gsutil.md
Mike Frysinger9fc0fc02020-09-05 05:18:571948[crosbug/10048]: https://crbug.com/192478
Allen Webb22bbd9b2020-07-16 12:06:321949[Tips And Tricks]: tips-and-tricks.md
Mike Frysinger9fc0fc02020-09-05 05:18:571950[something harder]: https://www.google.com/search?q=the+fourth+dimension
1951[issues with virtual packages]: https://crbug.com/187712
Evan Benn6a6383b2019-10-31 23:01:071952[What does build_packages actually do?]: portage/ebuild_faq.md#what-does-build-packages-do
Andrew McRae4f3e97c2019-05-30 06:07:351953[Cros Flash page]: cros_flash.md
Taoyu Li642425c2019-07-08 08:59:421954[Debug Button Shortcuts]: debug_buttons.md
Mike Frysinger9fc0fc02020-09-05 05:18:571955[Chrome OS Devices]: https://dev.chromium.org/chromium-os/developer-information-for-chrome-os-devices
1956[Developer Hardware]: https://dev.chromium.org/chromium-os/getting-dev-hardware/dev-hardware-list
1957[crosh]: https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/crosh/
1958[crbug/710629]: https://crbug.com/710629
Harry Cuttsfe8ca1c2020-09-16 12:48:221959[cros deploy]: cros_deploy.md
Satoru Takabayashi803fd1b2018-05-25 02:29:321960[Create a branch for your changes]: #Create-a-branch-for-your-changes
Jack Rosenthal15b90912019-06-05 16:29:251961[Making changes to the Chromium web browser on Chromium OS]: simple_chrome_workflow.md
Mike Frysinger9fc0fc02020-09-05 05:18:571962[Remote Debugging in Chromium OS]: https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/remote-debugging
Jorge Lucangeli Obes469a2b72019-10-14 13:05:591963[cgdb]: https://cgdb.github.io/
Satoru Takabayashi803fd1b2018-05-25 02:29:321964[crbug.com/new]: https://crbug.com/new
Steven Bennetts7f08b002018-06-29 23:28:441965[Simple Chrome Workflow]: simple_chrome_workflow.md
Daniel Erat756631d2018-12-13 02:27:151966[Tast]: https://chromium.googlesource.com/chromiumos/platform/tast/
1967[Autotest]: https://autotest.github.io/
1968[Tast Quickstart]: https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/quickstart.md
1969[Tast: Running Tests]: https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/running_tests.md
1970[Tast: Writing Tests]: https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/writing_tests.md
1971[Tast Overview]: https://chromium.googlesource.com/chromiumos/platform/tast/+/HEAD/docs/overview.md
1972[tast-users mailing list]: https://groups.google.com/a/chromium.org/forum/#!forum/tast-users
1973[Chrome OS lab]: http://sites/chromeos/for-team-members/lab/lab-faq
Mike Frysinger9fc0fc02020-09-05 05:18:571974[Autotest User Documentation]: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/HEAD/docs/user-doc.md
1975[Creating a new Autotest test]: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/HEAD/docs/user-doc.md#Writing-and-developing-tests
1976[Running Autotest Smoke Suite On a VM Image]: https://dev.chromium.org/chromium-os/testing/running-smoke-suite-on-a-vm-image
1977[Seeing which Autotest tests are implemented by an ebuild]: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/HEAD/docs/user-doc.md#Q4_I-have-an-ebuild_what-tests-does-it-build
1978[Creating an image that has been modified for test]: https://chromium.googlesource.com/chromiumos/third_party/autotest/+/HEAD/docs/user-doc.md#W4_Create-and-run-a-test_enabled-image-on-your-device
1979[about_os_credits.html]: https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/browser/resources/chromeos/about_os_credits.html
1980[devserver]: https://chromium.googlesource.com/chromiumos/chromite/+/HEAD/docs/devserver.md
1981[directory structure]: source_layout.md
1982[The Chromium OS developer FAQ]: https://dev.chromium.org/chromium-os/how-tos-and-troubleshooting/developer-faq
Evan Benn6a6383b2019-10-31 23:01:071983[Chromium OS Portage Build FAQ]: portage/ebuild_faq.md
Satoru Takabayashi803fd1b2018-05-25 02:29:321984[rootfs-thread]: https://groups.google.com/a/chromium.org/group/chromium-os-dev/browse_thread/thread/967e783e27dd3a9d/0fa20a1547de2c77?lnk=gst
Mike Frysinger9fc0fc02020-09-05 05:18:571985[Running Smoke Suite on a VM Image]: https://dev.chromium.org/chromium-os/testing/running-smoke-suite-on-a-vm-image
1986[Debugging Tips]: https://dev.chromium.org/chromium-os/how-tos-and-troubleshooting/debugging-tips
Evan Benn6a6383b2019-10-31 23:01:071987[Working on a Branch]: work_on_branch.md
Mike Frysinger9fc0fc02020-09-05 05:18:571988[Git server-side information]: https://dev.chromium.org/chromium-os/how-tos-and-troubleshooting/git-server-side-information
Evan Benn6a6383b2019-10-31 23:01:071989[Portage Package Upgrade Process]: portage/package_upgrade_process.md
1990[Chromium OS Sandboxing]: sandboxing.md
Mike Frysinger9fc0fc02020-09-05 05:18:571991[Go in Chromium OS]: https://dev.chromium.org/chromium-os/developer-guide/go-in-chromium-os
1992[Go]: https://golang.org
1993[Chromium OS dev group]: https://groups.google.com/a/chromium.org/group/chromium-os-dev
1994[Chromium bug tracker]: https://crbug.com/
Satoru Takabayashi803fd1b2018-05-25 02:29:321995[Chromium Gerrit]: https://chromium-review.googlesource.com/
1996[Chromium OS gitweb]: https://chromium.googlesource.com/
Mike Frysinger9fc0fc02020-09-05 05:18:571997[Chromium OS build waterfall]: https://ci.chromium.org/p/chromeos
1998[#chromium-os channel]: https://webchat.freenode.net/?channels=chromium-os
Mike Frysingercb52c092018-09-25 03:51:071999[Gerrit Workflow]: contributing.md
Mike Frysinger9fc0fc02020-09-05 05:18:572000[Git for Computer Scientists]: https://eagain.net/articles/git-for-computer-scientists/
Satoru Takabayashi803fd1b2018-05-25 02:29:322001[Git Magic]: http://www-cs-students.stanford.edu/~blynn/gitmagic/
2002[Git Manual]: http://schacon.github.com/git/user-manual.html
Mike Frysinger9fc0fc02020-09-05 05:18:572003[Gentoo Development Guide]: https://devmanual.gentoo.org/
Satoru Takabayashi803fd1b2018-05-25 02:29:322004[Gentoo Embedded Handbook]: https://wiki.gentoo.org/wiki/Embedded_Handbook
Evan Benn6a6383b2019-10-31 23:01:072005[Gentoo Cross Development Guide]: https://wiki.gentoo.org/wiki/Embedded_Handbook
2006[Gentoo Wiki on Cross-Compiling]: https://wiki.gentoo.org/wiki/Crossdev
Mike Frysinger9fc0fc02020-09-05 05:18:572007[Gentoo Package Manager Specification]: https://ci.chromium.org/p/chromeos
Satoru Takabayashi803fd1b2018-05-25 02:29:322008[repo user docs]: https://source.android.com/source/using-repo
Mike Frysinger9fc0fc02020-09-05 05:18:572009[repo-discuss group]: https://groups.google.com/group/repo-discuss
Tom Hughes9ae6c932019-08-14 17:00:492010[Developer Mode]: ./developer_mode.md
Mike Frysinger9fc0fc02020-09-05 05:18:572011[./stack_traces.md]: stack_traces.md