peter aagaard kristensenblue-kite.dk › tech › my_first_android_port.pdf · system basic android...
TRANSCRIPT
![Page 1: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/1.jpg)
MY FIRST ANDROIDTM PORT
Peter Aagaard Kristensen
![Page 2: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/2.jpg)
2
MY FIRST ANDROIDTM
PORT
Agenda
• Source• Building• Kernel• Startup• Hardware• Debugging
![Page 3: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/3.jpg)
3
MY FIRST ANDROIDTM
PORT
Where to start
• developer.android.com• source.android.com• kandroid.org• pdk.android.com• android.git.kernel.org
![Page 4: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/4.jpg)
4
MY FIRST ANDROIDTM
PORT
android.git.kernel.org
![Page 5: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/5.jpg)
5
MY FIRST ANDROIDTM
PORT
android.git.kernel.org
![Page 6: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/6.jpg)
6
MY FIRST ANDROIDTM
PORT
android.git.kernel.org
![Page 7: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/7.jpg)
7
MY FIRST ANDROIDTM
PORT
Getting the source
• git• repo• Garrit
![Page 8: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/8.jpg)
8
MY FIRST ANDROIDTM
PORT
Starting with repo
<?xml version="1.0" encoding="UTF-8"?><manifest>
<remote name="korg"fetch="git://android.git.kernel.org/"review="review.source.android.com" />
<default revision="master"remote="korg" />
<project path="build" name="platform/build" revisio n="b7c844e7cf05b4cea629178bfa793321391d21de" ><copyfile src="core/root.mk" dest="Makefile" />
</project>
<project path="common" name="kernel/common" revisio n="74fca6a42863ffacaf7ba6f1936a9f228950f657" />
<project path="bionic" name="platform/bionic" revis ion="95604529ec25fe7923ba88312c590f38aa5e3d9e" /><project path="bootable/bootloader/legacy" name="pl atform/bootable/bootloader/legacy" /><project path="bootable/diskinstaller" name="platfo rm/bootable/diskinstaller" /><project path="bootable/recovery" name="platform/bo otable/recovery" />
...
</manifest>
$ repo init -u http://blue-kite.dk/repos/at91sam9g2 0-manifest.git/
$ repo sync
![Page 9: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/9.jpg)
9
MY FIRST ANDROIDTM
PORT
MyDroid
Makefile
Vendor specific codevendor
Basic Android systemsystem
Binary host tools and other prebuildsprebuilt
Standard applications and providerspackages
Drivers for hardware accesshardware
Frameworks for display, audio, camera, media ...frameworks
Collection of librariesexternal
Simulator and other development toolsdevelopment
Dalvik virtual machinedalvik
Linux kernelcommon
Android build systembuild
Bootloadersbootable
Androids C librarybionic
Files for repo.repo
![Page 10: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/10.jpg)
10
MY FIRST ANDROIDTM
PORT
Garrit$ repo start$ repo upload
• review.source.android.com
http://code.google.com/p/gerrit/
![Page 11: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/11.jpg)
11
MY FIRST ANDROIDTM
PORT
Android build system
• Make LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)
LOCAL_SRC_FILES:= logcat.cpp
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_MODULE:= logcat
include $(BUILD_EXECUTABLE)
...
Logcat Android.mk
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := user
LOCAL_SRC_FILES := $(call all-java-files-under, src )
LOCAL_PACKAGE_NAME := CameraLOCAL_CERTIFICATE := media
include $(BUILD_PACKAGE)
# Use the following include to make our test apk.include $(call all-makefiles-under,$(LOCAL_PATH))
Camera application Android.mk
• out• Default build• Outputs
– root– system
• Did it built?• Did it boot?
![Page 12: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/12.jpg)
12
MY FIRST ANDROIDTM
PORT
Android kernel
• Default branch android-2.6.27• ~ 36.000 lines diff from v2.6.27• YAFFS2 ~ 15.000• Binder ~ 4.000• Ashmem ~ 1.000• Logger ~ 1.000• USB, MMC, Bluetooth, Power, …
![Page 13: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/13.jpg)
13
MY FIRST ANDROIDTM
PORT
ashmem
• Anonymous Shared Memory• Share file descriptor and mmap• Memory reclaim
![Page 14: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/14.jpg)
14
MY FIRST ANDROIDTM
PORT
Binder
• IPC• Thread pools
Process A Process BBinder
Service BApp A
![Page 15: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/15.jpg)
15
MY FIRST ANDROIDTM
PORT
Logger
• Cyclic log in kernel memory• Header: PID, TID, timestamp• Main /dev/log/main 64KB
– Input: priority, tag and message
• Events /dev/log/events 256KB• Radio /dev/log/radio 64KB• log and logcat• Great debug tool
![Page 16: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/16.jpg)
16
MY FIRST ANDROIDTM
PORT
Main log
I/DEBUG ( 1392): debuggerd: Jan 26 2010 21:47:21I/vold ( 1391): Android Volume Daemon version 2.0D/vold ( 1391): Bootstrapping completeD/AndroidRuntime( 1401):D/AndroidRuntime( 1401): >>>>>>>>>>>>>> AndroidRunt ime START <<<<<<<<<<<<<<D/AndroidRuntime( 1401): CheckJNI is OFFI/ ( 1410): ServiceManager: 0xad08W/AudioHardwareInterface( 1410): Using stubbed audi o hardware. No sound will be produced.D/AudioHardwareInterface( 1410): setMode(NORMAL)I/CameraService( 1410): CameraService started: pid=1 410I/AudioFlinger( 1410): AudioFlinger's thread 0xb340 ready to runD/AndroidRuntime( 1401): --- registering native func tions ---I/SamplingProfilerIntegration( 1401): Profiler is d isabled.I/Zygote ( 1401): Preloading classes...D/dalvikvm( 1401): GC freed 791 objects / 50440 byt es in 4msD/dalvikvm( 1401): GC freed 255 objects / 16392 byt es in 4msD/dalvikvm( 1401): GC freed 298 objects / 19120 byt es in 5ms
Startup
![Page 17: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/17.jpg)
17
MY FIRST ANDROIDTM
PORT
I/DEBUG ( 1392): debuggerd: Jan 26 2010 21:47:21I/vold ( 1391): Android Volume Daemon version 2.0D/vold ( 1391): Bootstrapping completeD/AndroidRuntime( 1401):D/AndroidRuntime( 1401): >>>>>>>>>>>>>> AndroidRunt ime START <<<<<<<<<<<<<<D/AndroidRuntime( 1401): CheckJNI is OFFI/ ( 1410): ServiceManager: 0xad08W/AudioHardwareInterface( 1410): Using stubbed audi o hardware. No sound will be produced.D/AudioHardwareInterface( 1410): setMode(NORMAL)I/CameraService( 1410): CameraService started: pid=1 410I/AudioFlinger( 1410): AudioFlinger's thread 0xb340 ready to runD/AndroidRuntime( 1401): --- registering native func tions ---I/SamplingProfilerIntegration( 1401): Profiler is d isabled.I/Zygote ( 1401): Preloading classes...D/dalvikvm( 1401): GC freed 791 objects / 50440 byt es in 4msD/dalvikvm( 1401): GC freed 255 objects / 16392 byt es in 4msD/dalvikvm( 1401): GC freed 298 objects / 19120 byt es in 5ms
Main log
I/SurfaceFlinger( 1706): SurfaceFlinger is startingI/SurfaceFlinger( 1706): SurfaceFlinger's main threa d ready to run. Initializing graphics H/W...I/gralloc ( 1706): using (fd=22)I/gralloc ( 1706): id = Virtual FBI/gralloc ( 1706): xres = 320 pxI/gralloc ( 1706): yres = 480 pxI/gralloc ( 1706): xres_virtual = 320 pxI/gralloc ( 1706): yres_virtual = 960 pxI/gralloc ( 1706): bpp = 16I/gralloc ( 1706): r = 11:5I/gralloc ( 1706): g = 5:6I/gralloc ( 1706): b = 0:5I/gralloc ( 1706): width = 51 mm (159.372543 dpi)I/gralloc ( 1706): height = 76 mm (160.421051 dpi)I/gralloc ( 1706): refresh rate = 60.00 HzE/FramebufferNativeWindow( 1706): xDpi -2046820352E/FramebufferNativeWindow( 1706): yDpi -2046820352
Startup
SurfaceFlinger
![Page 18: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/18.jpg)
18
MY FIRST ANDROIDTM
PORT
Android bootInit• Mount of
– /dev– /sys – /proc
• Startup of properties• uevent handling• Execute init.rc• …
on init
loglevel 3
# setup the global environmentexport PATH /sbin:/system/sbin:/system/bin:/system/ xbin
# create mountpoints and mount tmpfs on sqlite_stmt_j ournalsmkdir /sdcard 0000 system systemmount tmpfs tmpfs /sqlite_stmt_journals size=4m
# log "on init called at $(date)"
on boot
service servicemanager /system/bin/servicemanageruser systemcriticalonrestart restart zygoteonrestart restart media
service zygote /system/bin/app_process -Xzygote /syst em/bin --zygote --start-system-server
socket zygote stream 666onrestart write /sys/power/state ononrestart restart media
service media /system/bin/mediaserveruser mediagroup system audio camera graphics inet net_bt net_bt _admin
Init.rc
![Page 19: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/19.jpg)
19
MY FIRST ANDROIDTM
PORT
AT91SAM9G20-EK
• 400MHz ARM9 CPU• 256 MB NAND flash• 8 MB Dataflash• 64 MB SDRAM• Ethernet• USB host and device• RS232 debug ports• No display• No modem
![Page 20: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/20.jpg)
20
MY FIRST ANDROIDTM
PORT
Boot
• at91.com/linux4sam
![Page 21: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/21.jpg)
21
MY FIRST ANDROIDTM
PORT
Boot
![Page 22: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/22.jpg)
22
MY FIRST ANDROIDTM
PORT
Boot
U-boot env
AT91Bootrap
U-boot
Linux kernel
root (jffs2)
android root(yaffs2)
0x4200
0x8400
0x42000
0x400000
0x4000000
0x0
Dataflash
NAND flash
• at91.com/linux4sam• Prebuilt
– U-boot– Linux kernel– Ångström root filesystem
• opkg package manager
![Page 23: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/23.jpg)
23
MY FIRST ANDROIDTM
PORT
No input
• No display– Virtual frame buffer– android-vnc-server– fbset -g 320 480 320 960 16 -rgba 5/11,6/5,5/0,0/0
• No touch– Virtual touch driver– android-vnc-server
![Page 24: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/24.jpg)
24
MY FIRST ANDROIDTM
PORT
Debugging
• logcat• GDB• Code inspection• Issues
– pmem initialization– Battery– Screen power state
![Page 25: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/25.jpg)
25
MY FIRST ANDROIDTM
PORT
Resources
• blue-kite.dk/tech
![Page 26: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/26.jpg)
26
MY FIRST ANDROIDTM
PORT
Q&A
![Page 27: Peter Aagaard Kristensenblue-kite.dk › tech › my_first_android_port.pdf · system Basic Android system prebuilt Binary host tools and other prebuilds packages Standard applications](https://reader036.vdocuments.us/reader036/viewer/2022081400/5f1c3a258e6378165e631875/html5/thumbnails/27.jpg)
27
MY FIRST ANDROIDTM
PORT
License
Copyright 2010 ©, Peter Aagaard Kristensen.This presentation is licensed under Creative Commons 3.0 Attribution License.
Portions of this presentation are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.
Android is a trademark of Google Inc. Use of this trademark is subject to Google Permissions.