原文网址:http://www.kandroid.org/online-pdk/guide/build_new_device.html
配置一个新产品
详细描述
以下步骤描述如何为一个新的移动设备配置makefiles以让产品能够运行Android系统。
1. 在vendor/目录下创建一个公司目录
mkdir vendor/<company_name>
2. 在步骤1中你创建的公司目录下创建一个products目录
mkdir vendor/<company_name>/products/
3. 创建一个特定产品的makefile,叫做vendor/<company_name>/products/<first_product_name>.mk,它至少包含如下代码:
$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk) # # Overrides PRODUCT_NAME := <first_product_name> PRODUCT_DEVICE := <board_name>
4. 为一个特定产品添加变量,可以被添加的变量定义在Product Definition文件中。
5. 在products目录中,创建一个AndroidProducts.mk文件,这个文件指向一个产品的makefiles,它主要负责寻找所有的产品。
# # This file should set PRODUCT_MAKEFILES to a list of product makefiles # to expose to the build system. LOCAL_DIR will already be set to # the directory containing this file. # # This file may not rely on the value of any variable other than # LOCAL_DIR; do not use any conditionals, and do not look up the # value of any variable that isn't set in this file or in a file that # it includes. # PRODUCT_MAKEFILES := \ $(LOCAL_DIR)/first_product_name.mk \
6. 在你的公司目录下创建一个特定板子目录,它要匹配PRODUCT_DEVICE变量,<board_name>将会引用上面特定产品的makefile。任何使用该板子的产品都将包含一个makefile。
mkdir vendor/<company_name>/<board_name>
7. 在前面一步创建的目录中创建一个BoardConfig.mk文件(vendor/<company_name>/<board_name>)
# These definitions override the defaults in config/config.make for <board_name> # # TARGET_NO_BOOTLOADER := false # TARGET_HARDWARE_3D := false # TARGET_USE_GENERIC_AUDIO := true
8. 如果你希望修改系统属性,在<board_name>目录中创建一个system.prop文件(vendor/<company_name>/<board_name>)。
# system.prop for # This overrides settings in the products/generic/system.prop file # # rild.libpath=/system/lib/libreference-ril.so # rild.libargs=-d /dev/ttyS0
9. 在products/AndroidProducts.mk中添加指向<second_product_name>.mk文件
PRODUCT_MAKEFILES := \ $(LOCAL_DIR)/first_product_name.mk \ $(LOCAL_DIR)/second_product_name.mk
10. 在vendor/<company_name>/<board_name>的Android.mk文件中至少包含如下代码:
# make file for new hardware from # LOCAL_PATH := $(call my-dir) # # this is here to use the pre-built kernel ifeq ($(TARGET_PREBUILT_KERNEL),) TARGET_PREBUILT_KERNEL := $(LOCAL_PATH)/kernel endif # file := $(INSTALLED_KERNEL_TARGET) ALL_PREBUILT += $(file) $(file): $(TARGET_PREBUILT_KERNEL) | $(ACP) $(transform-prebuilt-to-target) # # no boot loader, so we don't need any of that stuff.. # LOCAL_PATH := vendor/<company_name>/<board_name> # include $(CLEAR_VARS) # # include more board specific stuff here? Such as Audio parameters. #
11. 为同种板子创建第二个产品,创建第二个特定的产品的makefile叫做vendor/company_name/products/<second_product_name>.mk,包含如下内容:
$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk) # # Overrides PRODUCT_NAME := <second_product_name> PRODUCT_DEVICE := <board_name>
到了这里,你应该有两个新产品,叫做<first_product_name>和<second_product_name>为了验证一个产品是否配置正确(例如<first_product_name>),执行如下命令:
. build/envsetup.sh make PRODUCT-<first_product_name>-user
你应该能找到新版本的二进制文件位于/out/target/product/<board_name>。
新产品文件树
以下文件树说明在你的系统上照以上步骤完成应该有的。
- <company_name>
- <board_name>
- Android.mk
- product_config.mk
- system.prop
- products
- AndroidProducts.mk
- <first_product_name>.mk
- <second_product_name>.mk
- <board_name>
产品定义文件
特殊产品变量定义在产品定义文件中,一个产品定义文件可以继承其它的产品定义文件,从而减少代码复制和便于维护。
在产品定义文件中包含的变量包括:
Parameter | Description | Example |
---|---|---|
PRODUCT_NAME | End-user-visible name for the overall product. Appears in the "About the phone" info. | |
PRODUCT_MODEL | End-user-visible name for the end product | |
PRODUCT_LOCALES | A space-separated list of two-letter language code, two-letter country code pairs that describe several settings for the user, such as the UI language and time, date and currency formatting. The first locale listed in PRODUCT_LOCALES is is used if the locale has never been set before. | en_GB de_DE es_ES fr_CA |
PRODUCT_PACKAGES | Lists the APKs to install. | Calendar Contacts |
PRODUCT_DEVICE | Name of the industrial design | dream |
PRODUCT_MANUFACTURER | Name of the manufacturer | acme |
PRODUCT_BRAND | The brand (e.g., carrier) the software is customized for, if any | |
PRODUCT_PROPERTY_OVERRIDES | List of property assignments in the format "key=value" | |
PRODUCT_COPY_FILES | List of words likesource_path:destination_path . The file at the source path should be copied to the destination path when building this product. The rules for the copy steps are defined in config/Makefile | |
PRODUCT_OTA_PUBLIC_KEYS | List of OTA public keys for the product | |
PRODUCT_POLICY | Indicate which policy this product should use | |
PRODUCT_PACKAGE_OVERLAYS | Indicate whether to use default resources or add any product specific overlays | vendor/acme/overlay |
PRODUCT_CONTRIBUTORS_FILE | HTML file containing the contributors to the project. | |
PRODUCT_TAGS | list of space-separated words for a given product |
下面的片段描述一个典型产品定义文件。
$(call inherit-product, build/target/product/generic.mk) #Overrides PRODUCT_NAME := MyDevice PRODUCT_MANUFACTURER := acme PRODUCT_BRAND := acme_us PRODUCT_LOCALES := en_GB es_ES fr_FR PRODUCT_PACKAGE_OVERLAYS := vendor/acme/overlay