Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building Android OS Topics: Building Android and Kernel

Similar presentations


Presentation on theme: "Building Android OS Topics: Building Android and Kernel"— Presentation transcript:

1 Building Android OS Topics: Building Android and Kernel
Date: 11/7/2017

2 References (study these)

3 Android OS Architecture

4 Android Binary Component
1. Application Processor Images Bootloader Image Kernel Image Platform Image 2. Communication Processor Image

5 Android OS Image Component
Bootloader Image Initialize system and launch Linux kernel Kernel Image Include Linux Kernel (bzImage) Basic Linux OS system and device drivers “kernel” or other names Platform Image Include Android Framework, Native Libraries, Android Runtime, HAL The core of Android OS except kernel image “system.img” Other Images CP(Communication Processor) Image, User Data, …

6 Android Boot Sequence 1. Kernel Booting - Initialization
- Call init process 2. Init Process - Launch daemons - Start Zygote 3. Start Zygote and Dalvik - Virtual machine - Initial process 4. System Server - Start Java Service

7 Android Boot Sequence 1. Power On and System Startup
Starts when we press the power button. The Boot ROM code starts executing from a pre-defined location which is hardwired in ROM. It loads the Bootloader into RAM and starts executing.

8 Android Boot Sequence 2. Bootloader
The bootloader is a small program which runs before Android does. Bootloader is NOT part of the Android operating system. The bootloader executes in two stages. In the first stage it detects external RAM and loads a program which helps in the second stage. In the second stage, the bootloader setups the network, memory, etc, which requires to run kernel.

9 Android Boot Sequence 3. Kernel
The Android kernel starts in a similar way as the Linux kernel.  Setup cache, protected memory, scheduling and loads drivers. binder, ashmem, logger, wakelocks, oom, … When the kernel finishes the system setup, it looks for “init” in the system files.

10 Android Boot Sequence 4. init process Init is the very first process
It is a root process, or the grandfather of all processes. The init process has two responsibilities.      1- Mounts directories like /sys , /dev    or /proc      2- Runs init.rc script At  this stage, you can finally see the Android logo in your screen.

11 Android Boot Sequence 5. Zygote and Dalvik
Start Davlik Virtual Machine - an interpreter for the Java programming language. It’s written for CPU utilization and to minimize memory usage Starts a process called “Zygote”. The Zygote enables code sharing across the Dalvik VM, achieving a lower memory footprint and minimal startup time. The Zygote preloads and initializes core library classes. At this time, you can see the boot animation.

12 Android Boot Sequence 6. System Services
After the above steps are completed,  Zygote launches the system services.  The Zygote forks a new process to launch the system services. Core services: Starting power manager Creating the Activity Manager Starting context manager Starting system contact providers Starting battery service Starting alarm manager Starting sensor service

13 Android Source Tree art - Android RunTime
bionic - libc library, math library, (dynamic) linker dalvik – Dalvik virtual machine device – configurations for various smartphone models external - not Android original code(sqlite, openCV) docs - documentation frameworks The heart of Android source code Built-in application, Java framework, C++ Native code, Android service hardware – hardware vendor specific code(Intel, ARM…) kernel – kernel source tree out – build output files are located prebuilt – toolchain(gcc), other pre-built image or program

14 Android Platform Build

15 Android OS Build Basic hardware requirements:
64bit machine for Gingerbread or higher version 100GB hard disk for source code 200GB hard disk for build Multi-core server is strongly recommended!! Basic software requirements: Linux (Ubuntu 12.04) for Gingerbread or higher version Java Development Kit (1.8 or higher version) Python 2.6 GNU Make and GCC

16 Android Platform Build
1. Download Repo $ mkdir ~/bin $ PATH=~/bin:$PATH $ curl downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo

17 Android Platform Build
2. Repo init $ repo init -u

18 Android Platform Build
3. Repo sync (downloading source files) $ repo sync

19 Android Platform Build
4. Build setting $ source build/envsetup.sh $ lunch

20 Android Platform Build
5. Make We build platform image for emulator Select building setting (1) in the lunch menu $ make

21 Android Platform Build
6. Output files After a few hours later, build finishes “android/out/target/product/mini-emulator-x86_64/” “ramdisk.img”, “system.img”, “userdata.img”

22 Android Kernel Build

23 Android Kernel Build 1. Download source files
$ git clone Reference for Android Kernel list

24 Android Kernel Build 1. Download source files
No files downloaded, we need to checkout branch $ cd goldfish $ git branch -a

25 Android Kernel Build 1. Download source files
$ git checkout -t origin/android-goldfish b goldfish $ ls

26 Android Kernel Build 2. Build kernel for Emulator
We build kernel image for Android emulator $ /home/seulki/android/prebuilts/qemu-kernel/build- kernel.sh --arch=x86

27 Android Kernel Build 3. Output kernel image
“goldfish/arch/x86/boot/bzImage”

28 Loading kernel to Emulator
1. Copy “bzImage” to the Android emulator folder “C:\Users\Seulki\AppData\Local\Android\Sdk\system- images\android-23\google_apis\x86” 2. Change filename from “kernel-qemu” to “kernel-qemu2” 3. Change filename from “bzImage” to “kernel-qemu” 4. Launch Android Emulator

29 Flashing images into real device
1. Your custom images can be flashed to real devices “fastboot” tool in Android SDK 2. Entering to the download mode Turn off the phone. Press and hold the volume down and power buttons simultaneously, and keep holding them for about 10 seconds. 3. Flashing flash-all fastboot flash bootloader <bootloader image file name>.img fastboot flash boot <boot image file name>.img fastboot flash system <system file name>.img fastboot flash radio <radio image file name>.img DO NOT FLASH IMAGES IF YOU’RE NOT SURE!

30 Make-up Assignment Part 1 - Kernel
Android uses many input devices such as touchscreen, touch key and hardware key. But for an emulator, it cannot use physical input devices mentioned above. Instead, a mouse pointer connected to your laptop is used as a touchscreen pointer for an emulator screen. Find the location of pointer device driver in Kernel source. Print a log message for pointer every time your laptop-mouse clicks on the emulator screen like the below picture (you need to load your modified kernel to the emulator).

31 Make-up Assignment Part 2 - Platform
Sensor data from sensor devices in your phone travel though multiple Android software layers to arrive at a sensor application. It starts from a physical sensor device and travels though kernel device driver, sensor HAL(Hardware Abstraction Layer), sensor service, sensor framework(SensorManger) and finally arrives at an application. In this assignment, we are going to look at sensor HAL in detail. Where is the location of sensor HAL source files? What is the difference between sensor HAL code for real device and emulator? Add one sensor to the HAL that is not currently supported for emulator. You don’t need to add the new sensor to other layers(sensor service, sensor framework) and kernel. Build your own sensor HAL with the sensor you have newly added (make sure it does not make any compile errors).


Download ppt "Building Android OS Topics: Building Android and Kernel"

Similar presentations


Ads by Google