Creating a custom device

During our journey, you learned how to retrieve the source code and how to set up the build system. In this section, you are going to learn how to create a new target device and add it to the build system. The device we are going to create now has specific hardware features. It's a proof-of-concept device, with the only purpose of showing you how easily and quickly you can create a brand new device and then customize it.

Every device definition is contained in the device/ folder. First level folders contains all the manufacturer's folders. Every manufacturer folder contains its own devices. Let's create our own manufacturer and device folders: our brand is Irarref and our model is an F488. Open a Terminal, reach the WORKING_DIRECTORY folder, and run:

~$ mkdir –p device/irarref/f488

Once we have the folder structure in place, we need to create all those files that will allow the build system to detect our device and make it available as a target for the build system. We are going to create the following files:

  • Android.mk: Describes in a generic way how to compile the source files. Essentially, it represents a snippet of the global Makefile that will be later incorporated by the build system at the appropriate time.
  • AndroidProducts.mk: This file contains a PRODUCS_MAKEFILEs variable, with a list of all the available products. In our scenario, we only have one device and it's represented by these files.
  • full_f488.mk: This file specifies any relevant information about the device.
  • BoardConfig.mk: This file specifies any relevant information about the device board.
  • vendorsetup.sh: This script makes the device available to envsetup.sh and lunch.

Diving into device configuration

As we know, our first device is quite simple, but very instructive. Let's see how our device specification is spread inside all our configuration files:

  • Android.mk:
    LOCAL_PATH:= $(call my-dir)
    Include $(CLEAN_VARS)
    
    Ifneq ($(filter f488, $(TARGET_DEVICE)),)
    Include $(call all-makefile-unter, $(LOCAL_PATH))
    Endif
  • AndroidProducts.mk:
    PRODUCT_MAKEFILES:= $(LOCAL_DIR)/full_f488.mk
  • full_f488.mk:
    $(call inherit-product, 
    $(SRC_TARGET_DIR)/product/aosp_base.mk
    #
    DEVICE_PACKAGE_OVERLAY:=
    
    PRODUCT_PACKAGE+=
    PRODUCT_COPY_FILES+=
    PRODUCT_NAME:= full_f488
    PRODUCT_DEVICE:= f488
    PRODUCT_MODEL:= Android for Irarref F488
  • BoardConfig.mk:
    TARGET_NO_BOOTLOADER := true
    TARGET_NO_KERNEL := true
    TARGET_CPU_ABI := armeabi
    HAVE_HTC_AUDIO_DRIVER := true
    BOARD_USES_GENERIC_AUDIO := true
    
    # no hardware camera
    USE_CAMERA_STUB := true
    
    # CPU
    TARGET_ARCH_VARIANT := armv7-a-neon
    ARCH_ARM_HAVE_TLS_REGISTER := true
  • vendorsetup.sh:
    add_lunch_combo full_f488-eng

Our Android.mk is pretty standard and completely based on what we have learned in the previous sections. AndroidProducts.mk just includes full_f488.mk, as expected.

The full_f488.mk file contains a few interesting lines. First of all, it includes aosp_base.mk, a configuration file provided by the system, common to lots of real devices.

Moving on, we found a few interesting variables:

  • DEVICE_PACKAGE_OVERLAY:=: This variable allows us to create a custom overlay, customizing, for instance, some settings of specific modules in the AOSP system. If you check, for instance, this variable in the equivalent file for the shamu device, you can notice that they are using it to customize a few settings in the launcher application.
  • PRODUCT_PACKAGE+=: This variable allows us to add packages to the compilation process.
  • PRODUCT_COPY_FILES+=: This variable performs a file copy operation. The syntax is pretty straight forward: source_file:dest_file
  • PRODUCT_NAME:= full_f488: This variable specifies the product name. This is the exact same value that lunch will print as TARGET_PRODUCT.
  • PRODUCT_DEVICE:= f488: This variable specifies the device name.
  • PRODUCT_MODEL:=: Android for Irarref F488: This variable specifies the device model label that we will find in our Android system under Settings | About phone | Model Number.

With all these files in place, you can now relaunch envsetup.sh and our brand new proof-of-concept device will be in the list of the available devices.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.197.212