android移植

试验平台:芯晟CSM1201

老内核版本:2.6.12.5

第一步,先升级芯晟内核到Android1.0的内核版本-2.6.25

第二步,移植Android

先总结一下第一步的移植过程以及遇到问题的解决办法。

首先是拿到原版2.6.12.5内核,与芯晟内核作比较,将芯晟修改和加入的部分,先做简单的拷贝到2.6.25内核,这里需要注意有几个目录或目录下下的文件是编译过程中生成的,不要预先拷贝,如script下的一些.cmd,arch/asm目录,include/asm等。芯晟在12.5内核中主要修改了arch和driver目录,重点关注相应的Kbuild和Makefile。

然后同时开两个shell窗口,分别进入25内核和芯晟内核做make menuconfig操作,对比芯晟内核的配置来作25内核的配置,其中有些老内核的配置选项在新内核中已经不再支持或者位置变了,需要灵活处理。另外如果上一步的Kbuild修改是正确的,那么芯晟加入的内核配置选项在两版内核的menuconfig中应该是基本相同的。

内核配置完后就开始编译。遇到的问题记录如下:

1.entry_armv.S汇编出错,提示的错误是bad command 'get_irqnr_preamble r5, lr',google之发现只要把这条指令引掉即可;

2.还是emtry_armv.S,出现错误internal relocation (type:OFFSET_IMM) not fixed up,google、百度了三天,有的说是编译器问题,有的说是constant.h问题,我还换了新版编译器试了仍然不行。就在几乎绝望的时候,最后发现是有个该汇编文件中#include <asm/arch/entry-macro.S>,entr_macro.S中有个宏VA_VIC_BASE没定义,#include <asm/hardware.h>之后解决了。

3.arch/arm/kernel/head.S,错误提示:

arch/arm/kernel/head.S:267: Error: missing ')'
arch/arm/kernel/head.S:267: Error: garbage following instruction -- `ldr r4,=(((0xc0000000UL)+0x00008000)-0x4000)'

是我的include/asm-arm/orion2/memory.h中定义了#define PHYS_OFFSET (0x00000000UL),但是UL已经被include/asm-arm/memory.h定义成#define UL(x) (x##UL)

因而导致编译器出现错误。将include/asm-arm/orion2/memory.h中#define PHYS_OFFSET (0x00000000UL)改为#define PHYS_OFFSET UL(0x00000000)后解决。

4.arch\arm\kernel\entry-common.S,bad command ' arch_ret_to_user r1, lr',原因同1,引掉即可

接下来就是芯晟加入的驱动在新版内核上的修改了,有一些宏定义、数据结构以及函数已经变化了,做了不少修改。修改了大概两天时间,最后终于编译通过,生成了Uimage。

以下是内核运行过程中出现的错误及解决办法:

1.在starting kernel...的位置停下了

解决办法:重新配置内核,在kernel hacking中加上debug和lowlevel debug功能。重新编译uImage,重新内核启动发现是machineID不对,于是修改arch/arm/tools/mach-types文件,将芯晟的machineID改为719。

重启kernel,停在done, booting the kernel.

打开printk.c中的VIRGO_EARLY_PRINTK宏,出现打印:

<4>[    0.000000] Linux version 2.6.25 (root@ubuntu) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #20 Tue Aug 17
20:29:47 PDT 2010
<4>[    0.000000] start_kernel............13
<4>[    0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
<4>[    0.000000] Machine: ORION
<4>[    0.000000] Memory policy: ECC disabled, Data cache writeback
<7>[    0.000000] On node 0 totalpages: 25600
<7>[    0.000000]   DMA zone: 200 pages used for memmap
<7>[    0.000000]   DMA zone: 0 pages reserved
<7>[    0.000000]   DMA zone: 25400 pages, LIFO batch:7
<7>[    0.000000]   Normal zone: 0 pages used for memmap
<7>[    0.000000]   Movable zone: 0 pages used for memmap
<3>[    0.000000] MM: CPU does not support supersection mapping for 0x10140000000 at 0xf1140000
<3>[    0.000000] MM: CPU does not support supersection mapping for 0x101f1000000 at 0xf11f1000
<3>[    0.000000] MM: CPU does not support supersection mapping for 0x101e0000000 at 0xf11e0000
<3>[    0.000000] MM: CPU does not support supersection mapping for 0x35000000000 at 0xf8000000

问题出在哪呢?

原来是16版本内核之后,map_desc结构发生了变化,

struct map_desc {------------------------------2.6.16
unsigned long virtual;---------------虚地址
unsigned long pfn;-------------------Page Frame Number 页帧号
unsigned long length;
unsigned int type;
};

struct map_desc {------------------------------2.6.9
unsigned long virtual;
unsigned long physical;------------物理地址
unsigned long length;
unsigned int type;
};


根据以上变化,修改后的物理内存->虚拟地址的映射关系如下:

static struct map_desc virgo_io_desc[6] __initdata = {
{
  .virtual = VA_VIC_BASE ,
  .pfn = __phys_to_pfn(PA_VIC_BASE),//PA_VIC_BASE,
  .length = SZ_64K,
  .type = MT_DEVICE
},
{
  .virtual = VA_UARTS_BASE, 
  .pfn = __phys_to_pfn(PA_UARTS_BASE),//PA_UARTS_BASE,
  .length = SZ_16K,
  .type = MT_DEVICE
},
{
  .virtual = VA_TIMERS_BASE,
  .pfn = __phys_to_pfn(PA_TIMERS_BASE),//PA_TIMERS_BASE,
  .length = SZ_64K,
  .type = MT_DEVICE
},
{
  .virtual = VA_ETH_BASE,
  .pfn = __phys_to_pfn(PA_ETH_BASE),//PA_ETH_BASE ,
  .length = SZ_64K,
  .type = MT_DEVICE
},
{
  .virtual = VA_ATA_BASE,  
  .pfn = __phys_to_pfn(PA_ATA_BASE),//PA_ATA_BASE ,
  .length = SZ_16K,
  .type = MT_DEVICE
},
{
  .virtual = VA_PCMCIA_BASE,
  .pfn = __phys_to_pfn(PA_PCMCIA_BASE),//PA_PCMCIA_BASE,
  .length = SZ_16K,
  .type = MT_DEVICE
}
}; // Data from Virgo MemoryMap
修改后停在calibrate_delay,说明timer有问题,jiffs没好用。

仔细查了一下25内核其他cpu架构下的timer驱动,发现跟12内核有很大差别。于是找来芯晟32内核中的timer部分加以修改,添加到25内核中,并修改arch/arm/Kconfig,

config GENERIC_TIME
bool
default y

config GENERIC_CLOCKEVENTS
bool
default y

编译生成uImage后重新启动内核,跑到local_irq_enable又死了(假死机,因为timer中断里还有打印)。

继续调试的时候发现如果把timer初始化去掉就可以往下跑,说明还是timer中断有问题。仔细对比芯晟32内核中timer部分的修改发现是我把PA_TIMER0_BASE定义错了,也就是定时器0的硬件地址不对,改正后 local_irq_enable过去了。

然后跑到挂载根文件系统的时候再次出现kernel panic,估计是我之前改了一些跟MTD block driver和fs的东西造成的。因为目前只能通过NFS方式挂载android文件系统,因此我决定先将boot argument改为nfs方式挂载。这么改完后仍然出现kernel panic,PC指针停在了cn100_interrupt的位置,这是CSM1201板子上的以太网中断服务程序。仔细检查发现是cn100_interrupt中有一个指针搞错了。但是矫正后内核仍然无法启动。因为我之前将cn100的驱动针对新版内核做了一些改动,就是这部分导致网络不好用。最后对比芯晟32内核中cn100驱动进行修改,网络驱动终于好用了。

接下来我还是继续调试MTD block驱动部分。

首先配置内核,将MTD block驱动的debug log放开,打印出:

mtd: Giving out device 0 to physmap-flash.0

google后发现可能跟boot参数有关。仔细检查boot参数:

setenv bootargs 'root=/dev/mtdblock/2 rootfstype=jffs2 rw init=/init mem=100M console=ttyS0,115200 mtdparts=phys_mapped_flash:640k(u-boot1)ro,1664k(kernel),4480k(jffs2),1088k(app),320k(stbinfo),512k(u-boot2)ro,5824k(res),320k(cainfo),1024k(bootlogo)'

发现mtdparts=phys_mapped_flash这句比较可疑,phys_mapped_flash是从哪来的呢?

在老版内核中搜索“phys_mapped_flash”,发现内核pphysmap.c中有:

struct map_info physmap_map = {
.name = "phys_mapped_flash",
.phys = CONFIG_MTD_PHYSMAP_START,
.size = CONFIG_MTD_PHYSMAP_LEN,
.bankwidth = CONFIG_MTD_PHYSMAP_BANKWIDTH,
};

于是到新版内核中去找,发现有:

static struct platform_device physmap_flash = {
.name  = "physmap-flash",
.id  = 0,
.dev  = {
  .platform_data = &physmap_flash_data,
},
.num_resources = 1,
.resource = &physmap_flash_resource,
};

于是将boot参数改为mtdparts=physmap-flash。重启内核后仍然出现

mtd: Giving out device 0 to physmap-flash.0

boot参数改成mtdparts=physmap-flash.0后,有了一些进展,打印如下:
[    8.880000] 9 cmdlinepart partitions found on MTD device physmap-flash.0
[    8.890032] Creating 9 MTD partitions on "physmap-flash.0":
[    8.900034] 0x00000000-0x000a0000 : "u-boot1"
[    8.910029] mtd: Giving out device 0 to u-boot1
[    8.981516] 0x000a0000-0x00240000 : "kernel"
[    8.990092] mtd: Giving out device 1 to kernel
[    9.060259] 0x00240000-0x006a0000 : "jffs2"
[    9.070113] mtd: Giving out device 2 to jffs2
[    9.141523] 0x006a0000-0x007b0000 : "app"
[    9.160037] mtd: Giving out device 3 to app
[    9.230289] 0x007b0000-0x00800000 : "stbinfo"
[    9.250105] mtd: Giving out device 4 to stbinfo
[    9.310282] 0x00800000-0x00880000 : "u-boot2"
[    9.330098] mtd: Giving out device 5 to u-boot2
[    9.390244] 0x00880000-0x00e30000 : "res"
[    9.400112] mtd: Giving out device 6 to res
[    9.470158] 0x00e30000-0x00e80000 : "cainfo"
[    9.480109] mtd: Giving out device 7 to cainfo
[    9.540383] 0x00e80000-0x00f80000 : "bootlogo"
[    9.550113] mtd: Giving out device 8 to bootlogo
[    9.670462] input: ORION Remote Controller as /devices/virtual/input/input0
[    9.770478] Orion Watchdog Timer: timer margin 40 sec
[    9.890413] TCP cubic registered
[    9.930079] NET: Registered protocol family 1
[    9.940207] NET: Registered protocol family 17
[   10.000428] RPC: Registered udp transport module.
[   10.010062] RPC: Registered tcp transport module.
[   10.070386] Root-NFS: No NFS server available, giving up.
[   10.080150] VFS: Unable to mount root fs via NFS, trying floppy.
[   10.110265] MTDSB: dev_name "/dev/root"
[   10.120065] MTDSB: path_lookup() returned 0, inode c5c00c08
[   10.130051] List of all partitions:
<4>[   10.140046] 1f00        640 mtdblock0[   10.140046] 1f00        640 mtdblock0 (driver?)
(driver?)
<4>[   10.160035] 1f01       1664 mtdblock1[   10.160035] 1f01       1664 mtdblock1 (driver?)
(driver?)
<4>[   10.180031] 1f02       4480 mtdblock2[   10.180031] 1f02       4480 mtdblock2 (driver?)
(driver?)
<4>[   10.200032] 1f03       1088 mtdblock3[   10.200032] 1f03       1088 mtdblock3 (driver?)
(driver?)
<4>[   10.220032] 1f04        320 mtdblock4[   10.220032] 1f04        320 mtdblock4 (driver?)
(driver?)
<4>[   10.240033] 1f05        512 mtdblock5[   10.240033] 1f05        512 mtdblock5 (driver?)
(driver?)
<4>[   10.260032] 1f06       5824 mtdblock6[   10.260032] 1f06       5824 mtdblock6 (driver?)
(driver?)
<4>[   10.280033] 1f07        320 mtdblock7[   10.280033] 1f07        320 mtdblock7 (driver?)
(driver?)
<4>[   10.300032] 1f08       1024 mtdblock8[   10.300032] 1f08       1024 mtdblock8 (driver?)
(driver?)
<4>[   10.320022] No filesystem could mount root, tried: [   10.320022] No filesystem could mount root, tried:  jffs2 jffs2

<0>[   10.350042] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
[   10.350042] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

然后google"mtdblock0 (driver?)",发现有人遇到同样的问题,原因是新版内核不支持devfs造成的,应该将boot参数中的root=/dev/mtdblock/2改为root=31:2
试了一下,确实好用。

至此内核终于跑起来了!

最后的boot参数如下:

setenv bootargs 'root=31:2 rootfstype=jffs2 rw init=/init mem=100M console=ttyS0,115200 mtdparts=physmap-flash.0:640k(u-boot1)ro,1664k(kernel),4480k(jffs2),1088k(app),320k(stbinfo),512k(u-boot2)ro,5824k(res),320k(cainfo),1024k(bootlogo)'

接下来就是移植Android内核到第一步升级后的芯晟内核。通过比较发现Android对内核的修改和芯晟对内核的修改几乎没有重合的地方,因此移植相对容易。这里参考了网上一位外国朋友Peter McDermott 的文章-《Porting Android to a new device》:

What did Google change in the kernel?
We checked the differences between the Android kernel and the standard Linux kernel and found that Google had changed 75 files and added an additional 88. We have prepared an annotated list of changed files at the end of this document, and a brief summary here.

· Goldfish -- 44 Files-- The Android emulator runs a virtual CPU that Google calls Goldfish. Goldfish executes ARM926T instructions and has hooks for input and output -- such as reading key presses from or displaying video output in the emulator.
These interfaces are implemented in files specific to the Goldfish emulator and will not be compiled into a kernel that runs on real devices. So we safely ignored these files in our work.

· YAFFS2 -- 35 Files-- Unlike PCs, which store files on disks, mobile phones store files in sold-state flash memory chips. The HTC G1 uses NAND flash, a type of flash memory that is becoming more popular due to its combination of high density and low cost.
YAFFS2 is an acronym for "Yet Another Flash File System, 2nd edition." It provides a high-performance interface between the Linux kernel and NAND flash devices. YAFFS2 was already freely available for Linux. However, it is not part of the standard 2.6.25 Linux kernel, and so Google added it to Android.

· Bluetooth -- 10 files-- Google made changes to 10 files in the Bluetooth communications stack. These changes fix apparent bugs related to Bluetooth headsets, and add Bluetooth debugging and access control functions.

· Scheduler -- 5 files-- The Android kernel also contains slight changes to the CPU process scheduler and time-keeping algorithms. We don't know the history of these changes, and the impact was not evident based on a cursory examination.

· New Android Functionality -- 28 files-- In addition to bug fixes and other small changes, Android contains a number of new subsystems that are worth mentioning here, including the following:

o

o IPC Binder-- The IPC Binder is an Inter-Process Communication (IPC) mechanism. It allows processes to provide services to other processes via a set of higher-level APIs than are available in standard Linux. An Internet search indicated that the Binder concept originated at Be, Inc., and then made its way into Palm's software, before Google wrote a new Binder for Android.

o Low Memory Killer-- Android adds a low-memory killer that, each time it's called, scans the list of running Linux processes, and kills one. It was not clear in our cursory examination why Android adds a low-memory killer on top of the already existing one in the standard Linux kernel.

o Ashmem-- Ashmem is an Anonymous SHared MEMory system that adds interfaces so processes can share named blocks of memory. As an example, the system could use Ashmem to store icons, which multiple processes could then access when drawing their UI. The advantage of Ashmem over traditional Linux shared memory is that it provides a means for the kernel to reclaim these shared memory blocks if they are not currently in use. If a process then tries to access a shared memory block the kernel has freed, it will receive an error, and will then need to reallocate the block and reload the data.

o RAM Console and Log Device-- To aid in debugging, Android adds the ability to store kernel log messages to a RAM buffer. Additionally, Android adds a separate logging module so that user processes can read and write user log messages.

o Android Debug Bridge-- Debugging embedded devices can best be described as challenging. To make debugging easier, Google created the Android Debug Bridge (ADB), which is a protocol that runs over a USB link between a hardware device running Android and a developer writing applications on a desktop PC.

Android also adds a new real-time clock, switch support, and timed GPIO support. We list the impacted files for these new modules at the end of this document.

·

· Power Management -- 5 files-- Power management is one of the most difficult pieces to get right in mobile devices, so we split it out into a group separate from the other pieces. It's interesting to note that Google added a new power management system to Linux, rather than reuse what already existed. We list the impacted files at the end of this document.

· Miscellaneous Changes -- 36 files-- In addition to the above, we found a number of changes that could best be described as, 'Miscellaneous.' Among other things, these changes include additional debugging support, keypad light controls, and management of TCP networking.

· NetFilter -- 0 files-- Finally, our change list showed Netfilter as having 22 changed files. However, examination showed the only difference was the capitalization of the filenames (xt_DSCP.c vs. xc_dscp.c). The contents of the files were all identical. So we ignored these files in our port.

因为我的移植是针对机顶盒的,因此bluetooth和power management都是不需要的,我的试验平台是NOR FLASH,因此也不需要YAFFS2文件系统。剩下的改动只需做简单的拷贝即可。然后重新做menuconfig,把Android新增的功能选上。编译很容易就过了。 但是内核启动的时候提示:

Kernel panic - not syncing: Attempted to kill init!

搜了一下发现必须用Android自己的根文件系统。

 

开始编译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/bin:$PATH

再接着在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了!

 

你可能感兴趣的:(android移植)