Wednesday, December 10, 2008

Tips to import sample Android projects to Eclipse

I am a newbie to Eclipse and Android applications development. I installed the Eclipse yesterday and tried to take a look at the Android sample to start with. I had problems to import sample project into Eclipse. Google is always the one I first tried. I found this article: How to import sample Android projects to Eclipse. It is helpful to me. I think it will also be helpful to others.
Here is the tips: Simply create project from existing source (then use "Browse" to select sample shipped with SDK).

Sunday, December 7, 2008

Nokia N810 with android ported

Peter McDermott has an article about the process of porting android to the Nokia N810. Quite a lot of helpful information included.

http://www.nthcode.com/pubs/porting-android-to-a-new-device.html

Kogan Agora Pro is the next android handset













The Kogan Agora Pro has popped up in Australia as the latest android handset and is available for international pre-order. The phone has a 2.5 inch resistive touchscreen, QUERTY keyboard, 3G and GPS for $399.
HIGHLIGHTS:
· 2.5-inch TFT-LCD flat touch-sensitive screen
· Integrated QWERTY keyboard
· High-speed 3G network connection
· One-Touch Google Search ™
· Easy Web Browsing
· Easy-to-use email with attachment support for images, videos, music and documents
· Customisable Home Screen with instant Email, text message and IM notifications
· Instant access to mobile Internet services (Gmail ™, YouTube ™, Google Talk ™, Google Calendar ™, Google Maps ™)
· Music Player
· microSD™ expansion slot for all your storage needs
· Wi-Fi network access (included with Kogan Agora Pro)
· GPS navigation capability (included with Kogan Agora Pro)
· 2.0 megapixel camera (included with Kogan Agora Pro)
http://gizmodo.com/5101708/kogan-agora-pro-is-the-next-android-handset

Android Dev Phone 1 for developers

The Android Dev Phone 1 is a SIM-unlocked and hardware-unlocked device that is designed for advanced developers. The device ships with a system image that is fully compatible with Android 1.0, so you can rely on it when developing your applications. You can use any SIM in the device and can flash custom Android builds that will work with the unlocked bootloader.

The device currently costs $399 (USD) (including free shipping in the US), and will be available for purchase in 18 international markets, including the US, UK, Germany, Japan, India, Canada, France, Taiwan, Spain, Australia, Singapore, Switzerland, Netherlands, Austria, Sweden, Finland, Poland, and Hungary.

More information, see http://code.google.com/android/dev-devices.html

Wednesday, December 3, 2008

struct ipv6_mreq has no member named ipv6mr_interface

When I am porting ffmpeg to Google Android, I got an error: 'struct ipv6_mreq' has no member named 'ipv6mr_interface'. I dont understand what happened. When I google the related information, I got this article: Linux kernel headers violate RFC2553. The corresponding header file is bionic/libc/kernel/common/linux/in6.h. I have to correct the usage of ipv6_mreq.ipv6mr_interface into ipv6_mreq.ipv6mr_ifindex.
What I am concern is does Bionic libc use the ipv6_mreq structure in a correct way?

Monday, November 24, 2008

Android build system

Found document in android open source. They are in myandroid/development/pdk/docs/. Following information are from the "Android build system" section. It is more helpful than "Add a new component into open source Android".
A makefile defines how to build a particular application. Makefiles typically include all of the following elements:
  1. Name: Give your build a name (LOCAL_MODULE := ).
  2. Local Variables: Clear local variables with CLEAR_VARS (include $(CLEAR_VARS)).
  3. Files: Determine which files your application depends upon (LOCAL_SRC_FILES := main.c).
  4. Tags: Define tags, as necessary (LOCAL_MODULE_TAGS := eng development).
  5. Libraries: Define whether your application links with other libraries (LOCAL_SHARED_LIBRARIES := cutils).
  6. Template file: Include a template file to define underlining make tools for a particular target (include $(BUILD_EXECUTABLE)).
The following snippet illustrates a typical makefile.
LOCAL_PATH := $(my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE :=
LOCAL_SRC_FILES := main.c
LOCAL_MODULE_TAGS := eng development
LOCAL_SHARED_LIBRARIES := cutils
include $(BUILD_EXECUTABLE)
(HOST_)EXECUTABLE, (HOST_)JAVA_LIBRARY, (HOST_)PREBUILT, (HOST_)SHARED_LIBRARY,
(HOST_)STATIC_LIBRARY, PACKAGE, JAVADOC, RAW_EXECUTABLE, RAW_STATIC_LIBRARY,
COPY_HEADERS, KEY_CHAR_MAP

Saturday, November 15, 2008

Good start to port 3-party to Android

After you have the open source Android, look into folder external/openssl/README.android. It is a good start to port application to Android.

Friday, November 14, 2008

Add a new component into open source Android

The android build system is complicated. It is not easy to create a simple build script to build single component. But it is much easier to add a new component into the build system. Here is a sample to build the "Hello world!" for Android, and it is dynamic linked executable.
  1. create a directory for the new component in $(YOUR_ANDROID)/external folder: $(YOUR_ANDROID)/external/hello
  2. put the hello.c into the directory: $(YOUR_ANDROID)/external/hello/
  3. create Android.mk in $(YOUR_ANDROID)/external/hello/ directory, the Android.mk likes the following:
    LOCAL_PATH:=$(call my-dir)
    include $(CLEAR_VARS)
    LOCAL_ARM_MODE := arm
    LOCAL_SRC_FILES:= \
    hello.c
    LOCAL_MODULE := hello
    include $(BUILD_EXECUTABLE)
  4. add the following line into $(BUILD_SYSTEM)/main.mk,$(BUILD_SYSTEM) is in $(YOUR_ANDROID)/build/core:
    external/hello
  5. launch the build command in $(YOUR_ANDROID): make hello
you will have the build target hello in $(YOUR_ANDROID)/out/target/product/generic/system/bin.
You can use include $(BUILD_SHARED_LIBRARY) to create shared library. Find more in $(YOUR_ANDROID)/build/core/config.mk.

Wednesday, November 12, 2008

build open source android

Refer to Get Source (Android Open Source Project) to get a copy of android open source and make full build. I had a successful build.
The android build system is quite complicated. To make a specific component, run 'make module_name'. Find the module_name in Android.mk, referenced by LOCAL_MODULE. For example, make app_process will build the app_process only.

Friday, October 24, 2008

repo the android opensource via proxy

If you are using proxy, you will get error when run: "repo init -u git://android.git.kernel.org/platform/manifest.git".
Here is a tip to repo via proxy.
To use GIT behind a proxy, have a look at:
http://www.aptgetupdate.de/2007/07/27/git-hinterm-proxy-nutzen/

Basically the steps are:
1 - sudo apt-get install socket
2 - in your home directory, put a shell script called "proxy-cmd.sh"
containing (replace YOUR_PROXY and YOUR_PROXY_PORT with your own proxy
parameters):
#! /bin/bash
(echo "CONNECT $1:$2 HTTP/1.0"; echo; cat ) | socket YOUR_PROXY
YOUR_PROXY_PORT | (read a; read a; cat )
3 - chmod +x proxy-cmd.sh
4 - export GIT_PROXY_COMMAND=/proxy-cmd.sh

Wednesday, October 22, 2008

Android 1.0 drawable tables within android.jar

Android 1.0 drawables shows the images/icons within the android.jar.

You can use any of these images/icons with your Android app, the same way you would with your own "drawables," by simple referencing the correct name in the "android.R.drawable" package, for example:
myMenuItem.setIcon(android.R.drawable.ic_menu_save);

Tuesday, October 21, 2008

Google Android Native libc Bionic library

Google developed a custom library for the C compiler (libc) called Bionic. This was necessary for three main reasons:
  • License: they wanted to keep GPL out of user-space. Bionic code uses the BSD license.
  • Size: the library has to be loaded in each process, so it needs to be small. Bionic is about 200K, or half the size of glibc (the GNU version of libc).
  • Speed: limited CPU power means it needs to be fast. Bionic has a small size and fast code paths, including a very fast and small custom pthread implementation.
Bionic has built-in support for important Android-specific services such as system properties and logging. It doesn’t support certain POSIX features, like C++ exceptions and wide chars, which were not needed on Android. Thus it’s not quite compatible with the gnu libc. All native code must be compiled against bionic, not glibc.

Google Android gets open

Google's open source android now actually open, go to http://source.android.com/download to have a downloading.

Sunday, March 16, 2008

OmniGSoft Games on Android

"OmniGSoft Games on Android" is OmniGSoft's entry for Android Developer Challenge, which consists of ten independent 3D mobile games for Google Android Platform. All games are designed and implemented on OmniGsoft's proprietary cross-platform 3D game engine that supports multiple mobile platforms such as Android, Windows Mobile and JavaME. Powered by OpenGL|ES as 3D graphics power plant and Android accelerometer as an alternative game control, these mobile games are aiming to provide the highest quality of 3D graphics and gaming experience on Android platform.

Sunday, March 2, 2008

Using busybox for google android

Busybox is a very good tool. Here is some tips to make your android developing life easier:
1. busybox telnetd -l /sbin/sh, this is to start telnetd so you can telnet to the android
2. busybox ftpget/ftpput, this is a ftp tool to download/upload files to/from android
3. busybox telnet, telnet tool
4. busybox tftp, tftp tool
5. busybox wget, wget tool
6. more ...

Tuesday, February 26, 2008

sizeof(struct v4l2_requestbuffers) different in kernel and in user compiled program

$ANDROID_M5_KERNEL/kernel/include/linux/videodev2.h:560
struct v4l2_requestbuffers
{
__u32 count;
enum v4l2_buf_type type;
enum v4l2_memory memory;
__u32 reserved[2];
};
The sizeof(struct v4l2_requestbuffers) is 16 bytes running in kernel, while 20 bytes running in user compiled native program. I checked the structure size in detail and found that the sizeof(enum v4l2_buf_type) and sizeof(enum v4l2_memory) are both 1. The actual size of this structure is 4 + 1 + 1 + 8 = 14 bytes. The two continuous enum occupy 4 bytes for DWORD alignment.

In user compiled native program, the sizeof(enum) is 4. Total sizeof(struct) is 20 bytes. Only the size will not cause big problems. But the variable VIDIOC_REQBUFS will be affected by the size of the structure. See following _IOWR definition.
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
That causes the VIDIOC_REQBUFS can't be matched in the kernel code.

To fix the problem, change the structure to the following:
struct v4l2_requestbuffers
{
__u32 count;
enum v4l2_buf_type type;
__u32 reserved[2];
enum v4l2_memory memory;
};
For DWORD alignment, both enum will occupy 4 bytes although each one is 1 byte long in kernel.

Thursday, February 21, 2008

More android apps in android m5 sdk

We can see more google android applications in the latest google android sdk (m5-rc14). Following is the applications:
# Prepping: /system/app/AlarmClock.apk:/system/app/AlarmProvider.apk:/system/app/Anagrams.apk:/system/app/ApiDemos.apk:/system/app/Bounce.apk:/system/app/Browser.apk:/system/app/Calculator.apk:/system/app/Calendar.apk:/system/app/CalendarProvider.apk:/system/app/Camera.apk:/system/app/Contacts.apk:/system/app/DataSets.apk:/system/app/Development.apk:/system/app/Drm.apk:/system/app/Fallback.apk:/system/app/GDataFeedsProvider.apk:/system/app/GTalkDiagnostics.apk:/system/app/GTalkSettings.apk:/system/app/GlobalTime.apk:/system/app/Gmail.apk:/system/app/GmailProvider.apk:/system/app/GoogleApps.apk:/system/app/GoogleAppsProvider.apk:/system/app/Home.apk:/system/app/IM.apk:/system/app/ImProvider.apk:/system/app/LocalePicker.apk:/system/app/Maps.apk:/system/app/MasfProxyService.apk:/system/app/MediaProvider.apk:/system/app/Mms.apk:/system/app/Music.apk:/system/app/NotePad.apk:/system/app/PackageInstaller.apk:/system/app/Phone.apk:/system/app/Settings.apk:/system/app/SettingsProvider.apk:/system/app/SetupWizard.apk:/system/app/Snake.apk:/system/app/Street.apk:/system/app/Sync.apk:/system/app/SyncProvider.apk:/system/app/Talk.apk:/system/app/TelephonyProvider.apk:/system/app/Term.apk:/system/app/ToDoList.apk:/system/app/Updater.apk:/system/app/Vending.apk:/system/app/VoiceDialer.apk:/system/app/Voicemail.apk:/system/app/YouTube.apk:/system/app/gtalkservice.apk
File not found: /system/app/AlarmClock.apk
File not found: /system/app/AlarmProvider.apk
File not found: /system/app/Anagrams.apk
File not found: /system/app/ApiDemos.apk
File not found: /system/app/Bounce.apk
File not found: /system/app/Calculator.apk
File not found: /system/app/Calendar.apk
File not found: /system/app/CalendarProvider.apk
File not found: /system/app/Camera.apk
File not found: /system/app/DataSets.apk
File not found: /system/app/Drm.apk
File not found: /system/app/GDataFeedsProvider.apk
File not found: /system/app/GTalkDiagnostics.apk
File not found: /system/app/GlobalTime.apk
File not found: /system/app/Gmail.apk
File not found: /system/app/GmailProvider.apk
File not found: /system/app/IM.apk
File not found: /system/app/LocalePicker.apk
File not found: /system/app/Mms.apk
File not found: /system/app/Music.apk
File not found: /system/app/NotePad.apk
File not found: /system/app/PackageInstaller.apk
File not found: /system/app/Settings.apk
File not found: /system/app/SetupWizard.apk
File not found: /system/app/Snake.apk
File not found: /system/app/Street.apk
File not found: /system/app/Sync.apk
File not found: /system/app/SyncProvider.apk
File not found: /system/app/Talk.apk
File not found: /system/app/Term.apk
File not found: /system/app/ToDoList.apk
File not found: /system/app/Updater.apk
File not found: /system/app/Vending.apk
File not found: /system/app/VoiceDialer.apk
File not found: /system/app/Voicemail.apk
File not found: /system/app/YouTube.apk
Prep complete.
Interesting that there are streat.apk, I guess it may be google streat view application.

Check on "Allow old ABI binaries ..." got Illegal instruction

With the google android kernel source, after "make goldfish_defconfig", check on "Kernel Features" -> "Allow old ABI binaries to run with this kernel", I got following simple native program failed with "Illegal instruction". The test native program source is in the following:
#include
#include
#include
#include
#include

void _sig_handler(int signo)
{
printf("Got it: %d, %x, \n", signo, &signo);
}

int
main(int argc, char * argv[])
{
struct sigaction sa;

memset(&sa, 0x0, sizeof(sa));
sa.sa_flags = SA_RESTART;
sa.sa_handler = _sig_handler;
if (sigaction(SIGALRM, &sa, NULL) < 0) {
perror("sigaction");
return -1;
}

alarm(1);
sleep(2);
printf("Sleep ... done\n");
return 0;
}
Follow the article Initialize libc for Android to create a dynamic linked android native program, and upload it to emulator. This native program will end with "Illegal instruction".

ABI is abbreviated of Application Binary Interface, but I dont know why it will have such problems when check on Old ABI binaries. So dont use it before you know you have to and how to.

Tips:
1. after create a new kernel file, e.g. zImage, use -kernel zImage to use it in android emulator.

Friday, February 1, 2008

Google Android is using ALSA as audio

The Google Android Emulator is using /dev/eac as the audio device. The /dev/eac is the Android QEMU audio driver. The ioctl interface is empty. There is a comment line giving the hints that Google Android is going to use ALSA as audio.
static int goldfish_audio_ioctl(struct inode* ip, struct file* fp, unsigned int cmd, unsigned long arg)
{
/* temporary workaround, until we switch to the ALSA API */
if (cmd == 315)
return -1;
else
return 0;
}
ALSA Introduction:
The Advanced Linux Sound Architecture (ALSA) provides audio and MIDI functionality to the Linux operating system. Here is the Advanced Linux Sound Architecture (ALSA) project homepage. ALSA has the following significant features:
  • Efficient support for all types of audio interfaces, from consumer sound cards to professional multichannel audio interfaces.
  • Fully modularized sound drivers.
  • SMP and thread-safe design.
  • User space library (alsa-lib) to simplify application programming and provide higher level functionality.
  • Support for the older Open Sound System (OSS) API, providing binary compatibility for most OSS programs.

Thursday, January 31, 2008

trying building shared library for google android

There is an article Shared library "Hello World!" for Android, describes how to create a simple shared library for google android, and shows how to link with the shared library to create a dynamic linked executable. The steps are correct, but it is not easy to create a shared library for google android with an existing linux distribution open source software.

Here is some findings when I tried to create a shared library for google android with a open source software:
1. pthread related functions are implemented in google android libc.so
2. no stderr, stdin, stdout definition are found in google android
3. some function mangling is different, such as strtod, strtol, isspace, and etc. Some can be fixed with some MACRO variable, such as __NO_INLINE__. Need to identify one by one, read the include head files in CROSS_COMPILE_FOLDER /arm-none-linux-gnueabi/libc/usr/include/
4. no mkstemp64, open64, and other xxx64 functions found

Following are the pthread found in google android /system/lib/libc.so:
42: 0000a41c 32 FUNC GLOBAL DEFAULT 7 pthread_cond_signal
61: 0000a26c 56 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_gettype
64: 0000a510 32 FUNC GLOBAL DEFAULT 7 pthread_attr_destroy
69: 0000a144 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getstacksize
71: 0000afa0 620 FUNC GLOBAL DEFAULT 7 pthread_create
75: 0000a3a8 28 FUNC GLOBAL DEFAULT 7 pthread_getspecific
86: 0000a050 72 FUNC GLOBAL DEFAULT 7 pthread_attr_init
92: 0000ad60 304 FUNC GLOBAL DEFAULT 7 pthread_exit
119: 0000a1b0 24 FUNC GLOBAL DEFAULT 7 pthread_attr_getstack
165: 0000a15c 24 FUNC GLOBAL DEFAULT 7 pthread_attr_getstackaddr
177: 0000a8c8 228 FUNC GLOBAL DEFAULT 7 pthread_key_delete
202: 0000a254 24 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_destroy
208: 0000a22c 16 FUNC GLOBAL DEFAULT 7 pthread_equal
265: 0000a1ec 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getguardsize
299: 0000aad8 188 FUNC GLOBAL DEFAULT 7 pthread_cond_timedwait_mo
340: 0000ac58 176 FUNC GLOBAL DEFAULT 7 pthread_detach
352: 0000a0f0 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getschedpoli
368: 0000a154 8 FUNC GLOBAL DEFAULT 7 pthread_attr_setstackaddr
387: 0000a4b0 96 FUNC GLOBAL DEFAULT 7 pthread_getschedparam
441: 0000a43c 32 FUNC GLOBAL DEFAULT 7 pthread_cond_broadcast
459: 0000a45c 84 FUNC GLOBAL DEFAULT 7 pthread_setschedparam
471: 0000a9ac 176 FUNC GLOBAL DEFAULT 7 pthread_key_create
499: 0000a3cc 80 FUNC GLOBAL DEFAULT 7 pthread_kill
505: 0000aa5c 124 FUNC GLOBAL DEFAULT 7 pthread_cond_timeout_np
512: 0000a1fc 44 FUNC GLOBAL DEFAULT 7 pthread_getattr_np
514: 0000a120 36 FUNC GLOBAL DEFAULT 7 pthread_attr_setstacksize
546: 0000a3c4 8 FUNC GLOBAL DEFAULT 7 pthread_sigmask
559: 0000a35c 16 FUNC GLOBAL DEFAULT 7 pthread_cond_init
643: 0000a174 60 FUNC GLOBAL DEFAULT 7 pthread_attr_setstack
647: 0000a2a4 64 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_settype
681: 0000a0d0 20 FUNC GLOBAL DEFAULT 7 pthread_attr_getdetachsta
694: 0000a690 180 FUNC GLOBAL DEFAULT 7 pthread_mutex_unlock
772: 0000a228 4 FUNC GLOBAL DEFAULT 7 pthread_self
778: 0000a23c 24 FUNC GLOBAL DEFAULT 7 pthread_mutexattr_init
788: 00009630 0 FUNC GLOBAL DEFAULT 7 __pthread_clone
818: 0000a344 24 FUNC GLOBAL DEFAULT 7 pthread_mutex_destroy
826: 0000a744 388 FUNC GLOBAL DEFAULT 7 pthread_mutex_lock
831: 0000ac50 8 FUNC GLOBAL DEFAULT 7 pthread_cond_wait
845: 0000a1c8 36 FUNC GLOBAL DEFAULT 7 pthread_attr_setguardsize
858: 0000a55c 308 FUNC GLOBAL DEFAULT 7 pthread_mutex_trylock
869: 0000a36c 24 FUNC GLOBAL DEFAULT 7 pthread_cond_destroy
874: 0000a0e4 12 FUNC GLOBAL DEFAULT 7 pthread_attr_setschedpoli
886: 0000a2e4 96 FUNC GLOBAL DEFAULT 7 pthread_mutex_init
920: 0000a100 16 FUNC GLOBAL DEFAULT 7 pthread_attr_setschedpara
936: 0000a098 56 FUNC GLOBAL DEFAULT 7 pthread_attr_setdetachsta
942: 0000ad08 88 FUNC GLOBAL DEFAULT 7 pthread_join
952: 0000ab94 188 FUNC GLOBAL DEFAULT 7 pthread_cond_timedwait
963: 0000a110 16 FUNC GLOBAL DEFAULT 7 pthread_attr_getschedpara
967: 0000a384 36 FUNC GLOBAL DEFAULT 7 pthread_setspecific

Thursday, January 17, 2008

Set proxy for android web browser

There is no UI for proxy settings for android web browser. But the android web browser will read the proxy settings in its settings database.
Here is the instructions to enable the proxy in the android web browser.
  1. > adb shell
  2. # sqlite3 /data/data/com.google.android.providers.settings/databases/settings.db
  3. sqlite> INSERT INTO system VALUES(99,’http_proxy', 'proxy:port');
  4. sqlite>.exit
You can talk to settings.db for more information.
  1. sqlite> SELECT * FROM system;
  2. sqlite> .tables
  3. sqlite> .databases
  4. sqlite> .schema table_name
  5. sqlite> more SQL expression to talk to the tables
Don't forget the ';' at the end of the SQL expression.

Wednesday, January 16, 2008

Create google android strace tool

Prerequisite, you already have the cross compiler downloaded from download GNU toolchain site, make sure you select ARM GNU/Linux, and IA32 GNU/Linux.

  1. Download the strace source distribution from SourceForge strace project
  2. Extract the strace package on your linux machine
  3. Set your cross compiler information with command: # export CC=your_cross_compiler_folder/bin/arm-none-linux-gnueabi-gcc
  4. Add your_cross_compiler_folder/bin into your $PATH for path searching
  5. Change your current folder to strace package extract folder, use command: # ./configure -host=arm-linux
  6. You have the Makefile generated, edit it, append -static after CFLAGS variable in Makefile
  7. Compile it with simple command: # make
  8. You have the strace now, verify it with command: # file strace, you shall see "strace: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, not stripped"
Done, you have another powerful tool for your android

Manually start android in the google android emulator

The google android kernel will invoke services listed in the file /etc/init.rc after the kernel is started up. The /etc/init.rc is included in the ramdisk.img. Find the ramdisk.img in $EMULATOR_SDK_FOLDER/tools/lib/images/. One can change the ramdisk.img to change the init.rc and so to change the google android startup sequence.

Follow the tips in Step by step to create/modify ramdisk.img to change ramdisk.img.

Following is the items to comment out in init.rc to stop the android to be loaded at the initial time:
  1. Find the service section in the init.rc (following the startup section)
  2. Comment out the zygote sub-section, and runtime sub-section
  3. Recreate the ramdisk.img and replace the original ramdisk.img (backup the original if you want)
  4. Restart the google android emulator, use -debug-kernel to see more information
Comment out lines are listed for your reference:
#zygote {
#exec /system/bin/app_process
#args {
#0 -Xzygote
#1 /system/bin
#2 --zygote
#}
#autostart 1
#}
#runtime {
#exec /system/bin/runtime
#autostart 1
#}
After the google android emulator is started up, manually start up the google android services below:
  1. # adb shell to create a console
  2. # /system/bin/app_process -Xzygote /system/bin --zygote &
  3. # /system/bin/runtime &
Upload a strace tool to trace the above services:
  1. # strace -ff -F -tt -s 200 -o /tmp/log/zygote /system/bin/app_process -Xzygote /system/bin --zygote &
  2. # strace -ff -F -tt -s 200 -o /tmp/log/runtime /system/bin/runtime &

What can we expect for the google android next release

We have google android release m3-rc37a.
There are following files in the folder /system/app/:
Browser.apk
Contacts.apk
ContactsProvider.apk
Development.apk
Fallback.apk
GoogleApps.apk
GoogleAppsProvider.apk
Home.apk
ImProvider.apk
Maps.apk
MediaProvider.apk
Phone.apk
SettingsProvider.apk
TelephonyProvider.apk
XmppService.apk
XmppSettings.apk

While if we manually start the android, we can see some error informations:
Prepping: /system/app/AlarmProvider.apk:/system/app/Browser.apk:/system/app/Ca
lendar.apk:/system/app/Camera.apk:/system/app/Contacts.apk:/system/app/Developm
ent.apk:/system/app/GDataFeedsProvider.apk:/system/app/Gmail.apk:/system/app/Gm
ailProvider.apk:/system/app/GoogleApps.apk:/system/app/GoogleAppsProvider.apk:/
system/app/Home.apk:/system/app/ImProvider.apk:/system/app/Maps.apk:/system/app
/MediaPickerActivity.apk:/system/app/MediaProvider.apk:/system/app/Phone.apk:/s
ystem/app/PimProvider.apk:/system/app/ApiDemos.apk:/system/app/SettingsProvider
.apk:/system/app/Sms.apk:/system/app/SyncProvider.apk:/system/app/TelephonyProv
ider.apk:/system/app/XmppService.apk:/system/app/YouTube.apk

File not found: /system/app/AlarmProvider.apk
File not found: /system/app/Calendar.apk
File not found: /system/app/Camera.apk
File not found: /system/app/GDataFeedsProvider.apk
File not found: /system/app/Gmail.apk
File not found: /system/app/GmailProvider.apk
File not found: /system/app/MediaPickerActivity.apk
File not found: /system/app/PimProvider.apk
File not found: /system/app/ApiDemos.apk
File not found: /system/app/Sms.apk
File not found: /system/app/SyncProvider.apk
File not found: /system/app/YouTube.apk
Prep complete
We are expecting the next release, what kind of applications will be provided next time?

Tuesday, January 15, 2008

Can't execute native command on google android emulator

I created hello.c, compiled successfully with the cross compiler.
But I failed to run it on the target google android emulator. The error is: xxx: not found.
I checked the compiled file, it looks just fine. It really puzzled me.

At last, I got hints that it is because of there is no base libraries necessary on the google android emulator. For example, there is no /usr/lib directory, which should contain many .so files.

Simply re-create your native command with '-static' parameter, and try again.
Check your compiled file with the following command to ensure:
# file a.out
possible output looks like:
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, not stripped

Customize google android system.img for emulator

The google android emulator included in the google android sdk is limited. Although you can use 'adb push' to upload more tools, but one has to do it again next time. Follow the steps to create a enhanced system.img:
  1. system.img is yaffs2 flash file system, so firstly you need the mkfs.yaffs2 tool, download it in the following link: Release Android Yaffs2 Tool (Both X86 And ARM). One has to be a registered user to download the tools.
  2. use the 'adb push' to upload tools to android emulator, executables in /system/bin/, libraries in /system/lib, one can also create folder. One need change the file mode necessary.
  3. upload the ARM mkfs.yaffs2 tool, use the following command to create system.img: # mkfs.yaffs2 /system /system.img
  4. download the system.img to local with command 'adb pull', replace the system.img in your emulator folder/tools/lib/images/

Monday, January 14, 2008

Step by step to create/modify ramdisk.img

Benno's blog has an article to change the ramdisk image, I tried it and give more details here.

ramdisk.img is included in the google android sdk, it exists in folder $SDK_ROOT/tools/lib/images/ramdisk.img. The ramdisk.img included in the google android sdk is a gzipped ramdisk.cpio file.

Here is the steps:
  1. Upload the ramdisk.img to your linux machine
  2. Change the ramdisk.img name to ramdisk.cpio.gz, and extract it by: # gzip -d ramdisk.cpio.gz
  3. Create a temporary folder, say tmp, copy ramdisk.cpio to tmp folder
  4. Extract the ramdisk.cpio in the tmp folder with command: # cpio -i -F ramdisk.cpio
  5. Remove the ramdisk.cpio in the tmp folder, and make any changes you want to the extracted ramdisk.cpio in tmp folder
  6. Recreate the ramdisk.cpio with command: # cpio -i -t -F ../ramdisk.cpio | cpio -o -H newc -O ../ramdisk_new.cpio
Some notes:
  1. I change ramdisk.img to ramdisk.cpio.gz, and unzip it. It is because I find the -z parameter is not supported with my cpio. I tried the latest cpio (2.9), it doesn't work too.
  2. Check cpio version by # cpio --version. I'm using cpio version 2.4.
  3. Find the latest cpio (v 2.9) on site: gnu cpio
  4. Notice that in step 6, the command includes two O's. First o is lower-case, second is up-case.
  5. Notice in step 6, please remain ramdisk.cpio in up folder of tmp folder. The command need it there.

YAFFS(YAFFS2) and JFFS2 comparison

Google android emulator extracts the system.img and userdata.img with YAFFS flash file system. I don't know much about YAFFS and its difference with JFFS2. I google it and share here.
  • YAFFS uses less run-time RAM to hold its state so YAFFS scales better than JFFS2. There are quite a few systems using large NAND arrays (the largest partitions I know of are around the 6Gbyte mark).
  • YAFFS garbage collection is simpler and faster typically making for better performance under hard writing.
  • YAFFS uses a whole page per file for headers, and does not provide compression. This means that JFFS2 is probably a better fit to small partitions. The flip side though is that a lot of data (eg. MP3) does not compress very well and enabling compression really hurts performance.
  • While YAFFS has been used on NOR, it does not fit that well (because YAFFS does not use erase suspend). Thus if you're using smaller NAND partitions and using jffs2 on NOR, then a jffs2-only solution is very appealing.
From the wikipedia, I can see YAFFS is Yet Another Flash File System, it is specifically designed for NAND flash. Here are some links for more information:
JFFS2 is a log-structured file system designed for use on flash devices in embedded systems. Rather than using a kind of translation layer on flash devices to emulate a normal hard drive, as is the case with older flash solutions, it places the filesystem directly on the flash chips. Here are some links for more information about JFFS2:
More information about Flash memory.
Flash memory is non-volatile computer memory that can be electrically erased and reprogrammed. There are NOR memories and NAND memories.
NOR memories:
Reading from NOR flash is similar to reading from random-access memory, provided the address and data bus are mapped correctly. Because of this, most microprocessors can use NOR flash memory as execute in place (XIP) memory, meaning that programs stored in NOR flash can be executed directly without the need to copy them into RAM. NOR flash chips lack intrinsic bad block management, so when a flash block is worn out, the software or device driver controlling the device must handle this, or the device will cease to work reliably.
When unlocking, erasing or writing NOR memories, special commands are written to the first page of the mapped memory. These commands are defined by the Common Flash memory Interface (CFI) and the flash chips can provide a list of available commands to the physical driver.
NAND memories:

NAND flash architecture was introduced by Toshiba in 1989. NAND flash memories cannot provide execute in place due to their different construction principles. These memories are accessed much like block devices such as hard disks or memory cards. The pages are typically 512 or 2,048 or 4,096 bytes in size. Associated with each page are a few bytes (typically 12–16 bytes) that should be used for storage of an error detection and correction checksum.

The pages are typically arranged in blocks. A typical block would be:
  • 32 pages of 512 bytes
  • 64 pages of 2,048 bytes.
  • 64 pages of 4,096 bytes.


Sunday, January 13, 2008

google android emulator console

Each running emulator instance includes a console facility that lets you dynamically query and control the simulated device environment. Connect to the console by the following command:
# telnet localhost 5554
If you have multiple emulator started, subsequent console port is 5556, 5558, etc.

In the current release, the console provides the following commands:
  • help|h|? ;print a list of commands
  • redir ;manage port redirections
  • network ;manage network settings
  • gsm ;GSM related commands
  • sms ;SMS related commands
  • kill ;kill the emulator instance
  • quit|exit ;quit control session
For more details of the console commands usage, refer to the Google Android Emulator documentation.

About Google Android Emulator

At the very beginning, google released google android SDK, it is running on the emulator. There is no hardware.

The Google android emulator is included in the google android sdk. So far google provides three platforms sdk, they are windows, Mac OS X (intel), Linux (i386). The emulator is in the tools folder: emulator.

The google android emulator is based on the qemu, which is a open source. Google makes some changes based on the qemu 0.8.2. The source code is also available. With the emulator source, you can make any changes you want, and replace the original one to look for information you want. One command to compile the emulator source code: build-emulator.sh

Available links:
  1. Google android sdk
  2. Google android emulator source package
  3. Qemu open source

Friday, January 11, 2008

Extract google android file system image

To run google android on the truely hardware, you may need the google android file system image.

Google android file system consists of two parts: system and data.
You can find the google android file system image on benno's website: Android filesystem images

You can also extract the google android file system by yourself from the android emulator by the following way:
1. download the google android sdk and extract onto your platform
2. start up the google android emulator
3. upload a busybox tool to the google android emulator, you can find a busybox binary on benno's website: busybox for android, you can also find the cross-compiler (select ARM GNU/Linux, and IA32 GNU/Linux) and create a busybox tool by yourself.
4. to upload files to the google android emulator, run the following command:
# adb push filename /target_folder/filename
the target_folder is the folder on the file system of google android emulator. e.g. /system/bin/
put the busybox to /system/bin, so you can see busybox tool in the extracted file system.
5. open a google android shell command window:
# adb shell
6. change the busybox mode to 555:
# chmod 555 /system/bin/busybox
7. create the tarball for /system and /data:
# busybox tar cvf /system.tar /system
# busybox tar cvf /data.tar /data
8. pull the tarball file from the google android emulator:
# adb pull system.tar /system.tar
# adb pull data.tar /data.tar

a note: when you want run google android on your truely hardware, the data.tar is not a must.

Get start playing with Google Android

The Android platform is a software stack for mobile devices including an operating system, middleware and key applications. Developers can create applications for the platform using the Android SDK. Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use which runs on top of a Linux kernel.

Google provides Android SDK for three platforms: Windows, Mac OS X (intel), Linux (i386). There is Android emulator included in the SDK package. So first find a Android SDK for your platform: Download the Android SDK from Google.

Next, extract the Android SDK package into your system, let's say the root folder is $ANDROID_SDK.

Open a command window (shell window), change the working directory to $ANDROID_SDK/tools/. You will see tens of executable files, one is emulator. Simply start it with the following command:
# emulator
If you want to see the emulator kernel boot up detail information, start it with the following command:
# emulator -debug-kernel

When the Android started up, the following window is shown.
You can open a Android shell by the command:
# adb shell

It is a Linux kernel 2.6.23 (Android is linux kenel based) shell, play with it in the same way as linux.







Here is the Android kernel boot up log fyi:
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 android.checkjni=1 keycharmap=qwerty2
android.ril=ttyS1
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
Memory: 94280KB available (2268K code, 458K data, 96K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
android_power_init
android_power_init done
NET: Registered protocol family 16
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
checking if image is initramfs... it is
Freeing initrd memory: 228K
goldfish_new_pdev goldfish_interrupt_controller at ff000000 irq -1
goldfish_new_pdev goldfish_device_bus at ff001000 irq 1
goldfish_new_pdev goldfish_timer at ff003000 irq 3
goldfish_new_pdev goldfish_rtc at ff010000 irq 10
goldfish_new_pdev goldfish_tty at ff002000 irq 4
goldfish_new_pdev goldfish_tty at ff011000 irq 11
goldfish_new_pdev smc91x at ff012000 irq 12
goldfish_new_pdev goldfish_fb at ff013000 irq 13
goldfish_new_pdev goldfish_audio at ff004000 irq 14
goldfish_new_pdev goldfish_events at ff014000 irq 15
goldfish_new_pdev goldfish_nand at ff015000 irq -1
goldfish_new_pdev goldfish-switch at ff016000 irq 16
goldfish_new_pdev goldfish-switch at ff017000 irq 17
goldfish_pdev_worker registered goldfish-switch
goldfish_pdev_worker registered goldfish-switch
goldfish_pdev_worker registered goldfish_nand
goldfish_pdev_worker registered goldfish_events
goldfish_pdev_worker registered goldfish_audio
goldfish_pdev_worker registered goldfish_fb
goldfish_pdev_worker registered smc91x
goldfish_pdev_worker registered goldfish_tty
goldfish_pdev_worker registered goldfish_tty
goldfish_pdev_worker registered goldfish_rtc
goldfish_pdev_worker registered goldfish_timer
goldfish_pdev_worker registered goldfish_device_bus
goldfish_pdev_worker registered goldfish_interrupt_controller
goldfish_audio_probe
Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
yaffs Oct 30 2007 16:24:34 Installing.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
allocating frame buffer 320 * 480, got ffc10000
Console: switching to colour frame buffer device 40x30
console [ttyS0] enabled
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize
loop: module loaded
nbd: registered device at major 43
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre
No IRQF_TRIGGER set_type function for IRQ 12 (goldfish)
eth0: SMC91C11xFD (rev 1) at c6800000 IRQ 12 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
goldfish nand dev0: size 4000000, page 2048, extra 64, erase 131072
goldfish nand dev1: size 4000000, page 2048, extra 64, erase 131072
mice: PS/2 mouse device common for all mice
*** events probe ***
events_probe() addr=0xc6804000 irq=15
input: goldfish-events-keyboard as /class/input/input0
goldfish_rtc goldfish_rtc: rtc core: registered goldfish_rtc as rtc0
logger: created 64K log 'log_main'
logger: created 64K log 'log_events'
logger: created 64K log 'log_radio'
IPv4 over IPv4 tunneling driver
GRE over IPv4 tunneling driver
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
802.1Q VLAN Support v1.8 Ben Greear
All bugs added by David S. Miller
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
goldfish_rtc goldfish_rtc: setting the system clock to 2008-01-12 02:48:13 (1200
106093)
Freeing init memory: 96K
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
sh: can't access tty; job control turned off
# binder_open(c0833428 c0a0a4a0) (pid 468) got c5f13000
binder_open(c0833428 c5a6b9e0) (pid 460) got c5bbf000
binder_open(c0833428 c5a6b2e0) (pid 474) got c4716000
android_power: auto off timeout set to 604800 seconds
Descriptor2Node failed secondary: desc=4, max=32, node=c5bc0350, weak=0
binder_open(c0833428 c4f533a0) (pid 510) got c4754000
binder_open(c0833428 c4f53920) (pid 511) got c3a30000
binder_open(c0833428 c3421860) (pid 527) got c3428000

Create adb shell in android emulator

Type the following command to start the adb shell:
# adb shell
For the full usage of adb, please refer the following link: Android Debug Bridge Tool

Rotate Android Screen to Landscape/Portrait

Here are some tips of android screen rotation.

On the emulator, after the Android system is started up, open another command window, type the following command line in the adb shell to change the screen to landscape:
# service call window 18 i32 1
type the following command line to change the screen to portrait:
# service call window 18 i32 0