The document discusses running existing software on Android by either running the binary directly on Android, rebuilding the software for Android, or running the Android system on an existing Linux environment. It provides examples of copying dependency libraries to run an existing binary on Android. It also discusses creating an Android.mk file or using a configure script to rebuild software for the Android environment. Finally, it outlines a process to run the entire Android system framework within a chroot on an Ubuntu Linux system on the target hardware.
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Reusing your existing software on Android
1. Reusing your existing software
on
Android
2010.9.3
2011.8.5 updated
Tetsuyuki Kobayashi
1
2. Who am I?
20+ years involved in embedded systems
10 years in real time OS, such as iTRON
10 years in embedded Java Virtual Machine
Now GCC, Linux, QEMU, Android, …
Blogs
http://d.hatena.ne.jp/embedded/ (Personal)
http://blog.kmckk.com/ (Corporate)
http://kobablog.wordpress.com/(English) new
Twitter
@tetsu_koba
2
3. Today's topic
Introduction
Running your software on
Android
No rebuild, binary as is
Rebuild
Running Android on your
existing linux environment
3
4. Audience
Already using Linux in your project
Have interest in Android
Thinking how to migrate to
Android
4
5. Why Android?
Clear separation between system and
application
Download-able application
3rd party, community
Easy upgrade, bug fix
Web service using HTML5 browser
core
And more ... 5
6. Why reuse?
Don't discard all your existing
software resource.
But don't think all your software
resource is reusable.
What is your strength?
Select wisely
6
7. Let's try prototyping
Anyway, port Android on your
board.
I show you some techniques for a
quick hack in this session.
7
8. Things to consider
Execution overhead
Memory/Storage usage
Easiness to follow version up of
Android
8
9. 3 topics
Running existing binary on
Android
Rebuilding for Android
Running Android on your Linux
9
10. Running existing binary on
Android
Just copy
If the same ABI (EABI on ARM)
You have to copy all files you
need
'ldd' to identify dynamic library
dependency
Fortunately, Android does not
have /lib, /bin, /usr/*. Don't worry
11. Example : bash
user@arm-lucid:~$ ldd /bin/bash
libncurses.so.5 => /lib/libncurses.so.5 (0x40006000)
libdl.so.2 => /lib/libdl.so.2 (0x40039000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40045000)
libc.so.6 => /lib/libc.so.6 (0x40057000)
/lib/ld-linux.so.3 (0x2a000000)
user@arm-lucid:~$
Copy these files and not change file path.
Or make symblic link as looks like.
See Also
http://blog.kmckk.com/archives/2936886.html
11
12. Running existing binary on
Android
Pros
Easy!
Good for experiment
Cons
Duplicate libraries
increase memory/storage usage
May not work for all cases
Not good for product.
Not applicable for libraries to link with
DalvikVM 12
13. Rebuilding for Android
Making Android.mk
Build your project as a part of
the whole Android system
Using configure script
Build independently
Use NDK for compiler, system
library and include headers
13
14. Making Androd.mk
Get whole android source tree by 'repo
sync'
Copy simple project and use it as template
Remove unused files and add your files
Modify Android.mk
Build your project as a part of Android
14
15. Using configure script
Set environment variables before run
configure
CC, CFLAGS, LDFLAGS
Options for gcc
-mandroid, --sysroot=$SYSROOT
See this page for detail
http://blog.kmckk.com/archives/2918745.html
http://blog.kmckk.com/archives/3867590.html
15
16. Caveats
System lib doesn't support C++ exceptions and
RTTI.
Static link GNU libstdc++.
Multi byte char support is minimal.
No system V IPC.
IPv6 seems not yet supported.
GCC TLS extension (__thread) doesn't work.
16
17. Rebuilding for Android
Pros
The best for Memory/Storage usage
Only solution for libraries to link with DalvikVM
Cons
Hard to rebuild because ...
Bionic(Android libc) Caveats
Some header files missing
18. Running Android on your Linux
Running whole Android system
framework on your existing Linux
environment.
I show you a quick hack to do this.
Of cource, there is some limitation.
18
19. Running Android on your Linux
Android
Android
Your existing Linux user land
Android-patched Linux kernel
Android-patched Linux kernel
19
20. How to run Android on Ubuntu
1.Port Android to your board
2.Run ARM Ubuntu on your board
with Android-patched Linux kernel
3.Put all Android files into /android
on Ubuntu
4.Invoke 'sudo chroot /android /init'
on Ubuntu
20
21. Trouble shooting
Some processes caused SEGV
In my case, vold and netd
Patch is in my blog
http://blog.kmckk.com/archives/3520227.html
21
22. Android lunched successfully
You can browse internet by Android browser.
You can use Eclipse to install and debug Java
applications.
SMP kernel works fine on KZM-CA9-01
board(Quad-Core Cortex-A9) and KZM-A9-Dual
(Dual-Core Cortex-A9)
22
25. Summary of this hack
Use Android patched kernel
Nothing to modify in Ubuntu
Screen(framebuffer device) and
key & touch input are used only
from Android
Very easy. Try it!
25
26. Next step
How manage I/O devices?
Frame buffer
Layered frame buffer and set transparency
/dev/fb0 for Android, /dev/fb1 for Ubuntu
How communicate between Ubuntu & Android?
At least, socket is available.
Ashmem for shared memory?
Binder?
26
27. Q&A
Thank you for listening!
Any comments to blogs are welcome.
@tetsu_koba
27