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