Clay Murphy | a5864b5 | 2015-07-30 11:44:49 -0700 | [diff] [blame] | 1 | page.title=Adding a New Device |
Clay Murphy | 61fe852 | 2015-07-07 17:15:12 -0700 | [diff] [blame] | 2 | @jd:body |
| 3 | |
| 4 | <!-- |
| 5 | Copyright 2015 The Android Open Source Project |
| 6 | |
| 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | you may not use this file except in compliance with the License. |
| 9 | You may obtain a copy of the License at |
| 10 | |
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | |
| 13 | Unless required by applicable law or agreed to in writing, software |
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | See the License for the specific language governing permissions and |
| 17 | limitations under the License. |
| 18 | --> |
| 19 | <div id="qv-wrapper"> |
| 20 | <div id="qv"> |
| 21 | <h2>In this document</h2> |
| 22 | <ol id="auto-toc"> |
| 23 | </ol> |
| 24 | </div> |
| 25 | </div> |
| 26 | |
Clay Murphy | a5864b5 | 2015-07-30 11:44:49 -0700 | [diff] [blame] | 27 | <p>Use the information in this page to create the Makefiles for your device and |
| 28 | product. Please note, unlike the other pages in this section, the contents here |
| 29 | are applicable only when creating an entirely new device type and are intended |
| 30 | for company build and product teams only.</p> |
Clay Murphy | 61fe852 | 2015-07-07 17:15:12 -0700 | [diff] [blame] | 31 | |
| 32 | <h2 id="build-layers">Understand Build Layers</h2> |
| 33 | |
| 34 | <p>The build hierarchy includes the abstraction layers that correspond to the |
| 35 | physical makeup of a device. These layers are described in the table below. |
| 36 | Each layer relates to the one above it in a one-to-many relationship. For |
| 37 | example, an architecture can have more than one board and each board can have |
| 38 | more than one product. You may define an element in a given layer as a |
| 39 | specialization of an element in the same layer, thus eliminating copying and |
| 40 | simplifying maintenance.</p> |
| 41 | |
| 42 | <table> |
| 43 | <tbody><tr> |
| 44 | <th>Layer</th> |
| 45 | <th>Example</th> |
| 46 | <th>Description</th> |
| 47 | </tr> |
| 48 | <tr> |
| 49 | <td>Product</td> |
| 50 | <td>myProduct, myProduct_eu, myProduct_eu_fr, j2, sdk</td> |
| 51 | <td><p>The product layer defines the feature specification of a shipping product such as the modules to build, |
| 52 | locales supported, and the configuration for various locales. In other words, this is the name of the |
| 53 | overall product. Product-specific variables are defined in product definition Makefiles. A product |
| 54 | can inherit from other product definitions, |
| 55 | which simplifies maintenance. A common method is to create a base product that contains features that apply |
| 56 | for all products, then creating product variants based on that base product. For example, you can have |
| 57 | two products that differ only by their radios (CDMA vs GSM) inherit from the same base product that does not define a radio. |
| 58 | </td> |
| 59 | |
| 60 | </tr> |
| 61 | <tr> |
| 62 | <td>Board/Device</td> |
| 63 | <td>sardine, trout, goldfish</td> |
| 64 | <td>The device/board layer represents the physical layer of plastic on the |
| 65 | device (i.e. the industrial design of the device). For example, North American |
| 66 | devices probably include QWERTY keyboards whereas devices sold in France |
| 67 | probably include AZERTY keyboards. This layer also represents the bare |
| 68 | schematics of a product. These include the peripherals on the board and their |
| 69 | configuration. The names used are merely codes for different board/device configurations.</td> |
| 70 | </tr> |
| 71 | <tr> |
| 72 | <td>Arch</td> |
| 73 | <td>arm, x86, mips, arm64, x86_64, mips64</td> |
| 74 | <td>The architecture layer describes the processor configuration and ABI (Application Binary Interface) running on the board. </td> |
| 75 | </tr> |
| 76 | </table> |
| 77 | |
| 78 | <h2 id="build-variants">Use Build Variants</h2> |
| 79 | |
| 80 | <p>When building for a particular product, it's often useful to have minor |
| 81 | variations on what is ultimately the final release build. In a module |
| 82 | definition, the module can specify tags with <code>LOCAL_MODULE_TAGS</code>, |
| 83 | which can be one or more values of <code>optional</code> (default), |
| 84 | <code>debug</code>, <code>eng</code>.</p> |
| 85 | |
| 86 | <p>If a module doesn't specify a tag (by <code>LOCAL_MODULE_TAGS</code>), its |
| 87 | tag defaults to <code>optional</code>. An optional module is installed only if |
| 88 | it is required by product configuration with <code>PRODUCT_PACKAGES</code>. |
| 89 | |
| 90 | <p>These are the currently-defined build variants:</p> |
| 91 | |
| 92 | <table border=1> |
| 93 | <tr> |
| 94 | <td> |
| 95 | <code>eng<code> |
| 96 | </td> |
| 97 | <td> |
| 98 | This is the default flavor. |
| 99 | <ul> |
| 100 | <li>Installs modules tagged with: <code>eng</code> and/or <code>debug</code>. |
| 101 | <li>Installs modules according to the product definition files, in addition to tagged modules.</li> |
| 102 | <li><code>ro.secure=0</code> |
| 103 | <li><code>ro.debuggable=1</code> |
| 104 | <li><code>ro.kernel.android.checkjni=1</code> |
| 105 | <li><code>adb</code> is enabled by default. |
| 106 | </td> |
| 107 | </tr> |
| 108 | <tr> |
| 109 | <td> |
| 110 | <code>user<code> |
| 111 | </td> |
| 112 | <td> |
| 113 | This is the flavor intended to be the final release bits. |
| 114 | <ul> |
| 115 | <li>Installs modules tagged with <code>user</code>.</li> |
| 116 | <li>Installs modules according to the product definition files, in addition to tagged modules.</li> |
| 117 | <li><code>ro.secure=1</code> </li> |
| 118 | <li><code>ro.debuggable=0</code> </li> |
| 119 | <li><code>adb</code> is disabled by default.</li> |
| 120 | </td> |
| 121 | </tr> |
| 122 | <tr> |
| 123 | <td> |
| 124 | <code>userdebug<code> |
| 125 | </td> |
| 126 | <td> |
| 127 | The same as <code>user</code>, except: |
| 128 | <ul> |
| 129 | <li>Also installs modules tagged with <code>debug</code>. |
| 130 | <li><code>ro.debuggable=1</code> |
| 131 | <li><code>adb</code> is enabled by default. |
| 132 | </td> |
| 133 | </tr> |
| 134 | </table> |
| 135 | |
| 136 | <h2 id="build-a-product">Build a Product</h2> |
| 137 | |
| 138 | <p> |
| 139 | There are many ways to organize the source files for your device. We'll briefly |
| 140 | go over how the Nexus 6 implementation was organized as an example, but you can |
| 141 | organize your source files and build the way you see fit. |
| 142 | </p> |
| 143 | <p> |
| 144 | Nexus 6 was implemented with a main device configuration named |
| 145 | <code>shamu</code>. From this device configuration, a product is created with a |
| 146 | product definition Makefile that declares product-specific information about |
| 147 | the device such as the name and model. You can view the |
| 148 | <code>device/moto/shamu</code> directory to see how all of this is setup. |
| 149 | </p> |
| 150 | <h3 id="makefiles">Write the Makefiles</h2> |
| 151 | <p> |
| 152 | The following steps describe how to set up product Makefiles in a way similar |
| 153 | to that of the Nexus 6 product line: |
| 154 | </p> |
| 155 | <ol> |
| 156 | <li>Create a <code>device/<company_name>/<device_name></code> directory for your |
| 157 | product. For example, <code>device/moto/shamu</code>. This directory will contain source code |
| 158 | for your device along with the Makefiles to build them. |
| 159 | </li> |
| 160 | |
| 161 | <li>Create a <code>device.mk</code> Makefile that declares the files and modules needed for the |
| 162 | device. For an example, see <code>device/moto/shamu/device.mk</code>. |
| 163 | </li> |
| 164 | |
| 165 | <li>Create a product definition Makefile to create a specific product based on the device. The |
| 166 | following Makefile is taken from <code>device/moto/shamu/aosp_shamu.mk</code> as an example. |
| 167 | Notice the product is inheriting from the |
| 168 | <code>device/moto/shamu/device.mk</code> and |
| 169 | <code>vendor/moto/shamu/device-vendor.mk</code> files via the Makefile while |
| 170 | also declaring the product-specific information such as name, brand, and model. |
| 171 | |
| 172 | <pre> |
| 173 | # Inherit from the common Open Source product configuration |
| 174 | $(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk) |
| 175 | |
| 176 | PRODUCT_NAME := aosp_shamu |
| 177 | PRODUCT_DEVICE := shamu |
| 178 | PRODUCT_BRAND := Android |
| 179 | PRODUCT_MODEL := AOSP on Shamu |
| 180 | PRODUCT_MANUFACTURER := motorola |
| 181 | PRODUCT_RESTRICT_VENDOR_FILES := true |
| 182 | |
| 183 | $(call inherit-product, device/moto/shamu/device.mk) |
| 184 | $(call inherit-product-if-exists, vendor/moto/shamu/device-vendor.mk) |
| 185 | |
| 186 | PRODUCT_NAME := aosp_shamu |
| 187 | |
| 188 | PRODUCT_PACKAGES += \ |
| 189 | Launcher3 |
| 190 | </pre> |
| 191 | |
| 192 | <p> |
| 193 | See <a href="#prod-def">Product Definition Variables</a> for additional product-specific |
| 194 | variables you can add to your Makefiles. |
| 195 | </p> |
| 196 | </li> |
| 197 | |
| 198 | <li>Create an <code>AndroidProducts.mk</code> file that points to the product's Makefiles. In |
| 199 | this example, only the product definition Makefile is needed. The example below is from |
| 200 | <code>device/moto/shamu/AndroidProducts.mk</code>: |
| 201 | <pre> |
| 202 | # |
| 203 | # This file should set PRODUCT_MAKEFILES to a list of product makefiles |
| 204 | # to expose to the build system. LOCAL_DIR will already be set to |
| 205 | # the directory containing this file. |
| 206 | # |
| 207 | # This file may not rely on the value of any variable other than |
| 208 | # LOCAL_DIR; do not use any conditionals, and do not look up the |
| 209 | # value of any variable that isn't set in this file or in a file that |
| 210 | # it includes. |
| 211 | # |
| 212 | |
| 213 | PRODUCT_MAKEFILES := \ |
| 214 | $(LOCAL_DIR)/aosp_shamu.mk |
| 215 | </pre> |
| 216 | </li> |
| 217 | |
| 218 | <li>Create a <code>BoardConfig.mk</code> Makefile that contains board-specific configurations. |
| 219 | For an example, see <code>device/moto/shamu/BoardConfig.mk</code>. |
| 220 | </li> |
| 221 | |
| 222 | <li>Create a <code>vendorsetup.sh</code> file to add your product (a "lunch combo") to the build |
| 223 | along with a <a href="#build-variants">build variant</a> separated by a dash. For example: |
| 224 | <pre> |
| 225 | add_lunch_combo <product_name>-userdebug |
| 226 | </pre> |
| 227 | </li> |
| 228 | |
| 229 | <li>At this point, you can create more product variants based on the same device. |
| 230 | </li> |
| 231 | |
| 232 | </ol> |
| 233 | <h3 id="prod-def">Set Product Definition Variables</h3> |
| 234 | <p> |
| 235 | Product-specific variables are defined in the product's Makefile. Variables maintained in a |
| 236 | product definition files include: |
| 237 | </p> |
| 238 | <table> |
| 239 | <tbody> |
| 240 | <tr> |
| 241 | <th> |
| 242 | Parameter |
| 243 | </th> |
| 244 | <th> |
| 245 | Description |
| 246 | </th> |
| 247 | <th> |
| 248 | Example |
| 249 | </th> |
| 250 | </tr> |
| 251 | <tr> |
| 252 | <td> |
| 253 | PRODUCT_AAPT_CONFIG |
| 254 | </td> |
| 255 | <td> |
| 256 | <code>aapt</code> configurations to use when creating packages |
| 257 | </td> |
| 258 | <td></td> |
| 259 | </tr> |
| 260 | <tr> |
| 261 | <td> |
| 262 | PRODUCT_BRAND |
| 263 | </td> |
| 264 | <td> |
| 265 | The brand (e.g., carrier) the software is customized for, if any |
| 266 | </td> |
| 267 | <td></td> |
| 268 | </tr> |
| 269 | <tr> |
| 270 | <td> |
| 271 | PRODUCT_CHARACTERISTICS |
| 272 | </td> |
| 273 | <td> |
| 274 | <code>aapt</code> characteristics to allow adding variant-specific resources to a package. |
| 275 | </td> |
| 276 | <td> |
| 277 | tablet,nosdcard |
| 278 | </td> |
| 279 | </tr> |
| 280 | <tr> |
| 281 | <td> |
| 282 | PRODUCT_COPY_FILES |
| 283 | </td> |
| 284 | <td> |
| 285 | List of words like <code>source_path:destination_path</code>. The file at the source path |
| 286 | should be copied to the destination path when building this product. The rules for the copy |
| 287 | steps are defined in config/Makefile |
| 288 | </td> |
| 289 | <td></td> |
| 290 | </tr> |
| 291 | <tr> |
| 292 | <td> |
| 293 | PRODUCT_DEVICE |
| 294 | </td> |
| 295 | <td> |
| 296 | Name of the industrial design. This is also the board name, and the build system uses it to locate the <code>BoardConfig.mk.</code> |
| 297 | </td> |
| 298 | <td> |
| 299 | <code>tuna</code> |
| 300 | </td> |
| 301 | </tr> |
| 302 | <tr> |
| 303 | <td> |
| 304 | PRODUCT_LOCALES |
| 305 | </td> |
| 306 | <td> |
| 307 | A space-separated list of two-letter language code, two-letter country code pairs that |
| 308 | describe several settings for the user, such as the UI language and time, date and currency |
| 309 | formatting. The first locale listed in PRODUCT_LOCALES is used as the product's default locale. |
| 310 | </td> |
| 311 | <td> |
| 312 | <code>en_GB de_DE es_ES fr_CA</code> |
| 313 | </td> |
| 314 | </tr> |
| 315 | <tr> |
| 316 | <td> |
| 317 | PRODUCT_MANUFACTURER |
| 318 | </td> |
| 319 | <td> |
| 320 | Name of the manufacturer |
| 321 | </td> |
| 322 | <td> |
| 323 | <code>acme</code> |
| 324 | </td> |
| 325 | </tr> |
| 326 | <tr> |
| 327 | <td> |
| 328 | PRODUCT_MODEL |
| 329 | </td> |
| 330 | <td> |
| 331 | End-user-visible name for the end product |
| 332 | </td> |
| 333 | <td></td> |
| 334 | </tr> |
| 335 | <tr> |
| 336 | <td> |
| 337 | PRODUCT_NAME |
| 338 | </td> |
| 339 | <td> |
| 340 | End-user-visible name for the overall product. Appears in the Settings > About screen. |
| 341 | </td> |
| 342 | <td></td> |
| 343 | </tr> |
| 344 | <tr> |
| 345 | <td> |
| 346 | PRODUCT_OTA_PUBLIC_KEYS |
| 347 | </td> |
| 348 | <td> |
| 349 | List of Over the Air (OTA) public keys for the product |
| 350 | </td> |
| 351 | <td></td> |
| 352 | </tr> |
| 353 | <tr> |
| 354 | <td> |
| 355 | PRODUCT_PACKAGES |
| 356 | </td> |
| 357 | <td> |
| 358 | Lists the APKs and modules to install. |
| 359 | </td> |
| 360 | <td> |
| 361 | <code>Calendar Contacts</code> |
| 362 | </td> |
| 363 | </tr> |
| 364 | <tr> |
| 365 | <td> |
| 366 | PRODUCT_PACKAGE_OVERLAYS |
| 367 | </td> |
| 368 | <td> |
| 369 | Indicate whether to use default resources or add any product specific overlays |
| 370 | </td> |
| 371 | <td> |
| 372 | <code>vendor/acme/overlay</code> |
| 373 | </td> |
| 374 | </tr> |
| 375 | <tr> |
| 376 | <td> |
| 377 | PRODUCT_PROPERTY_OVERRIDES |
| 378 | </td> |
| 379 | <td> |
| 380 | List of system property assignments in the format "key=value" |
| 381 | </td> |
| 382 | <td></td> |
| 383 | </tr> |
| 384 | </tbody> |
| 385 | </table> |