msm8909+android5.1.1编译前配置及增加新项目和产品所需分支
编译前的选项配置:
(1) source build/envseutp.sh
(2) choosecomb
1. source build/envsetup.sh
source 是用来运行 shell 脚本的命令 功能和 "." 和相同,因此 也可以写作: . build/envsetup.sh
including device/lge/mako/vendorsetup.shincludingdevice/generic/mini-emulator-x86/vendorsetup.shincludingdevice/generic/mini-emulator-armv7-a-neon/vendorsetup.shincludingdevice/generic/mini-emulator-x86_64/vendorsetup.shincluding device/generic/mini-emulator-mips/vendorsetup.shincludingdevice/generic/mini-emulator-arm64/vendorsetup.shincluding device/qcom/common/vendorsetup.shincludingdevice/htc/flounder/vendorsetup.shincluding device/asus/fugu/vendorsetup.shincludingdevice/asus/tilapia/vendorsetup.shincludingdevice/asus/grouper/vendorsetup.shincluding device/asus/deb/vendorsetup.shincludingdevice/samsung/manta/vendorsetup.shincludingvendor/qcom/proprietary/common/vendorsetup.shincluding sdk/bash_completion/adb.bash
2. choosecombo
Project choices are: 1. CB03Which would you like? [CB03] 1 Build type choices are: 1. release 2. debug Which would you like? [1] 1 Product choices are: 1. msm8909Which product would you like? [msm8909] 1 Variant choices are: 1. user 2. userdebug 3. engWhich would you like? [eng] 1 chipset are: 1. 8909 2. 8209Which would you like? [8909] 1 Multisim choices are: 1. ssss 2. dsdsWhich would you like? [ssss] 1 ============================================PLATFORM_VERSION_CODENAME=RELPLATFORM_VERSION=5.1.1TARGET_PRODUCT=msm8909TARGET_BUILD_VARIANT=userTARGET_BUILD_TYPE=releaseTARGET_BUILD_APPS=TARGET_ARCH=armTARGET_ARCH_VARIANT=armv7-a-neonTARGET_CPU_VARIANT=cortex-a7TARGET_2ND_ARCH=TARGET_2ND_ARCH_VARIANT=TARGET_2ND_CPU_VARIANT=HOST_ARCH=x86_64HOST_OS=linuxHOST_OS_EXTRA=Linux-3.16.0-30-generic-x86_64-with-Ubuntu-14.04-trustyHOST_BUILD_TYPE=releaseBUILD_ID=LMY47VSIMCOM_PROJECT=CB03SIMCOM_MULTISIM=ssssOUT_DIR=out============================================
上面内容对应envseup.sh的choosecombo函数,主要调用choosetype,chooseproduct,choosevariant等函数,确定TARGET_PRODUCT,TARGET_BUILD_TYPE,TARGET_BUILD_VARIANT。
function choosecombo(){ chooseproject $1 echo choosetype $2 echo echo chooseproduct $3 echo echo choosevariant $4#modify to display TARGET_CHIPSET and builddate dynamicly by xueguobing begin echo echo choose_CHIPSET $5#modify to display TARGET_CHIPSET and builddate dynamicly by xueguobing end echo echo echo echo chooseMultisim $6 initbuildspec echo set_stuff_for_environment printconfig}
下面我们具体来看每个选项的内容
2.1 project choices(项目选择)
Project choices are: 1. CB03Which would you like? [CB03] 1 实现如下:PROJECT_CHOICES=(CB03 C6000)function chooseproject(){ T=$(gettop) #获取Android源码根目录 echo "Project choices are:" local index=1 local v for v in ${PROJECT_CHOICES[@]} do # The product name is the name of the directory containing # the makefile we found, above. echo " $index. $v" #比如显示1.CB03 index=$(($index+1)) done local default_value=CB03 local ANSWER export SIMCOM_PROJECT= #导出环境变量 while [ -z "$SIMCOM_PROJECT" ] do echo -n "Which would you like? [$default_value] " if [ -z "$1" ] ; then read ANSWER else echo $1 ANSWER=$1 fi if [ -z "$ANSWER" ] ; then export SIMCOM_PROJECT=$default_value elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then if [ "$ANSWER" -le "${#PROJECT_CHOICES[@]}" ] ; then exportSIMCOM_PROJECT=${PROJECT_CHOICES[$(($ANSWER-1))]} fi else if check_project $ANSWER then export SIMCOM_PROJECT=$ANSWER else echo "** Not a validproject: $ANSWER" fi fi if [ -n "$1" ] ; then break fi done }
这里导出了SIMCOM_PROJECT变量的值,比如C6000
加入我们要增加另个工程,比如C6000,要修改PROJECT_CHOICES的值,
修改前:
PROJECT_CHOICES=(CB03)
修改后:
PROJECT_CHOICES=(CB03 C6000)
中间不能用逗号。
基于上面的修改,所有项选择之后输出
read(): can't openbuild/buildplus/namespace/names.ini for read: 没有那个文件或目录 atbuild/buildplus/tool/qrdplus_target_gen.pl line 98.
target build Env generate failed, yourshould abort continuous make procedure!
此错误信息是initbuildspec()输出的
function initbuildspec(){ local -a GEN_QRDPLUS_ENV_RET GEN_QRDPLUS_ENV_PL=build/buildplus/tool/qrdplus_target_gen.pl #modify by lzq default mode is ct GEN_QRDPLUS_ENV_RET=(`perl $GEN_QRDPLUS_ENV_PL $SIMCOM_PROJECT`) if [ "$GEN_QRDPLUS_ENV_RET" != "GEN_SUCCESS" ] ;then echo "target build Env generate failed, your should abortcontinuous make procedure!" fi}
这里会找build\buildplus\namespace\目录下是否有names_ $(SIMCOM_PROJECT).ini的文件。所以需要在此目录下增加names_C6000.ini文件才可以编译通过。
2.2 build type选择
Build type choices are: 1. release 2. debug Which would you like? [1] 1 实现如下:function choosetype(){ echo "Build type choices are:" echo " 1. release" echo " 2. debug" echo local DEFAULT_NUM DEFAULT_VALUE DEFAULT_NUM=1 DEFAULT_VALUE=release export TARGET_BUILD_TYPE= local ANSWER while [ -z $TARGET_BUILD_TYPE ] do echo -n "Which would you like? ["$DEFAULT_NUM"] " if [ -z "$1" ] ; then read ANSWER else echo $1 ANSWER=$1 fi case $ANSWER in "") export TARGET_BUILD_TYPE=$DEFAULT_VALUE ;; 1) export TARGET_BUILD_TYPE=release ;; release) export TARGET_BUILD_TYPE=release ;; 2) export TARGET_BUILD_TYPE=debug ;; debug) export TARGET_BUILD_TYPE=debug ;; *) echo echo "I didn't understand your response. Please try again." echo ;; esac if [ -n "$1" ] ; then break fi done set_stuff_for_environment # 设置环境变量}
这里导出环境变量TARGET_BUILD_TYPE,其值为release或是debug,调用set_stuff_for_environment()来设置环境变量,如下:
function set_stuff_for_environment(){ settitle set_java_home setpaths set_sequence_number export ANDROID_BUILD_TOP=$(gettop) #With this environment variable new GCC can apply colors to warnings/errors exportGCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'}
2.3 product choices(产品选择)
Product choices are: 1. msm8909Which product would you like? [msm8909] 1 实现如下:## This function isn't really right: It chooses a TARGET_PRODUCT# based on the list of boards. Usually, that gets you something# that kinda works with a generic product,but really, you should# pick a product by name.#function chooseproduct(){# Find the list of all products by lookingfor all AndroidProducts.mk files under the# device/, vendor/ andbuild/target/product/ directories and look for the format# LOCAL_DIR/<ProductSpecificFile.mk>and extract the name ProductSpecificFile from it.# This will give the list of all productsthat can be built using choosecombo local -a prodlist # Find all AndroidProducts.mk files underthe dirs device/, build/target/ and vendor/# Extract lines containing .mk from them# Extract lines containing LOCAL_DIR# Extract the name of the product specificfile prodlist=(`/usr/bin/find device/qcom/msm8909 -name AndroidProducts.mk2>/dev/null| xargs grep -h \.mk| grep LOCAL_DIR| cut -d'/' -f2|cut -d' ' -f1|sort|uniq|cut -d'.' -f1`) export TARGET_PRODUCT= local index=1 local p echo "Product choices are:" for p in ${prodlist[@]} do echo " $index. $p" let "index = $index + 1" done if [ "x$TARGET_PRODUCT" != x ] ; then default_value=$TARGET_PRODUCT else default_value=msm8909 fi local ANSWER while [ -z "$TARGET_PRODUCT" ] do echo -n "Which product would you like? [$default_value] " if [ -z "$1" ] ; then read ANSWER else echo $1 ANSWER=$1 fi if [ -z "$ANSWER" ] ; then export TARGET_PRODUCT=$default_value elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then local poo=`echo -n $ANSWER` if [ $poo -le ${#prodlist[@]} ] ; then exportTARGET_PRODUCT=${prodlist[$(($ANSWER-1))]} else echo "** Bad productselection: $ANSWER" fi else if check_product $ANSWER then export TARGET_PRODUCT=$ANSWER else echo "** Not a validproduct: $ANSWER" fi fi if [ -n "$1" ] ; then break fi done set_stuff_for_environment}
这里有几个重要的信息:
(1) 通过查找device、vendor和build/target/product/下AndroidProducts.mk文件来寻找所有的产品,寻找此目录下LOCAL_DIR/<ProductSpecificFile.mk>文件和提取名为ProductSpecificFile的文件
比如\device\qcom\msm8909\ AndroidProducts.mk,此文件内容如下:
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/msm8909.mk
提取msm8909.mk文件,msm8909就是一个产品。
我们如果要增加一个C6000的产品,需要做下面的处理:
(1) \device\qcom
基于此目录的msm8909产品,增加C6000产品的目录,然后修改AndroidProducts.mk文件内容如下:
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/C6000.mk
所以还需要基于msm8909.mk改为C6000.mk,然后把C6000.mk中关于msm8909产品和项目名称为CB03的地方统一修改为C6000,但其中引用到的mixer_paths_msm8909_pm8916.xml文件这里的msm8909不需要改为C6000,因为共用msm8909处理器,也需要把device\qcom\C6000\overlay\CB03改为C6000
(2) \vendor\qcom
没有修改
(3) build/target/product/
没有修改
(4) envsetup.sh从device/qcom枚举所有的产品名
prodlist=(`/usr/bin/finddevice/qcom/msm8909 -name AndroidProducts.mk 2>/dev/null|
这是自带的,如果枚举所有的,可改为device/qcom,如果只想枚举指定的,比如msm8909和C6000,可改为
prodlist=(`/usr/bin/finddevice/qcom/msm8909 device/qcom/C6000 -name AndroidProducts.mk 2>/dev/null|
(5) 导出TARGET_PRODUCT,其值为msm8909或是C6000
(6) 设置产品名称的显示顺序
prodlist=(`/usr/bin/finddevice/qcom/msm8909 device/qcom/C6000 -name AndroidProducts.mk 2>/dev/null| xargs grep -h \.mk| grep LOCAL_DIR|cut -d'/' -f2|cut -d' ' -f1|sort|uniq|cut -d'.' -f1`) 显示结果Product choices are: 1. C6000 2. msm8909
这种方式会根据字母顺序来显示,如果想按照自己制定的顺序来显示,如下:
prodlist=(`/usr/bin/finddevice/qcom/msm8909 device/qcom/C6000 -name AndroidProducts.mk 2>/dev/null| xargs grep -h \.mk| grep LOCAL_DIR|cut -d'/' -f2|cut -d'.' -f1`) 显示结果Product choices are: 1. msm8909 2. C6000
2.4 variant choices不同的选择
Variant choices are: 1. user 2. userdebug 3. engWhich would you like? [eng] 1 实现如下:VARIANT_CHOICES=(user userdebug eng)function choosevariant(){ echo "Variant choices are:" local index=1 local v for v in ${VARIANT_CHOICES[@]} do # The product name is the name of the directory containing # the makefile we found, above. echo " $index. $v" index=$(($index+1)) done local default_value=eng local ANSWER export TARGET_BUILD_VARIANT= while [ -z "$TARGET_BUILD_VARIANT" ] do echo -n "Which would you like? [$default_value] " if [ -z "$1" ] ; then read ANSWER else echo $1 ANSWER=$1 fi if [ -z "$ANSWER" ] ; then export TARGET_BUILD_VARIANT=$default_value elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then if [ "$ANSWER" -le"${#VARIANT_CHOICES[@]}" ] ; then exportTARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]} fi else if check_variant $ANSWER then export TARGET_BUILD_VARIANT=$ANSWER else echo "** Not a validvariant: $ANSWER" fi fi if [ -n "$1" ] ; then break fi done}
导出环境变量TARGET_BUILD_VARIANT,其值为(user userdebug eng)三选一。
2.5 chipset
chipset are: 1. 8909 2. 8209Which would you like? [8909] 1 CHIPSET=(8909 8209)function choose_CHIPSET(){echo "chipset are:" local index=1 local v for v in ${CHIPSET[@]} do # The product name is the name of the directory containing # the makefile we found, above. echo " $index. $v" index=$(($index+1)) done local default_value=8909 local ANSWER export TARGET_CHIPSET= while [ -z "$TARGET_CHIPSET" ] do echo -n "Which would you like? [$default_value] " if [ -z "$1" ] ; then read ANSWER else echo $1 ANSWER=$1 fi if [ -z "$ANSWER" ] ; then export TARGET_CHIPSET=$default_value elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then if [ "$ANSWER" -le "${#CHIPSET[@]}" ] ; then exportTARGET_CHIPSET=${CHIPSET[$(($ANSWER-1))]} fi else if check_variant $ANSWER then export TARGET_CHIPSET=$ANSWER else echo "** Not a validvariant: $ANSWER" fi fi if [ -n "$1" ] ; then break fi done}
导出环境变量TARGET_CHIPSET,其值为8909或是8209。
2.6 multisim choices
Multisim choices are: 1. ssss 2. dsdsWhich would you like? [ssss] 1 MULTISIM_CHOICES=(ssss dsds)function chooseMultisim(){ T=$(gettop) export SIMCOM_MULTISIM= local choose_multisim=0 local default_value= case $SIMCOM_PROJECT in "CB03") choose_multisim=1 default_value=ssss ;; *) choose_multisim=1 default_value=ssss ;; esac if [ $choose_multisim -eq 1 ] ; then echo "Multisim choices are:" local index=1 local v for v in ${MULTISIM_CHOICES[@]} do echo " $index. $v" index=$(($index+1)) done local ANSWER while [ -z "$SIMCOM_MULTISIM" ] do echo -n "Which would you like? [$default_value] " if [ -z "$1" ] ; then read ANSWER else echo $1 ANSWER=$1 fi if [ -z "$ANSWER" ] ; then export SIMCOM_MULTISIM=$default_value elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then if [ "$ANSWER" -le "${#MULTISIM_CHOICES[@]}" ] ;then exportSIMCOM_MULTISIM=${MULTISIM_CHOICES[$(($ANSWER-1))]} fi else if check_multisim $ANSWER then export SIMCOM_MULTISIM=$ANSWER else echo "** Not a validmultisim: $ANSWER" fi fi if [ -n "$1" ] ; then break fi done fi}
导出环境变量SIMCOM_MULTISIM,其值为ssss或是dsds
基于上面的修改后,然后编译C6000,make –j4,遇到的问题如下:
(1) make: *** 没有规则可以创建目标“build/scm_scripts/C6000.mk”。 停止
envsetup.sh下关于我们make这个动作的函数如下
function m(){ local T=$(gettop) local DRV=$(getdriver $T) if [ "$T" ]; then $DRV make -C $T -f build/core/main.mk $@ else echo "Couldn't locate the top of the tree. Try setting TOP." fi}
可知会调用build/core/main.mk,此文件下通过TARGET_PRODUCT和SIMCOM_PROJECT环境变量搜索,相关部分如下
$(info********************************************)ifneq (,$(SIMCOM_PROJECT))$(info ! override withvendor/simcom/$(SIMCOM_PROJECT) !)$(shell cp -rfvendor/simcom/$(SIMCOM_PROJECT)/frameworks ./)$(shell cp -rfvendor/simcom/$(SIMCOM_PROJECT)/packages ./)else$(info SIMCOM_PROJECT is null!)endif$(info********************************************) includebuild/buildplus/target/QRDExt_target.minifeq ($(Module_Nfc_Pn547), yes)$(info ! override withvendor/simcom/Nfc_Pn547 !)$(shell cp -rf vendor/simcom/Nfc_Pn547/*./)endif #ifeq (build/scm_scripts/$(SIMCOM_PROJECT)_$(TARGET_CUSTOMER).mk,$(wildcard build/projectEnv/$(TARGET_PRODUCT)_$(TARGET_CUSTOMER).mk))#includebuild/scm_scripts/$(SIMCOM_PROJECT)_$(TARGET_CUSTOMER).mk#elseincludebuild/scm_scripts/$(SIMCOM_PROJECT).mk#endif
可知要创建build/scm_scripts/C6000.mk这个文件,然后编译
(2) make: *** 没有规则可以创建“out/target/product/C6000/obj/ETC/init.rc_intermediates/init.rc”需要的目标“system/core/rootdir/init_C6000.rc”。 停止
所以我们需要创建system/core/rootdir/init_C6000.rc
(3) Can't find defaultconfiguration "arch/arm/configs/msm8909-1gb-C6000-perf_defconfig"!
所以需要创建msm8909-1gb-C6000-perf_defconfig文件,此文件中的CONFIG_ARCH_MSM8909_CB03=y改为CONFIG_ARCH_MSM8909_C6000=y,此配置在\kernel\arch\arm\mach-msm\Kconfig用到,增加内容:
config ARCH_MSM8909_C6000 bool "C6000 Product" depends on ARCH_MSM8909 help Support for MSM8909 C6000.
(4) make: *** 没有规则可以创建“out/target/product/C6000/persist/WCNSS_qcom_wlan_nv.bin”需要的目标“device/qcom/C6000/WCNSS_qcom_wlan_nv_C6000.bin”。 停止。
把此目录下的WCNSS_qcom_wlan_nv_CB03.bin改为WCNSS_qcom_wlan_nv_C6000.bin
(5) make: ***[out/target/product/C6000/obj/PACKAGING/target_files_intermediates/C6000-target_files-eng.zip]错误 1
更多的编译错误信息如下:
Package target files:out/target/product/C6000/obj/PACKAGING/target_files_intermediates/C6000-target_files-eng.zipprepare the ota cp files.[vendor/simcom/C6000/mp_images]out/host/linux-x86/bin/acp vendor/simcom/C6000/mp_images/NON-HLOS.bin out/target/product/C6000/NON-HLOS.otaacp: file'vendor/simcom/C6000/mp_images/NON-HLOS.bin' does not existmake: ***[out/target/product/C6000/obj/PACKAGING/target_files_intermediates/C6000-target_files-eng.zip]错误 1 #### make failed to build some targets(39:57 (mm:ss)) ####
编译生成了所需要的系统文件,但少了misc.img、msm8909-otg-eng.zip、NON-HLOS.ota、Package_backup.zip、rpm.ota、sbl1.otg、splash.img、target_files-package.zip、tz.ota
可知需要vendor/simcom/C6000/mp_images文件夹下的NON-HLOS.bin文件来生成C6000-target_files-eng.zip文件,所以我们需要创建vendor/simcom/C6000文件夹及需要的文件,
(6) 编译成功,但还是少了misc.img和splash.img
在vendor目录下搜索misc,发现vendor\qcom\proprietary\qrdplus\Extension\apps\BootAnimation\Android.mk文件相关内容如下:
$(shell cp -r$(LOCAL_PATH)/$(SIMCOM_PROJECT)/splash.img $(PRODUCT_OUT)/splash.img)$(shell cp -r$(LOCAL_PATH)/$(SIMCOM_PROJECT)/misc.img $(PRODUCT_OUT)/misc.img)
可知要拷贝BOOtAnimation目录下$(SIMCOM_PROJECT)下的splash.img、misc.img文件拷贝到$(PRODUCT_OUT)下,所以我们需要创建C6000的目录及需要的文件。
(7) 烧录系统,开机的时候白屏,进入系统还是白屏,休眠唤醒后显示和TP正常
改为采用CB03编译出来的emmc_appsboot.mbn(uboot部分)就显示OK了,说明和uboot有关。
/c4050-q4/bootable/bootloader/lk/project/msm8909.mk文件增加
ifeq ($(SIMCOM_PROJECT), C6000)DEFINES += MSM8909_C6000=1Endif
bootable\bootloader\lk\target\msm8909\include\target\display.h
改为
#if (MSM8909_CB03 || MSM8909_C6000)static struct gpio_pin reset_gpio = { "msmgpio", 8, 3, 1, 0, 1};#elsestatic struct gpio_pin reset_gpio = { "msmgpio", 25, 3, 1, 0, 1};#endif
然后显示就OK了。
(8) 用CB03编译,大小为852MB;用C6000编译,大小为846MB
编译出来的系统在点击桌面应用图标的时候,有提示音,做下面的修改
\device\qcom\common\common.mk
ifneq (, $(filter CB03, $(SIMCOM_PROJECT)))
改为
ifneq (, $(filter CB03 C6000,$(SIMCOM_PROJECT)))
到此编译出来的烧录就不存在上面的问题。
(9) 增加C6000相对应的设备树文件
\kernel\arch\arm\boot\dts\qcom\Makefile增加
dtb-$(CONFIG_ARCH_MSM8909) +=msm8909-sim.dtb \下面增加
dtb-$(CONFIG_ARCH_MSM8909_C6000) +=msm8909-1gb-qrd-skue-c6000.dtb
增加msm8909-1gb-qrd-skue-c6000.dts,此文件需要#include "msm8909-qrd-skue-c6000.dtsi",所以需要增加msm8909-qrd-skue-c6000.dtsi文件
msm8909-qrd-skue-cb03.dtsi文件内容如下
#include"msm8909-qrd-cb03.dtsi"需要增加c6000对应的。#include"msm8909-camera-sensor-skue.dtsi"#include"dsi-panel-otm9605ag-qhd-video.dtsi" //major QHD LCM replace otm9605a#include"dsi-panel-otm9605a-qhd-cb03-video.dtsi" //major QHD LCM replaceotm9605a CB03#include"dsi-panel-otm9605a-qhd-video.dtsi" //majorQHD LCM#include"dsi-panel-hx8389bg-qhd-video.dtsi" //minorQHD LCM#include"dsi-panel-nt35512-fwvga-video.dtsi" //majorFWVGA LCM#include"dsi-panel-ili9806e-fwvga-video.dtsi" //minorFWVGA LCM#include"dsi-panel-jd9161ba-fwvga-video.dtsi" //minorFWVGA LCM replace ili9806e#include"dsi-panel-ili9806e-wvga-video.dtsi" //minorWVGA LCM
但因为我们C6000和cb03的video部分一样,所以保留dsi-panel-otm9605a-qhd-cb03-video.dtsi,增加msm8909-qrd-c6000.dtsi文件,此文件下
#include "msm8909-cb03.dtsi"需要增加c6000对应的。#include "msm8909-pm8909.dtsi"#include"msm8909-pinctrl-cb03.dtsi"需要增加c6000对应的。
(10) vendor\qcom\proprietary\common\config\device-vendor.mk,
此文件下有增PRODUCT_LIST += CB03
我这里暂时没有增加
PRODUCT_LIST += C6000
编译出来的系统测试发现近距离传感器无效,接着验证
参考链接:
Android source build/envsetup.sh 及lunch 过程
http://blog.csdn.net/desler/article/details/47857889
Android编译系统详解(一)——build/envsetup.sh
http://www.xuebuyuan.com/2183167.html