Your SlideShare is downloading. ×
Android porting for dummies @droidconin 2011
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Android porting for dummies @droidconin 2011

7,164
views

Published on

Android porting presentation at droidconin 2011

Android porting presentation at droidconin 2011

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
7,164
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
510
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Android Porting Amit Pundir Android Engineer, Linaro [email_address] @pundiramit
  • 2. Agenda For This Session
    • Android Software Stack
    • 3. Android Open Source Project
      • Build Requirements
      • 4. Code Access
      • 5. Code Structure
      • 6. Target Build Configurations
    • Android Boot Process
    • 7. Android Debugging/Troubleshooting
  • 8. Android Software Stack
  • 9. Applications Applications Application Frameworks Libraries & Runtime Linux Kernel Audio Display Hardware Abstraction Layers Firmware Binaries WiFi Binder Camera Logger ... GPS Radio (RIL) Camera Media NFS Sensors Audio ... Skia Core Libraries Dalvik VM ... SQlite ALSA Freetype Input Webkit System Services Power Manager Activity Manager Content Manager Battery Service Location Manager Audio Service Network Manager Package Manager Window Manager ... Home Settings Media Player Camera Dialer ... Media Server Service Manager ...
  • 10. Android Open Source Project (AOSP)
  • 11. Heads up: Preparing Development Machines for AOSP
      • JBQ's mail on android-building list for the future release of ICS in AOSP.
    -> 06GB of download -> 25GB disk space to do single build -> 80GB disk space to build all AOSP configs -> 16GB RAM recommended -> 5+ hours of CPU time for a single build on a 2x quad-core 2.4 GHz HT with 24GB RAM and no SSD.
      • Initializing Android build environment
    -> 64bit Ubuntu-10.04. Workarounds available to build AOSP on 32bit machines as well. -> Sun-Java6, git, build-essentials, libgl1-mesa, libc6 ... etc
  • 12. AOSP Code Access
      • AOSP consists of multiple independent projects maintained by Git.
      • Moved to android.googlesource.com after kernel.org shutdown.
    -> No Git web preview and Gerrit available yet.
      • `repo` tool.
    -> Git Wrapper script to download AOSP.
      • AOSP manifest file to download/sync-up with a specific AOSP snapshot.
  • 13. AOSP Code Access (contd.)
      • repo init -u $(REPO_MANIFEST_URL) -b $(MANIFEST_BRANCH) -m $(MANIFEST_FILE)
    -> `repo` initialization.
      • repo sync
    -> Start download or sync-up. Example: $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1 $ repo sync
  • 14. AOSP Code Structure
  • 15. bionic Android's C library. bootable Legacy Bootloader/Recovery code for reference build AOSP Build framework cts Android's Compatibility Test Suite dalvik Dalvik Virtual Machine development Development tools #tutorials #monkey device Vendor specific configuration files external External projects used in AOSP frameworks Android core application framework hardware Hardware specific libraries/modules #HAL kernel Linux Kernel libcore Apache Harmony. Free Java implementation. Used by Dalvik. ndk Native Development Kit packages AOSP's stock applications prebuilt Prebuilt binaries such as Toolchain sdk Android's Software Development Kit system Android's core system libraries/binaries #init #toolbox #adb
  • 16. Android Kernel
  • 17. Android Kernel
          • Android patches are not available in upstream Linux kernel.
          • 18. Android maintains `android-common` tree
    -> Android patches on top of Linus's base tree.
          • Extract patches and apply them to your Target specific kernel.
  • 19. Android Kernel Features
      • Binder
    -> Android's IPC mechanism. Inspired from Open Binder project.
      • Ashmem or Anonymous Shared Memory
    -> Shared memory allocator. Discards shared units under memory pressure.
      • Logger
    -> Android's driver which logs data from user space.
      • Wakelocks
    -> Prevents a system to enter suspend or low power states.
  • 20. Android Kernel Features (contd.)
      • Out Of Memory handler
    -> Aggressive OOM handler. Triggers before Kernel's default implementation.
      • Alarm
    -> Android's alarm timer implementation on top of Kernel's RTC implementation.
      • RAM console
    -> Logs last Kernel log. Accessible through /proc/last_kmsg
      • Paranoid network
    -> Network administration through uid/pid e.g AID_NET_*
  • 21. Android HAL
  • 22. Android Hardware Abstraction Layers
          • HAL interfaces are exposed through *HardwareInterface Classes.
    -> Hooked to System at run time using hw_get_module() or dynamic linking, dlopen()
          • HALs linked to framework at build time.
          • HAL modules using standard Linux `sysfs` and `/dev` node entries
  • 23. AOSP Build Process
  • 24. AOSP Build System
      • Building the system
    -> . build/envsetup.sh -> Setting up build environment -> lunch -> Choose the TARGET_PRODUCT -> export USE_CCACHE = 1 -> will cache object files generated by the C/C++ compiler which can be used to speed up next build. -> make -jX -> where X = “number of CPU cores in your build machine” + 1. OR -> m , mm or mmm -> make aliases which is handy while building AOSP projects independently.
  • 25. AOSP Build configuration
      • Target build requirements are set by build/core/{main.mk, config.mk, product.mk, product_config.mk}
      • Build process looks for target specific config file BoardConfig.mk at device/*/$(TARGET_DEVICE) or vendor/*/$(TARGET_DEVICE)
      • TARGET_PRODUCT = TARGET_DEVICE = PRODUCT_DEVICE, where PRODUCT_DEVICE is defined in AndroidProducts.mk present at device/*/* .
  • 26. Target Build/Run time configuration
    • Build time config files device/*/{AndroidProducts.mk, BoardConfig.mk, AndroidBoard.mk}
    • Run time config files init.rc , init.TARGET_PRODUCT.rc , ueventd.rc , ueventd.TARGET_PRODUCT.rc , vold.fstab etc
    • Set optional PRODUCT_PACKAGES in build configuration for Pre-loaded applications.
    • Generate Project manifest file for Target. It is different from an Android Application Manifest file.
  • 27. Android Boot Process
  • 28. Kernel Init Service Manager system server Zygote (-> Dalvik) On init ... On boot ... binder Android Framework Services/Servers Activity Manager Power Manager Package Manager Content Manager Battery Service Window Manager Location Manager Audio Service Alarm Manager Network Manager Media Server ... Android Application
  • 29. Android Debugging/Troubleshooting
  • 30. Android Debugging/Troubleshooting (contd.)
      • Debug logs are important. Get as much as you can.
    -> Increase loglevel in init.rc
      • Run time debugging.
    -> dmesg -> Dump Kernel logs -> logcat -> Dump logs (Main, System, Events, Radio). -> adb and ddms -> Android debug bridge and tool for remote debugging. -> dumpsys and dumpstate -> Dump system services meminfo
  • 31. Android Debugging/Troubleshooting (contd.)
      • Android Postmortem
    -> /proc/last_kmsg -> Last dmesg or kernel log to debug random Kernel crashes.
      • Traceview
    -> debug and profile an Android application.
  • 32. Android Debugging/Troubleshooting (contd.)
      • Android community support channels.
    -> android-porting google group. -> for porting AOSP to new devices -> #android on freenode IRC server -> android-building google group. -> help in building AOSP -> ask-linaro forum -> Ask Linux/Android queries. -> #linaro-android on freenode -> rowboat google group. -> for porting AOSP to Omap3 devices. -> #rowboat on freenode.
  • 33. Thank You.