zoukankan      html  css  js  c++  java
  • MocroDroid拾遗

    customize/make/xxx.mak 是跟硬件平台相关的编译配置文件,里面定义平台所使用的平台、芯片驱动等信息,是展讯里所谓的project。通过mk脚本可以将project 进行编译,生成最终的烧录文件

    目前支持的平台有sc8800g,sc8810

    文件中带3RDPARTY_XXX(XXX为大写)的,表示模块放在3rdparty相应目录xxx(xxx为小写)内,如果同时定义多个,需要使用:分隔,如

    3RDPARTY_CAMERA = ov5640:ov2655:ov7675:ov2640:gc0309:nmi601

    模块内可以存在hal/framework/kernel/special这几个目录,前面三个为对应到Android相应模块中的代码,special是为是兼容已调试好的模块(做以前模块到Android平台的适配层?)

    添加驱动包需要注意的地方:

    在编译系统的时候,会通过customize/perl/prebuild.pl去检查3rdparty/xxx/xxx/special/build.sh是否可执行
    如果不能执行,会导致customize/customer_cfg/$prj/.chiplist.cfg配置错误,从而导致编译失败
    所以在添加添加包后,需要将相应的build.sh设置为可执行

    open  OUTPUT_FILE, ">>$chiplist_dir" or die "$chiplist_dir: $!";
    print OUTPUT_FILE "# chiplist.cfg auto generated by Spradtrum\n\n";
    print OUTPUT_FILE "chip_path=\"";
    
    my @chiplists = &chiplist_get();
    foreach my $list(@chiplists)
    {
        die "$list is not execuable file\n"if(!-x $list);
            $list =~s/\/special\/build\.sh//i;
        $list =~s/^3rdparty//i;
        print OUTPUT_FILE "$list\n";
    }
    print OUTPUT_FILE "\"";
    close OUTPUT_FILE;

    customize/customer_cfg/XXX/res中存放着相关的rc配置文件,AndroidBoard.mk、BoardConfig.mk、sprd_apps.mk等重要的编译配置文件

    还有system.prop、键盘配置文件,分区表

    编译出错1

    frameworks/base/libs/utils/RefBase.cpp: 在成员函数‘void android::RefBase::weakref_type::trackMe(bool, bool)’中:
    frameworks/base/libs/utils/RefBase.cpp:507:67: 错误: 将‘const android::RefBase::weakref_impl’作为‘void android::RefBase::weakref_impl::trackMe(bool, bool)’的‘this’实参时丢弃了类型限定 [-fpermissive]
    make[1]: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1

    解决办法:编辑frameworks/base/libs/utils/Android.mk文件,修改

    LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

    LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

    编译出错2

    <命令行>:0:0: 错误: “_FORTIFY_SOURCE”重定义 [-Werror]
    <built-in>:0:0: 附注: 这是先前定义的位置
    cc1plus: all warnings being treated as errors
    make[1]: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] 错误 1

    修改build/core/combo/HOST_linux-x86.mk line 61:

    HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
    改为
    HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

    编译出错3

      CC [M]  /home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver/cy8c21x34_ts.o
    /home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver/cy8c21x34_ts.c: In function 'cy8c21x34_ts_probe':
    /home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver/cy8c21x34_ts.c:490: error: implicit declaration of function 'kzalloc'
    /home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver/cy8c21x34_ts.c:490: warning: assignment makes pointer from integer without a cast
    /home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver/cy8c21x34_ts.c:585: error: implicit declaration of function 'kfree'
    make[4]: *** [/home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver/cy8c21x34_ts.o] 错误 1
    make[3]: *** [_module_/home/yondy/android/idh.code/3rdparty/tp/CY8C21X34/special/driver] 错误 2
    make[2]: *** [sub-make] 错误 2
    make[1]: *** [all] 错误 2

    在cy8c21x34_ts.h中添加

     #include<linux/slab.h>

    下载android的kernel进行对比

    git clone https://android.googlesource.com/kernel/common -b android-2.6.39

    git clone --branch android-2.6.39 https://android.googlesource.com/kernel/common

    --------------------------------------

     ./mk -o=2sim sp6820a u adr 出错

    Use of uninitialized value $CUR_MODULE_PATH in string ne at customize/perl/main.pl line 373.
    2012/12/16 16:17:26 androiding ...
    update android
    SH_INFO:make_android.sh [PATH:/home/yondy]
    Couldn't locate the top of the tree.  Try setting TOP.

    编译时定位不到TOP目录,提示出现的位置 customize/shell/make_android.sh中

    source ${ANDROID_3RDPARTY_ANDROID_TOP}/build/envsetup.sh
    
    cd $1
    
    SHELLINFO echo "SH_INFO:make_android.sh [PATH:$PWD]" >&2
    
    mm

    其中的$1为空,也就是回到了home位置,导致无法编译
    向上找到实际调用make_android.sh的地方 customize/make/makefile.sprd

    android:
        $(hide) echo $(SHOWTIME) $@ing ...
        $(hide) echo $(CUR_ACTION) $(CUR_MODULE)
        $(hide) cd $(SHELL_SCRIPT) && \
        ($(BUILD_MODE) ./make_android.sh $(KMOD_PATH)) $(DEAL_STDOUT_MODULE)

    继续寻找KMOD_PATH
    来自customize/shell/main.pl的调用

    $makeCmd = "make -f customize/make/makefile.sprd $cmdArg @mOpts";
    
    #省略若干
    if ( ($CUR_MODULE_PATH ne "") && (($uMod eq "android") or ($uMod eq "ko")))
    {
    $result += &system_call("$makeCmd $uMod CUR_ACTION=$uAct CUR_MODULE=$uMod KMOD_PATH=$CUR_MODULE_PATH");
    }
    else
    {
    $result += &system_call("$makeCmd $uMod CUR_ACTION=$uAct CUR_MODULE=$uMod");
    }
    $CUR_MODULE_PATH是获取./mk -o=2sim sp6820a u adr 往后的参数,也就是在编译的时候,需要将编译目录加上,变成
    ./mk -o=2sim sp6820a u adr ./
    或者修改上面的代码,补充KMOD_PATH


    由上面可以看出

    展讯的new/update的主调用过程是:
    ./mk -> customize/shell/main.pl -> customize/make/makefile.sprd -> customize/shell/build.products.sh -> customize/customer_cfg/$selected_product/res/build.sh

    展讯的编译android主调用过程是:
    ./mk -> customize/shell/main.pl -> customize/make/makefile.sprd -> customize/shell/make_android.sh
    最终调用到/build/envsetup.sh,使用android的mm命令进行编译


    -----------------------------------------------------------------

    修改frameworks出现的问题
    Install: out/host/linux-x86/bin/apicheck
    Checking API: checkapi-current
    (unknown): error 5: Added public field android.provider.Settings.System.AVALIABLE_CARD_COUNTS
    
    ******************************
    You have tried to change the API from what has been previously approved.
    
    To make these errors go away, you have two choices:
       1) You can add "@hide" javadoc comments to the methods, etc. listed in the
          errors above.
    
       2) You can update current.xml by executing the following command:
             make update-api
    
          To submit the revised current.xml to the main Android repository,
          you will need approval.
    ******************************

    修改了frameworks的接口或字段以后,可以有两种选择
    1、通过make update-api 将新修改的内容更新到current.xml

      在展讯代码里是./mk -o=2sim sp6820a ua

    2、通过注解/**{@hide}*/将其标注为不公开

     ----------------------------------------------------------
    在最后阶段打包system.img出错
    Install system fs image: system.img
    Re-install system & userdata image
    SH_INFO:Error: Can't find .chiplist.cfg [LINE:8] PWD(/home/yondy/android/idh.code/3rdparty)
    make[1]:正在离开目录 `/home/yondy/android/idh.code'

    输出错误的文件位置在customize/customize_cfg/sp6820a/res/build.sh

    if [ -f ${ANDROID_CUSTOMIZE_BASE}/customer_cfg/${ANDROID_3RDPARTY_SELECTED_PRODUCT}/.chiplist.cfg ] ;then
        source ${ANDROID_CUSTOMIZE_BASE}/customer_cfg/${ANDROID_3RDPARTY_SELECTED_PRODUCT}/.chiplist.cfg
        echo "SH_INFO:chip_path($chip_path)" >&2
    else
        if [ "$1" != "clean" -a "$1" != "idh" -a "$1" != "idhb" ] ; then
        echo "SH_INFO:Error: Can't find .chiplist.cfg [LINE:$LINENO] PWD($PWD)" >&2
        exit 0
        fi
    fi

     经检查.chiplist.cfg是存在的,很大的可能是ANDROID_CUSTOMIZE_BASE或ANDROID_3RDPARTY_SELECTED_PRODUCT不正确


    customize/shell/build.products.sh中定义了ANDROID_3RDPARTY_SELECTED_PRODUCT;调用过程是build.products.sh >> build.sh

    export ANDROID_3RDPARTY_SELECTED_PRODUCT="$selected_product"
    unset ll_args[0]
    unset ll_args[1]
    [ $do_build ] && { $ANDROID_3RDPARTY_PRODUCTS_PATH/$selected_product/res/build.sh $subcmd ${ll_args[@]}; }
    cd $ANDROID_3RDPARTY_PRODUCTS_PATH/http://www.cnblogs.com/
    if [ ${ll_ota} = "1" ]; then
        make otapackage >&2
        customize/customer_cfg/$selected_product/res/build.sh update_image
    fi

    实际上只编译android时,是不会执行到build.products.sh的,所以需要在其他的地方定义ANDROID_3RDPARTY_SELECTED_PRODUCT

    customize/shell/build.3rdparty.common.sh定义了ANDROID_CUSTOMIZE_BASE

    export ANDROID_3RDPARTY_BASE=$(readlink -f ${ANDROID_3RDPARTY_ANDROID_TOP}/3rdparty)
    export ANDROID_CUSTOMIZE_BASE=$(readlink -f ${ANDROID_3RDPARTY_ANDROID_TOP}/customize)

    build.3rdparty.common.sh由customize/shell/make_android.sh调用

    而make.sprd在调用make_android.sh时,只带了一个参数($(BUILD_MODE) ./make_android.sh $(KMOD_PATH)) $(DEAL_STDOUT_MODULE)

    需要在这个地方将编译的project信息带进来,所以修改为($(BUILD_MODE) ./make_android.sh $(KMOD_PATH)  $(PROJECT)) $(DEAL_STDOUT_MODULE)

    make_android.sh中增加ANDROID_3RDPARTY_SELECTED_PRODUCT=$2

     ------------------------------------------------------

    添加wifi的预设文件

    /external/wpa_supplicant/wpa_supplicant.conf (/external/wpa_supplicant_6/wpa_supplicant/wpa_supplicant.conf) 可以配置wifi的默认SSID列表及关联优先级别(编译后是/etc/wifi/wpa_supplicant.conf)

    network={
        ssid="CMCC"
        key_mgmt=NONE
        priority=1
    }
    
    network={
        ssid="CMCC-EDU"
        key_mgmt=NONE
        priority=2
    }

     wifi驱动的相关参考见 http://blog.chinaunix.net/uid-27570663-id-3328552.html

    ----------------------------------

    ./mk -o=2sim sp6820a new 调用分析
    ./mk -> customize/shell/main.pl -> customize/make/makefile.sprd -> customize/shell/build.products.sh -> customize/customer_cfg/$selected_product/res/build.sh 

     customize/shell/main.pl

    对输入的参数进行匹配,检查是否合法,提取出$project等参数

    检查customize/make/${project}.mak文件是否存在

    &parse_custmake(${project}); 解析mak文件,将里面的配置解析后存放到$ENV{$KEY} = $VALUE;

    如果是new操作,则将project/mode/sim三个属性写入到 make.ini,再将make.ini的内容再读出来

    然后生成相应的编译参数,放到数组mOpts中存起来, 再生成对应的编译命令,先执行prebuild.pl  初始化,再执行相应的命令进行编译

                $kernel_ver = &gen_kernelver();
                $uboot_ver  = &gen_ubootver();
                push(@mOpts, "ENABLE_LOG=$log");
                push(@mOpts, "PROJECT=$project");
                push(@mOpts, "ROOTDIR=$enterdir");
                push(@mOpts, "CUR_SIM=$sim");
                push(@mOpts, "SUPPORT_WIFI=$wifi");
                push(@mOpts, "SUPPORT_BT=$bt");
                push(@mOpts, "SUPPORT_GPS=$gps");
                push(@mOpts, "SUPPORT_VT=$vt");
                push(@mOpts, "CUR_MODE=$mode");
                push(@mOpts, "KERNEL_VER=$kernel_ver");
                push(@mOpts, "UBOOT_VER=$uboot_ver");
                push(@mOpts, "IDH_PARAM=$idhparam");
                push(@mOpts, "SUPPORT_MPDP=$ismpdp");
                            push(@mOpts, "SUPPORT_GSENSOR=$lsensor");
                push(@mOpts, "SUPPORT_GSENSOR=$gsensor");
                push(@mOpts, "SUPPORT_MSENSOR=$msensor");
                if($cust_act eq "new")
                {
                    &system_call("rm -rf $build_folder");
                }
    ###################
    $cmdArg = "CMD_ARGU=\"@mOpts\"";
    $makeCmd = "make -f customize/make/makefile.sprd $cmdArg @mOpts";
    &mkdir_according_path($logdir, "false");

    执行prebuild.pl进行初始化

    &system_call("touch $logdir/${project}_prebuild.log");
            push @loglist, "$logdir/${project}_prebuild.log";
            &system_call("perl customize/perl/prebuild.pl  customize/make/${project}.mak   2>&1 | tee $logdir/${project}_prebuild.log");

    customize/build/prebuild.pl

    print "#####################################################################\n";
    print "step[1]: Judge some error conditions\n";
    print "#####################################################################\n";
    检查customize/make/${project}.mak是否存在
    
    print "#####################################################################\n";
    print "step[2]: parse customize/make/rules.mak\n";
    print "#####################################################################\n";
    &rules_parse();
    解析customize/make/rules.cfg,按行读取里面的内容,如CPY_FILE_TYPE = png:apk  进行指定文件的复制操作
    
    
    print "#####################################################################\n";
    print "step[3]: according to $filename generate hash table\n";
    print "#####################################################################\n";
    &generate_hash($filename);
    $kver = &kernel_ver_get();
    $uver = &uboot_ver_get();
    
    
    print "#####################################################################\n";
    print "step[4]: clean softlink and hardlink\n";
    print "#####################################################################\n";
    &system_call("perl customize/perl/cleanall.pl $prj  $makeValue{BUILD_SPRD_PLATFORM}");
    
    
    print "#####################################################################\n";
    print "step[5]: remove conflict file list \n";
    print "#####################################################################\n";
    my $conflictp  = "3rdparty/conflict/$prj";
    my $collision_file = "3rdparty/conflict/collision.lst";
    &system_call("rm -rf $collision_file");
    
    print "#####################################################################\n";
    print "step[6]: generate customer app feature control files\n";
    print "#####################################################################\n";
    &system_call("perl customize/perl/appcfg.pl  $prj");
    ##根据用户的参数,在下面的java和cpp中将对应的APP启用或禁用
    ##"3rdparty/app/$makeValue{$type}/special/android/frameworks/base/core/java/android/util/SprdFeatureUtils.java";
    ##"3rdparty/app/$makeValue{$type}/special/android/frameworks/base/include/utils/SprdFeatureUtils.h";
    print "#####################################################################\n";
    print "step[7]: generate customer kernel cfg files\n";
    print "#####################################################################\n";
    #&system_call("perl customize/perl/kcfg.pl  $prj");
    
    
    print "#####################################################################\n";
    print "generate kernel cfg folders and makefiles\n";
    print "step[8]: judge whether kernel cfg src folder and dst folder are exist\n";
    print "#####################################################################\n";
    ##将$kver/arch/arm/mach-$makeValue{BUILD_SPRD_PLATFORM}/board-$prj中与将ustomize/customer_cfg/$prj/kernel里的同名文件先删除
    ##也就是删除kernel/arch/arm/mach-sc8810/board-sp6820a里的文件
    print "#####################################################################\n";
    print "generate kernel cfg folders and makefiles\n";
    print "step[9]: generate softlink between customer_cfg kernel folder and kernel cfg folder\n";
    print "#####################################################################\n";
    ##将ustomize/customer_cfg/$prj/kernel里的文件软链接到$kver/arch/arm/mach-$makeValue{BUILD_SPRD_PLATFORM}/board-$prj

    print "#####################################################################\n"; 
    print "generate kernel cfg folders top Kconfig and Makefiles\n";
    print "step[10]: generate kernel cfg top folder makefiles\n";
    print "#####################################################################\n";

    print "#####################################################################\n";
    print "generate kernel cfg sub folders and sub makefiles\n";
    print "step[11]: generate kernel cfg sub folder makefiles\n";
    print "#####################################################################\n";

    print "#####################################################################\n";
    print "generate kernel driver folders and makefiles\n";
    print "step[12]: generate softlink between 3rdparty module kernel folder and\n";
    print "kernel driver folder\n";
    print "#####################################################################\n";
    ##遍历3rdparty中的驱动目录,根据mak中的驱动配置,

    print "####################################################################\n";
    print "generate customer cfg hal softlink and makefile\n";
    print "step[13]: generate softlink between customer cfg hal files and dst hal files\n";
    print "####################################################################\n";

    print "####################################################################\n";
    print "generate 3rdparty module hal/framework/special softlink and makefile\n";
    print "step[14]: generate hal/framework/specail softlink and makefile\n";
    print "####################################################################\n";

    print "####################################################################\n";
    print "generate uboot softlink and makefile\n";
    print "step[15]: generate uboot softlink and makefile\n";
    print "####################################################################\n";

    print "####################################################################\n";
    print "generate factory mode softlink and makefile\n";
    print "step[16]: generate engineering softlink and makefile\n";
    print "####################################################################\n";

    print "####################################################################\n";
    print "generate special module softlink and chiplist\n";
    print "step[17]: generate special module softlink and chiplist\n";
    print "####################################################################\n";

    print "####################################################################\n";
    print "check file collision condition\n";
    print "step[18]: check patch directory(3rdparty/customize)collision condition\n";
    print "####################################################################\n";
    &system_call("perl customize/perl/pcollision.pl $prj $collision_file $conflictp");

    print "####################################################################\n";
    print "generate dummy Android.mk in related folder\n";
    print " step[19]: generate dummy Android.mk\n";
    print "####################################################################\n";


    编译命令调用到customize/make/makefile.sprd 

    new:
        $(hide) echo $(SHOWTIME) $@ing ...
        $(hide) echo $(BUILD_MODE)
        $(hide) echo $(SIM_OPT)
        $(hide) echo $(SUPPORT_WIFI)
        $(hide) echo $(SUPPORT_BT)
        $(hide) echo $(SUPPORT_GPS)
        $(hide) echo $(SUPPORT_VT)
        $(hide) cd $(SHELL_SCRIPT) && \
        ($(BUILD_MODE) ./build.products.sh $(PROJECT) $(SIM_OPT) $(SUPPORT_WIFI) $(SUPPORT_BT) $(SUPPORT_GPS) $(SUPPORT_VT) fprebuild) $(DEAL_STDOUT_ACTION)



    customize/Shell/build.products.sh >> customize/customer_cfg/$selected_product/res/build.sh update_image

    customize/customer_cfg/Sp6820a/res/build.sh
    source customize/customer_cfg/Sp6820a/.chiplist.cfg
    source  costomize/shell/build.3rdparty.common.sh
    将编译用的文件复制到vendor目录
    customize/customer_cfg/Sp6820a/res/AndroidBoard.mk:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/BoardConfig.mk:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/apns-conf.xml:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/BoardConfig_IDH.mk:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/rc.local:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/vold.fstab:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/system.prop:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/sprd-keypad.kcm:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/sprd-keypad.kl:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/sprd_apps.mk:./vendor/sprd/product
    customize/customer_cfg/Sp6820a/res/init.sp6820.3rdparty.rc:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/init.sp6820.rc:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/modem_bins:./vendor/sprd/hsdroid
    customize/customer_cfg/Sp6820a/res/recovery.fstab:./vendor/sprd/hsdroid


  • 相关阅读:
    【leetcode】1365. How Many Numbers Are Smaller Than the Current Number
    【leetcode】1363. Largest Multiple of Three
    【leetcode】1362. Closest Divisors
    【leetcode】1361. Validate Binary Tree Nodes
    【leetcode】1360. Number of Days Between Two Dates
    【leetcode】1359. Count All Valid Pickup and Delivery Options
    【leetcode】1357. Apply Discount Every n Orders
    【leetcode】1356. Sort Integers by The Number of 1 Bits
    ISE应用入门的一些问题
    DDR的型号问题
  • 原文地址:https://www.cnblogs.com/yondy/p/2748922.html
Copyright © 2011-2022 走看看