Android internals 03 - Build system, emulator (rev_1.1)
-
Upload
egor-elizarov -
Category
Education
-
view
2.936 -
download
6
description
Transcript of Android internals 03 - Build system, emulator (rev_1.1)
Android internalsEgor ElizarovSPbSU 2012
Egor Elizarov SPbSU 20122
Legal info
Android internals by Egor Elizarov is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
You are free to – copy, distribute, display, and perform the work
– make derivative works Under the following conditions
– Attribution. You must give the original author credit
– Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one
All pictures and trademarks are the property of their respective owners. Use of these trademarks and pictures is subject to owners permissions.
Corrections, suggestions, contributions and translations are welcome!
Egor Elizarov SPbSU 20123
Lecture 3
Android build system,
Emulator
yegor.yelizarov(at)gmail.com
http://vk.com/android_internalsRev: 1.1Last update: 05/30/2012
Egor Elizarov SPbSU 20124
Previous time
AOSP
High level architecture
Android OS bring up
CTS & CDD
repo / git / gerrit
Code layout
Egor Elizarov SPbSU 20125
Android build system
Based on GNU Make
Build system code is in “build” directory (./build/core/main.mk - start point)
Android.mk files
All output and temporary files are in “out” directory
Egor Elizarov SPbSU 20126
Makefile structure
Structure:
Target: depenencies List of commands
Usage:
make target
Egor Elizarov SPbSU 20127
Interesting files
Android.mk — build scenario for module
buildspec.mk — variable defenitions for build system
envsetup.sh — setup environment, add some helper functions
Egor Elizarov SPbSU 20128
Sample Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := list_of_sources
LOCAL_C_INCLUDES := list_of_directories_with_header_files
LOCAL_SHARED_LIBRARIES := list_of_shared_libraries
LOCAL_STATIC_LABRARIES := list_of_static_libraries
LOCAL_MODULE_TAGS := debug
LOCAL_MODULE := module_name
include $(BUILD_EXECUTABLE)
Egor Elizarov SPbSU 20129
More variables
LOCAL_MODULE_PATH := install_path
LOCAL_CFLAGS := flags_for_compiler
LOCAL_LDFLAGS := flags_for_linker
LOCAL_OVERRIDES_PACKAGES := packages_to_be_dropped
Etc.
Egor Elizarov SPbSU 201210
Target hierarchyCPU type
Bare schematics
Fixed peripherals
Fixed applications
Egor Elizarov SPbSU 201211
buildspec.mk
TARGER_PRODUCT = product_name
TARGET_BUILD_TYPE = debug
SHOW_COMMANDS = true
USE_CCACHE = 1
BUILD_TINY_ANDROID = true (board bring up/ low level debugging)
Egor Elizarov SPbSU 201212
Some make targets
make droid (default target)
make update-api (update current API)
make sdk (build SDK)
make help (prints more targets)
Egor Elizarov SPbSU 201213
Build process
Egor Elizarov SPbSU 201214
Building AOSP
cd AOSP
. build/envsetup.sh
lunch
Select generic-eng version
make -j4
Egor Elizarov SPbSU 201215
Add new program
Egor Elizarov SPbSU 201216
Board specific files
BoardConfig.mk (Target configuration)
Board_name.mk (board related defenitions, list of packages)
Device.mk (list of files to be copied, list of packages, etc.)
Egor Elizarov SPbSU 201217
Android emulator
Based on Qemu VM
Goldfish – codename for emulator
Code in development/tools/emulator & external/qemu
Provided as part of SDK
Egor Elizarov SPbSU 201218
Emulator features
Runs full Android stack down to the kernel level
ARM v5 CPU and correcponding MMU
LCD with different resolutions
GSM modem
Simulates application interrupts, data channel lost, etc.
Egor Elizarov SPbSU 201219
Qemu
Single loop for each core
Worker threads for long term tasks
Tiny Code Generator (TCG)
Kernel Virtual Machine (KVM)
Egor Elizarov SPbSU 201220
Emulator window
Egor Elizarov SPbSU 201221
Tools
android — control AVD, update SDK, manage android projects
emulator — launches emulator
adb — remote debug console
mksdcard — create SD card image
Egor Elizarov SPbSU 201222
Android Debug Bridge
adb kill-server
adb devices
adb logcat
adb shell
adb push what where
adb pull what where
Egor Elizarov SPbSU 201223
ADB internals
USB or TCP/IP
Egor Elizarov SPbSU 201224
Launch emulator
$ out/host/linux-x86/bin/emulator &
$ adb kill-server
$ adb shell
Egor Elizarov SPbSU 201225
Target filesystem layout
/system — main system directory
/data — main data directory
/cache — Dalvik cache
/sdcard — SD card mount point
/etc; /sys; /proc; /dev; /sbin; /root; /mnt — derived from linux
Egor Elizarov SPbSU 201226
Next time
“Androdized” kernel
Bionic standard C library
Logging system
Source: http://androidcommunity.com
Egor Elizarov SPbSU 201227
Useful links
http://vk.com/android_internals
http://mrbook.org/tutorials/make/
http://elinux.org/Android_Build_System
K. Yaghmour. Embedded Android. Early Release, O'Reilly, October 2011
http://developer.android.com/guide/developing/tools/emulator.html
http://developer.android.com/guide/developing/devices/emulator.html
http://blog.vmsplice.net/2011/03/qemu-internals-overall-architecture-and.html
Egor Elizarov SPbSU 201228
Thanks to
Sergey Matyukevich for review and advices (www.linkedin.com/pub/sergey-matyukevich/31/889/769)
Nikolay F. Fominykh for review and advices
Nikita Shulga for advices and notes (http://www.linkedin.com/pub/nikita-shulga/8/582/287)