Transcript Android

Lab4
android-porting
Android
• 起源:Android是基於Linux核心的軟體平
台和作業系統,是Google在2007年11月5日
公布的手機系統平台,早期由Google開發,
後由開放手機聯盟(Open Handset Alliance)
開發
• 開放日期:2008年10月21日
Android
•
•
•
•
•
Android開放部份:
SDK:
目前已到2.0版本
Source code:
除了google本身的master版本,各個團體也
有所維護的版本
• ex:android-x86、FreeRunner
Android-Architecture
Android-Architecture
•
•
•
•
•
採用Software-Stack架構,分為四個部份:
Application
Framework
Middleware(Libraries + Dalvik VM)
Operation System
OPENMOKO
• OpenMoko是一個遵從FLOSS哲學、旨在建
立一個開放的GSM制式智能手機平台的項
目。它運行於Linux平台,使用ipkg包管理
器。OpenMoko 是一個以GPL、LGPL等授
權釋出的開放原始碼軟體專案,目標是創
造出世界第一個完整公開的手機軟體平台
Architecture
Android Porting
• android kernel
• android root filesystem
Build Kernel
Build Kernel
• Install the packages:
– sudo apt-get install monotone build-essential
help2man diffstat texi2html texinfo cvs gawk cogito
zip unzip
– sudo apt-get install gcc g++ autoconf automake
binutils libtool libglib2.0-dev ccache libxrender-dev
intltool
– sudo apt-get install subversion
– sudo aptitude install git-core
– sudo apt-get install quilt
– sudo aptitude install git-core
– sudo update-alternatives --config git
Build Kernel
• Cross Toolchain
– openmoko-i686-arm-linux-gnueabitoolchain.tar.bz2
– web site:
http://downloads.openmoko.org/developer/toolchai
ns
Build Kernel
• git clone git://git.openmoko.org/git/kernel.git
kernel
(source link)
(filename)
– 視所需下載kernel source
• git clone git://git.openmoko.org/git/kernel.git
linux-2.6
• cd linux-2.6
• git checkout origin/andy-tracking
Build Kernel
– download mkimage(from jollen)
– http://people.openmoko.org/jollen/openmoko-kernel
– cp arch/arm/configs/gta02-moredrivers-defconfig GTA02/.config
– 依機型而異
•
./build GTA02
– If the error message like: "arm-angstrom-linux-gnueabi-ld:
unrecognized option '-Wl,-rpath-link,/usr/local/openmoko/arm/armangstrom-linux-gnueabi/lib'" until /usr/local/openmoko/arm/setup-env
is modified.
– You could try
export LDFLAGS="-L${OMTOOL_DIR}/arm/arm-angstrom-linuxgnueabi/lib -rpath-link ${OMTOOL_DIR}/arm/arm-angstrom-linuxgnueabi/lib -O1"
Build Android Image
Android build
• To set up your Linux development environment, make
sure you have the following:
• An armv4 toolchain is required to compile the sources
– download android-toolchain_20081019-koolu1_i386.deb
– http://android.git.kernel.org/pub/android-toolchain20081019.tar.bz2
– sudo dpkg -i android-toolchain_20081019-koolu1_i386.deb
– To use this toolchain, create a buildspec.mk file at the
toplevel of your Android working tree, and add the following
line to it:
– TARGET_TOOLS_PREFIX := /opt/androidtoolchain/bin/armv4t-android-eabi-
Android build
• Git 1.5.4 or newer and the GNU Privacy Guard.
– sudo apt-get install git-core gnupg
• JDK 5.0, update 12 or higher.
– sudo apt-get install sun-java6-jdk
• The following packages: flex, bison, gperf, libsdl-dev,
libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip,
curl.
– sudo apt-get install flex bison gperf libsdl-dev libesd0-dev
libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1gdev
• You might also want Valgrind, a tool that will help you find
memory leaks, stack corruption, array bounds overflows, etc.
– sudo apt-get install valgrind
Android build method
• Make sure you have a ~/bin directory in your home
directory, and check to be sure that this bin directory is in
your path:
– mkdir ~/bin
– echo $PATH
• Download the repo script and make sure it is executable:
– curl http://android.git.kernel.org/repo > ~/bin/repo
– chmod a+x ~/bin/repo
• Create an empty directory to hold your working files:
– mkdir ~/mydroid
– cd ~/mydroid
Android build method
• Run repo init to bring down the latest version of Repo
with all its most recent bug fixes. You must specify a
URL for the manifest:
– repo init -u git://gitorious.org/android-onfreerunner/freerunner_platform_manifest.git -b cupcake
• When prompted, configure Repo with your real name
and email address. If you plan to submit code, use an
email address that is associated with a Google
account.A successful initialization will end with a
message such as
– repo initialized in .../mydroid
– Your client directory should now contain a .repo directory
where files such as the manifest will be kept.
Android build method
• Fetch the rest of the sources:
– repo sync
• Build your images
– make TARGET_PRODUCT=freerunner
• After build
– You need to download cp_android_OS shell script and
mkjffs2 shell script
– /out/target/product/freerunner has
content ,ramdisk.img ,system.img ,userdata.img
– ./cp_android_OS release
– ./mkjffs2
– Get androidfs.jffs2
BTW…..
android-on-freerunner現況
• koolu 已沒有在maintain
• 目前是由另一個團體在更新
• 但只有完整的image檔,並沒有提供相關的
cross_compiler_toolchain
build android to openmoko
• format sd card FAT Type
• download android Image
– http://code.google.com/p/android-onfreerunner/downloads/list?can=1&q=&colspec=Filename+Summary+Uploade
d+Size+DownloadCount+AndroidVersion+BuildVersion
• download android-on-freerunner-cupcake-week-2009-46.tar.gzs
• sudo tar –jxvf android-on-freerunner-cupcake-week-2009-46.tar.gzs
on your sd card
build android to openmoko
• Press AUX button(左上) then press power
button(右下)
– Into nor flash (also nand flash check the wiki)
– choose the boot from sd card
Android Application
Tools
• Eclipse 3.4
– web site:http://www.eclipse.org/
• Android sdk 1.5
– web site:
http://developer.android.com/sdk/index.html
• java jdk1.5以上
– web site:
http://java.sun.com/javase/downloads/index.jsp
Install process
• Start Eclipse, then select Help > Software
Updates.... In the dialog that appears, click the
Available Software tab
• Click Add Site..
Install process
• enter this URL in the "Location" field:
– https://dl-ssl.google.com/android/eclipse/
– Click OK
Install process
• choose the android sdk
Open android project
project name
application name
package name
activity name
compile android application
• build project
install android application to
freerunner
• connect the freerunner to PC by usb
• Turn on freerunner
• Use lsusb to check the connection is ok
USB Connecting
• sudo ifconfig usb0 192.168.0.200
• export ADBHOST=192.168.0.202
• adb devices
• adb install HelloMoko.apk
Homework
• Build android on freerunner
• Write the application which shows “hello
openmoko” and your student ID on the
freerunner
Homework
• Grading policy:
– A. Reports 40%
– B. Functionality 60%
– Report12/01 PM11:59
• E-mail to [email protected]
• File format is “組別_LAB4_Student ID No.pdf”
– (ex: 1_LAB4_9562812_9562812.pdf)
– Demo
• Time
– 11/30~12/04
• E-mail to [email protected] check your demo time
• Place: Room 721, General Building II
Homework
• Requests for report
– Please find APIs about accelerometer(三軸加速器
) and describe how to use it
– Some feedback about this homework
Refrence
• android 官網
– http://developer.android.com/index.html
• android on freerunner 論壇
– http://code.google.com/p/android-onfreerunner/
• jollen blog
– http://www.jollen.org/blog/