zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

Android系统移植与调试之------->Amlogic方案编译步骤

Androidamp调试系统 编译 方案 步骤 gt
2023-09-27 14:29:34 时间

切换目录到 /home/roco/work/amlogic/Document中,拷贝amlogic-tool.zip到 /home/pyou下解压生成 amlogic-tool目录

该目录下有以下3个压缩文件

1. arm-2010q1-188-arm-none-eabi-i686-pc-linux-gnu.tar.bz2

2. arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu1.tar.bz2

3. gnutools-arc2.3-p0-ubuntu-9.04-2010-5-10.tar.bz2

由于前面两个解压的目录相同,所以新建一个目录188,并将arm-2010q1-188-arm-none-eabi-i686-pc-linux-gnu.tar.bz2移到188目录下,解压生成目录/amlogic-tool/188/arm-2010q

切换目录到/amlogic-tool,分别解压gnutools-arc2.3-p0-ubuntu-9.04-2010-5-10.tar.bz2文件和arm-2010q1-202-arm-none-linux-gnueabi-i686-pc-linux-gnu1.tar.bz2 文件,生成目录/amlogic-tool/arm-2010q1和目录/amlogic-tool/opt


2.2 修改.bashrc 文件添加环境变量

切换目录到 /home/pyou目录下,使用ll命令查文件列表,然后使用vim命令修改.bashrc 文件,在该文件最后添加环境变量。如下所示:

PATH="$PATH:/home/pyou/amlogic-tool/188/arm-2010q1/bin:/home/pyou/amlogic-tool/arm-2010q1/bin:/home/pyou/amlogic-tool/opt/gnutools/arc2.3-p0/elf32-4.2.1/bin:/home/pyou/amlogic-tool/opt/gnutools/arc2.3-p0/uclibc-4.2.1/bin"



切换目录到~/mx0831-0525/uboot目录下

使用make help |grep roco 查看项目配置,查看命令列表,然后再命令列表中查找到make m6_roco_1212_config命令并使用该命令进行编译,编译完后再使用make命令进行编译,在~/mx0831-0525/uboot/build目录下会生成u-boot.bin文件

1. make m6_roco_1212_config

2. Make

3. cp build/u-boot.bin  ../device/other/TBDG1073


4. 编译项目

这个命令是用来将envsetup.sh里的所有用到的命令加载到环境变量里去,我们来分析下它。

envsetup.sh里的主要命令如下:

function help() # 显示帮助信息
function get_abs_build_var()# 获取绝对变量
function get_build_var()# 获取绝对变量
function check_product()# 检查product
function check_variant()# 检查变量
function setpaths()  # 设置文件路径
function printconfig()# 打印配置
function set_stuff_for_environment()   # 设置环境变量
function set_sequence_number()     # 设置序号
function settitle()  # 设置标题
function choosetype()  # 设置type
function chooseproduct()   # 设置product
function choosevariant()   # 设置variant
function tapas()   # 功能同choosecombo
function choosecombo()   # 设置编译参数
function add_lunch_combo()   # 添加lunch项目
function print_lunch_menu()  # 打印lunch列表
function lunch()# 配置lunch
function m()# make from top
function findmakefile()  # 查找makefile
function mm()  # make from current directory
function mmm()   # make the supplied directories
function croot()# 回到根目录
function cproj()
function pid()
function systemstack()
function gdbclient()
function jgrep()# 查找java文件
function cgrep()   # 查找c/cpp文件
function resgrep()
function tracedmdump()
function runhat()
function getbugreports()
function startviewserver()
function stopviewserver()
function isviewserverstarted()
function smoketest()
function runtest()
function godir () # 跳到指定目录 405

 # add_lunch_combo函数被多次调用,就是它来添加Android编译选项
 # Clear this variable.  It will be built up again when the vendorsetup.sh
 406 # files are included at the end of this file.
 # 清空LUNCH_MENU_CHOICES变量,用来存在编译选项
 407 unset LUNCH_MENU_CHOICES
 408 function add_lunch_combo()   
 409 {
 410     local new_combo=$1         # 获得add_lunch_combo被调用时的参数
 411     local c
     # 依次遍历LUNCH_MENU_CHOICES里的值,其实该函数第一次调用时,该值为空
 412     for c in ${LUNCH_MENU_CHOICES[@]} ; do 
 413         if [ "$new_combo" = "$c" ] ; then    # 如果参数里的值已经存在于LUNCH_MENU_CHOICES变量里,则返回
 414             return
 415         fi
 416     done
     # 如果参数的值不存在,则添加到LUNCH_MENU_CHOICES变量里
 417     LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
 418 }


# 这是系统自动增加了一个默认的编译项 generic-eng
 420 # add the default one here
 421 add_lunch_combo generic-eng    # 调用上面的add_lunch_combo函数,将generic-eng作为参数传递过去
 422 
 423 # if were on linux, add the simulator.  There is a special case
 424 # in lunch to deal with the simulator
 425 if [ "$(uname)" = "Linux" ] ; then
 426     add_lunch_combo simulator
 427 fi

# 下面的代码很重要,它要从vendor目录下查找vendorsetup.sh文件,如果查到了,就加载它
1037 # Execute the contents of any vendorsetup.sh files we can find.
1038 for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/build/vendorsetup.sh 2  /dev/null`
1039 do
1040     echo "including $f"
1041    . $f       # 执行找到的脚本,其实里面就是厂商自己定义的编译选项
1042 done
1043 unset f

envsetup.sh其主要作用如下:

1. 加载了编译时使用到的函数命令,如:help,lunch,m,mm,mmm等
2. 添加了两个编译选项:generic-eng和simulator,这两个选项是系统默认选项
3. 查找vendor/ -厂商目录 /和vendor/ 厂商目录 /build/目录下的vendorsetup.sh,如果存在的话,加载执行它,添加厂商自己定义产品的编译选项
 其实,上述第3条是向编译系统添加了厂商自己定义产品的编译选项,里面的代码就是:add_lunch_combo xxx-xxx。

根据上面的内容,可以推测出,如果要想定义自己的产品编译项,简单的办法是直接在envsetup.sh最后,添加上add_lunch_combo myProduct-eng,当然这么做,不太符合上面代码最后的本意,我们还是老实的在vendor目录下创建自己公司名字,然后在公司目录下创建一个新的vendorsetup.sh,在里面添加上自己的产品编译项

 


#touch vendor/farsight/vendorsetup.sh

#echo "add_lunch_combo fs100-eng"   vendor/farsight/vendorsetup.sh


 

这样,当我们在执行source build/envsetup.sh命令的时候,可以在shell上看到下面的信息:

 


按数字17,因为该项目是17对应的项目TBG1073-user 。

lunch命令是envsetup.sh里定义的一个命令,用来让用户选择编译项,来定义Product和编译过程中用到的全局变量。

我们一直没有说明前面的fs100-eng是什么意思,现在来说明下,fs100是我定义的产品的名字,eng是产品的编译类型,除了eng外,还有user, userdebug,分别表示:

eng: 工程机,

user:最终用户机

userdebug:调试测试机

tests:测试机 

由此可见,除了eng和user外,另外两个一般不能交给最终用户的,记得m8出来的时候,先放出了一部分eng工程机,然后出来了user机之后,可以用工程机换。

 

那么这四个类型是干什么用的呢?其实,在main.mk里有说明,在Android的源码里,每一个目标(也可以看成工程)目录都有一个Android.mk的makefile,每个目标的Android.mk中有一个类型声明:LOCAL_MODULE_TAGS,这个TAGS就是用来指定,当前的目标编译完了属于哪个分类里。

 

    PS:Android.mk和Linux里的makefile不太一样,它是Android编译系统自己定义的一个makefile来方便编译成:c,c++的动态、静态库或可执行程序,或java库或android的程序,

4.3 使用make custom1 命令

清除make clean

打补丁make custom1

打完补丁后记得执行以下命令

find . -name *.xml.orig | xargs rm 

find . -name *.xml.reg | xargs rm

        find . -name *.xml.rej | xargs rm

4.4 使用make otapackage –j8 命令

执行完该命令后会在out/target/product/TBDG1073/目录下生成一些zip升级压缩包,如:out/target/product/TBDG1073/TBDG1073-ota-20130708.v016.zip  

生成的目标平台的相关的文件在out/target/product/board_name/中(board_name要与目标平台相匹配)。


recovery模式启动的镜像,

由header+kernel(uImage)+ramdisk-recovery.img构成


==================================================================================================

  作者:欧阳鹏  欢迎转载,与人分享是进步的源泉!

  转载请保留原文地址:http://blog.csdn.net/ouyang_peng

==================================================================================================





字节卷动 You will never know how excellent you are unless you impel yourself once.