开始编译Android。
先参考网上的文章拿到Android源代码。下载Android源码需要用到Git和Repo。Git是一个开源的分布式版本控制软件,它非常适合管理很大的项目,项目文件可以分布储存在多个Git repositories(仓库), 这样可以很方便地创建分支,进行版本比较等,所以Android也用它来进行源码管理。 Repo是基于Git的工具,它可以让我们更方便地管理Git repositories.
接下来我们要在Ubuntu上面安装这两个工具, 在安装之前要先安装一些必要的Linux Packages: JDK 5.0(Java 6不支持因为@Override的不兼容), lex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.
在Ubuntu的Terminal运行以下命令: $ sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
这里需要注意的是sun-java5-jdk的源在Ubuntu9.10后就没有了, 所以安装sun-java5-jdk 要切换Sources.list才能安装,具体可以参考这篇Blog.
Git(上面的git-core)装完了,接下来装Repo, 在home目录创建bin目录,然后获取Repo并授于它执行的权限:
$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
接下来把bin目录加入$PATH:
$ export PATH=$HOME/binPATH
再接着在home目录创建mydroid目录用来存放Android源码
$ mkdir mydroid
$ cd mydroid
最后下载Android源码,如果要拿最新的主分支源代码用:
$ repo init -u git://android.git.kernel.org/platform/manifest.git
要下载某个分支的代码使用-b选项,比如我要下载android-1.5的代码使用如下命令:
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-1.5
接下来:
$ repo sync
接下来要经过很长时间的下载,然后开始编译。
编译Android需要注意的就是编译环境的配置,如果使用JDK1.6则必须用64位的libstdc++.so,因为Android有四个makefile对此做了强制,在使用JDK1.6的时候加了-m64的编译链接选项。另外,使用JDK1.6编译的时候会出现javadoc无法生成导致编译失败,因此我编译的时候改为使用JDK1.5,这样也不用安装64位的库了。Android编译需要大量临时空间,编译前先给虚拟机分配1G以上内存,否则编译经常会卡死在”target Dex: core“;同时需6G多的硬盘空间,注意预留。
然后就可以进入android,
source build/envsetup.mak,
export ANDROID_JAVA_HOME=$JAVA_HOME
然后make,大概要4、5个小时左右编译完成,可以看到新生成了一个out目录。其中
out/target/product/generic/有三个.img文件ramdisk.img、system.img、userdata.img,那是给模拟器使用的映像文件,如果要在真机上跑,可将out/system目录和out/data目录拷贝到out/root目录下,该目录就是android的根文件系统。然后让android内核通过NFS挂载到out/root目录下,会发现一条打印,告知/initlogo.rle不存在,这是android内核要加载开机画面。
到网上搜索了一下找到了android logo制作方法:
首先下载advanced batch converter,将图片转换成raw格式,然后使用android生成的out/host/linux-x86/bin/rgb2565命令将raw格式图片转成rle格式,命令如下:
rgb2565 -rle initlogo.raw initlogo.rle
将生成的initlogo.rle拷贝到android根文件系统根目录下。
修改init.rc文件,去掉除mount tmpfs tmpfs /sqlite_stmt_journals size=4m之外所有的mount命令,
重新启动内核,可以看到logo显示出来了。
文件系统启动后打印信息如下:
[ 10.220104] CSM CN100 eth0: MII transceiver 1 status 0x786d advertising 01e1.
[ 10.260488] eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[ 11.300202] IP-Config: Complete:
[ 11.310030] device=eth0, addr=192.168.127.161, mask=255.255.255.0, gw=255.255.255.255,
[ 11.350141] host=192.168.127.161, domain=, nis-domain=(none),
[ 11.360028] bootserver=192.168.127.160, rootserver=192.168.127.160, rootpath=
[ 11.400104] Looking up port of RPC 100003/2 on 192.168.127.160
[ 11.501515] Looking up port of RPC 100005/1 on 192.168.127.160
[ 11.760442] VFS: Mounted root (nfs filesystem).
[ 11.780526] Freeing init memory: 120K
[ 11.830169] Warning: unable to open an initial console.
[ 24.310431] init: cannot find '/system/bin/playmp3', disabling 'bootsound'
sh: can't access tty; job control turned off
# [ 38.570283] warning: `rild' uses 32-bit capabilities (legacy support in use)
<3>[ 22.620480] init: Unable to open persistent property directory /data/property errno: 2
[ 24.780245] init: cannot find '/system/bin/playmp3', disabling 'bootsound'
sh: can't access tty; job control turned off
# <6>[ 39.420487] warning: `rild' uses 32-bit capabilities (legacy support in use)
其中init: Unable to open persistent property directory /data/property errno: 2
是因为init.rc中将nfs挂在为只读了:
mount rootfs rootfs / ro remount
改成mount rootfs rootfs / rw remount即可
android启动不久就出现了如下错误:
[ 658.980000] System halted.
[ 873.940484] binder: release 650:650 transaction 1074 in, still active
[ 873.960000] binder: send failed reply for transaction 1074 to 718:728
[ 873.970070] binder: release 650:654 transaction 1068 in, still active
[ 873.980156] binder: send failed reply for transaction 1068 to 729:736
[ 878.600229] init: untracked pid 687 exited
[ 878.610222] init: untracked pid 691 exited
[ 878.620226] init: untracked pid 729 exited
[ 878.640219] init: untracked pid 740 exited
[ 878.650153] init: untracked pid 749 exited
[ 1365.641527] binder: 635:684 transaction failed 29189, size 168-0
[ 1389.770177] System halted.
[ 1884.971653] binder: 635:684 transaction failed 29189, size 168-0
[ 1927.680044] System halted.
[ 2271.570282] binder: release 812:883 transaction 2707 in, still active
[ 2271.580173] binder: send failed reply for transaction 2707 to 872:920
[ 2275.040108] init: untracked pid 848 exited
[ 2275.050236] init: untracked pid 852 exited
[ 2275.070146] init: untracked pid 891 exited
[ 2275.090154] init: untracked pid 898 exited
[ 2275.100231] init: untracked pid 911 exited
出现android Power off画面,有一个圆圈在转动。
这是因为android-1.5的framework检测不到battery level(电池电量),认为电量为0,自动把系统挂起了。
The reason may be that no battery and power soruce can be detected by
system.
(battery level =0 and unknown charging status)
So ShutdownThread is invoked by KeyguardUpdateMonitor to power off the
system.
Please comment line 300 of "frameworks/policies/base/phone/com/android/
internal/policy/impl/KeyguardUpdateMonitor"
and make again to get the new rootfs.
Then the battery check can be avoided when booting.
按照上面的说明注释掉frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java文件中的
// ShutdownThread.shutdownAfterDisablingRadio(mContext, false);
详细出处参考:http://www.itqun.net/content-detail/143864.html
重新编译制作android rootfs,启动,android桌面出来了,但是仍然有一个“Please connect charger”
的提示框。
下一步就是要想办法让android能接收和处理遥控按键。
android使用标准linux输入设备获取按键键值并处理,而芯晟内核已经把遥控驱动设计成标准输入设备的形式,所以只要修改android的键盘映射即可。android默认使用系统的 /system/usr/keylayout/qwerty.kl作为键值映射文件。修改此文件并重新编译、安装根文件系统。修改后的qwerty.kl文件内容如下:
key 399 GRAVE
key 0 1
key 7 2
key 6 3
key 4 4
key 11 5
key 10 6
key 8 7
key 15 8
key 14 9
key 13 0
key 91 BACK WAKE_DROPPED
key 230 SOFT_RIGHT WAKE
key 60 SOFT_RIGHT WAKE
key 107 ENDCALL WAKE_DROPPED
key 62 ENDCALL WAKE_DROPPED
key 78 MENU WAKE_DROPPED
key 139 MENU WAKE_DROPPED
key 59 MENU WAKE_DROPPED
key 127 SEARCH WAKE_DROPPED
key 217 SEARCH WAKE_DROPPED
key 228 POUND
key 227 STAR
key 231 CALL WAKE_DROPPED
key 61 CALL WAKE_DROPPED
key 232 DPAD_CENTER WAKE_DROPPED
key 23 DPAD_DOWN WAKE_DROPPED
key 103 DPAD_UP WAKE_DROPPED
key 102 HOME WAKE
key 66 DPAD_LEFT WAKE_DROPPED
key 65 DPAD_RIGHT WAKE_DROPPED
key 115 VOLUME_UP
key 114 VOLUME_DOWN
key 1 POWER WAKE
key 212 CAMERA
key 16 Q
key 17 W
key 18 E
key 19 R
key 20 T
key 21 Y
key 22 U
key 28 I
key 24 O
key 25 P
key 26 LEFT_BRACKET
key 27 RIGHT_BRACKET
key 43 BACKSLASH
key 30 A
key 31 S
key 32 D
key 33 F
key 34 G
key 35 H
key 36 J
key 37 K
key 38 L
key 39 SEMICOLON
key 40 APOSTROPHE
key 63 DEL
key 44 Z
key 45 X
key 46 C
key 47 V
key 48 B
key 49 N
key 50 M
key 51 COMMA
key 52 PERIOD
key 53 SLASH
key 21 ENTER
key 56 ALT_LEFT
key 100 ALT_RIGHT
key 42 SHIFT_LEFT
key 54 SHIFT_RIGHT
key 41 TAB
key 57 SPACE
key 150 EXPLORER
key 155 ENVELOPE
key 12 MINUS
key 67 EQUALS
key 215 AT
至此终于可以通过遥控器操作android了!
欢迎光临 九鼎创展论坛 (http://bbs.9tripod.com/) | Powered by Discuz! X3.2 |