Quick hack to run Android 2.3(Gingerbread) on KZM-A9-Dual board

I tried to run Android 2.3 (Gingerbread) on KZM-A9-Dual board. I show you this quick hack.
(Japanese version)

0. Preparation

Get source code of android-2.3

At the new directory:

$ mkdir android-2.3
$ cd android-2.3
$ export ANDROID=$PWD
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.3.4_r1
$ repo sync -j4

If you already have android-2.3.3, let’s update it

$ cd android-2.3
$ export ANDROID=$PWD
$ repo forall -c git checkout -f
$ rm -rf out out.*$ repo init -b android-2.3.4_r1
$ repo sync -j4

1. At first, build the emulator

set environment variables such as PATH to use java6

env.sh:

export ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export PATH=$JAVA_HOME/bin:$PATH
$ . env.sh
$ . build/envsetup.sh
$ lunch generic-eng

Build

$ time make -j8 2>&1 |tee make.log

Time to build

real 15m7.034s
user 124m28.730s
sys 6m51.310s

My build machine is Ubuntu 10.04, CPU: Intel Core i7 950 @3.07GHz, memory 12GB

Start the emulator

$ emulator &
$ adb logcat

2. Build for KZM-A9-Dual board

set environment variables and build

./build.sh:

export ARCH_ARM_HAVE_TLS_REGISTER=true
export TARGET_ARCH_VARIANT=armv7-a-neon
export TARGET_CPU_SMP=true
export WITH_JIT=true
export JS_ENGINE=v8
time make -j8 showcommands 2&>1 |tee make.log
$ rm -rf out
$ ./build.sh

Time to build. Faster than last time because source file is in cache.

real 13m54.898s
user 108m58.990s
sys 6m11.980s

Copy root file system to NFS server.

./make_nfsroot.sh:

ROOT=/export/android/root
[ -e $ROOT ] && sudo rm -rf $ROOT
mkdir -p $ROOT
cd out/target/product/generic/
#cd out/target/product/kzm9d/
zcat ramdisk.img | (cd $ROOT; cpio -i)
cp -a system $ROOT#cp -a data $ROOT
#[ -e $ROOT/data/app ] && chmod 771 $ROOT/data/app
cp $ROOT/init.rc $ROOT/init.rc.org
sed -e 's/mount rootfs/#mount rootfs/' $ROOT/init.rc.org > $ROOT/init.rc
sudo chown -R root:root $ROOT
$ ./make_nfsroot.sh

Boot on KZM-A9-Dual board.
The kernel boot parameters are following. Assume NFS server’s IP address is 192.168.1.26.

root=/dev/nfs nfsroot=192.168.1.26:/export/android/root ip=dhcp \
noinitrd init=/init mem=129M@0x40000000 mem=256M@0x50000000 \
debug no_console_suspend=1 console=ttyS1,115200n8n \
androidboot.console=ttyS1 video=qfb rootwait rw

In this moment, LCD screen is not displayed correctly. This is because kernel driver expect 24bit color but Android makes screen in 16bit color.

On the serial console,

$ ps
USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
root      1     0     264    180   c00aef2c 0000875c S /init
root      2     0     0      0     c006291c 00000000 S kthreadd
root      3     2     0      0     c004aa68 00000000 S migration/0
root      4     2     0      0     c0053450 00000000 S ksoftirqd/0
root      5     2     0      0     c004aa68 00000000 S migration/1
root      6     2     0      0     c0053450 00000000 S ksoftirqd/1
root      7     2     0      0     c005eaf8 00000000 S events/0
root      8     2     0      0     c005eaf8 00000000 S events/1
root      9     2     0      0     c005eaf8 00000000 S work_on_cpu/0
root      10    2     0      0     c005eaf8 00000000 S work_on_cpu/1
root      11    2     0      0     c005eaf8 00000000 S khelper
root      12    2     0      0     c005eaf8 00000000 S suspend
root      13    2     0      0     c005eaf8 00000000 S kblockd/0
root      14    2     0      0     c005eaf8 00000000 S kblockd/1
root      15    2     0      0     c005eaf8 00000000 S ksuspend_usbd
root      16    2     0      0     c01de9d4 00000000 S khubd
root      17    2     0      0     c005eaf8 00000000 S kmmcd
root      18    2     0      0     c0085ae0 00000000 S pdflush
root      19    2     0      0     c0085ae0 00000000 S pdflush
root      20    2     0      0     c0089e44 00000000 S kswapd0
root      21    2     0      0     c005eaf8 00000000 S aio/0
root      22    2     0      0     c005eaf8 00000000 S aio/1
root      23    2     0      0     c005eaf8 00000000 S nfsiod
root      24    2     0      0     c005eaf8 00000000 S emxx_fb
root      25    2     0      0     c005eaf8 00000000 S emxx_lcd
root      26    2     0      0     c01b7c04 00000000 S kv4l2_rot
root      27    2     0      0     c01b7c04 00000000 S kv4l2_tmr
root      28    2     0      0     c01b7c04 00000000 S kv4l2_lcd
root      29    2     0      0     c01d1580 00000000 S mtdblockd
root      30    2     0      0     c005eaf8 00000000 S ehci-wq
root      31    2     0      0     c005eaf8 00000000 S usb_suspend
root      32    2     0      0     c0203f1c 00000000 S usb_mass_storag
root      33    2     0      0     c005eaf8 00000000 S rpciod/0
root      34    2     0      0     c005eaf8 00000000 S rpciod/1
root      35    2     0      0     c0218c5c 00000000 S mmcqd
root      36    1     248    156   c00aef2c 0000875c S /sbin/ueventd
system    41    1     768    260   c022950c afd0b6fc S /system/bin/servicemanager
root      42    1     3824   564   ffffffff afd0bdac S /system/bin/vold
root      43    1     3796   560   ffffffff afd0bdac S /system/bin/netd
root      44    1     628    264   c02588c0 afd0c0cc S /system/bin/debuggerd
radio     45    1     4336   672   ffffffff afd0bdac S /system/bin/rild
root      46    1     61324  26580 c00aef2c afd0b844 S zygote
media     47    1     16804  3692  ffffffff afd0b6fc S /system/bin/mediaserver
bluetooth 48    1     1216   572   c00aef2c afd0c59c S /system/bin/dbus-daemon
root      49    1     776    316   c02a8424 afd0b45c S /system/bin/installd
keystore  50    1     1704   432   c02588c0 afd0c0cc S /system/bin/keystore
shell     51    1     696    336   c0050934 afd0c3ac S /system/bin/sh
root      52    1     3356   160   ffffffff 00008294 S /sbin/adbd
system    66    46    129248 35628 ffffffff afd0b6fc S system_server
system    114   46    74028  21096 ffffffff afd0c51c S com.android.systemui
app_24    122   46    79320  19184 ffffffff afd0c51c S com.android.inputmethod.latin
radio     134   46    87000  19468 ffffffff afd0c51c S com.android.phone
app_18    138   46    80080  24552 ffffffff afd0c51c S com.android.launcher
app_7     165   46    82172  21832 ffffffff afd0c51c S android.process.acore
app_0     196   46    73144  16628 ffffffff afd0c51c S com.android.deskclock
app_14    202   46    75192  17628 ffffffff afd0c51c S android.process.media
app_3     216   46    72420  16788 ffffffff afd0c51c S com.android.bluetooth
app_25    233   46    83452  17004 ffffffff afd0c51c S com.android.mms
app_26    251   46    75884  17968 ffffffff afd0c51c S com.android.email
app_27    266   46    74056  17156 ffffffff afd0c51c S com.android.providers.calendar
app_1     285   46    72836  15444 ffffffff afd0c51c S com.android.protips
app_19    295   46    72360  15720 ffffffff afd0c51c S com.android.music
app_21    304   46    73872  16348 ffffffff afd0c51c S com.android.quicksearchbox
app_28    314   46    72480  17800 ffffffff afd0c51c S com.cooliris.media
shell     324   51    856    316   00000000 afd0b45c R ps
$

OK if these processes are alive.

Bring files from KZM-A9-Dual build tree

Set $FROYO at the top directory of KZM-A9-Dual source code, which is include in DVD with the board

$ export FROYO=/path/to/KZM-A9-Dual/source/mydroid/

copy gralloc and related header files

$ cp $FROYO/bionic/libc/kernel/common/linux/fbcommon.h bionic/libc/kernel/common/linux/
$ cd hardware/libhardware/modules/
$ mv gralloc /tmp
$ cp -a $FROYO/hardware/renesas/emxx/libgralloc gralloc
$ cd gralloc/
$ cp Android.mk Android.mk.org
$ vi Android.mk

Edited Android.mk at the following line.

$ diff -u Android.mk.org Android.mk

--- Android.mk.org 2011-05-02 14:23:39.357460129 +0900
+++ Android.mk 2011-05-02 14:24:35.807459846 +0900
@@ -28,6 +28,6 @@
  framebuffer.cpp 
  mapper.cpp
  
-LOCAL_MODULE := gralloc.emxx
+LOCAL_MODULE := gralloc.default
 LOCAL_CFLAGS:= -DLOG_TAG="gralloc"
 include $(BUILD_SHARED_LIBRARY)

Back to the top directory, and clean build. (You need clean build because makefile is changed.)

$ cd $ANDROID$ rm -rf out
$ ./build.sh

Time to build

real 13m52.893s
user 109m16.830s
sys 6m10.000s
$ ./make_nfsroot.sh

Then boot the board again. Now the screen is diplayed correctly.
But icons and fonts are smaller than expected.
(I found the reason and solved. See this page.)

DSC00340 DSC00341

Adjust settings

DNS server settings are required to browse internet. And need to modify /system/etc/vold.fstab to mount SD card.
Copy these files from previous KZM-A9-Dual source tree to NFS server.

$ export NFS_ROOT=/export/android/root
$ sudo cp $FROYO/device/kmc/kzm9d/init.kzm9d.rc $NFS_ROOT/
$ sudo cp $FROYO/device/kmc/kzm9d/init.kzm9d.sh $NFS_ROOT/system/etc/
$ sudo cp $FROYO/device/kmc/kzm9d/vold.fstab $NFS_ROOT/system/etc/

From gingerbread, the shell of serial console becomes not root. This is inconvient to work. So modify init.rc to get root shell on the serial console as before.

$ sudo diff -u init.rc.org init.rc
--- init.rc.org 2011-05-02 18:07:19.000000000 +0900
+++ init.rc 2011-05-02 18:08:47.000000000 +0900
@@ -283,8 +283,8 @@
 service console /system/bin/sh
     console
     disabled
-    user shell
-    group log
+#    user shell
+#    group log
 
 on property:ro.secure=0
     start console

Related pages

Icons and fonts are too small at Gingerbread (Resolved)
Tips of “repo sync” of Android
Downloading source code and build Android2.3(Gingerbread) (in Japanese)
Tips of repo sync of Android(in Japanese)

Advertisements

About tetsu_koba

Engineer.
This entry was posted in Android, KZM-A9-Dual. Bookmark the permalink.

7 Responses to Quick hack to run Android 2.3(Gingerbread) on KZM-A9-Dual board

  1. Pingback: Using ccache to build Android « Koba's blog

  2. Pingback: Comparing 3 JDKs by Android build time « Koba's blog

  3. Pingback: Boot Android 2.3(Gingerbread) from SD card on KZM-A9-Dual board « Koba's blog

  4. Pingback: Tips of “repo sync” of Android « Koba's blog

  5. super3001 says:

    hello kobaさん!

    this is indeed quite interesting and promising.
    can android 2.3 run smoothly or did you find any important issues with it?

    by the way, do you think your build could work with this tablet (http://dokidokido.com/category/tablet/n71n/index.html)? after all, it seems to use the same NEC-renesas (emma) CPU as your hardware. you can find the SDK for it here http://www.megaupload.com/?d=TJOWGB5G

    i have the foillowing issues with my tablet (android 2.2 N71N), and would like to know if you have the same problems with your device (KZM-A9):

    -playing video files (720p H264 mp4 and 480p DivX avi) is jerky
    -when it shuts down, it makes a loud whirring noise
    -it gets warmer than my other tablet
    -gsensor doesn’t work well with some games (xtreme race, donkey jump, etc)
    -volume is too low and distorted (when set at maximum)

    i wonder if these problems could be solved using your hacked gingerbread build.

    i look forward to your input.

    宜しくお願いします

  6. tetsu_koba says:

    This is just ‘quick hack’. Net yet optimized.

    You may misunderstand. A evaluation board and a tablet product is totally different. Don’t crack the tablet. If you want to learn Linux and Android, buy a evaluation board.

  7. Heya i’m for the first time here. I found this board and I in finding It truly useful & it helped me out a lot. I am hoping to present something again and aid others such as you aided me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s