Reusing your existing software on Android

4,020 views
3,964 views

Published on

Reusing your existing software on Android
1. Runnig the existing software on Android
1.1 Rebuilding by Android tool chain
1.2 Running the binary as is
2. Running Android on your existing Linux environment
I show you 'Android on Ubuntu server'

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,020
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
173
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Reusing your existing software on Android

  1. 1. Reusing your existing software on Android 2010.9.3 2011.8.5 updated Tetsuyuki Kobayashi 1
  2. 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. 3. Todays topic Introduction Running your software on Android  No rebuild, binary as is  Rebuild Running Android on your existing linux environment 3
  4. 4. Audience Already using Linux in your project Have interest in Android Thinking how to migrate to Android 4
  5. 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. 6. Why reuse? Dont discard all your existing software resource. But dont think all your software resource is reusable. What is your strength? Select wisely 6
  7. 7. Lets try prototyping Anyway, port Android on your board. I show you some techniques for a quick hack in this session. 7
  8. 8. Things to consider Execution overhead Memory/Storage usage Easiness to follow version up of Android 8
  9. 9. 3 topics Running existing binary on Android Rebuilding for Android Running Android on your Linux 9
  10. 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/*. Dont worry
  11. 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 Alsohttp://blog.kmckk.com/archives/2936886.html 11
  12. 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. 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. 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. 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. 16. Caveats System lib doesnt 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) doesnt work. 16
  17. 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. 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. 19. Running Android on your Linux Android Android Your existing Linux user land Android-patched Linux kernel Android-patched Linux kernel 19
  20. 20. How to run Android on Ubuntu1.Port Android to your board2.Run ARM Ubuntu on your board with Android-patched Linux kernel3.Put all Android files into /android on Ubuntu4.Invoke sudo chroot /android /init on Ubuntu 20
  21. 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. 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
  23. 23. Result of ps commanduser@arm-lucid:~$ ps ax PID TTY STAT TIME COMMAND 1 ? SLs 0:01 /sbin/init 2417 tty4 SLs+ 0:00 /sbin/getty -8 38400 tty4 2 ? S< 0:00 [kthreadd] 2418 tty5 SLs+ 0:00 /sbin/getty -8 38400 tty5 3 ? S< 0:00 [migration/0] 2421 tty2 SLs+ 0:00 /sbin/getty -8 38400 tty2 4 ? S< 0:00 [ksoftirqd/0] 2422 tty3 SLs+ 0:00 /sbin/getty -8 38400 tty3 5 ? S< 0:00 [watchdog/0] 2424 tty6 SLs+ 0:00 /sbin/getty -8 38400 tty6 6 ? S< 0:00 [migration/1] 2428 ? SLs 0:00 cron 7 ? S< 0:00 [ksoftirqd/1] 2454 tty1 SLs+ 0:00 /sbin/getty -8 38400 tty1 8 ? S< 0:00 [watchdog/1] 2470 ? SLs 0:00 sshd: user [priv] 9 ? S< 0:00 [migration/2] 2483 ? SL 0:00 sshd: user@pts/0 10 ? S< 0:00 [ksoftirqd/2] 2484 pts/0 SLs 0:00 -bash 11 ? S< 0:00 [watchdog/2] 2497 ? SLs 0:00 sshd: user [priv] 12 ? S< 0:00 [migration/3] 2511 ? SL 0:00 sshd: user@pts/1 13 ? S< 0:00 [ksoftirqd/3] 2512 pts/1 SLs 0:00 -bash 14 ? S< 0:00 [watchdog/3] 2520 pts/0 SL+ 0:00 /init 15 ? S< 0:00 [events/0] 2551 ? S<L 0:00 udevd --daemon 16 ? S< 0:00 [events/1] 2552 ? S<L 0:00 udevd --daemon 17 ? S< 0:00 [events/2] 2596 ? SLs 0:00 /system/bin/sh 18 ? S< 0:00 [events/3] 2597 pts/0 SL 0:00 /system/bin/servicemanager 19 ? S< 0:00 [work_on_cpu/0] 2598 pts/0 SL 0:00 /system/bin/debuggerd 20 ? S< 0:00 [work_on_cpu/1] 2599 pts/0 SLl 0:00 /system/bin/rild 21 ? S< 0:00 [work_on_cpu/2] 2600 pts/0 SL 0:05 zygote /bin/app_process -Xzygote /system/bin 22 ? S< 0:00 [work_on_cpu/3] --zygote --start-s 23 ? S< 0:00 [khelper] 2601 pts/0 SLl 0:00 /system/bin/mediaserver 24 ? S< 0:00 [suspend] 2602 pts/0 SL 0:00 /system/bin/dbus-daemon --system --nofork 25 ? S< 0:00 [kblockd/0] 2603 pts/0 SL 0:00 /system/bin/installd 26 ? S< 0:00 [kblockd/1] 2604 pts/0 SL 0:00 /system/bin/keystore /data/misc/keystore 27 ? S< 0:00 [kblockd/2] 2605 pts/0 SLl 0:00 /sbin/adbd 28 ? S< 0:00 [kblockd/3] 2613 pts/0 SLl 0:08 system_server 29 ? S< 0:00 [ksuspend_usbd] 2668 pts/0 SLl 0:00 com.android.inputmethod.latin 30 ? S< 0:00 [khubd] 2671 pts/0 SLl 0:00 com.android.phone 31 ? S< 0:00 [kmmcd] 2672 pts/0 SLl 0:01 com.android.launcher 32 ? S 0:00 [pdflush] 2673 pts/0 SLl 0:00 com.android.settings 33 ? S 0:00 [pdflush] 2701 pts/0 SLl 0:00 android.process.acore 34 ? S< 0:00 [kswapd0] 2728 pts/0 SLl 0:00 com.android.bluetooth 35 ? S< 0:00 [aio/0] 2735 pts/0 SLl 0:00 com.android.mms 36 ? S< 0:00 [aio/1] 2744 pts/0 SLl 0:00 android.process.media 37 ? S< 0:00 [aio/2] 2764 pts/0 SLl 0:00 com.android.providers.calendar 38 ? S< 0:00 [aio/3] 2776 pts/0 SLl 0:00 com.android.deskclock 39 ? S< 0:00 [nfsiod] 2786 pts/0 SLl 0:00 com.android.email 40 ? S< 0:01 [rpciod/0] 2796 pts/0 SLl 0:00 com.android.quicksearchbox 41 ? S< 0:00 [rpciod/1] 2807 pts/0 SLl 0:00 com.android.protips 42 ? S< 0:00 [rpciod/2] 2814 pts/0 SLl 0:00 com.android.music 43 ? S< 0:00 [rpciod/3] 2821 pts/0 SLl 0:00 com.cooliris.media 2297 ? SL 0:00 upstart-udev-bridge --daemon 2831 pts/1 RL+ 0:00 ps ax 2300 ? SLl 0:00 rsyslogd -c4 user@arm-lucid:~$ 2301 ? S<Ls 0:00 udevd --daemon 23 2378 ? SLs 0:00 /usr/sbin/sshd
  24. 24. Result of ps commanduser@arm-lucid:~$ ps ax PID TTY STAT TIME COMMAND 1 ? SLs 0:01 /sbin/init 2417 tty4 SLs+ 0:00 /sbin/getty -8 38400 tty4 2 ? S< 0:00 [kthreadd] 2418 tty5 SLs+ 0:00 /sbin/getty -8 38400 tty5 3 ? S< 0:00 [migration/0] 2421 tty2 SLs+ 0:00 /sbin/getty -8 38400 tty2 2422 tty3 SLs+ 0:00 /sbin/getty -8 38400 tty3 4 ? 5 ? S< S< 0:00 0:00 [ksoftirqd/0] [watchdog/0] Init of Ubuntu 2424 tty6 SLs+ 0:00 /sbin/getty -8 38400 tty6 6 ? S< 0:00 [migration/1] 2428 ? SLs 0:00 cron 7 ? S< 0:00 [ksoftirqd/1] 2454 tty1 SLs+ 0:00 /sbin/getty -8 38400 tty1 2470 ? SLs 0:00 sshd: user [priv] 8 ? 9 ? S< S< 0:00 0:00 [watchdog/1] [migration/2] Init of Android 2483 ? 2484 pts/0 SL SLs 0:00 0:00 sshd: user@pts/0 -bash 10 ? S< 0:00 [ksoftirqd/2] 11 ? S< 0:00 [watchdog/2] 2497 ? SLs 0:00 sshd: user [priv] 12 ? S< 0:00 [migration/3] 2511 ? SL 0:00 sshd: user@pts/1 13 ? S< 0:00 [ksoftirqd/3] 2512 pts/1 SLs 0:00 -bash 14 ? S< 0:00 [watchdog/3] 2520 pts/0 SL+ 0:00 /init 15 ? S< 0:00 [events/0] 2551 ? S<L 0:00 udevd --daemon 16 ? S< 0:00 [events/1] 2552 ? S<L 0:00 udevd --daemon 17 ? S< 0:00 [events/2] 2596 ? SLs 0:00 /system/bin/sh 18 ? S< 0:00 [events/3] 2597 pts/0 SL 0:00 /system/bin/servicemanager 19 ? S< 0:00 [work_on_cpu/0] 2598 pts/0 SL 0:00 /system/bin/debuggerd 20 ? S< 0:00 [work_on_cpu/1] 2599 pts/0 SLl 0:00 /system/bin/rild 21 ? S< 0:00 [work_on_cpu/2] 2600 pts/0 SL 0:05 zygote /bin/app_process -Xzygote /system/bin 22 ? S< 0:00 [work_on_cpu/3] --zygote --start-s 23 ? S< 0:00 [khelper] 2601 pts/0 SLl 0:00 /system/bin/mediaserver 24 ? S< 0:00 [suspend] 2602 pts/0 SL 0:00 /system/bin/dbus-daemon --system --nofork 25 ? S< 0:00 [kblockd/0] 2603 pts/0 SL 0:00 /system/bin/installd 26 ? S< 0:00 [kblockd/1] 2604 pts/0 SL 0:00 /system/bin/keystore /data/misc/keystore 27 ? S< 0:00 [kblockd/2] 2605 pts/0 SLl 0:00 /sbin/adbd 28 ? S< 0:00 [kblockd/3] 2613 pts/0 SLl 0:08 system_server 29 ? S< 0:00 [ksuspend_usbd] 2668 pts/0 SLl 0:00 com.android.inputmethod.latin 30 ? S< 0:00 [khubd] 2671 pts/0 SLl 0:00 com.android.phone 31 ? S< 0:00 [kmmcd] 2672 pts/0 SLl 0:01 com.android.launcher 32 ? S 0:00 [pdflush] 2673 pts/0 SLl 0:00 com.android.settings 33 ? 34 ? S S< 0:00 0:00 [pdflush] [kswapd0] Processes 2701 pts/0 2728 pts/0 SLl SLl 0:00 0:00 android.process.acore com.android.bluetooth 2735 pts/0 SLl 0:00 com.android.mms 35 ? 36 ? S< S< 0:00 0:00 [aio/0] [aio/1] of Android 2744 pts/0 SLl 0:00 android.process.media 37 ? S< 0:00 [aio/2] 2764 pts/0 SLl 0:00 com.android.providers.calendar 38 ? S< 0:00 [aio/3] 2776 pts/0 SLl 0:00 com.android.deskclock 39 ? S< 0:00 [nfsiod] 2786 pts/0 SLl 0:00 com.android.email 40 ? S< 0:01 [rpciod/0] 2796 pts/0 SLl 0:00 com.android.quicksearchbox 41 ? S< 0:00 [rpciod/1] 2807 pts/0 SLl 0:00 com.android.protips 42 ? S< 0:00 [rpciod/2] 2814 pts/0 SLl 0:00 com.android.music 43 ? S< 0:00 [rpciod/3] 2821 pts/0 SLl 0:00 com.cooliris.media 2297 ? SL 0:00 upstart-udev-bridge --daemon 2831 pts/1 RL+ 0:00 ps ax 2300 ? SLl 0:00 rsyslogd -c4 user@arm-lucid:~$ 2301 ? S<Ls 0:00 udevd --daemon 24 2378 ? SLs 0:00 /usr/sbin/sshd
  25. 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. 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. 27. Q&A Thank you for listening! Any comments to blogs are welcome.@tetsu_koba 27

×