xcode移植到android
2017-03-31 17:26:00 weixin_34396902 阅读数 23

在写这篇文章  此刻的我心已是伤痕累累


一直从事iOS开发工作  经常使用的开发工具也自然 是Xcode

要想移植到Android studio  首先下载安装 Android studio

进入官网  官网链接  可以看到


3109935-1095ab0b3f9cae5c.png

点击下载按钮 进行下载操作

至于 Android studio 的配置  暂且先不说了

打开下载好的 Android studio 


3109935-1e1cb3a7bbab1271.png

点击红色区域  找到自己的项目后 点击ok 按钮


3109935-45e61bef1f2b78a0.png

此刻进入到 Android studio 的界面 等待片刻   运行按钮 变绿后 点击


3109935-d24e5a3aba021e38.png

如果使用的是模拟器 在点击运行前一个步骤


3109935-02ae084091be368c.png

点击此按钮 进行模拟器的选择  这个过程 需要注意的是

选择模拟器时 ABI 一定要与当前计算机相一致  (使用 mac  应该选择 armeabi )

模拟器存在的情况下  点击运行按钮  等待一段时间  会发现 项目不会装在模拟器上 并且程序会终止

在Android studio 的Android monitor 中看到 提示 找不到 libMyGame.so 

这个原因 是因为没有进行编译   我们需要做的是

打开终端  进入 项目的目录  使用命令 cocos compile -p android --android-studio

发现特别坑的地方是   提示我  没有update  这个命令 让我使用Android studio  我天  真奇怪

 折腾好久后  发现下载的Android  tools 有问题 就是下面红色框中的文件

3109935-f0b059d563ecd49b.png

我们需要做的是 打开 官网链接  找到 并下载


3109935-5910452ece6cae11.png

下载完成后 覆盖原来的文件  即可  再次使用终端  输入之前的命令 完美  搞定

运行 项目  发现 闪退  即  还是没法在模拟器上显示

原因1: 加入的图片 或者新建的文件夹名称 不可是中文

原因2: 加入的图片 应该直接放在Resources文件夹中 如下图


3109935-f8a07599861077b3.png
2009-11-21 02:06:00 zez 阅读数 818

1、你需要修改AT命令;2、你需要重新对信息进行编、解码,这里主要是pdu与text之间编码的互换。由于目前只是调试sms所以主要的工作还是在信息的编、解码上;3、你需要改变一些状态,来绕过应用层对modem状态的判断,这样才能够始你的代码顺利运行起来。

framework层,用java实现,代码结构相对复杂,对于sms模块,主要关注:frameworks/base/telephony /java/com/android/internal/telephony/下以SMS开头的代码以及RIL.java,这个是framework与 ril通信的主要实现。
对ril层,主要关注:hardware/ril/reference-ril,从上面google官方的文档也可以知道,ril层移植主要涉及的内容。

从logcat日志的内容,可以确定framework层发给ril的短信内容采用的是pdu编码,而CDMA EVDO目前并不支持pdu编码的信息,对此我们可以有两种选择:1、修改framework层,把下发给ril的信息改为text mode的信息;2、修改ril,把pdu mode的信息还原成text mode的内容再发送。当然从效率上讲,第二种方式肯定低,不过考虑的源码代码都是对字符串的处理,如果修改framework层,则必将导致很多问题的出现,比如strlen、asrpintf等调用都会出问题(在text
mode下串尾符并能标示内容的结束,而且还经常出现)。因此在移植过程中对串尾符的处理是需要解决的问题之一。

信息内容的编解码
http://www.dreamfabric.com/sms/ (给出了在pdu mode下发短信和收短信时的信息编码方式)
http://stud.usv.ro/~amurariu/SMS%20and%20PDU%20format.htm(一个在线的pdu编解码工具,不过有一点需要注意,你用logcat工具dump出来的短信内容并不能通过该软件正确解码,原因出在android在编码信息时少了一个octet,只要在pdu帧短信内容长度前加“aa”就能正确解码,该值是短信有效期)

就先简单的介绍这些吧!

2013-07-30 23:58:00 weixin_33704591 阅读数 21

在串口,uboot环境里面输入fastboot
(1)先把uboot烧写
     fastboot flash uboot u-boot.bin
(2)先把kernel烧写
     fastboot flash kernel zImage
(3)先把system烧写
     fastboot flash system system.img

具体操作步骤见链接:http://download.csdn.net/detail/klcf0220/5842403

2012-01-09 13:42:39 simplehedy 阅读数 471
 
Android平台移植应该做两步工作移动通信,通信工程师的家园,通信人才,求职招聘,网络优化,通信工程,出差住宿,通信企业黑名单:K7b4x'i6k*H6p%|
Android系统的移植工作的目的是为了在特定的硬件上运行Android系统。在移植的过程中,把握关键要点,减少工作量是一个重要的方面。从工作的角度,通常的方法为,首先要熟悉硬件抽象层的接口,其次要集成和复用已有的驱动程序,主要的工作量在硬件抽象层的实现中。为了更好地理解和调试系统,也应该适当地了解上层对硬件抽象层的调用情况。.O1Y+L,C!K
  移植方面主要的工作有两个部分:
5y5X'e"V-P/b.C |  国内领先的通信技术论坛Linux驱动mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。;d0s*U!S.x)o7L
Android系统硬件抽象层移动通信,通信工程师的家园,通信人才,求职招聘,网络优化,通信工程,出差住宿,通信企业黑名单3_&M1N)w9x#t,G4f
Linux中的驱动工作在内核空间,Android系统硬件抽象层工作在用户空间,有了这两个部分的结合,就可以让庞大的Android系统运行在特定的硬件平台上。
2~:C#_)v)E5[7H/DMSCBSC 移动通信论坛Android移植的主要工作如图1所示。mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。3L)I/S$C5i!\!S3u1T

图1 Android移植的主要工作

在具有了特定的硬件系统之后,通常在Linux中需要实现其驱动程序,这些驱动程序通常是Linux的标准驱动程序,在Android平台和其他Linux平台基本上是相同的。主要的实现方面是Android系统中的硬件抽象层(Hardware Abstract Layer),硬件抽象层对下调用Linux中的驱动程序,对上提供接口,以供Android系统的其他部分(通常为Android本地框架层)调用。4@8r*B0z({9w:V8R!M+y5i
提示:Android硬件抽象层的接口是本地移植层的接口,不属于标准API,不具有向前或者向后兼容性。MSCBSC 移动通信论坛$o+Z3P9O4n
在Android系统需要移植的内容,主要包含了以下的各个部分:mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。$S,]$d4v/S0r:C4j8y
显示部分(Display)www.mscbsc.com2i;b-T.S(G"T(V
包括framebuffer驱动+Gralloc模块(可选择是否实现)
*j&q;@.h-I,V4xMSCBSC 移动通信论坛用户输入部分(Input)
!s#H5D0k;^,c/jwww.mscbsc.com包括Event驱动+EventHub(Android标准内容) |  国内领先的通信技术论坛5{)]!E1@ J&y3_!r"g
多媒体编解码(Codec)mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。3w3{5S1_4j-F,A
包括硬件Codec驱动+Codec插件(如OpenMax)
:m+^+j$`;n7F,Y"?*O6NMSCBSC 移动通信论坛3D加速器部分(3D Accelerator)mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。$g9u2q,u"D+N W8N
包括硬件OpenGL驱动+OpenGL插件 |  国内领先的通信技术论坛4l"o;S/v7?0w#_
音频部分(Audio)
%E/S#u6q-]3d6G |  国内领先的通信技术论坛包括Audio驱动+Audio硬件抽象层
8d2O9h+M5WMSCBSC 移动通信论坛视频输出部分(Video Out)
;n!E;\'A d$R;R._-E;Z移动通信,通信工程师的家园,通信人才,求职招聘,网络优化,通信工程,出差住宿,通信企业黑名单包括视频显示驱动+Overlay硬件抽象层
/o$n8q!](d8z x;S"J)[www.mscbsc.com摄像头部分(Camera)4w }.n"u9v;z
包括Camera驱动(通常是v4l2)+Camera硬件抽象层www.mscbsc.com"H&r,T+I*].A
电话部分(Phone) |  国内领先的通信技术论坛4F6@4}"@,p"~
Modem驱动程序+RIL库
*A![;U-b$Z"Mmscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。全球定位系统部分(GPS) |  国内领先的通信技术论坛2l8L/a+e#h2A*b
包括GPS驱动(通常为串口)+GPS硬件抽象层MSCBSC 移动通信论坛/I"|:C+v3t-?2j%b1Z'v
无线局域网部分(WIFI)
9c,f8E _-@6m$_MSCBSC 移动通信论坛包括Wlan驱动和协议+WIFI的适配层(Android标准内容)#t9\ p6_0i,J$g
蓝牙部分(Blue Tooth)+g,\2B7X3r
包括BT驱动和协议+BT的适配层(Android标准内容)
"S9p;v$o)^+w*owww.mscbsc.com传感器部分(Sensor) |  国内领先的通信技术论坛7V&j)i1C-D7h8h Z
包括Sensor驱动+Sensor硬件抽象层
2K'S$R%c C$u!Hmscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。震动器部分(Vibrator)
#c9j%g6}(W/}&l |  国内领先的通信技术论坛包括Vibrator驱动+Vibrator硬件抽象层(Android标准内容)
9V r$j%R&?)K背光部分(Light)mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。5T.C+n!x;\
包括Light驱动+ Light硬件抽象层移动通信,通信工程师的家园,通信人才,求职招聘,网络优化,通信工程,出差住宿,通信企业黑名单#[2g.o/~%f%x7w
警告器部分(Alarm)
8?5O!H*}1R%o8L6Fwww.mscbsc.com包括Alarm驱动和RTC系统+用户空间调用(Android标准内容)
6X#N+P;r%Q+w6bMSCBSC 移动通信论坛电池部分(Battery)+f%v-}+R9w3^.z)X&B)]
包括电池部分驱动+电池的硬件抽象层(Android标准内容)
8{:X9l _.R-x,C6C&A)Wwww.mscbsc.comAndroid中具有很多组件,但并不是每一个部件都需要移植,对于一些纯软的组件,就没有移植的必要。对于一些部件,例如浏览器引擎,虽然需要下层网络的支持,但是并非直接为其移植网络接口,而是通过无线局域网或者电话系统数据连接来完成标准的网络接口。 |  国内领先的通信技术论坛2U&`!\6Y(m2t0p,p7b#Q,s1\*w
Android的移植主要可以分成几个类型:基本图形用户界面(GUI)部分,包括显示部分和用户输入部分;和硬件相关的加速部分,包括媒体编解码和OpenGL;音视频输入输出环节,包括音频,视频输出和摄像头部分;连接部分,包括无线局域网,蓝牙,GPS;电话部分;附属部件包括传感器、背光、振动器等。
#c&d+a j'r#p,I%E移动通信,通信工程师的家园,通信人才,求职招聘,网络优化,通信工程,出差住宿,通信企业黑名单除了以上的移植方面,电源管理也是非常重要的一个方面,它和Android的各个子系统都有关系。
1x%\4z*B8z#N+E移动通信,通信工程师的家园,通信人才,求职招聘,网络优化,通信工程,出差住宿,通信企业黑名单Android系统主要需要移植部件如图2所示。
;k8j)h9p$Z0o%E |  国内领先的通信技术论坛

图2 Android系统主要需要移植部件

对于大部分子系统,硬件抽象层和驱动程序都需要根据实际系统的情况实现,例如:传感器部分、音频部分、视频部分、摄像头部分、电话部分。也有一些子系统,硬件抽象层是标准的,只需要实现Linux内核中的驱动程序即可,例如:输入部分、振动器部分、无线局域网部分、蓝牙部分等。对于有标准的硬件抽象层的系统,有的时候通常也需要做一些配置工作。mscbsc 移动通信论坛拥有30万通信专业人员,超过50万份GSM/3G等通信技术资料,是国内领先专注于通信技术和通信人生活的社区。8\,{1e"A!L#c9^(|
时至今日,随着Android系统的发展,它已经不仅仅是一个移动设备的平台,也可以用于消费类电子和智能家电,例如:上网本、电子书、数字电视机顶盒固定电话等。在这些平台上,通常需要实现比移动设备更少的部件。一般来说,基本用户界面部分(包括显示和用户输入)是需要移植的,其他部分是可选的。例如:电话系统、振动器、背光、传感器等一般不需要在非移动设备系统来实现;对于一些固定位置设备通常也不需要实现GPS系统。


2010-06-13 09:28:00 fh400 阅读数 1413

 

[ edit ]

1 Introduction


Google explains that Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This document explains the Android architecture by Google and porting procedure on the real hardware. The explanation is based on the m3 sdk version of the Android emulator.


If you have enough knowledge about patching the kernel, resolving rejections from a patch, making an ramdisk image, and the Linux kernel itself, reading this article will be easier.

[ edit ]

2 Copyright and Acknowledgements


This document is copyright (c) Kwangwoo Lee (kwangwoo.lee at gmail dot com). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License.

AndroidPortingOnRealTarget/ko - Korean translation by dasomoli (dasomoli at gmail dot com).
[ edit ]

3 The brief analysis of the Android architecture


[ edit ]

3.1 Android Kernel


The most different things are the Android kernel uses ARM EABI(Embedded Application Binary Interface) and O penBinder IPC(Inter Process Communication). If you want to compile the kernel supporting ARM EABI, you should rebuild toolchains to support ARM EABI.

The Android sdk emulates goldfish architecture using qemu. The alsa may be used for audio on Android. See the audio.c file in the goldfish architecture directory and the driver uses /dev/eac for audio on the Android system. RTC(Real Time Clock) device is also used through /dev/rtc0.

The following parts explain the main differences:

[ edit ]

3.1.1 ARM EABI


EABI is the new "Embedded" ABI by ARM Ltd. The changes are listed on Debian wiki. (http://wiki.debian.org/ArmEabiPort )

Example with long ftruncate64(unsigned int fd, loff_t length):

legacy ABI:
- put fd into r0
- put length into r1-r2
- use "swi #(0x900000 + 194)" to call the kernel

new ARM EABI:
- put fd into r0
- put length into r2-r3 (skipping over r1)
- put 194 into r7
- use "swi 0" to call the kernel

The Android uses EABI kernel feature. Enable kernel options of the CONFIG_AEABI and CONFIG_OABI_COMPAT. You can see the differences of the executable binary as follows :

  • Legacy ABI
$ arm-softfloat-linux-gnu-objdump -x t7-demo | grep private
private flags = 202: [APCS-32] [FPA float format] [software FP] [has entry point]

$ file t7-demo
t7-demo: ELF 32-bit LSB executable, ARM, version 1 (ARM),
for GNU/Linux 2.4.3, dynamically linked (uses shared libs),
for GNU/Linux 2.4.3, stripped

  • ARM EABI
$ arm-softfloat-linux-gnueabi-objdump -x t7-demo  | grep private
private flags = 4000002: [Version4 EABI] [has entry point]

$ file t7-demo
t7-demo: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
for GNU/Linux 2.6.14, dynamically linked (uses shared libs),
for GNU/Linux 2.6.14, stripped


What is the ABI for the ARM Architecture? Is it the same as the ARM EABI?

The ABI for the ARM Architecture is a standard developed by ARM and its partners (including CodeSourcery) that explains how compilers, assemblers, linkers, and other similar tools should generate object files and executable files. Tools that correctly implement the ABI for the ARM Architecture can interoperate; i.e., objects files built with one toolchain can be combined with object files built with another toolchain if both compilers use the ABI for the ARM Architecture. The "ARM EABI" is an informal name for the ABI for the ARM Architecture.

[ edit ]

3.1.2 O penBinder


The O penBinder provides a object-oriented operating system environment. It is designed to be hosted by traditional kernels. This project is started at Be. Inc. as the part of the next generation B eOS , and finished implementing at P almSource as a core part at the Cobalt system.

It is a system oriented component architecture rather than application oriented, and It provides IPC between processes, threadpool, memory management and clean up feature at the end of reference of an binder object.

The vanilla kernel do not have O penBinder IPC mechanism you should patch the kernel. The O penBinder offers thread management for the system through /dev/binder. It is the reason that Android system do not offer thread libraries.

After patching the kernel, you can see the files for binder at drivers/binder/.

[ edit ]

3.1.3 Frame Buffer


The basic frame buffer driver should be implemented already. After that you need to implement the differences between your architecture driver and the goldfish driver.

The frame buffer driver of the goldfish architecture supports the fb_pan_display function of the struct fb_ops. It means you should allocate memory twice rather than the actual frame size.

  • Initialize frame buffer information
struct fb_info *fbinfo;
...
fbinfo->fix.ypanstep = 1;
fbinfo->var.yres_virtual = gm->lcd.yres * 2;
fbinfo->fix.smem_len = (gm->lcd.xres *
gm->lcd.yres *
gm->lcd.bpp / 8) * 2;

  • Allocate frame buffer memory
struct mvfb_info *fbi;
...
fbi->map_size = PAGE_ALIGN(fbi->fb->fix.smem_len + PAGE_SIZE);
fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
&fbi->map_dma, GFP_KERNEL);

  • Implement fb_pan_display fuction hook
static int mvfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *fb)
{
...
}

static struct fb_ops mvfb_ops = {
.owner = THIS_MODULE,

.fb_check_var = mvfb_check_var,
.fb_set_par = mvfb_set_par,
.fb_setcolreg = mvfb_setcolreg,
.fb_blank = mvfb_blank,
.fb_pan_display = mvfb_pan_display,

.fb_fillrect = cfb_fillrect,
.fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit,

.fb_mmap = mvfb_mmap,
};

The device file is located at /dev/graphics/fb0.

[ edit ]

3.1.4 Input Devices


Android uses event device for user input. There are three devices such as keypad, qwerty2 keyboard and mouse. The qwerty2 keyboard and mouse are normal devices. So I just explain the keypad and touchscreen which mouse device is replaced with.

On the Android shell, Cat the /proc/bus/input/{devices,handlers} and then you will see the devices used for the Android.
$ adb shell

# cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="goldfish-events-keyboard"
P: Phys=
S: Sysfs=/class/inut/input0
U: Uniq=
H: Handlers=kbd mouse0 event0
...
#
# cat /proc/bus/input/handlers
N: Number=0 Name=kbd
N: Number=1 Name=mousedev Minor=32
N: Number=2 Name=evdev Minor=64
#

  • Keypad
Qemu emulates goldfish-events-keyboard. It is a keypad using event device(/dev/input/event0). So you should know which key event and values come from the event device to activate Android applications. To do that, read event0 device with cat and redirect the output to a file. If you push and release the key button on emulator, the output values will be saved.

The output format is struct input_event. So the output on each event is 16 bytes like 8 bytes for time, 2 bytes for type, 2 bytes for code, 4 bytes for value. Read input.txt and input-programming.txt about input event devices in the Documentation/input directory of the Linux kernel source code.

struct input_event {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
};

The Tiger7 evaluation board has it's own scancode table. The following shows the key layout on evaluation board, scancode table, and Android keycodes:
/*
* Key Layout Scancode Table
*
* 1 2 3 0x1 0x10 0x100
* 4 5 6 0x2 0x20 0x200
* 7 8 9 0x4 0x40 0x400
* * 0 # 0x8 0x80 0x800
*/

static unsigned short android_keycode[] = {
/*
* 0x66 0x67 0x9e Home Up Back
* 0x69 0xe8 0x6a Left Ok Right
* 0xe7 0x6c 0x6b Send Down Hangup
* 0xe5 Menu just_distinction_for_private
*/
KEY_HOME, KEY_UP, KEY_BACK,
KEY_LEFT, KEY_REPLY, KEY_RIGHT,
KEY_SEND, KEY_DOWN, KEY_END,
KEY_KBDILLUMDOWN, KEY_RESERVED, KEY_PLAY
};

There is a power button on emulator, but I skipped it to get output value.

If an interrupt of the keypad is caught, translate the scancode with the keycode of the Android on the above table and send event to user space application.
...
keycode = translate_keycode(scancode);
...
input_event(keydev->input, EV_KEY, keycode, KEY_PRESSED);
or
input_event(keydev->input, EV_KEY, keycode, KEY_RELEASED);
...

The high resolution timer - hrtimer is used for reduce keypad debounce.

  • Touchscreen
If you have a touchscreen driver supporting the event interface for a pointing device, it'll work well. If you do not have it, you may implement it or use other pointing devices. Fortunately the evaluation board has already implemented touchscreen driver - drivers/input/touchscreen/tsc2007.c - which is made just before beginning to porting Android. Refer the drivers on drivers/input/touchscreen/ to implement your own driver and the text files on Documentation/input/.

Here is the output of the /proc/bus/input/{devices,handlers} on evaluation board.
# cat /proc/bus/input/devices
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="MVT7 KEYPAD"
P: Phys=
S: Sysfs=/class/input/input0
U: Uniq=
H: Handlers=kbd event0 evbug
B: EV=f
...

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="TSC2007 Touchscreen"
P: Phys=0-0090/input0
S: Sysfs=/class/input/input1
U: Uniq=
H: Handlers=event1 evbug
B: EV=b
B: KEY=400 0 0 0 0 0 0 0 0 0 0
B: ABS=1000003

# cat /proc/bus/input/handlers
N: Number=0 Name=kbd
N: Number=1 Name=evdev Minor=64
N: Number=2 Name=evbug

As a result, the keypad uses /dev/input/event0 and the touchscreen interface uses /dev/input/event1 on application layer.

[ edit ]

3.1.5 Low Memory Killer


The Linux Kernel has an OOM(Out of Memory) killer for the situation that no memory is left to allocate for a request of a process. It examines all processes and keeps score with some restrictions. The process with highest score will be killed except init.

The Low Memory Killer of the Android behaves a bit different against OOM killer. It classifies processes according to the importance with groups and kills the process in the lowest group. It will make the system to be stable at the view of the end users. For example, the UI Process - foreground process - is the most important process for the end users. So to keep the process live looks more stable than keeping other background processes live.

Enable CONFIG_LOW_MEMORY_KILLER after patching the kernel.
[ edit ]

3.1.6 Android Logger


If you enable this feature, you can see some useful information about Android through /dev/log/main. There are three device files on /dev/log such as main, events, radio. The /dev/log/radio file seems to be related with a modem device and ril daemon - rild - on Android system.

When this logger is enabled, the system performance is a bit slower on the system. To use this feature, enable CONFIG_ANDROID_LOGGER.

[ edit ]

3.1.7 Android Power


The Android power is for the battery management on devices and some subsystem related with power management like inotify feature on file system. It is not necessary to start up Android through the init(S hellScript ) of the Android system. But the runtime binary looks up some files regarding Android power - /sys/android_power/acruire_partial_wake_lock - on starting up Android manually and failed to start up. Enable CONFIG_ANDROID_POWER to use.
- 예전 버전의 문서에서 init은 바이너리로 되어있었는데 쉘스크립트로 바뀌어 있네요. 이전 문서에서 말한 init은 안드로이드 램디스크의 루트 디렉토리 밑에 있는 init 바이너리를 말씀하신 것 같은데, 그 것이 아니고 다른 init인건가요? 아니면 그 init이 쉘 스크립트인 것인가요? -- dasomoli

- 문서를 작성한 m3 버전에서는 binary 였습니다. 다른 분이 shell script로 바꾼 것 같네요. 번역해 주셔서 감사합니다. -- 이광우

- m5 버전에서도 바이너리인 것 같아서요. 그리고 별 말씀을요.^^; -- dasomoli
[ edit ]

3.1.8 Panic Timeout


It is not necessary to start up Android on evaluation board. Set CONFIG_PANIC_TIMEOUT with a desired value.

[ edit ]

3.2 Android Root File system


Android emulator has 3 basic images on tools/lib/images directory.

  • ramdisk.img
  • system.img
  • userdata.img
ramdisk.img is gziped cpio archive. ramdisk image is very small and contains configuration files, and some executable files such as init and recovery. The init file is not a regular system V init. It is made just for the Android and do special things to start up the Android system.

system.img and userdata.img are VMS Alpha executable. system.img and userdata.img have the contents of /system and /data directory on root file system. They are mapped on NAND devices with yaffs2 file system. /dev/block/mtdblock0 for /system and /dev/block/mtdblock1 for /data.

/system directory has libraries and default system packages (*.apk). /data directory has timezone, cache, and A piDemos .apk package.

The main services are zygote(/system/bin/app_process), runtime(/system/bin/runtime), and dbus(/system/bin/dbus-daemon). You can see the /etc/init.rc file on the Android ramdisk image.

...
zygote {
exec /system/bin/app_process
args {
0 -Xzygote
1 /system/bin
2 --zygote
}
autostart 1
}
runtime {
exec /system/bin/runtime
autostart 1
}
...
dbus {
exec /system/bin/dbus-daemon
args.0 --system
args.1 --nofork
autostart 1
}
...

[ edit ]

3.3 Licenses of the Android Packages


tools/lib/images/NOTICE contains package lists and licenses for each libraries. The table of the licenses is cited from the presentation by Lim,G eunSik at 2008 Korea Android Summit.

Open Source License
Linux Kernel GPL
NetBSD C Library BSD
DBUS G PL2
O penBinder (core) G PL2
Y AFFS2 GPL
SQLite G PL2
Webkit BSD (including LGPL)
W ebCore LGPL
SDL LGPL
SGL Google(Skia)
O penGL SGI O penGL (BSD/MPL)


[ edit ]

4 Toolchain supporting ARM EABI


The toolchain represents the tools to be used for the system development. It contains C/C++ compiler, linker, libraries, binutils, and etc. The Android kernel and system requires EABI support. So legacy toolchain is not compatible to make the Android system.

[ edit ]

4.1 Building toolchain


To make life easier, I used the crosstool-0.43 script (http://www.kegel.com/crosstool/ ) by Dan Kegel. Unfortunately it is not support to build eabi toolchain, so I applied a glibc 2.5+ nptl build for arm softfloat eabi patch (http://sources.redhat.com/ml/crossgcc/2006-12/msg00076.html ) by Khem Raj.

$./arm-softfloat-eabi.sh

If the network is connected, the script will download and build toolchain using gcc 4.1.1 and glibc 2.5.

[ edit ]

4.2 Other toolchain


I did not use the codesourcery toolchain, but they said it will work for the building Android system.


[ edit ]

5 Kernel


To port the Android on a real hardware is started by Benno (http://benno.id.au ), you can see some useful information on his blog. On his blog some pre-compiled static binaries are linked. It is very helpful for debugging Android system. You can also build static build busybox and strace binaries, but it's better to get them and use.

You can get patch file including the differences between the Android kernel and the vanilla kernel with 2.6.23 version. It has all differences between them. So you need to extract parts of them, and make your own patch for your system architecture.

For example, the Android kernel has it's own yaffs file system patch. If you have your own yaffs or some other file systems like jffs2 on your architecture, then you need to remove the yaffs parts of the patch. The goldfish architecture which the Android kernel emulate an ARM architecture on qemu is not necessary part for your architecture. It can be removed.

The Android kernel emulates A RMv5 instructions. So A RM926EJ -S (A RMv5TEJ ) will be good to work.

[ edit ]

5.1 Patch kernel


Benno played with a N EO1973 device by openmoko. So he made patch files for it. Get the original patch file from http://benno.id.au/blog/2007/11/21/android-neo1973 , I used android.diff. It has whole things about goldfish, qemu, yaffs, and Android specific parts.

You can edit and remove the patch file directly. After making patch including binder, android power, android logger, low memory killer except goldfish and qemu specific parts, get vanilla 2.6.23 version Linux kernel and patch it.

If you use a 2.6.24.1 version Linux kernel, some part regarding android power should be fixed accordingly or disabled to work.

[ edit ]

5.2 .config


  • Necessary
...
CONFIG_PANIC_TIMEOUT=0
CONFIG_AEABI=y
CONFIG_OABI_COMPAT=y
CONFIG_BINDER=y
CONFIG_LOW_MEMORY_KILLER=y
...

  • Optional
...
# CONFIG_ANDROID_GADGET is not set
# CONFIG_ANDROID_RAM_CONSOLE is not set
# CONFIG_ANDROID_POWER is not set
# CONFIG_ANDROID_LOGGER is not set
...

[ edit ]

6 Root file system


The root file system is composed of three parts such as a primary ramdisk image on ram, a system image on nand dev0 (/dev/block/mtdblock0), and a data image on nand dev1 (/dev/block/mtdblock1). The mtd devices has a yaffs2 file system and each of them has 64 M iB capacity on the Android emulator.

The extracted system and data directories are copied to the real existing NAND device and they are mounted with --bind option to work on a real hardware.

[ edit ]

6.1 Get ramdisk image from emulator


1. unpack ramdisk image from tools/lib/images/ramdisk.img
$ gzip -cd ramdisk.img > ramdisk
$ cpio -iv -F ramdisk

cpio will extract files and directories on current working directory.

2. the contents list of the ramdisk
data
dev
etc
etc/default.prop
etc/firmware
etc/firmware/brf6150.bin
etc/firmware/brf6300.bin
etc/hcid.conf
etc/hosts
etc/init.gprs-pppd
etc/init.rc
etc/init.ril
etc/init.testmenu
etc/ppp
etc/ppp/chap-secrets
etc/ppp/ip-down
etc/ppp/ip-up
etc/qemu-init.sh
etc/system.conf
etc/system.d
etc/system.d/bluez-hcid.conf
etc/usbd.conf
init
proc
sbin
sbin/recovery
sys
system
tmp
var
var/run

[ edit ]

6.2 Get data and system directory from emulator


To get data and system directory you need a static compiled busybox binary. The compiled binary can be obtained from http://benno.id.au/blog/2007/11/14/android-busybox , or make your own binary.

1. launch the Android emulator

2. push static compiled busybox into emulator
# adb push busybox .

3. launch the Android shell
# adb shell

4. make tarball with busybox
# chmod +x /busybox
# busybox tar -c /data.tar /data
# busybox tar -c /system.tar /system
# exit

5. extract tarball from the emulator
# adb pull /data.tar .
# adb pull /system.tar .

Extract command often failed. So you may repeat it again until it has done successfully.

[ edit ]

6.3 Integrate the Android system with a existing ramdisk image.


The ramdisk for your architecture can make your work a bit easier. Copy the contents of the Android ramdisk to your own ramdisk except system and data directory. And make just mount point for system and data directory. The mount points will be used later with a bind option. The init binary of the Android ramdisk image is the key binary to start the system and It read a configuration file on /etc/init.rc.

Edit /etc/init.rc and comment out qemu part.

...
startup {
...
# qemu-init {
# exec /etc/qemu-init.sh
# }
}
...

Make run.sh script. /dev/block/mtdblock5 is a mtd partition on a real NAND device, and it is mounted on /mnt. data and system directories are already copied on mtdblock5. So the script below just shows bind mounting each directory on /. Fix your script according to your board configuration.

#!/bin/sh
mount -t yaffs /dev/block/mtdblock5 /mnt
mount --bind /mnt/data /data
mount --bind /mnt/system /system

# data folder is owned by system user on emulator. Fix 777 to other.
chmod 777 /data
#chmod 777 /system

export PATH=/system/sbin:/system/bin:/sbin/usr/local/bin
export LD_LIBRARY_PATH=/system/lib

export ANDROID_BOOTLOGO=1
export ANDROID_ROOT=/system
export ANDROID_ASSETS=/system/app
export EXTERNAL_STORAGE=/sdcard
export ANDROID_DATA=/data
export DRM_CONTENT=/data/drm/content

/init &

An optional configuration for touchscreen - T SLib .

...
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts

export LD_PRELOAD=/lib/libts.so:/lib/ts/pthres.so
...

[ edit ]

6.4 System and Data directories


The contents of the system and data directories are copied to mtdblock5 already. You should copy your own method. To use it, I chose bind mounting on root directory. Bind mounting is a technique to mount an existing directory with a new mount point.

[ edit ]

6.5 Run and Debug


Now the kernel, ramdisk, and data directories - data and system - are ready. It's time to see the red cylon eye. After boot up your integrated system, run the run.sh on root directory.

# cd /
# . /android/run.sh
yaffs: dev is 32505861 name is "mtdblock5"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.5, "mtdblock5"
yaffs: auto selecting yaffs2
# init: HOW ARE YOU GENTLEMEN
init: reading config file
init: device init
init: mtd partition -1,
init: mtd partition 0, "l1boot"
init: mtd partition 1, "u-boot"
init: mtd partition 2, "params"
init: mtd partition 3, "kernel"
init: mtd partition 4, "ramdisk"
init: mtd partition 5, "rootfs"
sh: can't access tty; job control turned off
# binder_open(c394bcc8 c3c731a0) (pid 1577) got c3e48000
binder_open(c394bcc8 c3cd8dc0) (pid 1616) got c319f000
binder_open(c394bcc8 c3cd8ac0) (pid 1673) got c3d10000
binder_open(c394bcc8 c3cd8940) (pid 1680) got c0e19000
binder_open(c394bcc8 c3cd88c0) (pid 1691) got c2fa0000
binder_open(c394bcc8 c3d174a0) (pid 1592) got c25b8000
binder_release(c394bcc8 c3cd88c0) (pid 1691) pd c2fa0000
#

  • Do not make eac device file on /dev. It is for the audio on qemu. If it exists, the start up sequence will wait forever to finish writing some data to the sound device.
  • Use the Android init binary instead of manual startup. The manual start up will require the android power patch. In that case the start up sequence will access /sys/android_power/acquire_partial_wake_lock and wait.
To debug the Android system, use static compiled strace binary from http://benno.id.au/blog/2007/11/18/android-runtime-strace and run the Android manually.

#!/bin/sh
# set environment variables above example
...
/system/bin/app_process -Xzygote /system/bin --zygote &
/system/bin/dbus-daemon --system &
/system/bin/runtime

The above example shows manual startup sequence, use strace on run /system/bin/runtime binary.

./strace -ff -F -tt -s 200 -o /tmp/strace runtime

[ edit ]

6.6 Screenshots


  • Skipped
[ edit ]

7 Application Development


The Android applications use Java syntax and xml layouts, but it is not a Java. Because they use their own virtual machine - dalvik - and compiler for dex file format. And use package named apk such as Home.apk, Phone.apk, ApiDemos.apk and etc.

The apk file is a Zip archive and it has four parts.

  • AndroidManifest.xml
  • classes.dex
  • resources.arsc
  • res directory
The Dex file format is explained on http://www.retrodev.com/android/dexformat.html . And the contents of the files and directories are explained some day by Google. It is not explained currently. We can just guess about it.

The Android SDK will create an *.apk file.

[ edit ]

7.1 Install Eclipse IDE



1. Eclipse IDE for Java developer (JDT and WST plugins are included) from http://www.eclipse.org/downloads/


3. ADT (Android Development Tools) with a eclipse plugin including Apache Ant

[ edit ]

7.2 Build and Run Sample Applications


1. Open sample projects and build

2. Run sample applications on emulator

[ edit ]

7.3 Screenshots


  • Android Platform on Nokia's N810 Product(arm1136jf-s)
    n810.kandroid200805.PNG

  • Android Platform on arm1136jf-S for another CE Product.
    fi.initial_display.jpg
  • invain님이 shot을 올려주셨군요. -- 이광우
[ edit ]

8 Epilogue


The Android system seems to be a new kind of a Linux based distribution for a mobile environment like Debian, RedHat , SuSE , and etc. They just use the Linux kernel and a lot of different libraries in the open source world. They offer a software based O penGL -ES library on a 3D acceleration currently, but they are developing on a hardware accelerated baseband processor for it. The hardware acceleration is necessary for fast UI rendering effects later.

The Android system on the sdk is not a completed one to port on a real hardware, because some device - for example, camera - related libraries and classes are not implemented yet and not opened for users. It seems to be under the development stage. So we would better to wait the Google announces the whole porting kit.

Until then, we should look for the business model with the Android system. It requires a bit high cpu performance, so the carrier vendors will require a cheap baseband processor (RF part) and a multimedia co-processor, because the baseband processor including multimedia features will be very expensive.

[ edit ]

9 Links and References

android移植

阅读数 2533

android 移植

阅读数 146

android移植

阅读数 1

android 移植

阅读数 210

没有更多推荐了,返回首页