This page collects information about and guides you through the installation of [http://www.google.de/ Google's] [http://code.google.com/android/ Android] on [http://www.ti.com/ TI's] [http://www.arm.com/ ARM] based [http://focus.ti.com/general/docs/wtbu/wtbusplashcontent.tsp?templateId=6123&contentId=4752 OMAP] [http://focus.ti.com/general/docs/wtbu/wtbugencontent.tsp?templateId=6123&navigationId=11988&contentId=4638&DCMP=WTBU&HQS=Other+OT+omap SoCs].

This page collects information about and guides you through the installation of [http://www.google.de/ Google's] [http://code.google.com/android/ Android] on [http://www.ti.com/ TI's] [http://www.arm.com/ ARM] based [http://focus.ti.com/general/docs/wtbu/wtbusplashcontent.tsp?templateId=6123&contentId=4752 OMAP] [http://focus.ti.com/general/docs/wtbu/wtbugencontent.tsp?templateId=6123&navigationId=11988&contentId=4638&DCMP=WTBU&HQS=Other+OT+omap SoCs].

''Note'': Only small parts of this page should be TI OMAP specific. The basic tasks should also apply to all other ARM926 or higher based SoCs at least able to run a 2.6.23 Linux kernel.

''Note'': Only small parts of this page should be TI OMAP specific. The basic tasks should also apply to all other ARM926 or higher based SoCs at least able to run a 2.6.23 Linux kernel.

+

+

''Note'': If you like this page, please see the [[Android Portal]] on this site for much more information about Android systems programming. See [[Android Porting]] for more links to porting information, articles and tutorials.

''Note'': This article assumes that your are familiar with some basics of embedded ARM Linux. E.g. you should know how to use diff & patch, how to boot your embedded ARM SoC with a recent non-Android Linux, how to use a cross compiler etc.

''Note'': This article assumes that your are familiar with some basics of embedded ARM Linux. E.g. you should know how to use diff & patch, how to boot your embedded ARM SoC with a recent non-Android Linux, how to use a cross compiler etc.

* For Zaurus/pxafb have a look to following [http://androidzaurus.seesaa.net/article/87973048.html solution]. See [http://www.oesf.org/forum/index.php?s=b33968d11c595adb9ac146a6d4c59366&showtopic=25517&st=15&start=15 OESF] as well.

* For Zaurus/pxafb have a look to following [http://androidzaurus.seesaa.net/article/87973048.html solution]. See [http://www.oesf.org/forum/index.php?s=b33968d11c595adb9ac146a6d4c59366&showtopic=25517&st=15&start=15 OESF] as well.

Revision as of 07:38, 27 November 2012

Note: Only small parts of this page should be TI OMAP specific. The basic tasks should also apply to all other ARM926 or higher based SoCs at least able to run a 2.6.23 Linux kernel.

Note: If you like this page, please see the Android Portal on this site for much more information about Android systems programming. See Android Porting for more links to porting information, articles and tutorials.

Note: This article assumes that your are familiar with some basics of embedded ARM Linux. E.g. you should know how to use diff & patch, how to boot your embedded ARM SoC with a recent non-Android Linux, how to use a cross compiler etc.

Versions

From time to time Google updates their Android releases. At time of writing this article version m5-rc14 was the recent one. You should always use the latest available version. And make sure you use an Android kernel (patch) for your hardware that matches the file system version (see below).

Hardware

Goldfish

Android SDK isn't targeted for a special (ARM) SoC. Instead, they use QEMU to create a virtual ARM SoC called Goldfish. The virtual ARM SoC boots an (currently 2.6.23, m5-rc14) ARM Linux kernel with Goldfish platform support on your (x86) Windows, MacOS X or Linux host.

Compiler

Getting Android working on real hardware, you need an ARM EABI (good EABI description, ignore the Debian specific stuff) compatible development environment. I.e., your tool chain, your kernel and user space must be compatible to ARM EABI. If you don't like to create your own ARM EABI compatible compiler, linker, library etc. you should use CodeSourcery'sARM GNU/Linux tool chain.

Note: The naming in the CodeSourcery download section is slightly confusing. You need the ARM GNU/Linux named tool chain which is indeed an ARM GNU/Linux EABI tool chain with glibc. The ARM EABI named tool chain there is something normally known as arm-elf tool chain without any Linux support and without glibc.

Code

As mentioned above, the Android SDK contains an emulator where a virtual ARM device runs the Android SW on your host PC. The Linux kernel used in this emulator is available in source code. In contrast, the user space file system (applications) is currently only available as binary as part of the SDK.

To get Android running on real HW, currently you need both, matching SDK and kernel source. You need kernel source to extract Android specific patches to add them to your SoC specific kernel. And SDK to get Android user space file system binaries. While getting Android kernel patches is somehow straight forward, extracting user space file system with Android applications in it is a little bit tricky.

Kernel

On Android project page the source code of the kernel is available. From full kernel tree with Android modifications included you can extract patches. With this, you have to extract the Android specific patches yourself from the complete kernel tree, use already extracted patches or get kernel patches by git.

As we want to run Android on real hardware, you can throw away all QEMU and Goldfish related changes. If you don't want to use yaffs2 file system (e.g. cause you don't have NAND or have it already in your tree), throw away yaffs2 related changes as well. If you use m5-rc14 (or higher?) you can remove OpenBinder related files (/driver/binder) as well. Result should be a generic, no ARM or OMAP specific Android patch you can apply to your (e.g. 2.6.23) kernel for your ARM based SoC.

Note: There seems to be some effort to make Android kernel patches available in a easier usable format.

Extracted patches

At some locations there are ready made patches available. The advantage of this is that you don't have to extract the patches yourself. The disadvantage is that you can't always be sure that they contain everything you need and that they match your SDK/user space file system (see below) version.

Note: Some guys on OMAP mailing list have Android patches extracted (currently from m5-rc14) and are willing to share them. Unfortunately they don't have any permanent web storage yet. If you have and like to help community with providing some web space, contact OMAP list.

Git patches

File System

Getting user space file system binaries running in emulator extracted is slightly tricky. We have to extract the binaries as currently access to source code have only Google itself and eventually WindRiver.

Again, there are two ways to get user space binaries: Extracting them your self or taking already extracted ones.

Binary extraction

The user space applications compiled for ARMv5 EABI are part of the Android SDK in system.img and userdata.img in tools/lib/images directory of SDK.

system.img and userdata.img are yaffs2 images. There is no way yet to mount them directly on a host to extract their content. An unyaffs tool is missing, so the only way to get the content is to start the emulator and extract the contents from running emulator.

If you look at the extracted size of the userdata image, the extracted one is bigger than the original userdata.img. So by the runtime extraction we get some temporary junk in it. For this, untar extracted userdata and remove a least some of the unnecessary stuff:

Remove all content of data/dalvik-cache/. It holds the decompressed files from the apk packages.

Remove the static busybox image. We only needed it for extraction and don't need it any more.

Note: Anybody likes to hack this unyaffs tool? Then the system.img and userdata.img extraction would be a lot easier.

Note: A user reports that he doesn't use the extracted data directory at all. He simply mounts a tempfs to /data as it seems that Android runtime creates most (all?) of the necessary files in /data itself at runtime.

Extracted binaries

At some locations there are ready made binaries available. The advantage of this is that you don't have to extract the binaries yourself. The disadvantage is that you can't always be sure that the images contain everything you need and that the images match your kernel patch (see above) version.

Note: Some guys on OMAP mailing list have Android binaries extracted (currently from m5-rc14) and are willing to share them. Unfortunately they don't have any permanent web storage yet (~30MB). If you have and like to help community with providing some web space, contact OMAP list.

Target

This section describes how to configure the software (kernel, file system) to run Android on real hardware target. Before you do this Android specific steps, you should make sure that everything works without any Android specifics. I.e. make sure that the (EABI) kernel boots, you can access all file systems (e.g. NFS or MMC or NOR or NAND etc.) and necessary drivers (e.g. keyboard, touchscreen etc.). Do this with booting into your normal (EABI) file system you always use. We later switch to Android file system then.

Note: Some of these settings are valid only for m5-rc14 and newer (?) (Binder config, /sys/android_power output) as it changed from older versions to m5-rc14.

EABI

CONFIG_AEABI=y
# CONFIG_OABI_COMPAT is not set

THUMB

CONFIG_ARM_THUMB=y

Android drivers

#
# Android
#
# CONFIG_ANDROID_GADGET is not set
# CONFIG_ANDROID_RAM_CONSOLE is not set
CONFIG_ANDROID_POWER=y
CONFIG_ANDROID_POWER_STAT=y
CONFIG_ANDROID_LOGGER=y
# CONFIG_ANDROID_TIMED_GPIO is not set
CONFIG_ANDROID_BINDER_IPC=y
#AshMem
CONFIG_ASHMEM=y

After you successfully booted the kernel with configuration above (and m5-rc14 kernel patch), make sure you have following /sys files:

File system configuration

We now switch to Android file system extracted above. This should be established on a device with enough space (> ~64MB) and which is accessible on your target. Options are e.g. NFS, NOR or NAND file system, hard disk or USB storage. In a first step it is sufficient if you are able to manually mount it from your (temporary) standard root file system. In a second step it is an option to use it directly as root fs.

The Android file system we establish here on one of the the storage from above is built from four parts:

Note: This depends on how you named and stored extracted user data and system image above.

Last step is to create some device nodes in /dev you need for running from this Android file system. There are several options how to establish this. One option is to extract device file system from running Android emulator as well. Second option is to use the same device file system you normally use in your standard file system. Choose the easiest way. If you did this, make sure you have Android specific device nodes with correct major/minor numbers as well.

Note: Copying device nodes the best way is to tar them at source and untar them then at target. For device nodes, cp command isn't the best option due to special device node format.

Start up

Starting Android using the file system and kernel created above, there are three ways:

Start via scripts

This section describes the second way to start Android. First boot into your normal file system and then switch to Android file system and start Android "manually", i.e. with help of some scripts. From the initial description of this method, this way is also known as the a.sh way (search for a.sh). The scripts used for this depend on your local configuration. You can take below scripts as example and adapt them for your local use.

These example scripts are used to first boot into standard root file system (e.g. JFFS2 in NOR) and then to mount (/mnt/usb) and start Android located on an ext2 formatted USB stick.

Starting runtime in background (&) and calling /system/bin/sh afterwards is optional. It gives you the option to have a shell at Android startup to e.g. observe /proc/meminfo, top or ps. Only useful if strace isn't enabled or not so noisy ;)

Start init via scripts

This third way is a mixture of the first two ways: Boot into a standard non-Android file system, then switch over to Android but there directly execute init as it would be done by root file system.

FAQ

Kernel patch

Q: Above section about kernel patch extraction mentioned that not all changes in Android kernel compared to stock kernel are needed for Android on real HW (e.g. Goldfish, QEMU and YAFFS2 related changes). What exactly do I need?

A: Regarding m5-rc14 and kernel 2.6.23 the (changed) files below seem to be sufficient to run Android on real HW:

OpenBinder

Q: When I extract the kernel patch, I additionally get a drivers/binder/ directory. Why isn't it listed/needed above?

A: The drivers/binder/ directory seems to contain OpenBinder. In Android m5-rc14 this seems to be replaced by drivers/android/binder.c. Therefore we don't need drivers/binder/ with m5-rc14 any more. Note that new binder.c in drivers/android is configured with CONFIG_ANDROID_BINDER_IPC, while drivers/binder was configured by (obsolete) CONFIG_BINDER.

Devices nodes

Q: Do I need special devices nodes? Which?

A: Above we only extracted system and userdata image. If you like, you can extract /dev entries as well. However, starting Android's runtime under strace control should give you a list which devices will be opened. Besides the standard ones you will need (incomplete?):

/dev/fb0

Blank screen

Q: I did all steps like above, strace output doesn't show any obvious errors, but if I start Android calling runtime I simply get a blank screen. No output (no ANDROID string, no red cycle eye, nothing), just blank screen. As when the frame buffer screen saver starts after ~10min. I use m5-rc14.

Note: For above output, strace has to be invoked with -f -ff -tt -s 200 options, else you wouldn't see this.

Page flipping frame buffer

Q: Okay, I get this page flipping not supported message above and have a blank screen. So my frame buffer driver doesn't support double buffer/page flipping. What do I have to change in frame buffer driver to support double buffer/page flipping?

Adding keypad support (e.g. on Mistral's OSK2530EVM, OMAP2430 based platform) and "waking" Android while it switches to suspend wakes it again. When Android goes into power saving mode, it prints the following messages

TLS issue and processors

TLS issue workaround

Q: I'd like to use (m5-rc14) Android on processors with TLS issue, what can I do?

A: On older ARM's the TLS register is emulated (trapped by the kernel) and on newer ARM's the register actually exists. Android (at least the version for Goldfish) is compiled with the assumption that the TLS
register is emulated and thus expects the kernel to trap it. A non-user defined config option called HAS_TLS_REG is set based on the processor version that is configured which controls if the trap code gets added to the kernel. So to get around the TLS issue, you will need to force the option ON even if the processor supports the TLS register. You can force it on for e.g. OMAP3 by doing the following. However, once source is available,
you really don't want to do this as it does cause a performance hit.

Limited main memory

Q: I have only limited main memory (SDRAM, e.g. 32MB). The system basically starts, but it is really sssllllooooowwww, slightly unusable. More or less only a proof of concept. Can I do anything to use Android even on systems with limited main memory?

A: Try to enable lowmemorykiller:

drivers/misc/lowmemorykiller/lowmemorykiller.c

For this, in kernel enable

CONFIG_LOW_MEMORY_KILLER=y

in Device drivers -> Misc devices. At Android startup this then results in messages like

...
send sigkill to 920 (app_process), adj 1, size 1838
...

Some buttons work, some not

Q: Some buttons work, some buttons don't work ... wrong mapping. How to see what key codes certain buttons are bound? And how to edit the mapping in Android?

There's a brute force approach to sorting out input events: run getevent on the emulator and on the target hardware and compare the results. It's in /system/bin. Keylayouts live in /system/usr/keylayout/*.kl and are used to translate from the raw input event codes to android keycodes. Keymaps live in /system/user/keychars/*.kcm.bin (undocumented binary format right now, sorry) and are used to describe how the key events and modifiers and such are related.

Filesystem, JFFS2 and SIGSEGV

Q: Which file system should I use to store Android user files? Is JFFS2 okay? I use JFFS2 and get SIGSEGVs. What can I do?

A: Don't use JFFS2 as file system for Android. Android does not support JFFS. Use an ext2/3 formatted medium. Or use YAFFS2 if you use a NAND device (as emulator does).

Using JFFS2

Q: Okay, I understand from above that Android doesn't support JFFS2. But, maybe there is a hack to try?

Using JFFS2, what you're might seeing here is the property service in init failing to create and mmap it's arena, which it tries to do in /, which in emulator world is initramfs. The android init/boot model is a little different in that android don't pivot over to a root filesystem, android mounts the system, data, etc partitions under the ramfs on /.

You might be able to hack around this by editing the string "/system_properties" to "/tmp/em_properties" or something like that, assuming you have tmpfs mounted on /tmp.

HW interfaces support

> I was able to add support for the keypad, touch and network in Android,
> however the interfaces like GPS, Accelerometer, vibrator, hardware 3D
> acceleration, battery etc. are not integrated with Android right now. I
> would appreciate if you could throw some light on these open issues. How
> exactly can these interfaces be integrated with Android?
We're trying to use the standard kernel/driver interfaces when possible,
but for things that may have a good deal of variation in implementation,
we're looking to provide a very thin "hardware interface library" layer
to adapt between the bottom of the userspace stack and the drivers or
whatnot for specific hardware platforms.
We'll continue to adopt standardized kernel solutions as they become
available -- We're now using the power supply framework in 2.6.24 for
monitoring battery/charge state (post M5 SDK -- it'll be in the next
release), for example.