[original file is celf-android-demo-071221.pdf by Jynji Kondo, Fujitsu Software Technologies]
[translated by ikoma]


CELF Technical Jamboree #18
Dec. 21, 2007


Google Android on Working Target

December 20, 2007
Jyunji Kondo
Fujitsu Software Technologies Limited


Agenda

* Motivation

* Misc Anecdotes while Porting

* Demo

2 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Embedded Linux WG and Android

* Background

3 Copyright 2007 WCMF, All rights reserved. [WCMF: Wilcom Core Module Forum]


Hypothesis

[See original file for figures]

 +-------+                     +-------+
 |  App  |  No fix             |  App  |
 |Package|  required           |Package|
 |(.apk) |  for apps           |(.apk) |
 +-------+                     +-------+
     |                             | 
+----|expand----------+           +----|expand----------+
|    V                |           |    V                |
|+--------+  +-------+|           |+--------+  +-------+|
|| Dalvik |  | Class ||           || Dalvik |  | Class ||
||Bytecode|  |Library||           ||Bytecode|  |Library||
|| (.dex) |  +-------+|           || (.dex) |  +-------+|
|+--------+      |    |           |+--------+      |    |
|     |          |convert         |     |          |convert
| conv|          |    |           | conv|          |    |
|     V          V    |           |     V          V    |
|+-------+   +-------+| VM can    |+-------+   +-------+|
||  CPU  |<->|  CPU  || also be   ||  CPU  |<->|  CPU  ||
||native | L |native || reused    ||native | L |native ||
|| code  | I | code  || as CPU    || code  | I | code  ||
||(ARMv5)| N |(ARMv5)|| arch is   ||(ARMv5)| N |(ARMv5)||
|+-------+ K +-------+| identical |+-------+ K +-------+|
|                     |           |                     |
|Dalvik VM (for AMRv5)|           |Dalvik VM (for AMRv5)|
+---------------------+           +---------------------+

+---------------------+           +---------------------+
|     Linux Kernel    |==========>|     Linux Kernel    |
|  (for ARMv5 + BSP)  |only kernel|  (for i.MX31 PHS)   |
+---------------------+ should be +---------------------+
                                           ported for each
                                           hardware

4 Copyright 2007 WCMF, All rights reserved.


For Openers, from dmesg

[See original file for screenshot]

C:¥android_sdk_windows_m3-rc20a¥tools>emulator -console -debug-kernel
Uncompressing Linux................................................................................. done, booting the kernel.
Linux version 2.6.23-gcc3bc3b4 (arve@arvelnx.corp.google.com) (gcc version 4.2.1) #3
Tue Oct 30 16:28:18 PDT 2007
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00003137
Machine: Goldfish
Memory policy: ECC disabled, Data cache writeback
CPU0: D VIVT write-through cache
CPU0: I cache: 4096 bytes, associativity 4, 32 byte lines, 32 sets
CPU0: D cache: 65536 bytes, associativity 4, 32 byte lines, 512 sets
Built 1 zonelists in Zone order. Total pages: 24384
Kernel command line: qemu=1 console=ttyS0 androidboot.console=ttyS0 android.checkjni=1
android.ril=ttyS1
Unknown boot option `androidboot.console=ttyS0': ignoring
Unknown boot option `android.checkjni=1': ignoring
Unknown boot option `android.ril=ttyS1': ignoring
PID hash table entries: 512 (order: 9, 2048 bytes)
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 96MB = 96MB total
:

5 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Notable lines from dmesg (1)

[See original file for screenshots]

CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00003137
Machine: Goldfish

Memory: 96MB = 96MB total
Memory: 94212KB available (2268K code, 458K data, 96K init)

goldfish_new_pdev goldfish_interrupt_controller at ff000000 irq -1
:
goldfish_pdev_worker registered goldfish-switch
:

yaffs Oct 30 2007 16:24:34 Installing.

logger: created 64K log 'log_main'
logger: created 64K log 'log_events'
logger: created 64K log 'log_radio'

6 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Notable lines from dmesg (2)

[See original file for screenshot]

init: HOW ARE YOU GENTLEMEN
init: reading config file
init: device init
init: mtd partition -1,
init: mtd partition 0, "system"
yaffs: dev is 32505856 name is "mtdblock0"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.0, "mtdblock0"
init: mtd partition 1, "userdata"
yaffs: dev is 32505857 name is "mtdblock1"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.1, "mtdblock1"
eth0: link up
# binder_open(c0843300 c59ca9e0) (pid 456) got c5ca5000
binder_open(c0843300 c59ca5e0) (pid 467) got c469d000
binder_open(c0843300 c46df9a0) (pid 464) got c46f4000
android_power: auto off timeout set to 604800 seconds
binder_open(c0843300 c41b7ac0) (pid 505) got c411b000
binder_open(c0843300 c41b79c0) (pid 504) got c396d000
binder_open(c0843300 c41b7dc0) (pid 521) got c39e3000

7 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Check Kernel Source Code (1)

* linux-2.6.23-android-m3-rc20.tar.gz in http://code.google.com/p/android/downloads/list

* git repository( http://groups.google.com/group/linux-msm-kernel/ )

* Kernel configuration

C:¥android_sdk_windows_m3-rc22a¥tools>adb pull /proc/config.gz config.gz

* Lesson from our experience:

8 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Check Kernel Source Code (2)

* These files seem to have to be added:

* Reference

5b79477dd1352450/b230a044e0627de9#b230a044e0627de9

9 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Preparing rootfs

* Login to emulator

  C:¥android_sdk_windows_m3-rc22a¥tools>adb push busybox /tmp/busybox
  C:¥android_sdk_windows_m3-rc22a¥tools>adb shell

* Extract major files from SDK using busybox

  C:¥android_sdk_windows_m3-rc22a¥tools>adb pull /tmp/rootfs.tar

* Reference

10 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


OK, Let's Begin!

* No trouble for kernel initialization, then /init

* Does not work...

* Modify /init/init.rc to prevent automatic invocation of zygote and runtime

* Runtime halted incompletely

# /system/bin/app_process -Xzygote /system/bin ‒zygote &
# /system/bin/runtime
"fatal error opening "/sys/android_power/acquire_partial_wake_lock""

* This is because drivers under drivers/android/ are missing

* As a result, by making files below visible, the red ball started to move

11 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Then, Binder

* Still does not work...

* Analyze using strace

# /system/bin/app_process -Xzygote /system/bin ‒zygote &
# /strace ‒f ‒ff ‒tt ‒s 200 /system/bin/runtime
:
00:52:52.583667 open("/dev/binder", O_RDWR¦O_LARGEFILE) = 4
00:52:52.615474 fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
00:52:52.615801 ioctl(4, 0xc0046209, 0xbe9bacbc) = -1 ENOTTY (Inappropriate ioctl
00:52:52.616147 close(4) = 0
00:52:52.616427 close(-1) = -1 EBADF (Bad file descriptor)
00:52:52.616676 ioctl(-1, 0x40046205, 0xbe9bacb8) = -1 EBADF (Bad file descriptor

* Lesson from our experience

* Finally the familiar screen with emulator appears

12 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


How to Build Application in C Language

* Built strace by ourselves

* Used CodeSourcery's ARM GNU/Linux version of toolchain

* Did not use DLL(/system/lib/) in Android; Used as static link

* Refernece

13 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Rendering Mechanism

* Screen flickers with icon operation and screen transition

* So studied mechanism of rendering

* Rendering by mmap'ing frame buffer (/dev/graphics/fb0)

* Frame buffer is as large as for two screens (double buffering)

* Screen change with ioctl(EBIOPUT_VSCREENINFO)

* Lesson from our experience

14 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Touch Screen

[See original file for image]

* Screen of SDK can be cliked and dragged to operate

* Investigated with embeddeding debugging code into qemu

* Android seems to be monitoring all device files under /dev/input/

* Modified information detected by touch screen to notify with /dev/input/event1

* Lesson from our experience

15 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Phone Functions (1)

[See original file for figure]

* rild (Radio Interface Layer daemon?) controls

/system/bin/rild -l /system/lib/libreference-ril.so -- -d /dev/smd0

* It seems that specific DLL is loaded for each communication method

* Libreference-ril.so is for GSM

* In SDK, a module called android modem is implemented on qemu side

+---------------------------+
| Android                   |
|  +-------------------+    |
|  |rlid               |    |
|  | +-------------------+  |
|  +-|libreference-ril.so|  |
|    +-------------------+  |
+-----------------------^---+
                        |
                        V
                      +---------+
+---------------------|/dev/smd0|-------------------+
| kernel              +---------+                   |
+---------------------------^-----------------------+
                            |
+---------------------------V-----------------------+
| Android             +-------------+               |
|                     |Android modem|               |
|                     +-------------+               |
+---------------------------------------------------+

16 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Phone Functions (2)

[See original file for figure]

* To support WSIM...

+---------------------------+
| Android                   |
|  +-------------------+    |                 +-------+   +-------+
|  |rlid               |    |                 |wsimd  |   |Android|
|  | +-------------------+  |   +--------+    |       |   | Modem |
|  +-|libreference-ril.so|<---->|Virtual |<-->|       |<->|       |
|    +-------------------+  |   |Terminal|    |       |   |       |
+---------------------------+   +--------+ +->|       |   |       |
                                           |  +-------+   +-------+
                                           |      ^
                                +----------+      |
                                |                 |
                                V                 V
                      +----------+            +-----------+
+---------------------|/dev/ttyS0|------------|Proprietary|-------+
| kernel              +----------+            |  Driver   |       |
|                           ^                 +-----------+       |
+---------------------------|-------------------------------------+
                            |
                            V
                        +-------+
                        | W-SIM |
                        +-------+

17 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


Phone Functions (3)

[See original file for figure]

* But ideally we want to do like this:

+---------------------------+
| Android                   |
|  +-------------------+    |
|  |rlid               |    |   For that purpose, we hope to know
|  | +-------------------+  |   the interface to libreference-ril.so
|  +-|libreference-ril.so| <----------+
|    +-------------------+  |         |
+-------------^-------------+         |
              |                       |
              V                       V
        +-----------+              +----------+           
+-------|Proprietary|--------------|/dev/ttyS0|-------------------+
| kernel|  Driver   |              +----------+                   |
|       +-----------+                    ^                        |
+----------------------------------------|------------------------+
                                         V
                                     +-------+
                                     | W-SIM |
                                     +-------+

18 Copyright 2007 FUJITSU SOFTWARE TECHNOLOGIES LIMITED


i.MX31 PHS Reference Design

[See original file for photo]

* By Freescale Semiconductor

* i.MX31 evaluation board

19 Copyright 2007 WCMF, All rights reserved.


Sandgate III-P

[See original file for photo]

* By Sophia Systems

* Marvell PXA310 evaluation board

20


Demonstration

* User Interface

* Internet Connection

* Voice Communication

* Start Up

* W-SIM Control

21


22

Fujitsu

THE POSSIBILITIES ARE INFINITE




Jamboree18AndroidDemo (2008-05-07 18:21:54由localhost编辑)