SlideShare a Scribd company logo
Reusing your existing software
             on
           Android
              2010.9.3
              2011.8.5 updated

         Tetsuyuki Kobayashi

                                 1
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
Today's topic

   Introduction
   Running your software on
    Android
      No rebuild, binary as is


      Rebuild


   Running Android on your
    existing linux environment
                                  3
Audience

   Already using Linux in your project
   Have interest in Android
   Thinking how to migrate to
    Android



                                          4
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
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
Let's try prototyping

   Anyway, port Android on your
    board.
   I show you some techniques for a
    quick hack in this session.



                                       7
Things to consider

   Execution overhead
   Memory/Storage usage
   Easiness to follow version up of
    Android





                                       8
3 topics
   Running existing binary on
    Android
   Rebuilding for Android
   Running Android on your Linux




                                    9
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
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
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
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
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
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
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
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
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
Running Android on your Linux



                               Android
                                Android



     Your existing Linux user land




        Android-patched Linux kernel
         Android-patched Linux kernel


                                          19
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
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
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
Result of ps command
user@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
Result of ps command
user@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
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
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
Q&A




         Thank you for listening!
         Any comments to blogs are welcome.
@tetsu_koba


                                          27

More Related Content

PPT
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
ODP
Embedded Android : System Development - Part III
PDF
Embedded Android : System Development - Part I
PDF
Understanding the Dalvik Virtual Machine
PDF
Android Binder IPC for Linux
PDF
Embedded Android : System Development - Part II (HAL)
PPTX
Overview of Android binder IPC implementation
PDF
Understanding the Android System Server
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Embedded Android : System Development - Part III
Embedded Android : System Development - Part I
Understanding the Dalvik Virtual Machine
Android Binder IPC for Linux
Embedded Android : System Development - Part II (HAL)
Overview of Android binder IPC implementation
Understanding the Android System Server

What's hot (20)

PDF
Android Storage - Vold
PDF
Android Treble: Blessing or Trouble?
PPTX
Understanding open max il
PDF
Design and Concepts of Android Graphics
PDF
Docker - un outil pour faciliter le développement et le déploiement informatique
PDF
The Android graphics path, in depth
PDF
Embedded Android : System Development - Part IV (Android System Services)
PPTX
Virtual machines and containers
PDF
Android Things : Building Embedded Devices
PPTX
Appium ppt
PPTX
Binder: Android IPC
PPTX
KVM and docker LXC Benchmarking with OpenStack
PDF
BKK16-315 Graphics Stack Update
PPT
presentation on Docker
PDF
Embedded Android : System Development - Part IV
PDF
Embedded Android : System Development - Part II (Linux device drivers)
ODP
Q4.11: Porting Android to new Platforms
PPT
Learning AOSP - Android Linux Device Driver
PDF
YAML Tips For Kubernetes by Neependra Khare
PPTX
6. Live VM migration
Android Storage - Vold
Android Treble: Blessing or Trouble?
Understanding open max il
Design and Concepts of Android Graphics
Docker - un outil pour faciliter le développement et le déploiement informatique
The Android graphics path, in depth
Embedded Android : System Development - Part IV (Android System Services)
Virtual machines and containers
Android Things : Building Embedded Devices
Appium ppt
Binder: Android IPC
KVM and docker LXC Benchmarking with OpenStack
BKK16-315 Graphics Stack Update
presentation on Docker
Embedded Android : System Development - Part IV
Embedded Android : System Development - Part II (Linux device drivers)
Q4.11: Porting Android to new Platforms
Learning AOSP - Android Linux Device Driver
YAML Tips For Kubernetes by Neependra Khare
6. Live VM migration
Ad

Similar to Reusing your existing software on Android (20)

PDF
Android On Ubuntu for developer
PPTX
Introduction to Docker
PDF
Shifter: Containers in HPC Environments
PDF
Chicago Docker Meetup Presentation - Mediafly
PDF
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
PPTX
Scaling Docker Containers using Kubernetes and Azure Container Service
PDF
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
PDF
Rooting Out Root: User namespaces in Docker
PDF
Introduction to Docker
PDF
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
PDF
2008-06-25 Marist System z Summer Professors Series
PDF
Présentation de Docker
PDF
App container rkt
PDF
Headless Android at AnDevCon3
PDF
Docker 활용법: dumpdocker
PDF
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
PDF
Docker for HPC in a Nutshell
PDF
Real-World Docker: 10 Things We've Learned
PDF
Revolutionizing WSO2 PaaS with Kubernetes & App Factory
PDF
Securité des container
Android On Ubuntu for developer
Introduction to Docker
Shifter: Containers in HPC Environments
Chicago Docker Meetup Presentation - Mediafly
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
Scaling Docker Containers using Kubernetes and Azure Container Service
MongoDB.local Austin 2018: MongoDB Ops Manager + Kubernetes
Rooting Out Root: User namespaces in Docker
Introduction to Docker
MongoDB.local DC 2018: MongoDB Ops Manager + Kubernetes
2008-06-25 Marist System z Summer Professors Series
Présentation de Docker
App container rkt
Headless Android at AnDevCon3
Docker 활용법: dumpdocker
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
Docker for HPC in a Nutshell
Real-World Docker: 10 Things We've Learned
Revolutionizing WSO2 PaaS with Kubernetes & App Factory
Securité des container
Ad

More from Tetsuyuki Kobayashi (20)

PDF
some topic of ffmpeg
PDF
New VIdeo CODEC AV1
PDF
Try new transport protocol SRT (ver. 2)
PDF
Try new transport protocol SRT
PDF
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
PDF
WebOS Open Source Edition を試してみた
PDF
Linuxのユーザーランドをinitから全てまるごとgolangで書く
PDF
組み込みLinuxでのGolangのススメ(Go con版)
PDF
組み込みLinuxでのGolangのススメ
PDF
Tricky implementation of Go ARM soft float
PDF
ARM 64bit has come!
PDF
Virtual memory 20070222-en
PDF
Simple and efficient way to get the last log using MMAP
PDF
Tips of Malloc & Free
PDF
Basic of virtual memory of Linux
PDF
PDF
ADB(Android Debug Bridge): How it works?
PDF
Tweaking Google TV emulator
ODP
Inter-process communication of Android
PDF
Android is NOT just 'Java on Linux'
some topic of ffmpeg
New VIdeo CODEC AV1
Try new transport protocol SRT (ver. 2)
Try new transport protocol SRT
Raspberry Pi Zero とカメラモジュールで作るライブ配信実験機
WebOS Open Source Edition を試してみた
Linuxのユーザーランドをinitから全てまるごとgolangで書く
組み込みLinuxでのGolangのススメ(Go con版)
組み込みLinuxでのGolangのススメ
Tricky implementation of Go ARM soft float
ARM 64bit has come!
Virtual memory 20070222-en
Simple and efficient way to get the last log using MMAP
Tips of Malloc & Free
Basic of virtual memory of Linux
ADB(Android Debug Bridge): How it works?
Tweaking Google TV emulator
Inter-process communication of Android
Android is NOT just 'Java on Linux'

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Understanding_Digital_Forensics_Presentation.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
cuic standard and advanced reporting.pdf
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
MYSQL Presentation for SQL database connectivity
The Rise and Fall of 3GPP – Time for a Sabbatical?
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Understanding_Digital_Forensics_Presentation.pptx
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Review of recent advances in non-invasive hemoglobin estimation
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
cuic standard and advanced reporting.pdf

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
  • 23. Result of ps command user@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. Result of ps command user@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. 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