SlideShare a Scribd company logo
1 of 15
Download to read offline
Init of Android


      2010.12.10


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)
   Twitter
       @tetsu_koba
                                                     2
Today's topic

   /init
   Boot part of init
   Daemon part of init
   Check it out using debugger



                                  3
/init

   Quite different from usual Linux
    system
   Add ”init=/init” in kernel boot
    parameter. Kernel searches only the
    following init
       /sbin/init
       /etc/init
       /bin/init
       /bin/sh
/init

   Android init is static linked. So it can
    run standalone
      (Linux /sbin/init is dynamically

       linked. If some trouble in dynamic
       link system, the whole system won't
       work)
Component of init
   See the source code of init
      system/core/init


   Init is made of 2 parts: boot part
    and daemon part
      At first, boot part is executed

       once
      After that daemon part executed

       repeatedly
int main(int argc, char **argv)
{
    /* Boot part   */
 
    for (;;) {

        /* Daemon part */

    }
}
Boot part

   Setup the directories
       /dev
       /proc
       /sys
   Parse /init.rc and execute it
   Yokohama Android Platform club
    has a lot of information for this
    topic (written in Japanese)
Daemon part

   Waiting for 4 fds by poll system
    call and handle these in forever
    loop
      device_fd


      property_set_fd


      signal_recv_fd


      keychord_fd
device_fd

   Receiving the device status
    notification from kernel and create
    or remove device files under /dev
   In usual Linux system, udevd do
    this.
property_set_fd

   Waiting for write request for
    system property
   Init process maintains master data
    of system property. The other
    processes share it in read only
    mode by android ashmem
    mechanism.
   (Let's talk this in other session)
signal_recv_fd

   Waiting for exiting child process
    and finish them by waitpid system
    call
   If the child process is registered as
    service, restart it as registered
    info.
keychord_fd

   Monitoring special key comination
    and start the associated service
   Effective only if system property
    ”ro.debuggable” == ”1” ||
    “init.svc.adbd” == “running”
   No services use this in default
    init.rc
See also

   KMC blog ”init of Android”
       http://blog.kmckk.com/archives/3137191.html
       This page have links of Yokohama Android
        Platform club, too.
       Written in Japanese
Q&A




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

                                     15

More Related Content

What's hot

Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)
fefe7270
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 

What's hot (20)

Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Embedded Android : System Development - Part I
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part I
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - Vold
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Android Binder: Deep Dive
Android Binder: Deep DiveAndroid Binder: Deep Dive
Android Binder: Deep Dive
 
CI CD Jenkins for Swift Deployment
CI CD Jenkins for Swift DeploymentCI CD Jenkins for Swift Deployment
CI CD Jenkins for Swift Deployment
 
Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)Android audio system(audio_hardwareinterace)
Android audio system(audio_hardwareinterace)
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Binder: Android IPC
Binder: Android IPCBinder: Android IPC
Binder: Android IPC
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 

Similar to Init of Android

Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
Etsuji Nakai
 
Yet Another Android Rootkit
Yet Another Android RootkitYet Another Android Rootkit
Yet Another Android Rootkit
FFRI, Inc.
 
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
 

Similar to Init of Android (20)

Timings of Init : Android Ramdisks for the Practical Hacker
Timings of Init : Android Ramdisks for the Practical HackerTimings of Init : Android Ramdisks for the Practical Hacker
Timings of Init : Android Ramdisks for the Practical Hacker
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
Linux startup
Linux startupLinux startup
Linux startup
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 
Yet Another Android Rootkit
Yet Another Android RootkitYet Another Android Rootkit
Yet Another Android Rootkit
 
Systemd mlug-20140614
Systemd mlug-20140614Systemd mlug-20140614
Systemd mlug-20140614
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
 
Ch04
Ch04Ch04
Ch04
 
Inter-process communication of Android
Inter-process communication of AndroidInter-process communication of Android
Inter-process communication of Android
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 
Explore Android Internals
Explore Android InternalsExplore Android Internals
Explore Android Internals
 
Industrialization of Android Development (Concept)
Industrialization of Android Development (Concept)Industrialization of Android Development (Concept)
Industrialization of Android Development (Concept)
 
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
 
Processes
ProcessesProcesses
Processes
 
Release notes 3_d_v61
Release notes 3_d_v61Release notes 3_d_v61
Release notes 3_d_v61
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Dori waldman android _course
Dori waldman android _courseDori waldman android _course
Dori waldman android _course
 

More from Tetsuyuki Kobayashi

Simple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAPSimple and efficient way to get the last log using MMAP
Simple and efficient way to get the last log using MMAP
Tetsuyuki Kobayashi
 
ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?ADB(Android Debug Bridge): How it works?
ADB(Android Debug Bridge): How it works?
Tetsuyuki Kobayashi
 

More from Tetsuyuki Kobayashi (20)

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

Init of Android

  • 1. Init of Android 2010.12.10 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)  Twitter  @tetsu_koba 2
  • 3. Today's topic  /init  Boot part of init  Daemon part of init  Check it out using debugger 3
  • 4. /init  Quite different from usual Linux system  Add ”init=/init” in kernel boot parameter. Kernel searches only the following init  /sbin/init  /etc/init  /bin/init  /bin/sh
  • 5. /init  Android init is static linked. So it can run standalone  (Linux /sbin/init is dynamically linked. If some trouble in dynamic link system, the whole system won't work)
  • 6. Component of init  See the source code of init  system/core/init  Init is made of 2 parts: boot part and daemon part  At first, boot part is executed once  After that daemon part executed repeatedly
  • 7. int main(int argc, char **argv) { /* Boot part   */   for (;;) { /* Daemon part */ } }
  • 8. Boot part  Setup the directories  /dev  /proc  /sys  Parse /init.rc and execute it  Yokohama Android Platform club has a lot of information for this topic (written in Japanese)
  • 9. Daemon part  Waiting for 4 fds by poll system call and handle these in forever loop  device_fd  property_set_fd  signal_recv_fd  keychord_fd
  • 10. device_fd  Receiving the device status notification from kernel and create or remove device files under /dev  In usual Linux system, udevd do this.
  • 11. property_set_fd  Waiting for write request for system property  Init process maintains master data of system property. The other processes share it in read only mode by android ashmem mechanism.  (Let's talk this in other session)
  • 12. signal_recv_fd  Waiting for exiting child process and finish them by waitpid system call  If the child process is registered as service, restart it as registered info.
  • 13. keychord_fd  Monitoring special key comination and start the associated service  Effective only if system property ”ro.debuggable” == ”1” || “init.svc.adbd” == “running”  No services use this in default init.rc
  • 14. See also  KMC blog ”init of Android”  http://blog.kmckk.com/archives/3137191.html  This page have links of Yokohama Android Platform club, too.  Written in Japanese
  • 15. Q&A Thank you for listening! Any comments to blogs are welcome. 15