《Android系统移植技术详解【强烈推荐非常经典】.doc》由会员分享,可在线阅读,更多相关《Android系统移植技术详解【强烈推荐非常经典】.doc(73页珍藏版)》请在三一办公上搜索。
1、Android系统开发编译环境配置主机系统:Ubuntu9.04(1)安装如下软件包sudo apt-get install git-core sudo apt-get install gnupgsudo apt-get install sun-java5-jdksudo apt-get install flexsudo apt-get install bisonsudo apt-get install gperfsudo apt-get install libsdl-devsudo apt-get install libesd0-devsudo apt-get install build-e
2、ssentialsudo apt-get install zipsudo apt-get install curlsudo apt-get install libncurses5-devsudo apt-get install zlib1g-devandroid编译对java的需求只支持jdk5.0低版本,jdk5.0 update 12版本和java 6不支持。(2)下载repo工具curl http:/android.git.kernel.org/repo /bin/repochmod a+x /bin/repo(3)创建源代码下载目录:mkdir /work/android-froyo-
3、r2(4)用repo工具初始化一个版本(以android2.2r2为例)cd /work/android-froyo-r2repo init -u git:/android.git.kernel.org/platform/manifest.git -b froyo初始化过程中会显示相关的版本的TAG信息,同时会提示你输入用户名和邮箱地址,以上面的方式初始化的是android2.2 froyo的最新版本,android2.2本身也会有很多个版本,这可以从TAG信息中看出来,当前froyo的所有版本如下:* new tag android-2.2.1_r1 - android-2.2.1_r1*
4、new tag android-2.2_r1 - android-2.2_r1* new tag android-2.2_r1.1 - android-2.2_r1.1* new tag android-2.2_r1.2 - android-2.2_r1.2* new tag android-2.2_r1.3 - android-2.2_r1.3* new tag android-cts-2.2_r1 - android-cts-2.2_r1* new tag android-cts-2.2_r2 - android-cts-2.2_r2* new tag android-cts-2.2_r3
5、 - android-cts-2.2_r3这样每次下载的都是最新的版本,当然我们也可以根据TAG信息下载某一特定的版本如下:repo init -u git:/android.git.kernel.org/platform/manifest.git -b android-cts-2.2_r3(5)下载代码repo syncfroyo版本的代码大小超过2G,漫长的下载过程。(6)编译代码cd /work/android-froyo-r2makeUbuntu下使用Simba服务实现局域网内文件共享Ubuntu下安装Simba服务器将linux电脑上的内容共享,同一局域网内的另外一台Windows
6、PC即可访问其共享内容,从而实现Windows电脑向访问本地文件一样访问Linux文件系统的内容。(1)安装Simaba服务器sudo apt-get install samba(2)安装samba图形化配置软件sudo apt-get install system-config-samba(3)创建一个Simba专用用户从“系统”“系统管理”“用户和组”,来创建。如图,先点击“解锁”,然后“添加新用户”然后输入新用户名字(如Simba)和密码(如111111),然后在“高级”里面,选择“主组”为sambashare后点击确定即可一句话来概括,就是创建一个主组为sambashare的用户(4)
7、配置samba共享从“系统”“系统管理”samba“,运行配置界面然后”首选项“”服务器设置“。点击:安全性,在最后的”来宾帐号“里面, 选择我们新建立的那个用户simba后点击确定(5)修改samba配置文件打开/etc/samba/smb.conf,修改valid users = XXXX为valid users = simba(6)重启samba服务sudo /etc/init.d/samba restart(7)添加共享文件从“系统”“系统管理”samba“,运行配置界面点击添加来添加共享文件夹,点击浏览来选择需要共享的文件夹,选择可擦写和显示,点击访问可以设置访问权限,最好设置成允许
8、所有用户访问本文来自CSDN博客,转载请标明出处:Ubuntu下tftp服务器的创建实验平台:Ubuntu9.04(1)安装tftp服务sudo apt-get install tftp tftpd openbsd-inetd(2)在根目录下创建文件夹 tftpboot文件夹并修改权限 cd / sudo mkdir tftpboot sudo chmod 777 tftpboot(3)修改/etc/inetd.conf文件如下:tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot(4)开启tftp服务su
9、do /etc/init.d/openbsd-inetd reload sudo in.tftpd -l /tftpboot(5)重启电脑,然后将测试文件放入/tftpboot目录下即可开始测试,出现问题可能一般都是权限问题/tftpboot目录下的文件访问权限改成0777本文来自CSDN博客,转载请标明出处:创建一个新的Android产品项目从google网站上下载的android源代码编译时默认是编译google设定的产品,如果要开发自己的产品,则需要重新定义一个产品项目,过程如下:首先我们定义产品的规格,举例如下:公司名称 ardent产品名称 MTP主板名称 merlin然后安装下面的
10、步骤新建产品项目:(1)在源代码目录下创建一个用户目录mkdir vendor(2)在用户目录下创建一个公司目录mkdir vendor/merlin(3)在公司目录下创建一个products目录mkdir vendor/merlin/products(4)在上面创建的products下创建一个产品makefile文件MTP.mk,内容如下:PRODUCT_PACKAGES := AlarmClock Email Fallback Launcher2 Music Camera Settings LatinIME NotePad SoundRecorder Bluetooth CertInsta
11、ller DeskClock$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)# OverridesPRODUCT_MANUFACTURER := ardentPRODUCT_BRAND := ardentPRODUCT_NAME := MTPPRODUCT_MODEL := MultiMedia Touch PhonePRODUCT_DEVICE := merlinPRODUCT_LOCALES := zh_CN产品makefile文件的编写有一套规则,详细情况见此文后面的补充内容。(5)在vendor/merlin/prod
12、ucts目录下创建一个AndroidProducts.mk文件,定义Android产品配置文件的路径,具体如下:PRODUCT_MAKEFILES := $(LOCAL_DIR)/MTP.mk(6)在公司目录下创建一个主板目录mkdir vendor/ardent/merlin(7)在主板目录下新建一个主板配置文件BoardConfig.mk,内容如下:TARGET_NO_BOOTLOADER := trueTARGET_NO_KERNEL := trueTARGET_CPU_ABI := armeabiBOARD_USES_GENERIC_AUDIO := trueUSE_CAMERA_ST
13、UB := true(8)如果你希望修改系统属性,则可以在主板目录下新建一个system.prop文件,该文件中可以修改系统属性,举例如下:# system.prop for # This overrides settings in the products/generic/system.prop file# rild.libpath=/system/lib/libreference-ril.so# rild.libargs=-d /dev/ttyS0(9)在主板目录下建议一个Android的主板配置文件AndroidBoard.mk,此文件是编译系统接口文件,内容如下:# make file
14、 for new hardware from #LOCAL_PATH := $(call my-dir)# this is here to use the pre-built kernelifeq ($(TARGET_PREBUILT_KERNEL),)TARGET_PREBUILT_KERNEL := $(LOCAL_PATH)/kernelendiffile := $(INSTALLED_KERNEL_TARGET)ALL_PREBUILT += $(file)$(file): $(TARGET_PREBUILT_KERNEL) | $(ACP) $(transform-prebuilt-
15、to-target)# no boot loader, so we dont need any of that stuff. #LOCAL_PATH := vendor/ardent/merlininclude $(CLEAR_VARS)# include more board specific stuff here? Such as Audio parameters. #(10)编译新的项目. build/envsetup.shmake PRODUCT-MTP-user补充内容:(1)上面的新建的几个文件的编写可以参考build/target/board/generic目录下的Android
16、Board.mk,BoardConfig.mk和system.prop(2)产品makefile的编写规则,变量定义解释如下:PRODUCT_NAME 终端用户可见的产品名称,对应到“Settings“中的“About the phone”信息 PRODUCT_MODEL End-user-visible name for the end product PRODUCT_LOCALES 1个以空格分隔开的两个字母的语言码加上2字节的国家码的列表,影响到Settings中的语言,时间,日期和货币格式设置, 举例:en_GB de_DE es_ES fr_CAPRODUCT_PACKAGES 需要
17、安装的APK应用程序列表PRODUCT_DEVICE 工作设计名称,即主板名称PRODUCT_MANUFACTURER 生产厂家PRODUCT_BRAND 软件设计针对的客户品牌 PRODUCT_PROPERTY_OVERRIDES 以key=value为格式的属性列表PRODUCT_COPY_FILES 文件复制列表,格式为“原文件路径:目的文件路径”,编译过程中会按照此规则复制文件 PRODUCT_OTA_PUBLIC_KEYS 产品的OTA公共密匙列表PRODUCT_POLICY 声明此产品使用的政策 PRODUCT_PACKAGE_OVERLAYS 指示是否使用默认资源或添加任何产品特
18、定的资源,例如:vendor/acme/overlayPRODUCT_CONTRIBUTORS_FILE HTML文件中包含项目的贡献者 PRODUCT_TAGS 以空格分隔开的指定产品关键词列表本文来自CSDN博客,转载请标明出处:ttp:/制作ubifs文件系统1,安装相关的软件包apt-get install liblzo2-dev2,获取相关的工具mkfs.ubifs和ubinize这两个工具是制作ubifs文件系统的时候用到,它们是mtd-utils工具包中的内容,mtd-utils工具包你可以从下面的网站下载和编译出来:官方网站:http:/www.linux-mtd.infrad
19、ead.org/index.html资源下载网站:http:/git.infradead.org/3,创建一个create-ubifs.sh脚本,主要是调用mkfs.ubifs和ubinize工具和相关参数来制作ubifs文件系统,内容如下:#!/bin/bash# Script to generate ubifs filesystem image. # ubinize configuration fileconfig_file=rootfs_ubinize.cfg# Function to check result of the commandcheck_result() if $? -ne
20、 0 then echo FAILEDelse echo SUCCESSFULfi# Function to check whether an application existscheck_program() for cmd in $do which $cmd /dev/null 2&1 if $? -ne 0 then echo echo Cannot find command $cmd echo exit 1 fidoneif $# -ne 5 then echo echo Usage: create-ubifs.sh page_size_in_bytes pages_per_block
21、 partition_size_in_bytes blocks_per_device path_to_rootfs echo exitfipage_size_in_bytes=$1echo Page size $page_size_in_bytesbytes.pages_per_block=$2echo Pages per block $pages_per_blockpartition_size_in_bytes=$3echo File-system partition size $partition_size_in_bytesbytes.blocks_per_device=$4echo Bl
22、ocks per device $blocks_per_devicepath_to_rootfs=$5# wear_level_reserved_blocks is 1% of total blcoks per devicewear_level_reserved_blocks=expr $blocks_per_device / 100echo Reserved blocks for wear level $wear_level_reserved_blocks#logical_erase_block_size is physical erase block size minus 2 pages
23、for UBIlogical_pages_per_block=expr $pages_per_block - 2logical_erase_block_size=expr $page_size_in_bytes * $logical_pages_per_blockecho Logical erase block size $logical_erase_block_sizebytes.#Block size = page_size * pages_per_blockblock_size=expr $page_size_in_bytes * $pages_per_blockecho Block s
24、ize $block_sizebytes.#physical blocks on a partition = partition size / block sizepartition_physical_blocks=expr $partition_size_in_bytes / $block_sizeecho Physical blocks in a partition $partition_physical_blocks#Logical blocks on a partition = physical blocks on a partitiion - reserved for wear le
25、velpatition_logical_blocks=expr $partition_physical_blocks - $wear_level_reserved_blocksecho Logical blocks in a partition $patition_logical_blocks#File-system volume = Logical blocks in a partition * Logical erase block sizefs_vol_size=expr $patition_logical_blocks * $logical_erase_block_sizeecho F
26、ile-system volume $fs_vol_sizebytes.echoecho Generating configuration file.echo rootfs-volume $config_fileecho mode=ubi $config_fileecho image=rootfs_ubifs.img $config_fileecho vol_id=0 $config_fileecho vol_size=$fs_vol_size $config_fileecho vol_type=dynamic $config_fileecho vol_name=system $config_
27、fileecho# Note: Check necessary program for installation#echo -n Checking necessary program for installation.#check_program mkfs.ubifs ubinize#echo Done#Generate ubifs imageecho -n Generating ubifs./mkfs.ubifs -x lzo -m $page_size_in_bytes -e $logical_erase_block_size -c $patition_logical_blocks -o
28、rootfs_ubifs.img -d $path_to_rootfscheck_resultecho -n Generating ubi image out of the ubifs./ubinize -o ubi.img -m $page_size_in_bytes -p $block_size -s $page_size_in_bytes $config_file -vcheck_resultrm -f rootfs_ubifs.imgrm -f $config_file(4)将mkfs.ubifs和ubinize以及create-ubifs.sh放置在同一目录下,然后调用create-
29、ubifs.sh即可创建ubifs文件系统,create-ubifs.sh用法如下:create-ubifs.sh page_size_in_bytes(页大小) pages_per_block(每个扇区的页数量) partition_size_in_bytes(分区大小) blocks_per_device(扇区数量) path_to_rootfs(文件系统路径)举例如下:./create-ubifs.sh 2048 64 83886080 4096 ./rootfs上面命令的意思是调用create-ubifs.sh将当前目录下的rootfs文件夹的内容制作成ubifs文件系统,nand f
30、lash的页大小为2k,每个扇区有64页,总共有4096个扇区,要制作的文件系统的大小为83886080字节。本文来自CSDN博客,转载请标明出处:android编译系统makefile(Android.mk)写法android编译系统的makefile文件Android.mk写法如下(1)Android.mk文件首先需要指定LOCAL_PATH变量,用于查找源文件。由于一般情况下Android.mk和需要编译的源文件在同一目录下,所以定义成如下形式:LOCAL_PATH:=$(call my-dir)上面的语句的意思是将LOCAL_PATH变量定义成本文件所在目录路径。(2)Android.
31、mk中可以定义多个编译模块,每个编译模块都是以include $(CLEAR_VARS)开始以include $(BUILD_XXX)结束。include $(CLEAR_VARS)CLEAR_VARS由编译系统提供,指定让GNU MAKEFILE为你清除除LOCAL_PATH以外的所有LOCAL_XXX变量,如LOCAL_MODULE,LOCAL_SRC_FILES,LOCAL_SHARED_LIBRARIES,LOCAL_STATIC_LIBRARIES等。include $(BUILD_STATIC_LIBRARY)表示编译成静态库include $(BUILD_SHARED_LIBRA
32、RY)表示编译成动态库。include $(BUILD_EXECUTABLE)表示编译成可执行程序(3)举例如下(frameworks/base/libs/audioflinger/Android.mk):LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS) 模块一ifeq ($(AUDIO_POLICY_TEST),true) ENABLE_AUDIO_DUMP := trueendifLOCAL_SRC_FILES:= AudioHardwareGeneric.cpp AudioHardwareStub.cpp AudioHardwareInte
33、rface.cppifeq ($(ENABLE_AUDIO_DUMP),true) LOCAL_SRC_FILES += AudioDumpInterface.cpp LOCAL_CFLAGS += -DENABLE_AUDIO_DUMPendifLOCAL_SHARED_LIBRARIES := libcutils libutils libbinder libmedia libhardware_legacyifeq ($(strip $(BOARD_USES_GENERIC_AUDIO),true) LOCAL_CFLAGS += -DGENERIC_AUDIOendifLOCAL_MODU
34、LE:= libaudiointerfaceifeq ($(BOARD_HAVE_BLUETOOTH),true) LOCAL_SRC_FILES += A2dpAudioInterface.cpp LOCAL_SHARED_LIBRARIES += liba2dp LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP LOCAL_C_INCLUDES += $(call include-path-for, bluez)endifinclude $(BUILD_STATIC_LIBRARY) 模块一编译成静态库include $(CLEAR_VARS) 模块
35、二LOCAL_SRC_FILES:= AudioPolicyManagerBase.cppLOCAL_SHARED_LIBRARIES := libcutils libutils libmediaifeq ($(TARGET_SIMULATOR),true) LOCAL_LDLIBS += -ldlelse LOCAL_SHARED_LIBRARIES += libdlendifLOCAL_MODULE:= libaudiopolicybaseifeq ($(BOARD_HAVE_BLUETOOTH),true) LOCAL_CFLAGS += -DWITH_A2DPendififeq ($(
36、AUDIO_POLICY_TEST),true) LOCAL_CFLAGS += -DAUDIO_POLICY_TESTendifinclude $(BUILD_STATIC_LIBRARY) 模块二编译成静态库include $(CLEAR_VARS) 模块三LOCAL_SRC_FILES:= AudioFlinger.cpp AudioMixer.cpp.arm AudioResampler.cpp.arm AudioResamplerSinc.cpp.arm AudioResamplerCubic.cpp.arm AudioPolicyService.cppLOCAL_SHARED_LI
37、BRARIES := libcutils libutils libbinder libmedia libhardware_legacyifeq ($(strip $(BOARD_USES_GENERIC_AUDIO),true) LOCAL_STATIC_LIBRARIES += libaudiointerface libaudiopolicybase LOCAL_CFLAGS += -DGENERIC_AUDIOelse LOCAL_SHARED_LIBRARIES += libaudio libaudiopolicyendififeq ($(TARGET_SIMULATOR),true)
38、LOCAL_LDLIBS += -ldlelse LOCAL_SHARED_LIBRARIES += libdlendifLOCAL_MODULE:= libaudioflingerifeq ($(BOARD_HAVE_BLUETOOTH),true) LOCAL_CFLAGS += -DWITH_BLUETOOTH -DWITH_A2DP LOCAL_SHARED_LIBRARIES += liba2dpendififeq ($(AUDIO_POLICY_TEST),true) LOCAL_CFLAGS += -DAUDIO_POLICY_TESTendififeq ($(TARGET_SI
39、MULATOR),true) ifeq ($(HOST_OS),linux) LOCAL_LDLIBS += -lrt -lpthread endifendififeq ($(BOARD_USE_LVMX),true) LOCAL_CFLAGS += -DLVMX LOCAL_C_INCLUDES += vendor/nxp LOCAL_STATIC_LIBRARIES += liblifevibes LOCAL_SHARED_LIBRARIES += liblvmxservice# LOCAL_SHARED_LIBRARIES += liblvmxipcendifinclude $(BUIL
40、D_SHARED_LIBRARY) 模块三编译成动态库(4)编译一个应用程序(APK) LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Name of the APK to build LOCAL_PACKAGE_NAME := LocalPackage # Tell it to build an APK include $(BUILD_PACK
41、AGE)(5)编译一个依赖于静态Java库(static.jar)的应用程序 LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) # List of static libraries to include in the package LOCAL_STATIC_JAVA_LIBRARIES := static-library # Build all java files in the java subdirectory LOCAL_SRC_FILES := $(call all-subdir-java-files) # Name of the APK to build LOCAL_PACKAGE_NAME := LocalPackage # Tell it to build an APK include $(BUILD_PACKAGE)(6)编译一个需要用平台的key签名的应用程序 LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS)