android 读写 dbf文件,Android笔记之三: 内核移植和Android文件系统

#include @@ -55,7 +56,8 @@ static int binder_read_proc_proc(

#endif

#ifndef __i386__

-#define FORBIDDEN_MMAP_FLAGS                (VM_WRITE | VM_EXEC)

+/* #define FORBIDDEN_MMAP_FLAGS                (VM_WRITE | VM_EXEC) */

+#define FORBIDDEN_MMAP_FLAGS                (VM_WRITE)

#else

#define FORBIDDEN_MMAP_FLAGS                (VM_WRITE)

#endif

* framebuffer

Android 使用了 double buffer/page flipping。 所以 framebuffer 的驱动必须支持 double buffer.

NaviEngine 原有的驱动并不支持该功能。我增加了这个patch: ne1-fb-double-buffer.patch

主要是增加了 ne1_fb_pan_display 函数。 这个函数是切换buffer时候被调用的。

Double buffer 设计成 上下两个buffer的模式, 因此, xres_virtual = xres, yres_virtual = yres * 2,

struct fb_info  结构体的 ypanstep 要设成 1。 另外,内核分配framebuffer内存的时候也需要分配两倍的内存。

这样,切换buffer 的时候会调用 ne1_fb_pan_display(), 该函数将新的内存地址写到LCD控制器。

+/*

+ * Set new x,y offsets in the virtual display for the visible area and switch

+ * to the new mode.

+ */

+static int ne1_fb_pan_display(struct fb_var_screeninfo *var,

+                   struct fb_info *info)

+{

+    struct ne1_fb_par *par = info->par;

+    unsigned int bytes_pixel = var->bits_per_pixel / 8;

+    unsigned long offset;

+

+    info->var.xoffset = var->xoffset;

+    info->var.yoffset = var->yoffset;

+

+    offset = var->xoffset * bytes_pixel +

+         var->yoffset * info->fix.line_length;

+

+    // Set buffer start address

+    ne1_fb_write64((NE1_HW_LAYER_1 << 32) | (NE1_HW_LAYER_0 + offset), par->regs + MF_SADR_01);

+

+    return 0;

+}

2. Android 文件系统

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

要在目标板上启动 Android, 需要 Android 的文件系统。这些可以从 Android 的模拟器里得到。  参考这边文章:  extract-google-android-file-system

以下是具体的步骤:

* Start emulator in debug mode and with sdcard:

# emulator -sdcard card.img -debug-kernel

* card.img is created by mksdcard command:

# mksdcard -l card 256M card.img

* Download busybox from above link or busybox for android.

* After emulator started, do this in host:

# adb push busybox /system/bin/busybox

# adb shell         (commands below runs on emulator shell)

# chmod 755 /system/bin/busybox

# cd /sdcard

# busybox tar cf system.tar /system

# cd /

# umount /sdcard

* Follow the guide above, it says the /data direcotry is also needed.

But from the init.rc, the init scripts create this directory. So

it is not necessary to dump data directory.

* shutdown the emulator, and copy system.tar out

# mount -o loop card.img /mnt/sdcard

# ls /mnt/sdcard/ -l

-r-xr-xr-x 1 root root 45923328 2009-01-09 13:46 system.tar

# cp /mnt/sdcard/system.img  .

# umount /mnt/sdcard

* Make android filesystem

Now we have all the files for android filesystem:

* system.tar dumped from emulator

* ramdisk.img in emulator directory:  tools/lib/images/

# mkdir android_rootfs

# cd android_rootfs

* unpack system.tar

# tar xf ~/android/system.tar

* unpack ramdisk.img

Android ram disk image is a gziped cpio archive.

# cp ramdisk.img ramdisk.gz

# gunzip ramdisk.gz

# cd android_rootfs

# cpio -iv < ../ramdisk

* Now the android rootfs contained the files we need.

另外,还有几个文件需要修改一下: init.rc init.goldfish.rc 和 /system/etc/init.goldfish.sh. 这几个文件都是针对 goldfish 目标板的。 init 程序会读这些文件并执行相应的命令。

init 程序读取配置文件的时候,目标板的名字是通过以下接口获得的:

# cat /proc/cpuinfo

Processor       : ARMv6-compatible processor rev 4 (v6l)

......

Hardware        : NE1

Revision        : 0000

上面 Hardware 就是 init 使用的目标板的名字。因此:

# cp init.goldfish.rc init.ne1.rc

# cp /system/etc/init.goldfish.sh /system/etc/init.ne1.sh

然后再修改 init.rc init.ne1.rc 和/system/etc/init.ne1.sh

3. 启动  Android

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

可以直接从 Android rootfs 里启动,也可以先从原有的根文件系统启动,然后通过 chroot 命令切换到 Android 文件系统并启动 Android. 这里选择后者。

NaviEngine 使用 NFS, 因此,首先从 NFS 启动系统,然后在切换到 Android 文件系统。 这里将 Android 文件系统放在 USB HardDisk 上。

NaviEngine 启动完之后,通过一下脚本  start_android.sh  切换到  Android 文件系统:

----------------------------------

#!/bin/sh -x

echo "Starting Android ..."

mount /dev/sda1 /mnt/usb

rm -f /mnt/usb/tmp/*

umount /sys

umount /dev/pts

umount /proc

umask 000

chroot /mnt/usb /system/bin/sh

----------------------------------

运行该脚本之后,进入了 Android 的 shell(注意上面 chroot 命令后面的参数: /system/bin/sh 表示切换之后运行该命令,启动shell)。

最后,执行该命令:

# ./init

init: cannot open '/initlogo.rle'

sh: can't access tty; job control turned off

# warning: `rild' uses 32-bit capabilities (legacy support in use)

LCD 上出现了 Android 文字和 Android 的 LOGO。  Enjoy it.

# ps

USER     PID   PPID  VSIZE RSS   WCHAN    PC         NAME

root     1     0     1376  500   c003f6e4 40064db0 S /bin/busybox

root     2     0     0     0     c0051208 00000000 S kthreadd

root     3     2     0     0     c0041e50 00000000 S ksoftirqd/0

root     4     2     0     0     c0061790 00000000 S watchdog/0

root     5     2     0     0     c004e124 00000000 S events/0

root     6     2     0     0     c004e124 00000000 S khelper

root     101   2     0     0     c004e124 00000000 S kblockd/0

root     112   2     0     0     c026323c 00000000 S khubd

root     115   2     0     0     c02829a4 00000000 S kseriod

root     135   2     0     0     c0070800 00000000 S pdflush

root     136   2     0     0     c0070800 00000000 S pdflush

root     137   2     0     0     c007531c 00000000 S kswapd0

root     139   2     0     0     c004e124 00000000 S aio/0

root     140   2     0     0     c004e124 00000000 S nfsiod

root     142   2     0     0     c004e124 00000000 S xfs_mru_cache

root     143   2     0     0     c004e124 00000000 S xfslogd/0

root     144   2     0     0     c004e124 00000000 S xfsdatad/0

root     357   2     0     0     c004e124 00000000 S kpsmoused

root     359   2     0     0     c004e124 00000000 S kstriped

root     362   2     0     0     c004e124 00000000 S hid_compat

root     386   2     0     0     c004e124 00000000 S rpciod/0

root     443   1     2192  232   c009dbf0 4012fb34 S /devel/usr/sbin/telnetd

root     452   1     1364  500   c003f6e4 40064db0 S /bin/ash

root     456   2     0     0     c0252278 00000000 S scsi_eh_1

root     457   2     0     0     c027ba3c 00000000 S usb-storage

root     472   452   2840  1292  c003f6e4 40125778 S /bin/sh

root     478   472   708   320   c003f6e4 afe0d0dc S /system/bin/sh

root     479   478   288   196   c009d69c 0000c58c S ./init

root     733   479   740   332   c003f6e4 afe0d0dc S /system/bin/sh

system   734   479   812   268   c0240428 afe0c33c S /system/bin/servicemanager

root     735   479   1848  356   ffffffff afe0c09c S /system/bin/mountd

root     736   479   668   268   c02b0220 afe0cccc S /system/bin/debuggerd

radio    737   479   3276  616   ffffffff afe0c9ac S /system/bin/rild

root     738   479   70640 18848 c009dbf0 afe0c464 S zygote

media    739   479   17828 3476  ffffffff afe0c33c S /system/bin/mediaserver

bluetooth 740   479   1168  572   c009d69c afe0d2ac S /system/bin/dbus-daemon

root     741   479   804   312   c0309e6c afe0c09c S /system/bin/installd

system   755   738   174828 27052 ffffffff afe0c33c S system_server

radio    793   738   101896 17776 ffffffff afe0d434 S com.android.phone

app_3    797   738   115224 23304 ffffffff afe0d434 S android.process.acore

app_21   808   738   92532 14636 ffffffff afe0d434 S com.example.android.softkeyboard

app_7    824   738   96228 15628 ffffffff afe0d434 S com.android.mms

app_0    837   738   92768 14784 ffffffff afe0d434 S com.android.alarmclock

app_25   846   738   95016 14920 ffffffff afe0d434 S android.process.im

app_22   853   738   95016 16244 ffffffff afe0d434 S com.android.calendar

app_2    867   738   94960 15668 ffffffff afe0d434 S android.process.media

root     882   733   888   348   00000000 afe0c09c R ps

也可以通过 logcat 命令查看 系统log。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值