Building Android for a new Mobile Device

Detailed Instructions

The directions below describe how to configure make files for new mobile devices and products.

  1. Create a company directory in //device/partner.
      mkdir device/partner/<company_name>
  2. Create a products directory beneath the company directory you created in step 1.
      mkdir device/partner/<company_name>/products/
  3. Create a product-specific make file, called device/partner/<company_name>/products/<first_product_name>.mk, that includes the following code:
      $(call inherit-product, target/product/generic.mk)
      #
      # Overrides
      PRODUCT_NAME := <first_product_name>
      PRODUCT_DEVICE := <board_name>
  4. In the products directory, create an AndroidProducts.mk file that point to (and is responsible for finding) the individual product make files.
      #
      # 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 \
  5. Create a board-specific directory beneath your company directory that matches the PRODUCT_DEVICE variable <board_name> referenced in the product-specific make file above. This will include a make file that gets accessed by any product using this board.
      mkdir device/partner/<company_name>/<board_name>
  6. Create a product_config.mk file in the directory created in the previous step (device/partner/<company_name>/<board_name>). If this directory does not include a product_config.mk file, the build will fail.
      # 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
  7. If you wish to modify system properties, create a system.prop file in your <board_name>directory(device/partner/<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
  8. Add a pointer to <second_product_name>.mk within products/AndroidProducts.mk.
      PRODUCT_MAKEFILES := \
        $(LOCAL_DIR)/first_product_name.mk \
        $(LOCAL_DIR)/second_product_name.mk
  9. device/partner/<company_name>/<board_name> must include an Android.mk file with at least the following code:

      # 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 := partner/<company_name>/<board_name>
      #
      include $(CLEAR_VARS)
      #
      # include more board specific stuff here? Such as Audio parameters.      
      #
  10. To create a second product for the same board, create a second product-specific make file calleddevice/partner/company_name/products/<second_product_name>.mk that includes:
      $(call inherit-product, partner/google/products/generic.mk)
      #
      # Overrides
      PRODUCT_NAME := <second_product_name>
      PRODUCT_DEVICE := <board_name>

By now, you should have two new products, called <first_product_name> and <second_product_name> associated with <company_name>. To verify that a product is properly configured (<first_product_name>, for example), execute the following:

  cd device
  . ./envsetup.sh
  partner_setup <first_product_name>
  make PRODUCT-<first_product_name>-user

You should find new build binaries located in device/out/target/product/<board_name>.

New Product File Tree

The file tree below illustrates what your own system should look like after completing the steps above.

  • <company_name>
    • <board_name>
      • Android.mk
      • product_config.mk
      • system.prop
    • products
      • AndroidProducts.mk
      • <first_product_name>.mk
      • <second_product_name>.mk

發佈了14 篇原創文章 · 獲贊 3 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章