2010年10月6日 星期三

[Android] Kernel Layout

hmtsay@ubuntu:~/kernel/froyo$ ls
arch     Documentation  init    MAINTAINERS  REPORTING-BUGS  usr
block    drivers        ipc     Makefile     samples         virt
COPYING  firmware       Kbuild  mm           scripts
CREDITS  fs             kernel  net          security
crypto   include        lib     README       sound
[]http://www.mulix.org/lectures/tau_linux_workshop/kernel_src_intro.pdf

Note. Android specific drivers is in ~/drivers/misc.
hmtsay@ubuntu:~/kernel/froyo/drivers/misc$ ls
acer-wmi.c       fujitsu-laptop.c   kgdbts.c           sgi-xp
asus-laptop.c    hdpuftrs           lkdtm.c            sony-laptop.c
atmel_pwm.c      hpilo.c            logger.c           tc1100-wmi.c
atmel-ssc.c      hpilo.h            lowmemorykiller.c  thinkpad_acpi.c
atmel_tclib.c    hp-wmi.c           Makefile           tifm_7xx1.c
binder.c         ibmasm             msi-laptop.c       tifm_core.c
compal-laptop.c  intel_menlow.c     phantom.c          timed_gpio.c
eeepc-laptop.c   ioc4.c             pmem.c             timed_output.c
eeprom_93cx6.c   Kconfig            ram_console.c      uid_stat.c
enclosure.c      kernel_debugger.c  sgi-gru

2010年10月5日 星期二

[Android] Project Layout

Core Project: foundation of the Android platform
hmtsay@ubuntu:~/android$ ls
bionic    cts          device      hardware  ndk       prebuilt
bootable  dalvik       external    libcore   out      
sdkbuild     development  frameworks  Makefile  packages  system

[] http://sites.google.com/a/android.com/opensource/projects
cts: Compatibility Test Suite
   []http://source.android.com/compatibility/cts-intro.html
device:
kernel: No (separated Android from Linux kernel)
libcore: ?
ndk: Provide tools and documentation for developers to create native code shared libraries.
out: Compile results? (see PS)
sdk: Provide tools, sample code, and docs for developer to create great applications.

External Project: Android makes use of many other open source projects
hmtsay@ubuntu:~/android/external$ ls
apache-http  elfutils    ipsec-tools     netperf   srec
astl         embunit     iptables        neven     stlport
bison        emma        jdiff           opencore  strace
blktrace     esd         jhead           openssl   svox
bluetooth    expat       jpeg            oprofile  tagsoup
bsdiff       fdlibm      jsilver         ping      tcpdump
bzip2        freetype    jsr305          ppp       tinyxml
clearsilver  fsck_msdos  junit           proguard  tremolo
dbus         genext2fs   kernel-headers  qemu      v8
dhcpcd       giflib      libffi          quake     webkit
dnsmasq      grub        libpcap         safe-iop  wpa_supplicant
dropbear     gtest       libpng          skia      wpa_supplicant_6e2fsprogs    guava       libxml2         sonivox   xmlwritereasymock     icu4c       mtpd            speex     yaffs2
elfcopy      iproute2    netcat          sqlite    zlib


Packages: standard Android applications and services
hmtsay@ubuntu:~/android/packages$ ls
apps  experimental  inputmethods  providers  wallpapers
hmtsay@ubuntu:~/android/packages$ ls apps/
AccountsAndSyncSettings  CertInstaller  Launcher2         QuickSearchBox
AlarmClock               Contacts       Mms               Settings
Bluetooth                DeskClock      Music             SoundRecorder
Browser                  Email          PackageInstaller  SpeechRecorder
Calculator               Gallery        Phone             Stk
Calendar                 Gallery3D      Protips           VoiceDialer
Camera                   HTMLViewer     Provision
hmtsay@ubuntu:~/android/packages$ ls providers/
ApplicationsProvider  DownloadProvider        MediaProvider
CalendarProvider      DrmProvider             TelephonyProvider
ContactsProvider      GoogleContactsProvider  UserDictionaryProvider

PS. out/: compile results
hmtsay@ubuntu:~/android/out$ ls
casecheck.txt  CaseCheck.txt  host  target  tmp  versions_checked.mk

PS. The system image of Android 2.2 Froyo is about 60MB. 
hmtsay@ubuntu:~/android/out/target/product/generic$ ls -l -a
total 60064
drwxr-xr-x  7 hmtsay hmtsay     4096 2010-10-04 07:52 .
drwxr-xr-x  3 hmtsay hmtsay     4096 2010-10-04 05:51 ..
-rw-r--r--  1 hmtsay hmtsay        7 2010-10-04 07:52 android-info.txt
-rw-r--r--  1 hmtsay hmtsay     1160 2010-10-04 05:51 clean_steps.mk
drwxr-xr-x  3 hmtsay hmtsay     4096 2010-10-04 06:20 data
-rw-r--r--  1 hmtsay hmtsay    16134 2010-10-04 07:52 installed-files.txt
drwxr-xr-x 13 hmtsay hmtsay     4096 2010-10-04 07:44 obj
-rw-r--r--  1 hmtsay hmtsay       50 2010-10-04 05:51 previous_build_config.mk
-rw-r--r--  1 hmtsay hmtsay   166468 2010-10-04 07:52 ramdisk.img
drwxr-xr-x  8 hmtsay hmtsay     4096 2010-10-04 06:21 root
drwxr-xr-x  4 hmtsay hmtsay     4096 2010-10-04 06:21 symbols
drwxr-xr-x 10 hmtsay hmtsay     4096 2010-10-04 07:35 system
-rw-------  1 hmtsay hmtsay 59794944 2010-10-04 07:52 system.img-rw-------  1 hmtsay hmtsay  1482624 2010-10-04 07:52 userdata.img

[Android] Development

1. Application (JAVA)


2. Target Porting
  *Target: Board
    -Linux Kernel Driver
    -Android Platform HAL Driver
  *Target: CPU
    -Architecture
    -Build Environment: Complier Flags, Linker Scripts, Prelinnk Map
    -C Library: Assembly, System Call stubs, Dynamic Linking Linker
    -ELF Processing Tool: Prelinker (apriori), Strip (soslim), ELF Section Processing (elfutils)
    -Dalvik Call Bridge: Assembly
    -Tool Chain

3. System Service
   -Bottom-up Design
   1) Add Native Library (C, C++)
   2) Add JAVA Classes in Platform Framework
   3) Connect JAVA Classes and Native Library via  JNI Interface
   4) Application calls new JAVA classes.

Android Eco-system

1. Software Developers  (Applications, Middlewares, Android Market)
2. Hardware Component Provider (ICs, Modules, Sensors)
3. Device Provider (Smart Phone, Tablet, Netbook, E-book, ...)
4. Infra-structure Provider (3G WCDMA, 3.5G HSDPA, USUPA , 4G LTE)
5. Service Provider
6. Users

Android Architecture

Android Architecture (including Patrick Brady's HAL)


Android_Platform

*4 Levels:
  1.Linux Kernel
    See Android Branch
  2. Runtmie Middleware
    1) Dalvik Virtual Machine for JAVA
      -Each application runs in its own porcess with its own instance of VM. Dalvik can handle multiple VMs. 
      -Register-based Architecture (True Java VMs are stack machines.): Less Instructions & Fast Execution
      -Dalvik Executable (.dex) format, Optimizations for memory, not Java bytecode
      - Compilation: .java --> .class --> .dex      -Android 2.2, Dalvik has a just-in-time compiler to speed up execution of bytecode
by compiling some or all of it to native machine code.
     2) Core Libraries (by JAVA) 
     -JAVA APIs: Data Structures, Utilities, File Access, Network Access, Graphics, ... (e.g., new)  
     3) Native Libraries (by C/C++)
       3.1 Bionic libc
          -Google customized C compiler for Android
            *License Issue: Bionic is BSD license to keep GPL out of user-space.
            *Small Size: about 200K, half  of glibc (GNU libc)
            *Fast Speed: small size & fast speed of pthread(POSIX Threads) implementation
            *Built-in support for important Android-specific services such as system properties and logging.
            *Not fully compatible to glib: not support all POSIX features not needed on Android.
[]http://discuz-android.blogspot.com/2008/10/google-android-native-libc-bionic.html
      2.2 Media Framework
         - Based on PacketVideo OpenCore
         -Support: standard video, audio, still-frame formats
         -Support: hardware/software codec plug-ins

ü      3.3 WebKit  web browser
         -Open source
         -Render pages in full (desktop) view
         -Support Full CSS, JavaScript, DOM, AJAX 
         -Support single-column and adaptive view rendering

      3.4 SQLite
ü         -Light-weight relational database management system
         -Popular in many systems         
ü

       3.5 Surface Manager (Surface Flinger)
         -Combine 2D and 3D surfaces from multiple applications to frame buffer device
ü
       -Surfaces passed as buffers via Binder IPC calls
       -Can use OpenGL ES and 2D hardware accelerator for its compositions
       -Double-buffering using page-flip
      3.6 Audio Manager (Audio Flinger): Processing multiple audio streams into PCM audio out paths
      3.7 SGL: 2D graphics engine
    3) HAL (Hardware Abstraction Layer)
      *In user space, Define the standardized interface for hardware drivers
      *Separate Android Platform from Linux Kernel
      *HW Drivers under HAL are not GPL-licensed and not required to be released

  3.Application Framework
    *Define component APIs used by the core applications
    *Developers reuse/replace the same components easily.   

ü
 
Feature
Role
View
System
Components to build appplications (e.g., lists, grids, text boxes, buttons, and embedded web browser)
Content
Provider
Access data from other applications or to share their own data
Resource
Manager
Provide access to non-code resources (e.g., localized string, graphics, and layout files)
Notification Manager
Display customer alerts in the status bar
Activity
Manager
Manage the lifecycle of (window) applications and provide a common navigation backstack
  4. Applications
  -Programming by JAVA
  -Core Applications: üEmail Client, SMS Program, Calendar, Maps, Browser, üContacts

  PS. 2& 3 are middlewares
  Note. Kernel Layer are GPL license; Other layers are Apache License.

Android Products:
 *SmartPhone, SmartBook (netbook), Tablet, Set-top Box, E-book, ...
      3.8 3D Libraries
ü          -Based on OpenGL ES 1.0 APIs
ü          -Can use H/W 3D acceleration oroptimized 3D S/W rasterizer
      3.9 FreeType: Rendering bitmap and vector font

Android Features

Android Features
1. Open (Source code)
2. Free Services
3. Cloud Computing/Storing
4. Support multiple hardware platform based on Linux Kernel
5. Adpots Standardized Technologies
6. Ready SDK, Tools, & Document

and refer to
1. http://en.wikipedia.org/wiki/Android_(operating_system)
2. http://developer.android.com/guide/basics/what-is-android.html

2010年10月4日 星期一

Android Porting: Make Platform

1. Setup VMware Player
2. Install ubuntu for Linux
3. Add Packages for Getting and Building Source Code
  $sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zliblg-dev
  Issue 1: Add JAVA 5/6 package
  Issue 2. Add repo
    <Step 1>curl http://android.git.kernel.org/repo >~/bin/repo
    <Step 2>chmod a+x ~/bin/repo
    <Step 3> export PATH=~/bin/repo:$PATH
3. Get Android Code Bases
  3.1 Get Android platform source code
  <Step 1> repo init –u git://android.git.kernel.org/platform/manifest.git –b android-2.2_r1
  <Step 2> repo sync


4. Build
   $make

   Issue 1: Build Android 2.2 froyo only in 64bit environment.
   Issue 2:  Build Android 2.2 froyo only by JDK6


[] Android Platform Development Kit: http://www.kandroid.org/android_pdk/index.html
  *Device Requirements:  http://www.kandroid.org/android_pdk/system_requirements.html