Satoru Takabayashi | 7cc76c9 | 2017-06-26 04:46:05 | [diff] [blame] | 1 | # Building Chrome for Chrome OS (Simple Chrome) |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 2 | |
Mike Frysinger | 05bebd5 | 2021-01-27 18:48:11 | [diff] [blame] | 3 | *** note |
| 4 | **Warning: This document is old & has moved. Please update any links:**<br> |
| 5 | https://chromium.googlesource.com/chromiumos/docs/+/HEAD/simple_chrome_workflow.md |
| 6 | *** |
| 7 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 8 | This workflow allows you to quickly build/deploy Chrome to a Chrome OS |
Steven Bennetts | 0d19591 | 2018-09-18 23:37:39 | [diff] [blame] | 9 | [VM] or device without needing a Chrome OS source checkout or chroot. It's useful |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 10 | for trying out your changes on Chrome OS while you're doing Chrome |
| 11 | development. If you have an OS checkout and want your local Chrome changes to |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 12 | be included when building a full OS image, see the [OS development guide]. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 13 | |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 14 | At its core is the `chrome-sdk` shell which sets up the shell environment and |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 15 | fetches the necessary SDK components (Chrome OS toolchain, sysroot, VM, etc.). |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 16 | |
| 17 | [TOC] |
| 18 | |
| 19 | ## Typography conventions |
| 20 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 21 | | Label | Paths, files, and commands | |
| 22 | |---------------|-------------------------------------------------------| |
| 23 | | (shell) | outside the chroot and SDK shell on your workstation | |
| 24 | | (sdk) | inside the `chrome-sdk` SDK shell on your workstation | |
| 25 | | (chroot) | inside the `cros_sdk` chroot on your workstation | |
Steven Bennetts | 0d19591 | 2018-09-18 23:37:39 | [diff] [blame] | 26 | | (device) | in your [VM] or Chrome OS device | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 27 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 28 | |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 29 | ## Getting started |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 30 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 31 | Check out a copy of the [Chrome source code and depot_tools]. |
| 32 | Be certain to [update .gclient] to include `target_os = ["chromeos"]`. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 33 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 34 | ### Get the Google API keys |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 35 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 36 | In order to sign in to Chrome OS you must have Google API keys: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 37 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 38 | * External contributors: See [api-keys]. You'll need to put them in your |
| 39 | `out_$BOARD/Release/args.gn file`, see below. |
Achuith Bhandarkar | 8363026 | 2020-05-24 10:20:59 | [diff] [blame] | 40 | * *Googlers*: See [chrome build instructions] to get the internal source. |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 41 | If you have `src-internal` in your `.gclient` file the official API keys |
| 42 | will be set up automatically. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 43 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 44 | ### Set up gsutil |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 45 | |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 46 | Use depot_tools/gsutil.py and run `gsutil.py config` to set the authentication |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 47 | token. (*Googlers*: Use your @google.com account.) Otherwise steps below may run |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 48 | slowly and fail with "Login Required" from gsutil. |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 49 | |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 50 | When prompted for a project ID, enter `134157665460` (this is the Chrome OS |
| 51 | project ID). |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 52 | |
Ben Pastene | 957ea27 | 2019-03-18 16:06:01 | [diff] [blame] | 53 | ### Install build deps |
| 54 | |
| 55 | You'll also need to pull in Android native toolchain dependencies to build |
| 56 | ARC++ support libraries. This is done by running the |
| 57 | [install-build-deps-android.sh] script in Chrome's source code, located at |
| 58 | `$CHROME_DIR/src/build/install-build-deps-android.sh`. |
| 59 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 60 | ### VM versus Device |
| 61 | |
Steven Bennetts | 0d19591 | 2018-09-18 23:37:39 | [diff] [blame] | 62 | The easiest way to develop on Chrome OS is to use a [VM]. |
| 63 | |
| 64 | If you need to test hardware-specific features such as graphics acceleration, |
| 65 | bluetooth, mouse or input events, etc, you may also use a physical device |
| 66 | (Googlers: Chromestop has the hardware). See [Set up the Chrome OS device] for |
| 67 | details. |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 68 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 69 | --- |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 70 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 71 | ## Enter the Simple Chrome environment |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 72 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 73 | Building Chrome for Chrome OS requires a toolchain customized for each |
Steven Bennetts | 0d19591 | 2018-09-18 23:37:39 | [diff] [blame] | 74 | Chromebook model (or "board"). For the Chrome OS [VM], and non-Googlers, use |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 75 | `amd64-generic`. For a physical device, look up the [Chrome OS board name] by |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 76 | navigating to the URL `about:version` on the device. For example: |
| 77 | `Platform 10176.47.0 (Official Build) beta-channel samus` has board `samus`. |
| 78 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 79 | To enter the Simple Chrome environment, run these from within your Chrome |
| 80 | checkout: |
Steven Bennetts | 5a79a1c | 2017-11-27 20:05:47 | [diff] [blame] | 81 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 82 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 83 | (shell) cd /path/to/chrome/src |
| 84 | (shell) export BOARD=amd64-generic |
= | 71679e6 | 2020-05-08 18:06:25 | [diff] [blame] | 85 | (shell) cros chrome-sdk --board=$BOARD --log-level=info [--download-vm] |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 86 | ``` |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 87 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 88 | The command prompt will change to look like `(sdk $BOARD $VERSION)`. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 89 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 90 | Entering the Simple Chrome environment does the following: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 91 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 92 | 1. Fetches the Chrome OS toolchain and sysroot (SDK) for building Chrome. |
| 93 | 1. Creates out_$BOARD/Release and generates or updates args.gn. |
= | 71679e6 | 2020-05-08 18:06:25 | [diff] [blame] | 94 | 1. Starts [Goma]. (*Non-Googlers* may need to disable this with `--nogoma`.) |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 95 | 1. `--download-vm` will download a Chrome OS VM and a QEMU binary. |
| 96 | |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 97 | ### cros chrome-sdk options |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 98 | |
Ryo Hashimoto | accfa88 | 2020-06-19 15:01:41 | [diff] [blame] | 99 | * `--chrome-branding` Sets up Simple Chrome to build and deploy the internal *Chrome* instead of *Chromium*. |
| 100 | * `--official` Enables the official build level of optimization. |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 101 | * `--gn-extra-args='extra_arg=foo other_extra_arg=bar'` For setting |
| 102 | extra gn args, e.g. 'dcheck_always_on=true'. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 103 | * `--log-level=info` Sets the log level to 'info' or 'debug' (default is |
| 104 | 'warn'). |
Erik Chen | 256c2d2 | 2020-01-10 23:41:04 | [diff] [blame] | 105 | * `--nogn-gen` Do not run 'gn gen' automatically. Use this option to persist |
| 106 | changes made to a previous session's gn args. |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 107 | |
Ryo Hashimoto | accfa88 | 2020-06-19 15:01:41 | [diff] [blame] | 108 | > **Googlers**: Use `--chrome-branding` if you need a branded *Chrome* build including resources and components from src-internal to work on internal features like ARC and assistant. `--official` doesn't involve branding, instead it enables an additional level of optimization and removes development conveniences like runtime stack traces. Use it for performance testing, not for debugging. |
| 109 | |
Claudio M | b5f7d76 | 2020-05-04 05:13:59 | [diff] [blame] | 110 | **Chrome OS developers** |
| 111 | |
| 112 | Use the following command: |
| 113 | ``` |
Ryo Hashimoto | accfa88 | 2020-06-19 15:01:41 | [diff] [blame] | 114 | (shell) cros chrome-sdk --chrome-branding --board=$BOARD --log-level=info |
Claudio M | b5f7d76 | 2020-05-04 05:13:59 | [diff] [blame] | 115 | ``` |
| 116 | |
| 117 | *Optional*: Please help development by setting `dcheck_always_on=true` and filing |
| 118 | bugs if you encounter any DCHECK crashes: |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 119 | ``` |
Ryo Hashimoto | accfa88 | 2020-06-19 15:01:41 | [diff] [blame] | 120 | (shell) cros chrome-sdk --chrome-branding --board=$BOARD --log-level=info --gn-extra-args='dcheck_always_on=true' |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 121 | ``` |
Pranav Batra | be53d22 | 2020-10-07 19:42:22 | [diff] [blame] | 122 | Alternatively, you can set `dcheck_is_configurable=true` to log DCHECK errors without crashing. |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 123 | |
| 124 | ### cros chrome-sdk tips |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 125 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 126 | > **Important:** When you sync/update your Chrome source, the Chrome OS SDK |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 127 | > version (src/chromeos/CHROMEOS_LKGM) may change. When the SDK version changes |
| 128 | > you may need to exit and re-enter the Simple Chrome environment to |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 129 | > successfully build and deploy Chrome. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 130 | |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 131 | > **Non-Googlers**: Only generic boards have publicly available SDK downloads, |
| 132 | > so you will need to use a generic board (e.g. amd64-generic) or your own |
| 133 | > Chrome OS build (see [Using a custom Chrome OS build]). For more info and |
| 134 | > updates star [crbug.com/360342]. |
| 135 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 136 | > **Note**: See also [Using a custom Chrome OS build]. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 137 | |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 138 | ### Shell-less flow |
| 139 | |
| 140 | It's also possible to follow all these instructions _outside_ the Simple Chrome |
| 141 | SDK shell, which conforms more closely to how the browser is built for its |
| 142 | other supported platforms. In this alternative workflow, the `cros chrome-sdk` |
| 143 | is never called directly by hand, but instead called once during `gclient sync`. |
| 144 | |
| 145 | To do this, simply add the board you're interested in to the `cros_boards` |
| 146 | [custom gclient var] of your .gclient file. The board's SDK will then be |
| 147 | downloaded (and cached) everytime you run `gclient sync`, which should be run |
| 148 | after every update to your chromium checkout. Similar to the shell, this will |
| 149 | also create a convenient build dir at `out_$BOARD/Release`. However, GN won't |
| 150 | automatically run in that dir. So to proceed with compilation, run: |
| 151 | |
| 152 | ``` |
| 153 | (shell) gn gen out_$BOARD/Release |
| 154 | ``` |
| 155 | |
| 156 | Then to compile Chrome: |
| 157 | |
| 158 | ``` |
| 159 | (shell) autoninja -C out_$BOARD/Release chrome |
| 160 | ``` |
| 161 | |
| 162 | And any tool or script you would run inside the shell needs to be tweaked to |
| 163 | include the full path inside chromite, and may need the board explicitly passed. |
| 164 | For example, a `deploy_chrome` invocation outside the shell looks like: |
| 165 | |
| 166 | ``` |
| 167 | (shell) ./third_party/chromite/bin/deploy_chrome --build-dir=out_${BOARD}/Release --device=$IP_ADDR --board=${BOARD} |
| 168 | ``` |
| 169 | |
| 170 | This shell-less flow is currently in use by all of [Chrome's builders], so |
| 171 | there's some guarantee that it will function correctly. Conversely, the |
| 172 | traditional flow that uses the shell has no such continuous build coverage and |
| 173 | is mostly community-supported. In practice, however, the two flows are mostly |
| 174 | identical under the hood. So if one works, the other is likely to as well. |
| 175 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 176 | --- |
Steven Bennetts | 5a79a1c | 2017-11-27 20:05:47 | [diff] [blame] | 177 | |
| 178 | ## Build Chrome |
| 179 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 180 | To build Chrome, run: |
| 181 | |
| 182 | ``` |
Jorge Lucangeli Obes | 12c0b7a | 2019-02-26 16:36:45 | [diff] [blame] | 183 | (sdk) autoninja -C out_${SDK_BOARD}/Release chrome nacl_helper |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 184 | ``` |
| 185 | |
Jorge Lucangeli Obes | 12c0b7a | 2019-02-26 16:36:45 | [diff] [blame] | 186 | > **Note**: Targets other than **chrome**, **nacl_helper** or |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 187 | > (optionally) **chromiumos_preflight** are not supported in Simple Chrome and |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 188 | > will likely fail. browser_tests should be run outside the Simple Chrome |
| 189 | > environment. Some unit_tests may be built in the Simple Chrome environment and |
| 190 | > run in the Chrome OS VM. For details, see |
| 191 | > [Running a Chrome Google Test binary in the VM]. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 192 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 193 | > **Note**: Simple Chrome uses [Goma]. To watch the build progress, find the |
| 194 | > Goma port (`$ echo $SDK_GOMA_PORT`) and open http://localhost:<port_number> |
| 195 | > in a browser. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 196 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 197 | > **Note:** The default extensions will be installed by the test image you use |
| 198 | > below. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 199 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 200 | --- |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 201 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 202 | ## Set up the Chrome OS device |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 203 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 204 | ### Getting started |
| 205 | |
| 206 | You need the following: |
| 207 | 1. USB flash drive 4 GB or larger (for example, a Sandisk Extreme USB 3.0) |
| 208 | 1. USB to Gigabit Ethernet adapter |
| 209 | |
| 210 | Before you can deploy your build of Chrome to the device, it needs to have a |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 211 | "test" OS image loaded on it. A test image has tools like rsync that are not |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 212 | part of the base image. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 213 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 214 | Chrome should be deployed to a recent Chrome OS test image, ideally the |
| 215 | version shown in your SDK prompt (or `(sdk) echo $SDK_VERSION`). |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 216 | |
| 217 | ### Create a bootable USB stick |
| 218 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 219 | **Non-Googlers**: The build infrastructure is currently in flux. See |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 220 | [crbug.com/360342] for more details. You may need to build your own Chrome OS |
| 221 | image. |
James Cook | b181cf7 | 2017-08-04 19:41:53 | [diff] [blame] | 222 | |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 223 | Flash the latest canary test image to your USB stick using `cros flash`: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 224 | |
| 225 | ``` |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 226 | (sdk) cros flash usb:// xbuddy://remote/${SDK_BOARD}/latest-canary |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 227 | ``` |
| 228 | |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 229 | You can also flash an image with the sdk version (the SDK prompt has the |
| 230 | full version, for instance, R81-12750.0.0): |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 231 | |
| 232 | ``` |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 233 | (sdk) cros flash usb:// xbuddy://remote/${SDK_BOARD}/R81-12750.0.0 |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 234 | ``` |
| 235 | |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 236 | > **Tip:** If the device already has a test image installed, the following |
| 237 | can be used to update the device directly. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 238 | |
| 239 | ``` |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 240 | (sdk) $ cros flash $IP_ADDR xbuddy://remote/${SDK_BOARD}/latest-canary |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 241 | ``` |
| 242 | |
Achuith Bhandarkar | 928352e | 2020-01-16 20:20:59 | [diff] [blame] | 243 | See the [CrOS Flash page] for more details. |
| 244 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 245 | ### Put your Chrome OS device in dev mode |
| 246 | |
Steven Bennetts | 0d19591 | 2018-09-18 23:37:39 | [diff] [blame] | 247 | You can skip this section if you're using a [VM]. |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 248 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 249 | > **Note:** Switching to dev mode wipes all data from the device (for security |
| 250 | > reasons). |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 251 | |
James Cook | 93506b0 | 2018-01-17 06:13:07 | [diff] [blame] | 252 | Most recent devices can use the [generic instructions]. To summarize: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 253 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 254 | 1. With the device on, hit Esc + Refresh (F2 or F3) + power button |
| 255 | 1. Wait for the white "recovery screen" |
| 256 | 1. Hit Ctrl-D to switch to developer mode (there's no prompt) |
| 257 | 1. Press enter to confirm |
| 258 | 1. Once it is done, hit Ctrl-D again to boot, then wait |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 259 | |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 260 | From this point on you'll always see the white screen when you turn on |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 261 | the device. Press Ctrl-D to boot. |
James Cook | 93506b0 | 2018-01-17 06:13:07 | [diff] [blame] | 262 | |
| 263 | Older devices may have [device-specific instructions]. |
| 264 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 265 | *Googlers*: If the device asks you to "enterprise enroll", click the X in the |
| 266 | top-right of the dialog to skip it. Trying to use your google.com credentials |
| 267 | will result in an error. |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 268 | |
James Cook | 93506b0 | 2018-01-17 06:13:07 | [diff] [blame] | 269 | ### Enable booting from USB |
| 270 | |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 271 | By default Chromebooks will not boot off a USB stick for security reasons. |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 272 | You need to enable it. |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 273 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 274 | 1. Start the device |
| 275 | 1. Press Ctrl-Alt-F2 to get a terminal. (You can use Ctrl-Alt-F1 to switch |
| 276 | back if you need to.) |
| 277 | 1. Login as `root` (no password yet, there will be one later) |
| 278 | 1. Run `enable_dev_usb_boot` |
James Cook | 3d13538 | 2017-10-16 16:58:01 | [diff] [blame] | 279 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 280 | ### Install the test image onto your device |
| 281 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 282 | > **Note:** Do not log into this test image with a username and password you |
| 283 | > care about. The root password is public ("test0000"), so anyone with SSH |
| 284 | > access could compromise the device. Create a test Gmail account and use that. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 285 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 286 | 1. Plug the USB stick into the machine and reboot. |
| 287 | 1. At the dev-mode warning screen, press Ctrl-U to boot from the USB stick. |
| 288 | 1. Switch to terminal by pressing Ctrl-Alt-F2 |
| 289 | 1. Login as user `chronos`, password `test0000`. |
| 290 | 1. Run `/usr/sbin/chromeos-install` |
| 291 | 1. Wait for it to copy the image |
| 292 | 1. Run `poweroff` |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 293 | |
| 294 | You can now unplug the USB stick. |
| 295 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 296 | ### Connect device to Ethernet |
| 297 | |
| 298 | Use your USB-to-Ethernet adapter to connect the device to a network. |
| 299 | |
James Cook | 614fafc | 2019-01-22 23:21:02 | [diff] [blame] | 300 | *Googlers*: If your building has Ethernet jacks connected to the test VLAN |
| 301 | (e.g. white ports), use one of those jacks. Otherwise get a second Ethernet |
| 302 | adapter and see [go/shortleash] to reverse tether your Chromebook to your |
| 303 | workstation. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 304 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 305 | ### Checking the IP address |
| 306 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 307 | 1. Click the status area in the lower-right corner |
| 308 | 1. Click the network icon |
| 309 | 1. Click the circled `i` symbol in the lower-right corner |
| 310 | 1. A small window pops up that shows the IP address |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 311 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 312 | You can also run `ifconfig` from the terminal (Ctrl-Alt-F2). |
James Cook | 3a2a063 | 2018-01-18 06:21:56 | [diff] [blame] | 313 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 314 | --- |
| 315 | |
| 316 | ## Deploying Chrome to the device |
| 317 | |
| 318 | To deploy the build to a device/VM, you will need direct SSH access to it from |
| 319 | your computer. The scripts below handle everything else. |
| 320 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 321 | ### Using deploy_chrome |
| 322 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 323 | The `deploy_chrome` script uses rsync to incrementally deploy Chrome to the |
| 324 | device/VM. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 325 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 326 | Specify the build output directory to deploy from using `--build-dir`. For the |
Steven Bennetts | 0d19591 | 2018-09-18 23:37:39 | [diff] [blame] | 327 | [VM]: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 328 | |
| 329 | ``` |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 330 | (sdk) deploy_chrome --build-dir=out_${SDK_BOARD}/Release --device=localhost:9222 |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 331 | ``` |
| 332 | |
| 333 | For a physical device, which must be ssh-able as user 'root', you must specify |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 334 | the IP address using `--device`: |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 335 | |
| 336 | ``` |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 337 | (sdk) deploy_chrome --build-dir=out_${SDK_BOARD}/Release --device=$IP_ADDR |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 338 | ``` |
| 339 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 340 | > **Note:** The first time you run this you will be prompted to remove rootfs |
| 341 | > verification from the device. This is required to overwrite /opt/google/chrome |
| 342 | > and will reboot the device. You can skip the prompt with `--force`. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 343 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 344 | ### Deploying Chrome to the user partition |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 345 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 346 | It is also possible to deploy Chrome to the user partition of the device and |
Achuith Bhandarkar | d257012 | 2018-08-03 00:56:43 | [diff] [blame] | 347 | set up a temporary mount from `/opt/google/chrome` using the option `--mount`. |
| 348 | This is useful when deploying a binary that will not otherwise fit on the |
| 349 | device, e.g.: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 350 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 351 | * When using `--nostrip` to provide symbols for backtraces. |
| 352 | * When using other compile options that produce a significantly larger image. |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 353 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 354 | ``` |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 355 | (sdk) deploy_chrome --build-dir=out_$SDK_BOARD/Release --device=$IP_ADDR --mount [--nostrip] |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 356 | ``` |
| 357 | |
Achuith Bhandarkar | d257012 | 2018-08-03 00:56:43 | [diff] [blame] | 358 | > **Note:** This also prompts to remove rootfs verification so that |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 359 | > /etc/chrome_dev.conf can be modified (see [Command-line flags and |
| 360 | > environment variables]). You can skip that by adding |
| 361 | > `--noremove-rootfs-verification`. |
| 362 | |
| 363 | #### Additional Notes: |
| 364 | |
Achuith Bhandarkar | d257012 | 2018-08-03 00:56:43 | [diff] [blame] | 365 | * The mount is transient and does not survive a reboot. The easiest way to |
| 366 | reinstate the mount is to run the same deploy_chrome command after reboot. |
| 367 | It will only redeploy binaries if there is a change. To verify that the |
| 368 | mount is active, run `findmnt /opt/google/chrome`. The output should be: |
| 369 | ``` |
| 370 | TARGET SOURCE FSTYPE OPTIONS |
| 371 | /opt/google/chrome /dev/sda1[/deploy_rootfs/opt/google/chrome] ext4 rw,nodev,noatime,resgid=20119,commit=600,data=ordered |
| 372 | ``` |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 373 | * If startup needs to be tested (i.e. before deploy_chrome can be run), a |
| 374 | symbolic link will need to be created instead: |
| 375 | * ssh to device |
Roman Sorokin | 1c9c768 | 2019-09-17 02:26:26 | [diff] [blame] | 376 | * `mkdir /usr/local/chrome` |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 377 | * `rm -R /opt/google/chrome` |
Roman Sorokin | 1c9c768 | 2019-09-17 02:26:26 | [diff] [blame] | 378 | * `ln -s /usr/local/chrome /opt/google/chrome` |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 379 | * `deploy_chrome --build-dir=out_${SDK_BOARD}/Release --device=$IP_ADDR |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 380 | --nostrip` |
| 381 | * The device can then be rebooted and the unstripped version of Chrome |
| 382 | will be run. |
| 383 | * `deploy_chrome` lives under `$CHROME_DIR/src/third_party/chromite/bin`. |
| 384 | You can run `deploy_chrome` outside of a `chrome-sdk` shell. |
| 385 | |
| 386 | ## Updating the Chrome OS image |
| 387 | |
| 388 | In order to keep Chrome and Chrome OS in sync, the Chrome OS test image |
| 389 | should be updated weekly. See [Create a bootable USB stick] for a tip on |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 390 | updating an existing test device if you have a Chrome OS checkout. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 391 | |
| 392 | --- |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 393 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 394 | ## Debugging |
| 395 | |
Satoru Takabayashi | 7cc76c9 | 2017-06-26 04:46:05 | [diff] [blame] | 396 | ### Log files |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 397 | |
Achuith Bhandarkar | 8bca781 | 2019-02-06 20:51:10 | [diff] [blame] | 398 | [Chrome-related logs] are written to several locations on the device running a |
| 399 | test image: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 400 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 401 | * `/var/log/ui/ui.LATEST` contains messages written to stderr by Chrome |
| 402 | before its log file has been initialized. |
Achuith Bhandarkar | 8bca781 | 2019-02-06 20:51:10 | [diff] [blame] | 403 | * `/var/log/chrome/chrome` contains messages logged by Chrome both before and |
| 404 | after login since Chrome runs with `--disable-logging-redirect` on test |
| 405 | images. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 406 | * `/var/log/messages` contains messages logged by `session_manager` |
| 407 | (which is responsible for starting Chrome), in addition to kernel |
| 408 | messages when a Chrome process crashes. |
Satoru Takabayashi | 7cc76c9 | 2017-06-26 04:46:05 | [diff] [blame] | 409 | |
| 410 | ### Command-line flags and environment variables |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 411 | |
| 412 | If you want to tweak the command line of Chrome or its environment, you have to |
| 413 | do this on the device itself. |
| 414 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 415 | Edit the `/etc/chrome_dev.conf` (device) file. Instructions on using it are in |
| 416 | the file itself. |
| 417 | |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 418 | ### Custom build directories |
| 419 | |
| 420 | This step is only necessary if you run `cros chrome-sdk` with `--nogn-gen`. |
| 421 | |
| 422 | To create a GN build directory, run the following inside the chrome-sdk shell: |
| 423 | |
| 424 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 425 | (sdk) gn gen out_$SDK_BOARD/Release --args="$GN_ARGS" |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 426 | ``` |
| 427 | |
| 428 | This will generate `out_$SDK_BOARD/Release/args.gn`. |
| 429 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 430 | * You must specify `--args`, otherwise your build will not work on the device. |
| 431 | * You only need to run `gn gen` once within the same `cros chrome-sdk` |
| 432 | session. |
| 433 | * However, if you exit the session or sync/update Chrome the `$GN_ARGS` might |
| 434 | change and you need to `gn gen` again. |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 435 | |
| 436 | You can edit the args with: |
| 437 | |
| 438 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 439 | (sdk) gn args out_$SDK_BOARD/Release |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 440 | ``` |
| 441 | |
| 442 | You can replace `Release` with `Debug` (or something else) for different |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 443 | configurations. See [Debug builds]. |
James Cook | 961c57d | 2018-01-23 21:34:05 | [diff] [blame] | 444 | |
| 445 | [GN build configuration] discusses various GN build configurations. For more |
| 446 | info on GN, run `gn help` on the command line or read the [quick start guide]. |
| 447 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 448 | ### Debug builds |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 449 | |
| 450 | For cros chrome-sdk GN configurations, Release is the default. A debug build of |
| 451 | Chrome will include useful tools like DCHECK and debug logs like DVLOG. For a |
| 452 | Debug configuration, specify |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 453 | `--args="$GN_ARGS is_debug=true is_component_build=false"`. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 454 | |
| 455 | Alternately, you can just turn on DCHECKs for a release build. You can do this |
| 456 | with `--args="$GN_ARGS dcheck_always_on=true"`. |
| 457 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 458 | To deploy a debug build you need to add `--nostrip` to `deploy_chrome` because |
| 459 | otherwise it will strip symbols even from a debug build. This requires |
| 460 | [Deploying Chrome to the user partition]. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 461 | |
Eliot Courtney | af7edf3 | 2020-06-16 05:49:50 | [diff] [blame] | 462 | See [./stack_traces.md] for some tips on getting stack traces at runtime |
| 463 | (not during a crash). |
| 464 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 465 | > **Note:** If you just want crash backtraces in the logs you can deploy a |
| 466 | > release build with `--nostrip`. You don't need a debug build (but you still |
| 467 | > need to deploy to a user partition). |
| 468 | > |
| 469 | > **Note:** You may hit `DCHECKs` during startup time, or when you login, which |
| 470 | > eventually may reboot the device. You can check log files in `/var/log/chrome` |
| 471 | > or `/home/chronos/user/log`. |
| 472 | > |
| 473 | > You can create `/run/disable_chrome_restart` to prevent a restart loop and |
| 474 | > investigate. |
| 475 | > |
| 476 | > You can temporarily disable these `DCHECKs` to proceed, but please file a |
| 477 | > bug for such `DCHECK` because it's most likely a bug. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 478 | |
| 479 | ### Remote GDB |
| 480 | |
Satoru Takabayashi | 7cc76c9 | 2017-06-26 04:46:05 | [diff] [blame] | 481 | Core dumps are disabled by default. See [additional debugging tips] for how to |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 482 | enable core files. |
| 483 | |
| 484 | On the target machine, open up a port for the gdb server to listen on, and |
Satoru Takabayashi | 7cc76c9 | 2017-06-26 04:46:05 | [diff] [blame] | 485 | attach the gdb server to the top-level Chrome process. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 486 | |
| 487 | ``` |
| 488 | (device) sudo /sbin/iptables -A INPUT -p tcp --dport 1234 -j ACCEPT |
Steven Bennetts | 8a0efd9 | 2018-11-27 17:32:52 | [diff] [blame] | 489 | (device) sudo gdbserver --attach :1234 $(pgrep chrome -P $(pgrep session_manager)) |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 490 | ``` |
| 491 | |
| 492 | On your host machine (inside the chrome-sdk shell), run gdb and start the Python |
| 493 | interpreter: |
| 494 | |
| 495 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 496 | (sdk) cd %CHROME_DIR%/src |
| 497 | (sdk) gdb out_${SDK_BOARD}/Release/chrome |
| 498 | Reading symbols from /usr/local/google2/chromium2/src/out_amd64-generic/Release/chrome... |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 499 | (gdb) pi |
| 500 | >>> |
| 501 | ``` |
| 502 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 503 | > **Note:** These instructions are for targeting an x86_64 device. For now, to |
| 504 | > target an ARM device, you need to run the cross-compiled gdb from within a |
| 505 | > chroot. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 506 | |
| 507 | Then from within the Python interpreter, run these commands: |
| 508 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 509 | ```python |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 510 | import os |
| 511 | sysroot = os.environ['SYSROOT'] |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 512 | board = os.environ['SDK_BOARD'] |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 513 | gdb.execute('set sysroot %s' % sysroot) |
| 514 | gdb.execute('set solib-absolute-prefix %s' % sysroot) |
| 515 | gdb.execute('set debug-file-directory %s/usr/lib/debug' % sysroot) |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 516 | # "Debug" for a debug build |
| 517 | gdb.execute('set solib-search-path out_%s/Release/lib' % board) |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 518 | gdb.execute('target remote $IP_ADDR:1234') |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 519 | ``` |
| 520 | |
| 521 | If you wish, after you connect, you can Ctrl-D out of the Python shell. |
| 522 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 523 | Extra debugging instructions are located at [debugging tips]. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 524 | |
| 525 | --- |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 526 | |
| 527 | ## Additional instructions |
| 528 | |
| 529 | ### Updating the version of the Chrome OS SDK |
| 530 | |
| 531 | When you invoke `cros chrome-sdk`, the script fetches the version of the SDK |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 532 | that corresponds to your Chrome checkout. To update the SDK, sync your Chrome |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 533 | checkout and re-run `cros chrome-sdk`. |
| 534 | |
| 535 | **IMPORTANT NOTES:** |
| 536 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 537 | * Every time that you update Chrome or the Chrome OS SDK, it is possible |
| 538 | that Chrome may start depending on new features from a new Chrome OS |
| 539 | image. This can cause unexpected problems, so it is important to update |
| 540 | your image regularly. Instructions for updating your Chrome OS image are |
| 541 | above in [Set up the Chrome OS device]. This is not a concern for a |
| 542 | downloaded VM. |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 543 | * Don't forget to re-configure your custom build directories if you have them |
| 544 | (see [Custom build directories]). |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 545 | |
| 546 | ### Specifying the version of the Chrome OS SDK to use |
| 547 | |
| 548 | You can specify a version of Chrome OS to build against. This is handy for |
| 549 | tracking down when a particular bug was introduced. |
| 550 | |
| 551 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 552 | (shell) cros chrome-sdk --board=$BOARD --version=11005.0.0 |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 553 | ``` |
| 554 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 555 | Once you are finished testing the old version of the chrome-sdk, you can |
| 556 | always start a new shell with the latest version again. Here's an example: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 557 | |
| 558 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 559 | (shell) cros chrome-sdk --board=$BOARD --clear-sdk-cache |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 560 | ``` |
| 561 | |
| 562 | ### Updating Chrome |
| 563 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 564 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 565 | (sdk) exit |
| 566 | (shell) git checkout master && git pull # (or if you prefer, git rebase-update) |
| 567 | (shell) gclient sync |
| 568 | (shell) cros chrome-sdk --board=$BOARD --log-level=info |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 569 | ``` |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 570 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 571 | > **Tip:** If you update Chrome inside the chrome-sdk, you may then be using an |
| 572 | > SDK that is out of date with the current Chrome. |
| 573 | > See [Updating the version of the Chrome OS SDK] section above. |
| 574 | |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 575 | |
| 576 | ### Updating Deployed Files |
| 577 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 578 | `deploy_chrome` determines which files to copy in `chrome_util.py` in the |
| 579 | [chromite repo] which is pulled into `chrome/src/third_party/chromite` via DEPS. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 580 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 581 | When updating the list: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 582 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 583 | 1. Make changes to the appropriate list (e.g. `_COPY_PATHS_CHROME`). |
| 584 | 1. Be aware that deploy_chrome is used by the chromeos-chrome ebuild, so when |
| 585 | adding new files make sure to set optional=True initially. |
| 586 | 1. Changes to chromite will not affect Simple Chrome until a chromite roll |
| 587 | occurs. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 588 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 589 | ### Using a custom Chrome OS build |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 590 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 591 | If you are making changes to Chrome OS and have a Chrome OS build inside a |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 592 | chroot that you want to build against, run `cros chrome-sdk` with the `--chroot` |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 593 | option: |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 594 | |
| 595 | ``` |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 596 | (shell) cros chrome-sdk --board=$BOARD --chroot=/path/to/chromiumos/chroot |
James Cook | ba126f1 | 2017-08-21 19:59:07 | [diff] [blame] | 597 | ``` |
| 598 | |
Harry Cutts | 2cfd02d | 2019-03-23 00:33:11 | [diff] [blame] | 599 | ### Running tests |
| 600 | |
Xiyuan Xia | 6c8ef61 | 2019-04-26 22:30:22 | [diff] [blame] | 601 | Chrome's unit and browser tests are compiled into test binaries. At the moment, |
| 602 | not all of them run on a Chrome OS device. Most of the unit tests and part of |
| 603 | interactive_ui_tests that measure Chrome OS performance should work. |
| 604 | |
| 605 | To build and run a chrome test on device (or VM), |
| 606 | ```bash |
| 607 | (sdk) .../chrome/src $ cros_run_test --build --device=$IP --chrome-test -- \ |
David Pursehouse | b3b7da1 | 2019-06-17 12:23:39 | [diff] [blame] | 608 | out_$SDK_BOARD/Release/interactive_ui_tests \ |
Xiyuan Xia | 6c8ef61 | 2019-04-26 22:30:22 | [diff] [blame] | 609 | --dbus-stub \ |
| 610 | --enable-pixel-output-in-tests \ |
| 611 | --gtest_filter=SplitViewTest.SplitViewResize |
| 612 | ``` |
| 613 | |
| 614 | Alternatively, manually build and use the generated `run_$TEST` scripts to run |
| 615 | like build bots: |
| 616 | ```bash |
| 617 | (sdk) .../chrome/src $ autoninja -C out_$SDK_BOARD/Release interactive_ui_tests |
| 618 | (sdk) .../chrome/src $ out_$SDK_BOARD/Release/bin/run_interactive_ui_tests \ |
| 619 | --device=$IP \ |
| 620 | --dbus-stub \ |
| 621 | --enable-pixel-output-in-tests \ |
| 622 | --gtest_filter=SplitViewTest.SplitViewResize |
| 623 | ``` |
| 624 | |
| 625 | To run tests locally on dev box, follow the [instructions for running tests on |
| 626 | Linux] using a separate GN build directory with `target_os = "chromeos"` in its |
| 627 | arguments. (You can create one using the `gn args` command.) |
Harry Cutts | 2cfd02d | 2019-03-23 00:33:11 | [diff] [blame] | 628 | |
| 629 | If you're running tests which create windows on-screen, you might find the |
| 630 | instructions for using an embedded X server in [web_tests_linux.md] useful. |
| 631 | |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 632 | ### Setting a custom prompt |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 633 | |
| 634 | By default, cros chrome-sdk prepends something like '`(sdk link R52-8315.0.0)`' |
Satoru Takabayashi | 7cc76c9 | 2017-06-26 04:46:05 | [diff] [blame] | 635 | to the prompt (with the version of the prebuilt system being used). |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 636 | |
| 637 | If you prefer to colorize the prompt, you can set `PS1` in |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 638 | `~/.chromite/chrome_sdk.bashrc`, e.g. to prepend a yellow |
| 639 | '`(sdk link 8315.0.0)`' to the prompt: |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 640 | |
| 641 | ``` |
| 642 | PS1='\[\033[01;33m\](sdk ${SDK_BOARD} ${SDK_VERSION})\[\033[00m\] \w \[\033[01;36m\]$(__git_ps1 "(%s)")\[\033[00m\] \$ ' |
| 643 | ``` |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 644 | NOTE: Currently the release version (e.g. 52) is not available as an |
| 645 | environment variable. |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 646 | |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 647 | [Custom build directories]: #custom-build-directories |
| 648 | [Updating the version of the Chrome OS SDK]: #updating-the-version-of-the-chrome-os-sdk |
| 649 | [Using a custom Chrome OS build]: #using-a-custom-chrome-os-build |
Ben Pastene | 2c4e46b | 2020-08-04 20:38:36 | [diff] [blame] | 650 | [custom gclient var]: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/chromeos_build_instructions.md#additional-gclient-setup |
| 651 | [Chrome's builders]: chrome_commit_pipeline.md#the-chromium-waterfall |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 652 | [Command-line flags and environment variables]: #command-line-flags-and-environment-variables |
| 653 | [Deploying Chrome to the user partition]: #deploying-chrome-to-the-user-partition |
| 654 | [Debug builds]: #debug-builds |
| 655 | [Create a bootable USB stick]: #create-a-bootable-usb-stick |
| 656 | [Set up the Chrome OS device]: #set-up-the-chrome-os-device |
Mike Frysinger | 9fc0fc0 | 2020-09-05 05:18:57 | [diff] [blame] | 657 | [OS development guide]: developer_guide.md |
| 658 | [Chrome source code and depot_tools]: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/build_instructions.md |
| 659 | [instructions for running tests on Linux]: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/build_instructions.md#Running-test-targets |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 660 | [update .gclient]: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/chromeos_build_instructions.md#updating-your-gclient-config |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 661 | [Chrome OS board name]: https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 662 | [GN build configuration]: https://www.chromium.org/developers/gn-build-configuration |
Mike Frysinger | 9fc0fc0 | 2020-09-05 05:18:57 | [diff] [blame] | 663 | [quick start guide]: https://gn.googlesource.com/gn/+/HEAD/docs/quick_start.md |
James Cook | 3d13538 | 2017-10-16 16:58:01 | [diff] [blame] | 664 | [device-specific instructions]: https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices |
| 665 | [generic instructions]: https://www.chromium.org/a/chromium.org/dev/chromium-os/developer-information-for-chrome-os-devices/generic |
Evan Benn | 6a6383b | 2019-10-31 23:01:07 | [diff] [blame] | 666 | [rootfs has been removed]: developer_mode.md#TOC-Making-changes-to-the-filesystem |
Steven Bennetts | 7f08b00 | 2018-06-29 23:28:44 | [diff] [blame] | 667 | [remounted as read-write]: https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/debugging-tips#TOC-Setting-up-the-device |
| 668 | [additional debugging tips]: https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/debugging-tips#TOC-Enabling-core-dumps |
Satoru Takabayashi | eef6f59 | 2017-06-23 04:16:36 | [diff] [blame] | 669 | [chromite repo]: https://chromium.googlesource.com/chromiumos/chromite/ |
Mike Frysinger | 9fc0fc0 | 2020-09-05 05:18:57 | [diff] [blame] | 670 | [issue 437877]: https://crbug.com/403086 |
| 671 | [CrOS Flash page]: cros_flash.md |
| 672 | [VM]: cros_vm.md |
| 673 | [Running a Chrome Google Test binary in the VM]: cros_vm.md#Run-a-Chrome-GTest-binary-in-the-VM |
James Cook | 614fafc | 2019-01-22 23:21:02 | [diff] [blame] | 674 | [go/shortleash]: https://goto.google.com/shortleash |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 675 | [debugging tips]: https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/debugging-tips |
Achuith Bhandarkar | 8363026 | 2020-05-24 10:20:59 | [diff] [blame] | 676 | [chrome build instructions]: https://g3doc.corp.google.com/company/teams/chrome/linux_build_instructions.md |
Achuith Bhandarkar | 61f5896 | 2018-08-29 00:05:31 | [diff] [blame] | 677 | [api-keys]: https://www.chromium.org/developers/how-tos/api-keys |
Mike Frysinger | 9fc0fc0 | 2020-09-05 05:18:57 | [diff] [blame] | 678 | [install-build-deps-android.sh]: https://chromium.googlesource.com/chromium/src/+/HEAD/build/install-build-deps-android.sh |
Evan Benn | 6a6383b | 2019-10-31 23:01:07 | [diff] [blame] | 679 | [Goma]: https://chromium.googlesource.com/infra/goma/client/ |
Achuith Bhandarkar | 8bca781 | 2019-02-06 20:51:10 | [diff] [blame] | 680 | [Chrome-related logs]: https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chrome_os_logging.md |
Mike Frysinger | 9fc0fc0 | 2020-09-05 05:18:57 | [diff] [blame] | 681 | [crbug.com/360342]: https://crbug.com/360342 |
| 682 | [crbug.com/403086]: https://crbug.com/403086 |
| 683 | [web_tests_linux.md]: https://chromium.googlesource.com/chromium/src/+show/HEAD/docs/web_tests_linux.md |
| 684 | [./stack_traces.md]: stack_traces.md |