AOSP 移植添加设备Device

作者&投稿:席江 (若有异议请与网页底部的电邮联系)
~ https://elinux.org/Android_Device

This is a breakdown of the files build/envsetup.sh, Makefile and the files they use, which describes how a device is specified and how Android is configured for it.

For each file there are some comments and code lines from the make files or scripts, which describe what they are doing and which files they are using. Also the files which can be used as an example are presented and the commands how to search for them.

This text is for developers who want to add a new device or change the configuration of an existing device. This gives some indications which files are involved.

== build/envsetup.sh ==

Some functions are defined by calling

<pre>
. build/envsetup.sh
</pre>
in the top directory.

Some environment variables are set by calling
<pre>
lunch
</pre>
in the top directory.

<pre>
export TARGET_PRODUCT= variant
export TARGET_SIMULATOR=false
export TARGET_BUILD_TYPE=release
</pre>

vendorsetup.sh is searched at this places:
<pre>
vendor/ /vendorsetup.sh
vendor/ / /vendorsetup.sh
device/ /*/vendorsetup.sh
</pre>

== vendorsetup.sh ==

This file is executed by build/envsetup.sh, and can use anything
defined in envsetup.sh.

In particular, you can add lunch options with the add_lunch_combo
function:

<pre>
add_lunch_combo full_crespo-userdebug
</pre>

The values of the macros TARGET_PRODUCT and TARGET_BUILD_VARIANT are derived from the option name: add_lunch_combo TARGET_BUILD_VARIANT

In the above example the resulting values are TARGET_PRODUCT=full_crespo and TARGET_BUILD_VARIANT=userdebug.

These files can be used as an example:
<pre>
find . -name vendorsetup.sh
</pre>

<pre>
./device/samsung/crespo/vendorsetup.sh
./device/samsung/crespo4g/vendorsetup.sh
./device/htc/passion/vendorsetup.sh
</pre>

== Makefile ==

Build process is started by calling

<pre>
make
</pre>

in the top directory.

The Makefile calls build/core/main.mk

== build/core/main.mk ==

Set up various standard variables based on configuration and host information.
<pre>
include $(BUILD_SYSTEM)/config.mk
</pre>

This allows us to force a clean build - included after the config.make
environment setup is done, but before we generate any dependencies. This
file does the rm -rf inline so the deps which are all done below will
be generated correctly

<pre>
include $(BUILD_SYSTEM)/cleanbuild.mk
</pre>

These are the modifier targets that don't do anything themselves, but
change the behavior of the build.
(must be defined before including definitions.make)

<pre>
INTERNAL_MODIFIER_TARGETS := showcommands checkbuild all
</pre>

Bring in standard build system definitions.
<pre>
include $(BUILD_SYSTEM)/definitions.mk
</pre>

== build/core/config.mk ==

Various mappings to avoid hard-coding paths all over the place

<pre>
include $(BUILD_SYSTEM)/pathmap.mk
</pre>

Try to include buildspec.mk, which will try to set stuff up.
If this file doesn't exist, the environemnt variables will
be used, and if that doesn't work, then the default is an
arm build

<pre>
-include $(TOPDIR)buildspec.mk
</pre>

Define most of the global variables. These are the ones that
are specific to the user's build configuration.

<pre>
include $(BUILD_SYSTEM)/envsetup.mk
</pre>

Search for BoardConfig.mk in

(TARGET_DEVICE)/BoardConfig.mk

device/*/ (TARGET_DEVICE)/BoardConfig.mk

and load the file

<pre>
include $(board_config_mk)
</pre>

<pre>
include $(BUILD_SYSTEM)/dumpvar.mk
</pre>

== BoardConfig.mk ==

These files can be used as an example:
<pre>
find . -name BoardConfig.mk
</pre>

<pre>
./device/samsung/crespo/BoardConfig.mk
./device/samsung/crespo4g/BoardConfig.mk
./device/htc/passion/BoardConfig.mk
./build/target/board/generic/BoardConfig.mk
./build/target/board/generic_x86/BoardConfig.mk
./build/target/board/emulator/BoardConfig.mk
./build/target/board/sim/BoardConfig.mk
</pre>

== build/buildspec.mk.default ==

This is a do-nothing template file. To use it, copy it to a file
named "buildspec.mk" in the root directory, and uncomment or change
the variables necessary for your desired configuration. The file
"buildspec.mk" should never be checked in to source control.

Choose a product to build for. Look in the products directory for ones
that work.

TARGET_PRODUCT

Choose a variant to build. If you don't pick one, the default is eng.

User is what we ship.

Userdebug is that, with a few flags turned on
for debugging.

Eng has lots of extra tools for development.

TARGET_BUILD_VARIANT

CUSTOM_MODULES

TARGET_SIMULATOR

Set this to debug or release if you care. Otherwise, it defaults to
release for arm and debug for the simulator.

TARGET_BUILD_TYPE

HOST_BUILD_TYPE

DEBUG_MODULE_ModuleName

TARGET_TOOLS_PREFIX

HOST_CUSTOM_DEBUG_CFLAGS

TARGET_CUSTOM_DEBUG_CFLAGS

CUSTOM_LOCALES

OUT_DIR

ADDITIONAL_BUILD_PROPERTIES

NO_FALLBACK_FONT

WEBCORE_INSTRUMENTATION

ENABLE_SVG

BUILD_ENV_SEQUENCE_NUMBER

== build/envsetup.mk ==

Set up version information.
<pre>
include $(BUILD_SYSTEM)/version_defaults.mk
</pre>

If you update the build system such that the environment setup
or buildspec.mk need to be updated, increment this number, and
people who haven't re-run those will have to do so before they
can build. Make sure to also update the corresponding value in
buildspec.mk.default and envsetup.sh.

<pre>
CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
</pre>

<pre>
include $(BUILD_SYSTEM)/product_config.mk
</pre>

TARGET_PRODUCT: sim full

TARGET_BUILD_VARIANT: eng user userdebug tests

== build/core/version_defaults.mk ==

Handle various build version information.

Guarantees that the following are defined:

PLATFORM_VERSION

PLATFORM_SDK_VERSION

PLATFORM_VERSION_CODENAME

DEFAULT_APP_TARGET_SDK

BUILD_ID

BUILD_NUMBER

Look for an optional file (BUILD_SYSTEM)/build_id.mk
</pre>

== build/core/build_id.mk ==

BUILD_ID is usually used to specify the branch name

BUILD_ID

DISPLAY_BUILD_NUMBER

== build/product_config.mk ==

Provide "PRODUCT-<prodname>-<goal>" targets, which lets you build
a particular configuration without needing to set up the environment.

<pre>
TARGET_PRODUCT := (product_goals))
TARGET_BUILD_VARIANT := (product_goals))
</pre>

Provide "APP-<appname>" targets, which lets you build
an unbundled app.

Include the product definitions.
We need to do this to translate TARGET_PRODUCT into its
underlying TARGET_DEVICE before we start defining any rules.

PRODUCT_DEVICE is defined in the product file (TARGET_PRODUCT).mk is searched in the list of product make files $(PRODUCT_MAKEFILES).

PRODUCT_MAKEFILES is set in AndroidProducts.mk files.

<pre>
(call get-product-makefiles,
$(SRC_TARGET_DIR)/product/AndroidProducts.mk))
</pre>

Convert a short name like "sooner" into the path to the product
file defining that product.

<pre>
INTERNAL_PRODUCT := (TARGET_PRODUCT))
</pre>

<pre>
TARGET_DEVICE := (INTERNAL_PRODUCT).PRODUCT_DEVICE)
PRODUCT_LOCALES := (PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
PRODUCT_BRAND
PRODUCT_MODEL
PRODUCT_MANUFACTURER
</pre>

<pre>
PRODUCT_OTA_PUBLIC_KEYS
</pre>

== AndroidProducts.mk ==

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.

File device/samsung/crespo/AndroidProducts.mk
<pre>
PRODUCT_MAKEFILES :=
$(LOCAL_DIR)/full_crespo.mk
</pre>

These files can be used as an example:
<pre>
find . -name AndroidProducts.mk
</pre>

<pre>
./device/sample/products/AndroidProducts.mk
./device/samsung/crespo/AndroidProducts.mk
./device/samsung/crespo4g/AndroidProducts.mk
./device/htc/passion/AndroidProducts.mk
./build/target/product/AndroidProducts.mk
</pre>

The command which returns the list of all AndroidProducts.mk files is defined in build/core/product.mk :
<pre>
define _find-android-products-files
(shell test -d vendor && find vendor -maxdepth 6 -name AndroidProducts.mk)
$(SRC_TARGET_DIR)/product/AndroidProducts.mk
endef
</pre>

== Product Files ==

Search for the files which can be used as an example:
<pre>
grep -R PRODUCT_DEVICE device build
</pre>

<pre>
device/samsung/crespo/full_crespo.mk:PRODUCT_DEVICE := crespo
device/samsung/crespo4g/full_crespo4g.mk:PRODUCT_DEVICE := crespo4g
device/htc/passion/full_passion.mk:PRODUCT_DEVICE := passion
build/target/product/sdk.mk:PRODUCT_DEVICE := generic
build/target/product/generic.mk:PRODUCT_DEVICE := generic
build/target/product/generic_x86.mk:PRODUCT_DEVICE := generic_x86
build/target/product/core.mk:PRODUCT_DEVICE := generic
build/target/product/full_x86.mk:PRODUCT_DEVICE := generic_x86
build/target/product/full.mk:PRODUCT_DEVICE := generic
build/target/product/sim.mk:PRODUCT_DEVICE := sim
</pre>

PRODUCT_DEVICE is used in these files
<pre>
build/core/product.mk: PRODUCT_DEVICE
build/core/product_config.mk:TARGET_DEVICE := (INTERNAL_PRODUCT).PRODUCT_DEVICE)
</pre>

== Add new device ==

Add the configuration files for the new device mydevice of the company mycompany.

Create AndroidProducts.mk
<pre>
mkdir -p device/mycompany/mydevice
nano device/mycompany/mydevice/AndroidProducts.mk
</pre>

<pre>
PRODUCT_MAKEFILES :=
$(LOCAL_DIR)/full_mydevice.mk
</pre>

Create file full_mydevice.mk

Example is build/target/product/full.mk
<pre>
nano device/mycompany/mydevice/full_mydevice.mk
</pre>

<pre>
(SRC_TARGET_DIR)/product/full_base.mk)
(SRC_TARGET_DIR)/board/generic/device.mk)

PRODUCT_NAME := full_mydevice
PRODUCT_DEVICE := mydevice
PRODUCT_BRAND := Android
PRODUCT_MODEL := Full Android on mydevice
</pre>

Create file vendorsetup.sh
<pre>
nano device/mycompany/mydevice/vendorsetup.sh
</pre>

<pre>
add_lunch_combo full_mydevice-eng
</pre>

Create file BoardConfig.mk

Examples are

build/target/board/generic/BoardConfig.mk

device/samsung/crespo/BoardConfig.mk

device/samsung/crespo/BoardConfigCommon.mk

<pre>
mkdir -p device/mycompany/mydevice
nano device/mycompany/mydevice/BoardConfig.mk
</pre>

<pre>

TARGET_NO_BOOTLOADER := true
TARGET_NO_KERNEL := true
TARGET_CPU_ABI := armeabi
HAVE_HTC_AUDIO_DRIVER := true
BOARD_USES_GENERIC_AUDIO := true

USE_CAMERA_STUB := true

TARGET_SHELL := mksh

TARGET_ARCH_VARIANT := armv7-a-neon
ARCH_ARM_HAVE_TLS_REGISTER := true
</pre>

Configure Android for mydevice
<pre>
. build/envsetup.sh
</pre>

<pre>
including device/htc/passion/vendorsetup.sh
including device/mycompany/mydevice/vendorsetup.sh
including device/samsung/crespo4g/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
</pre>

<pre>
lunch
</pre>

<pre>
You're building on Linux

Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. simulator
4. full_passion-userdebug
5. full_mydevice-eng
6. full_crespo4g-userdebug
7. full_crespo-userdebug

Which would you like? [full-eng] 5

============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=full_mydevice
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
</pre>

Build Android for mydevice
<pre>
make -j4
</pre>

<pre>
Combining NOTICE files: out/target/product/mydevice/obj/NOTICE.html
Target system fs image: out/target/product/mydevice/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/mydevice/system.img
Installed file list: out/target/product/mydevice/installed-files.txt
</pre>

[[Category:Android]]


北碚区13269249057: 移植的时候adb ogcat无法连接怎么办 -
姜冰富马: 使用 adb 时无法找到设备,解决办法如下: 1) 在终端运行 lsusb 会发现结果有会有如下类似记录: Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 ...

北碚区13269249057: 嵌入式系统bootloader移植方法
姜冰富马: 和具体硬件有关,一般根据硬件来做,bootloader说白了就BSP(板级支持包),起作用无非就是:首先初始化硬件(包括io,特殊功能寄存器),接着把嵌入式操作系统加载(拷贝)到内存中(一段代码拷贝程序),然后运行嵌入式系统.

北碚区13269249057: 如何正确刷入AOSP 希望更多的人用上流畅好用的ROM -
姜冰富马: 下载ROM包复制到手机 重启手机 在显示logo 并震动 指示灯亮时候 狂按音量上键 1 选择“擦除Data分区/恢复出厂设置---清除Data,syatem,cache,刷入新ROM选项” 2 选择“安装Zip包---从sdcard选择zip包” 3 重启到系统

北碚区13269249057: 华为P10在“添加虚拟键盘”时,无法关闭“Android 键盘” -
姜冰富马: 问题现象:在语言和输入法设置界面中,添加虚拟键盘时,Android 键盘(AOSP)为灰色.问题原因:为进一步保障手机数据的安全性,系统设计启用了文件级加密.如果用户设置将所有系统输入法全部禁用,且解锁类型设置为混合密码,此时默认使用未适配文件加密的输入法APK 将会出现无法调出输入法,导致用户您将无法进行解锁的场景.

北碚区13269249057: How to use the aosp keyboard? -
姜冰富马:[答案] 译:如何使用键盘aosp吗? AOSP "Android Open-Source Project"的缩写 中文意为"Android 开放源代码项目"

北碚区13269249057: 很抱歉,android 键盘(aosp)已停止运行怎么办? -
姜冰富马: 1. 按下述操作:进入 设置---语言和输入法---在“键盘和输入法”中点击“默认”(黑体字)---点击“中文拼音--谷歌拼音输入法”.此操作是将"默认"更改为“中文拼音--谷歌拼音输入法”. 2. 进入中文输入程序(如 搜索),即出现中文拼音键盘. 3. 注意:中文输入键盘底部中间位置有一语言种类提示条(如显示“中文”),其左侧的一个地球样图案的按钮,千万别按,一按就出现“抱歉,Android 键盘已经关闭”的提示,并且键盘消失. 请试试看!

北碚区13269249057: linux系统中开发板上Qt移植步骤 -
姜冰富马: 一、准备busybox 1.14.1qt-embedded-linux-opensource-src-4.5.1tslib 1.4gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72)构建一个新的根文件系统目录,路径为/root/rootfs二、具体步骤:1、编译安装busybox在官网下载最新版.可以...

北碚区13269249057: Windows 10手机怎么兼容Android -
姜冰富马: 1、win10并不是直接支持安装apk格式的应用,而是通过微软发布的工具为系统添加一个软件层,使AOSP(Android开放源代码项 目)作为一个子系统运行.2、对于Android开发者来说,他们能够以APK格式向微软提交使用Java或C++语言编写的应用,使其在Windows 10手机上运行.也就是说,微软会为开发者发布一个apk的“翻译工具”,通过该翻译工具将应用格式翻译为win10所能解读的格式.33、此外,微软还开发了Objective-C的编译器,以便iOS开发者可以利用微软的编译器重新编译应用,使之能在Windows 10手机上运行.所以说要在win10上跑安卓应用需要重新编译软件.

北碚区13269249057: Ubuntu支持哪些设备 -
姜冰富马: ubuntu支持ARM和X86架构处理器.所以原则上支持电脑、服务器、平板、手机等各类X86和ARM处理器设备.但是ARM移植困难比较高,开发工作量大,目前支持设备较少.对于X86架构电脑和服务器,ubuntu的支持度比较高,基本都可以尝试安装没有问题.对于ARM架构的平板和手机,由于移植难度,从Ubuntu Touch 官方 WIKI上可以看到,只支持少数几款,比如Nexus 10和Nexus 7.手机如,Nexus 4、魅族MX4 ubuntu版和BQ Aquaris E4.5 ubuntu版.

北碚区13269249057: windows phone 10兼不兼容安卓应用 -
姜冰富马: 兼容的,在手机版Windows 10中,微软将为系统添加一个软件层,使AOSP(Android开放源代码项目)作为一个子系统运行——与POSIX(可移植操作系统接口)作为子系统在Windows上的运行相似.对于Android开发者来说,他们能够以APK格式向微软提交使用Java或C++语言编写的应用,使其在Windows 10手机上运行

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网