180 likes | 420 Views
Android4SAM Porting Introduction. Agenda. Overview Linux kernel porting Android porting Customize according to your hardware Vendor folder structure & explanation Get, Config & Build Android system. Android building system. Overview. Hardware platform validation Linux kernel porting
E N D
Agenda • Overview • Linux kernel porting • Android porting • Customize according to your hardware • Vendor folder structure & explanation • Get, Config & Build Android system. • Android building system
Overview • Hardware platform validation • Linux kernel porting • Linux kernel + Android kernel patches • Necessary drivers • Kernel configuration file • Debugging • Android root file system porting • Customize components • Extra libraries • Debugging • Logcat • Take Android4SAM as an example • www.at91.com/Android4SAM
Kernel Porting (1) • Get the Linux kernel from mainline • git.kernel.org • Project name: linux/kernel/git/torvalds/linux-2.6.git • Choose version • According to Android requirement • Porting Linux to target platform • Make sure the minimum system can boot up • Enable other drivers • Display • Input • And etc • Example • www.at91.com/Linux4SAM
Kernel Porting (2) • Get Android official Linux kernel • Project name: kernel/common • Version: android-2.6.35, android-3.0, etc • Patch your Linux kernel • Get the difference between your kernel and Android kernel • Patch your Linux kernel • Enable Android requirement driver • Display • Input • Power management • And etc • Android kernel configuration • Refer to Android kernel’s “documentation/android.txt”
Android Porting Steps • Android Porting (1) – Get Source • Android Porting (2) – Add Product • Android Porting (3) – Customize • Android Porting (4) – Build Android • Android Porting (5) – Run Android • Android Porting (5) – Customize
Android Porting (1) – Get Source • Install git and repo • # sudo apt-get install git-core • # mkdir ~/bin • # curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo • # chmod a+x ~/bin/repo • Initialize and Get the code • # mkdir android • # repo init -u https://android.googlesource.com/platform/manifest -b <android-version> • # repo sync
Android Porting (2) – Add Product • File need for each product • Vendor • Product • AndroidBoard.mk • AndroidProducts.mk • BoardConfig.mk • <product_name>.mk • Common • Bootlogo • Packages • And etc
Android Porting (2.1) – Add Product • AndroidBoard.mk • It is a legacy mechanism to deal with a few edge-cases that can’t be managed otherwise. • No new rules should be added to this file. • AndroidProducts.mk • This file lists the product definition files that define configurations which are actually buildable. • <product-name>.mk • Product configuration • Packages included • Product name, manufacturer, device, brand. • BoardConfig.mk • This file sets variables that control the way modules are built throughout the system.
atmel Common Contain files for these three products sam9m10 Sam9m10 specific files and configuration … Android Porting (2.2) – Add Product
Android Porting (4) – Build Android • Prepare build environment • Installing the JDK • Installing required packages • Build Android source code • Initialize • # . build/envsetup.sh • Choose product • choosecombo • [Device/Simulator] [release/debug] [Product] [user/userdebug/eng] • e.g: # choosecombo Device release sam9m10 eng • lunch • [product]-[user/userdebug/eng] • e.g: # lunch sam9m10-eng • Build • # make –j4
Android Porting (5) – Run Android • Take Atmel as an example • AT91SAM9M10G45-EK board • Generate Android image • Use tool to generate SD image • Generate_sdcard_image.tar.gz • Need use other tools to burn to SD card • Use tools to generate UBI image • Generate_ubifs_image.tar.gz • Can be directly flash to NAND flash • Flash to product • Get the SAM-BA at Atmel website • Using SAM-BA to flash the image into NAND flash. • Run • Power up the system
Android Porting (6) -- Customize • Take Atmel as an example • Remove package • device/atmel/sam9m10 • sam9m10_generic.mk • Remove camera line from PRODUCT_PACKAGES • Rebuild Android and generate the images • Run and test • Add third party package • Copy the package source code to “device/atmel/common/packages” • Add “include $(common_dir)/packages/apps/<package_name>/Android.mk” in AndroidBoard.mk file • Add the package name to PRODUCT_PACKES • Rebuild Android and generate the images • Run and test
Android Porting (7) -- Debugging • ADB • Introduction • Android Debug Bridge • A versatile command line tool • A client-server program • Communicate with emulator or Android-powered device. • ADB command list • devices: list all connected devices • push: copy file/dir to device • pull: copy file/dir from device • shell: run remote shell interactively • Using ADB • Install ADB driver, and update it for Atmel chip • Using windows command console to run adb • More info: https://developer.android.com/guide/developing/tools/adb.html
Android Porting (7) -- Debugging • Logcat • Introduction • The Android logging system • Collecting and viewing system debug output • Logcat option • -b <buffer>: loads an alternate log buffer for viewing • -c: clears the entire log and exits • -d: dump the log to the screen and exits • -f <filename>: writes log message output to <filename> • -g: prints the size of speicifed log buffer and exits. • -n <count>: sets the maximum number of rotated logs to <count> • -s: sets the default filter spec to silent • -v <format>: sets the output format for log messages. • More info: https://developer.android.com/guide/developing/tools/logcat.html
Android Building System ---- summary • Setting the environment • Build/envsetup.sh • Detect and configure the host build environment • Provide useful command • Configure the building environment • Choosecombo or Lunch • Configure the target’s parameter • Build commands • m (= make) • Makes from the top of the tree • mm • Builds all of the modules in the current directory • mmm • Builds all of the modules in the supplied directories
Android Building System ---- Android.mk • Introduction • A tiny GNU Makefile fragment • Describe the sources to the build system • Use to define one or more modules • Key component • LOCAL_PATH • Must begin with the definition of the LOCAL_PATH • Locate source files in the development tree • LOCAL_MODULE • Define the module name • The name must be unique and not contain any spaces. • LOCAL_SRC_FILES • The source files that will be built and assembled into a module • Should not list header and included files • BUILD_SHARED_LIBRARY • BUILD_STATIC_LIBRARY