Android

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(Current State)
m (Smaller changes)
 
(171 intermediate revisions by 46 users not shown)
Line 1: Line 1:
 +
{{Languages|Android}}
 
{{Distributions|Android}}
 
{{Distributions|Android}}
  
= Updates =
+
{|align=right
 +
|__TOC__
 +
|}
 +
[[Image:Android-logo.png]]
 +
= Introduction =
 +
'''[[Android usage]]''' provides a brief overview to get started.
  
* 20081021 [[User:Cfriedt]] Android -> FreeRunner updates on my [http://perpetual-notion.blogspot.com/search/label/android blog]
+
{{Note|The Android for [[Neo_FreeRunner_GTA02_Hardware|FreeRunner]] development is hosted on [http://code.google.com/p/android-on-freerunner/ http://code.google.com/p/android-on-freerunner/].}}
* 20081022 [[User:Cfriedt]] I was able to 'trivially' compile all of the Android source code without error for the ARMv4T architecture by removing v5TE instructions. Although it will definitely not run anything predictably, at least now that I know the build system will work with a few simple substitutions in build/core/combo/arm-linux.mk. At this point I am able to go ahead and re-implement v5TE instructions as v4T instruction sequences instead (or re-implement entire sections of assembly with hand-optimized v4T instructions).
+
* 20081023 [[User:Bricode]] To track the status of which parts of the Android source tree contain ARMv5 specific code, I've created a table of where it is contained, and the status of patches. It can be found at: http://spreadsheets.google.com/pub?key=pzDEXnU19gkeTjpD28t-7fw
+
  
= Introduction =
+
This page is the central place for documentation about Android on the [[Neo_FreeRunner_GTA02_Hardware|FreeRunner]] handsets.
This page is dedicated to porting the [http://www.android.com Android OS] to the [[Neo 1973]] and [[Neo FreeRunner]] handsets. Since the Android OS was [http://source.android.com/posts/opensource  publically released] on 20081021, [http://benno.id.au/blog/2007/11/21/android-neo1973 work] [http://perpetual-notion.blogspot.com/search/label/android is] [http://groups.google.com/group/android-porting currently underway] to port Android to the [[Neo1973 Hardware|Neo 1973]] and [[Neo_FreeRunner_GTA02_Hardware|FreeRunner]] handsets.
+
  
== Goals ==
+
[http://code.google.com/android/ Android] is a software stack for mobile devices developed by the [http://www.openhandsetalliance.com/ The Open Handset Alliance.] Although Android is publicized as being [http://en.wikipedia.org/wiki/Open_source open source software] (most of the source code has been released) parts of the code have not been released yet.
# Systematically introduce patches for ARMv4T in the Android codebase
+
# Provide Neo1973 and Neo FreeRunner hardware-dependent patches in the Android codebase, leveraging the work already done by the Openmoko developers, without forcing Android-specific changes upstream
+
# Provide a useable Android filesystem and kernel on the [[Distributions]] page that conform to current Openmoko installation routines
+
  
== Early Attempts ==
+
A stable and working version of Android Cupcake is available for the Feerunner. The Froyo version is also available and continuously being improved. It is likely, in the near future, to be the distribution most suited for using the FreeRunner as a phone.
As [http://benno.id.au Ben Leslie] had pointed out on his [http://benno.id.au/blog/2007/11/21/android-neo1973 blog] far before the source code was released, [http://www.android.com Android] was originally designed to work with the ARMv5TE [http://en.wikipedia.org/wiki/Instruction_set_architecture instruction set architecture] (ISA), which allows for [http://en.wikipedia.org/wiki/ARM_architecture#DSP_Enhancement_Instructions DSP enhanced instructions]. Contrary to the ARMv5TE ISA, the Neo1973 and FreeRunner handsets both feature an arm920t core, which comply to the ARMv4T ISA.
+
  
Before the source code was released, kernel trap handlers were implemented to 'emulate' the ARMv5TE ISA. Although the results worked in many cases, trapping is costly and performance suffered as a result. Moreover, without explicitly knowing which conditions were set by various instructions, such as Thumb Mode execution, the result became nondeterministic.
+
= Usage =
 +
See: '''[[Android usage]]''' for detailed instructions on using Android on the FreeRunner.
  
== Current State ==
+
= Installation =
  
With the release of the Android [http://source.android.com source code], the Open Source community is no longer limited to dealing with a binary-only product. The Open Handset Alliance (OHA) has let their source code become their product for everyone enrich and benefit from.
+
[http://code.google.com/p/android-on-freerunner/wiki/GetIt Installing Android on Openmoko Freerunner]
  
Currently, porting efforts are underway in many circles. Patches should be submitted via the [http://source.android.com/submit-patches official Android channels].
+
= Development =
 +
Currently the development is done on [http://code.google.com/p/android-on-freerunner/ Android-on-Freerunner] (http://code.google.com/p/android-on-freerunner/)
  
To track the status of which parts of the Android source tree contain ARMv5 specific code, I've created a table of where it is contained, and the status of patches. It can be found at: http://spreadsheets.google.com/pub?key=pzDEXnU19gkeTjpD28t-7fw [[User:Bricode]]
+
See: [[Android porting]]
  
Sean McNail said that he was able to get Androind running (including telephony) in his Freerunner [http://3v1n0.tuxfamily.org/tumblelog/post/368 source].
+
= News =
 +
* 01 Oct 09 - new Home http://code.google.com/p/android-on-freerunner/  ( including googlegroup,IRC,mailinglist,... )
 +
* 19 Sept 09 - from Koolu-Forum:  ..."So I'm glad to announce a new Android Cupcake release for Freerunner! It's basically a merge of the Koolu code with Michael Trimarchi's enhancements and a few bug fixes and cosmetic things I've added. You can download it at our new Google Code site: http://code.google.com/p/android-on-freerunner/downloads/list "...
 +
* 22 May 09 - Koolu Releases Beta7 [http://trac.koolu.org/wiki/Releases]
 +
* 15 April 09 - Koolu Releases Beta6 [http://trac.koolu.org/wiki/Releases]
 +
* 07 March 09 - Panicking released a cupcake [http://panicking.kicks-ass.org/download/ rootfs]
 +
* 26 February 09 - As promised, Sean McNeil has released source code to [[GSM]] libraries [https://review.source.android.com/Gerrit#change,9013 Source]
 +
* 20090204 Koolu releases its Beta3 Android [http://freerunner.android.koolu.com/release-files release].
 +
** Changelog:
 +
*** Added GPS library that supports GPS under Android
 +
*** MAX_PROCESSES patch to enable more background processes to be run (fixes Pictures application)
 +
*** Added Dalvik optimization setting
 +
*** Started including 3rd party applications
 +
*** Updated user interfaces for GPS and Bluetooth to match new kernel
 +
*** Now report RSSI of Wifi signals to upper application layer
 +
*** Enable libsoundpool compilation to support audible clicks
  
Ben Leslie mentioned on the android-porting list that he was able to get the 'Android' logo to appear on his Neo 1973.
+
* 20090122 Koolu releases its Beta2 Android [http://freerunner.android.koolu.com/release-files release].
  
= How to Help =
+
* 20081219 Koolu releases its Beta Android [http://forum.koolu.org/files/androidfs-koolu-1_0.jffs2 Image] and [http://forum.koolu.org/files/uImage-android-patched_bc2caff9cdef8a16.bin kernel].
  
== Getting Started ==
+
* 20081202 [http://www.koolu.com Koolu], a Freerunner distributor, has released the source code of their Android port at [http://git.koolu.org http://git.koolu.org]. For details on the project source and some real detailed instructions on building the source, see the [http://trac.koolu.org/ the Koolu Trac Website for Android].  TODO: Find out where this link supposed to go->See the [[Android_porting#Building the Koolu Android Source]] instructions below for how to build an Android image for Freerunner.
  
You can start by following the instructions to download and build the Android source from scratch. Please see [http://source.android.com/download http://source.android.com/download] and follow the instructions for your architecture.
+
* 20081104 The first Android-image has been successfully created by Sean McNeil!  - sms and calling works, wifi and bluetooth doesn't. [http://onlinedev.blogspot.com/2008/11/porting-android-phase-3-done.html ''news-source'']
  
== Publicize Your Efforts ==
+
= See also =
 +
* http://code.google.com/p/android-on-freerunner/
 +
* [http://wiki.openmoko.org/wiki/User:Seanmcneil3 Sean McNeil] user page for some historical info
  
It's generally a good idea to make your efforts known via wiki systems, public mailing lists, forums, and publically open version control systems.
+
== Usage ==
  
Always take credit for your work but please don't do it in the form of comments. Some code is already hard enough to read without comments polluting the text. The best thing to do is to create a patch and put a header with your information at the top. Collaboration systems such as git might already do this for you (??).
+
* [http://code.google.com/p/android-on-freerunner/wiki/Applications List of applications] known to be working on AoF
  
If you create something new and have the ability to designate the license for it, please consider license compatibility issues.
+
* [http://digg.com/linux_unix/Video_demo_of_Freerunner_running_Android_Cupcake_Tutorial Short Video demo of Android] on [[FreeRunner]] to show how usable it is.
  
== Porting Strategy ==
+
* [http://braydon.com/blog/2009/5/1/koolu-android-on-neo-freerunner-video Koolu beta6 on Neo Freerunner Video]
  
* Analysis and leverage of the existing build system
+
* http://www.freewarelovers.com/android
** buid/core/combo/arm-linux.mk
+
*** -D__ARCH_ARM_4__ -D__ARCH_ARM_4T__
+
*** -march=armv4t -mcpu=arm920t
+
** fix various static references to 'armv5'
+
* Isolating ARMv5TE ISA dependent code
+
** e.g. grep -n -R -i "${armv5te_isa_pattern}" ~/android
+
* Abstracting
+
** ( C/C++ )
+
*** Use inlined functions / #ifdef statments to implement functions in a portable manner
+
*** For inlined assembler calls, it's acceptable for now to use generic C code instead, so long as later on we optimize it by hand.
+
** ( ASM )
+
*** Proprocessor statements based on ISA / architecture, e.g. #ifdef __ARCH_ARM_5__ ... #endif #ifdef __ARCH_ARM_4__ ... #endif
+
*** It's highly suggested that preprocessor statements should not be nested (i.e. make them mutually exclusive)
+
*** Some people have suggested that we should not do #ifdef's based on ARCH or ISA, but rather based on an AndroidConfig.h which would define macros like PLD(...) #ifdef HAVE_ARM_PLD pld #else ... #endif .
+
  
For each ARMv5TE instruction, one could potentially
+
* http://andappstore.com/
* Implement the instruction using general registers instead of DSP calls (i.e. eabi / softfloat)
+
* If that is a) nondeterministic, or b) slow, then sections of code need to be analyzed and hand-optimized for the ARMv4T isa
+
  
== List of Unsupported Instructions ==
+
* http://slideme.org/
 
+
This is a list of opcodes, extracted from the Android source, that are unsupported for ARMv4T compliant processors (specifically the arm920t). The opcodes represent instructions available for ARMv5, ARMv5T, and ARMv5TE architectures, which are not present in the ARMv4T ISA. The list was obtained by exhaustively editing the recompiling the Android source code until it compiled without error.
+
 
+
Please keep in mind, that in some cases, translating these instructions into a sequence of ARMv4T instructions will be impossible and / or result in nondeterministic execution because of
+
* the requirement of additional context
+
* the tendencies of certain opcodes to change condition registers that may or may not be present in the arm920t core
+
 
+
=== Opcodes ===
+
 
+
For now, so that the code is clearer, I would just suggest using C instead of assembly language so that less space is used.
+
 
+
{{scroll box|height=480px|text=
+
<TABLE BORDER="1">
+
<TR>
+
<TH>Opcode</TH>
+
<TH>Desription</TH>
+
<TH>[[http://www.arm.com/miscPDFs/14128.pdf PDF]] Page Number</TH>
+
<TH>C</TH>
+
<TH>ASM</TH>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">BLX(1)</TH>
+
<TD>Branch, Link, and Exchange</TD>
+
<TD>166</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">BLX(2)</TH>
+
<TD>Branch, Link, and Exchange</TD>
+
<TD>168</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">CLZ</TH>
+
<TD>Count Leading Zeros</TD>
+
<TD>175</TD>
+
<TD>
+
[[User:Cfriedt]] 20081026
+
<pre>
+
#include <stdint.h>
+
 
+
void clz( uint32_t * Rd, uint32_t * Rm )
+
{
+
uint32_t mask = 0x80000000;
+
 
+
// in case Rd == Rm
+
uint32_t dummy = 0;
+
 
+
if ( *Rm == 0 )
+
{
+
 
+
dummy = 32;
+
 
+
} else {
+
 
+
for ( dummy = 0 ;
+
dummy < 32 &&
+
( ! ( mask & (*Rm) ) ) ;
+
dummy++, mask >>= 1
+
);
+
 
+
}
+
 
+
(*Rd) = dummy;
+
 
+
}
+
</pre>
+
</TD>
+
<TD>
+
</TD>
+
</TR>
+
 
+
<TR>
+
<TH VALIGN="TOP">LDRD</TH>
+
<TD>Load Registers Doubleword</TD>
+
<TD>200</TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">PLD</TH>
+
<TD>Preload Data</TD>
+
<TD>240</TD>
+
<TD>Remove</TD>
+
<TD>Remove</TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">SMLA&lt;x&gt;&lt;y&gt;</TH>
+
<TD>Signed Multiply-Accumulate</TD>
+
<TD>291</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">SMLAL</TH>
+
<TD>Signed Multiply Accumulate Long</TD>
+
<TD>296</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">SMLAW&lt;x&gt;</TH>
+
<TD>Signed Multiply-Accumulate Word</TD>
+
<TD>302</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">SMULL</TH>
+
<TD>Signed Multiply Long</TD>
+
<TD>318</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">SMUL&lt;x&gt;&lt;y&gt;</TH>
+
<TD>Signed Multiply</TD>
+
<TD>316</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">SMULW&lt;y&gt;</TH>
+
<TD>Signed Multiply Word</TD>
+
<TD>320</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">QADD</TH>
+
<TD>Saturating Add</TD>
+
<TD>242</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">QDADD</TH>
+
<TD>Saturating Double and Add</TD>
+
<TD>249</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">QSUB</TH>
+
<TD>Saturating Subtract</TD>
+
<TD>253</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">QDSUB</TH>
+
<TD>Saturating Double and Subtract</TD>
+
<TD>251</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
<TR>
+
<TH VALIGN="TOP">STRD</TH>
+
<TD>Store Registers Doubleword</TD>
+
<TD>349</TD>
+
<TD></TD>
+
<TD></TD>
+
</TR>
+
</TABLE>
+
}}
+
 
+
=== Scanning for Files That Use the ARMv5TE ISA ===
+
 
+
Using the above list of opcodes, one can scan the Android source code for ARMv4T-incompatible instruction sequences.
+
 
+
'''Code:'''
+
<pre>
+
opcodes="blx clz ldrd pld smlabb smlabt smlatt smlal smlawb smlawt smulbb smulbt smull smultt smulwb smulwt qadd qdadd qsub qdsub strd"
+
 
+
opcodePat="$(echo ${opcodes} | sed -e 's/ /\\\|/g')"
+
 
+
fileList="$(grep -R -i "\(${opcodePat}\) " * 2>/dev/null | grep -v "^Binary file" | sed -e 's/:.*//' | grep -v "CREDITS\|README\|^\(kernel/\)\|\(\.txt\)$" | sort -u)"
+
 
+
for i in ${fileList}; do
+
echo "* ${i}"
+
done
+
</pre>
+
 
+
=== Source Files in Android that Use the ARMv5TE ISA ===
+
 
+
The list of files below may or may not be complete. There might also be some assembly code that is generated with a python script (verification?).
+
 
+
{{scroll box|height=150px|text=
+
* bionic/libc/arch-arm/bionic/memcmp.S
+
* bionic/libc/arch-arm/bionic/memcmp16.S
+
* bionic/libc/arch-arm/bionic/memcpy.S
+
* bionic/libc/arch-arm/bionic/strlen.c
+
* bionic/libc/kernel/arch-arm/asm/arch/irqs.h
+
* bionic/libc/tools/gensyscalls.py
+
* bootloader/legacy/nandwrite/init.S
+
* bootloader/legacy/usbloader/init.S
+
* dalvik/vm/arch/arm/CallEABI.S
+
* dalvik/vm/arch/arm/CallOldABI.S
+
* dalvik/vm/mterp/armv5/OP_AGET_WIDE.S
+
* dalvik/vm/mterp/armv5/OP_APUT_WIDE.S
+
* dalvik/vm/mterp/armv5/OP_IGET_WIDE.S
+
* dalvik/vm/mterp/armv5/OP_IGET_WIDE_QUICK.S
+
* dalvik/vm/mterp/armv5/OP_IPUT_WIDE.S
+
* dalvik/vm/mterp/armv5/OP_IPUT_WIDE_QUICK.S
+
* dalvik/vm/mterp/armv5/OP_SGET_WIDE.S
+
* dalvik/vm/mterp/armv5/OP_SPUT_WIDE.S
+
* dalvik/vm/mterp/out/InterpAsm-armv5.S
+
* dalvik/vm/oo/Object.h
+
* development/emulator/qtools/armdis.cpp
+
* development/emulator/qtools/thumbdis.cpp
+
* external/elfutils/src/Makefile
+
* external/elfutils/src/Makefile.am
+
* external/elfutils/src/Makefile.in
+
* external/freetype/include/freetype/config/ftconfig.h
+
* external/jpeg/jidctfst.S
+
* external/neven/Embedded/common/src/b_BasicEm/Math.c
+
* external/opencore/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp
+
* external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h
+
* external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4.h
+
* external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h
+
* external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v5.h
+
* external/opencore/codecs_v2/audio/aac/dec/src/pv_normalize.h
+
* external/opencore/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_gcc_v5.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_v5.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mac.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_msu.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mult.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_sub.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32_16.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_l.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_armv5.h
+
* external/opencore/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_gcc_armv5.h
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.asm
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.asm
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
+
* external/opencore/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm.h
+
* external/opencore/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h
+
* external/opencore/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h
+
* external/opencore/codecs_v2/audio/sbc/enc/src/sbcenc_filter.h
+
* external/opencore/codecs_v2/video/avc_h264/dec/src/vlc.cpp
+
* external/opencore/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
+
* external/opencore/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
+
* external/opencore/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
+
* external/opencore/fileformats/avi/parser/include/pv_avifile_streamlist.h
+
* external/opencore/fileformats/avi/parser/src/pv_avifile_streamlist.cpp
+
* external/openssl/crypto/bn/bn_prime.c
+
* external/qemu/target-arm/translate.c
+
* external/qemu/trace.c
+
* external/skia/include/corecg/SkFixed.h
+
* external/skia/include/corecg/SkMath.h
+
* external/skia/libcorecg/Sk64.cpp
+
* external/skia/libcorecg/SkMatrix.cpp
+
* external/skia/libsgl/effects/SkColorMatrixFilter.cpp
+
* external/skia/libsgl/sgl/SkBitmap.cpp
+
* external/skia/libsgl/sgl/SkBitmapShader.cpp
+
* external/skia/libsgl/sgl/SkGraphics.cpp
+
* external/srec/config/en.us/dictionary/c0.6.ok
+
* frameworks/base/libs/audioflinger/AudioMixer.cpp
+
* frameworks/base/libs/audioflinger/AudioResamplerSinc.cpp
+
* frameworks/base/opengl/libagl/iterators.S
+
* frameworks/base/opengl/libagl/matrix.h
+
* system/core/include/private/pixelflinger/ggl_fixed.h
+
* system/core/libpixelflinger/codeflinger/ARMAssembler.cpp
+
* system/core/libpixelflinger/codeflinger/ARMAssemblerInterface.cpp
+
* system/core/libpixelflinger/codeflinger/disassem.c
+
* system/core/libpixelflinger/codeflinger/texturing.cpp
+
* system/core/libpixelflinger/rotate90CW_4x4_16v6.S
+
* system/core/libpixelflinger/t32cb16blend.S
+
}}
+
 
+
=== Discussion ===
+
=== Notes ===
+
* (ASM) In order to return from a subroutine, use methods that are known to work from ARMv4T onwards <pre>mov pc,lr ==> bx lr</pre>
+
 
+
== Suggestions ==
+
* [[User:Cfriedt]] 20081024 I'm not sure how feasible this is, given that the [http://wiki.openmoko.org/wiki/Neo_FreeRunner_Hardware_Issues#SMedia_3362_Documentation_.26_OpenGL_ES_Drivers SMedia 3362 is heavily NDA'd]. However, since the arm920t lacks a floating-point unit / DSP core, is it possible to use the SMedia chip for general-purpose math? This would help in the Android platform, at least, for things like audio and video codecs. Aside from an OpenGL ES driver, OpenMoko documentation for the SMedia would be highly appreciated.
+
 
+
= Important Links =
+
(Please Update Me)
+
 
+
== Documentation ==
+
* [http://source.android.com/documentation Android Documentation]
+
* [http://www.arm.com/documentation/ ARM Documentation], (keywords: armv4t, armv5t, armv5te, arm920t, arm926ej-s)
+
* [http://www.arm.com/miscPDFs/9658.pdf ARM Assembly Language Programming]
+
* [http://www.cse.unsw.edu.au/~cs3221/labs/assembler-intro.pdf An Introduction to the GNU Assembler]
+
* [http://www.heyrick.co.uk/assembler/apcsintro.html ARM Procedure Call Standard], [http://en.wikipedia.org/wiki/Calling_convention#ARM ARM Calling Conventions]
+
 
+
== Instruction Set References ==
+
* [http://www.arm.com/miscPDFs/14128.pdf ARM Architecture Reference Manual], The definitive ISA documentation
+
* [http://www.simplemachines.it/doc/QRC0001H_rvct_v2.1_arm.pdf ARM Instruction Set Quick Reference Card]
+
* [http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf ARM and Thumb -2 Instruction Set Quick Reference Card]
+
* [http://infocenter.arm.com/help/topic/com.arm.doc.dvi0025b/DVI0025.pdf ARMv4T] (See section 1.4.13)
+
* [http://infocenter.arm.com/help/topic/com.arm.doc.dvi0014a/DVI0014A_ARM10T_PO.pdf ARMv5T] (See section 4.16)
+
* [http://www.arm.com/pdfs/ARM-DSP.pdf ARM DSP Enhanced Instruction Set]
+
* [http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042c/IHI0042C_aapcs.pdf Procedure Call Standard for the ARM Architecture]
+
 
+
== Hardware Reference ==
+
 
+
* [[Neo1973 Hardware]]
+
* [[Neo FreeRunner GTA02 Hardware]]
+
 
+
== Communities ==
+
* [http://source.android.com/discuss Android Public Mailing Lists]
+
** Specifically, [http://groups.google.com/group/android-porting android-porting]
+
* [http://lists.openmoko.org/mailman/listinfo OpenMoko Mailing Lists]
+
** Specifically, [http://lists.openmoko.org/mailman/listinfo/openmoko-kernel openmoko-kernel]
+
* [http://forum.koolu.org/viewforum.php?f=10 Android on FreeRunner] at KoolU.com
+
* [[Openmoko Local Groups]]
+
* [[Openmoko:Community_Portal]]
+
 
+
= See also =
+
  
* [[Debug_Board]]
+
* http://www.openintents.org/
  
= External Links =
+
== Videos ==
 +
* Videos : [http://digg.com/linux_unix/Video_demo_of_Freerunner_running_Android_Cupcake_Tutorial]
 +
* [http://youtube.com/watch?v=m4NbsLmF9j0 YouTube Video 1]
 +
* [http://youtube.com/watch?v=r6Op-7tNTiw YouTube Video 2]
  
[[Category:Distributions]]
+
[[Category:Android| ]]

Latest revision as of 15:47, 9 January 2012

Android is one of the many distributions that currently work on the Openmoko phones. You can compare a distribution with an Operating System on normal computers. It gives the phone all the software needed for operating. For more information about the different flavors, see distributions.

Contents

Android-logo.png

[edit] Introduction

Android usage provides a brief overview to get started.

NOTE: The Android for FreeRunner development is hosted on http://code.google.com/p/android-on-freerunner/.


This page is the central place for documentation about Android on the FreeRunner handsets.

Android is a software stack for mobile devices developed by the The Open Handset Alliance. Although Android is publicized as being open source software (most of the source code has been released) parts of the code have not been released yet.

A stable and working version of Android Cupcake is available for the Feerunner. The Froyo version is also available and continuously being improved. It is likely, in the near future, to be the distribution most suited for using the FreeRunner as a phone.

[edit] Usage

See: Android usage for detailed instructions on using Android on the FreeRunner.

[edit] Installation

Installing Android on Openmoko Freerunner

[edit] Development

Currently the development is done on Android-on-Freerunner (http://code.google.com/p/android-on-freerunner/)

See: Android porting

[edit] News

  • 01 Oct 09 - new Home http://code.google.com/p/android-on-freerunner/ ( including googlegroup,IRC,mailinglist,... )
  • 19 Sept 09 - from Koolu-Forum: ..."So I'm glad to announce a new Android Cupcake release for Freerunner! It's basically a merge of the Koolu code with Michael Trimarchi's enhancements and a few bug fixes and cosmetic things I've added. You can download it at our new Google Code site: http://code.google.com/p/android-on-freerunner/downloads/list "...
  • 22 May 09 - Koolu Releases Beta7 [1]
  • 15 April 09 - Koolu Releases Beta6 [2]
  • 07 March 09 - Panicking released a cupcake rootfs
  • 26 February 09 - As promised, Sean McNeil has released source code to GSM libraries Source
  • 20090204 Koolu releases its Beta3 Android release.
    • Changelog:
      • Added GPS library that supports GPS under Android
      • MAX_PROCESSES patch to enable more background processes to be run (fixes Pictures application)
      • Added Dalvik optimization setting
      • Started including 3rd party applications
      • Updated user interfaces for GPS and Bluetooth to match new kernel
      • Now report RSSI of Wifi signals to upper application layer
      • Enable libsoundpool compilation to support audible clicks
  • 20090122 Koolu releases its Beta2 Android release.
  • 20081219 Koolu releases its Beta Android Image and kernel.
  • 20081104 The first Android-image has been successfully created by Sean McNeil! - sms and calling works, wifi and bluetooth doesn't. news-source

[edit] See also

[edit] Usage

[edit] Videos

Personal tools

Android is one of the many distributions that currently work on the Openmoko phones. You can compare a distribution with an Operating System on normal computers. It gives the phone all the software needed for operating. For more information about the different flavors, see distributions.

Updates

  • 20081021 User:Cfriedt Android -> FreeRunner updates on my blog
  • 20081022 User:Cfriedt I was able to 'trivially' compile all of the Android source code without error for the ARMv4T architecture by removing v5TE instructions. Although it will definitely not run anything predictably, at least now that I know the build system will work with a few simple substitutions in build/core/combo/arm-linux.mk. At this point I am able to go ahead and re-implement v5TE instructions as v4T instruction sequences instead (or re-implement entire sections of assembly with hand-optimized v4T instructions).
  • 20081023 User:Bricode To track the status of which parts of the Android source tree contain ARMv5 specific code, I've created a table of where it is contained, and the status of patches. It can be found at: http://spreadsheets.google.com/pub?key=pzDEXnU19gkeTjpD28t-7fw

Introduction

This page is dedicated to porting the Android OS to the Neo 1973 and Neo FreeRunner handsets. Since the Android OS was publically released on 20081021, work is currently underway to port Android to the Neo 1973 and FreeRunner handsets.

Goals

  1. Systematically introduce patches for ARMv4T in the Android codebase
  2. Provide Neo1973 and Neo FreeRunner hardware-dependent patches in the Android codebase, leveraging the work already done by the Openmoko developers, without forcing Android-specific changes upstream
  3. Provide a useable Android filesystem and kernel on the Distributions page that conform to current Openmoko installation routines

Early Attempts

As Ben Leslie had pointed out on his blog far before the source code was released, Android was originally designed to work with the ARMv5TE instruction set architecture (ISA), which allows for DSP enhanced instructions. Contrary to the ARMv5TE ISA, the Neo1973 and FreeRunner handsets both feature an arm920t core, which comply to the ARMv4T ISA.

Before the source code was released, kernel trap handlers were implemented to 'emulate' the ARMv5TE ISA. Although the results worked in many cases, trapping is costly and performance suffered as a result. Moreover, without explicitly knowing which conditions were set by various instructions, such as Thumb Mode execution, the result became nondeterministic.

Current State

With the release of the Android source code, the Open Source community is no longer limited to dealing with a binary-only product. The Open Handset Alliance (OHA) has let their source code become their product for everyone enrich and benefit from.

Currently, porting efforts are underway in many circles. Patches should be submitted via the official Android channels.

To track the status of which parts of the Android source tree contain ARMv5 specific code, I've created a table of where it is contained, and the status of patches. It can be found at: http://spreadsheets.google.com/pub?key=pzDEXnU19gkeTjpD28t-7fw User:Bricode

Sean McNail said that he was able to get Androind running (including telephony) in his Freerunner source.

Ben Leslie mentioned on the android-porting list that he was able to get the 'Android' logo to appear on his Neo 1973.

How to Help

Getting Started

You can start by following the instructions to download and build the Android source from scratch. Please see http://source.android.com/download and follow the instructions for your architecture.

Publicize Your Efforts

It's generally a good idea to make your efforts known via wiki systems, public mailing lists, forums, and publically open version control systems.

Always take credit for your work but please don't do it in the form of comments. Some code is already hard enough to read without comments polluting the text. The best thing to do is to create a patch and put a header with your information at the top. Collaboration systems such as git might already do this for you (??).

If you create something new and have the ability to designate the license for it, please consider license compatibility issues.

Porting Strategy

  • Analysis and leverage of the existing build system
    • buid/core/combo/arm-linux.mk
      • -D__ARCH_ARM_4__ -D__ARCH_ARM_4T__
      • -march=armv4t -mcpu=arm920t
    • fix various static references to 'armv5'
  • Isolating ARMv5TE ISA dependent code
    • e.g. grep -n -R -i "${armv5te_isa_pattern}" ~/android
  • Abstracting
    • ( C/C++ )
      • Use inlined functions / #ifdef statments to implement functions in a portable manner
      • For inlined assembler calls, it's acceptable for now to use generic C code instead, so long as later on we optimize it by hand.
    • ( ASM )
      • Proprocessor statements based on ISA / architecture, e.g. #ifdef __ARCH_ARM_5__ ... #endif #ifdef __ARCH_ARM_4__ ... #endif
      • It's highly suggested that preprocessor statements should not be nested (i.e. make them mutually exclusive)
      • Some people have suggested that we should not do #ifdef's based on ARCH or ISA, but rather based on an AndroidConfig.h which would define macros like PLD(...) #ifdef HAVE_ARM_PLD pld #else ... #endif .

For each ARMv5TE instruction, one could potentially

  • Implement the instruction using general registers instead of DSP calls (i.e. eabi / softfloat)
  • If that is a) nondeterministic, or b) slow, then sections of code need to be analyzed and hand-optimized for the ARMv4T isa

List of Unsupported Instructions

This is a list of opcodes, extracted from the Android source, that are unsupported for ARMv4T compliant processors (specifically the arm920t). The opcodes represent instructions available for ARMv5, ARMv5T, and ARMv5TE architectures, which are not present in the ARMv4T ISA. The list was obtained by exhaustively editing the recompiling the Android source code until it compiled without error.

Please keep in mind, that in some cases, translating these instructions into a sequence of ARMv4T instructions will be impossible and / or result in nondeterministic execution because of

  • the requirement of additional context
  • the tendencies of certain opcodes to change condition registers that may or may not be present in the arm920t core

Opcodes

For now, so that the code is clearer, I would just suggest using C instead of assembly language so that less space is used.


Opcode Desription [PDF] Page Number C ASM
BLX(1) Branch, Link, and Exchange 166
BLX(2) Branch, Link, and Exchange 168
CLZ Count Leading Zeros 175

User:Cfriedt 20081026

#include <stdint.h>

void clz( uint32_t * Rd, uint32_t * Rm )
{
uint32_t mask = 0x80000000;

// in case Rd == Rm
uint32_t dummy = 0;

if ( *Rm == 0 )
{

dummy = 32;

} else {

for ( 	dummy = 0 ;
dummy < 32 &&
( ! ( mask & (*Rm) ) ) ;
dummy++, mask >>= 1
);

}

(*Rd) = dummy;

}
LDRD Load Registers Doubleword 200
PLD Preload Data 240 Remove Remove
SMLA<x><y> Signed Multiply-Accumulate 291
SMLAL Signed Multiply Accumulate Long 296
SMLAW<x> Signed Multiply-Accumulate Word 302
SMULL Signed Multiply Long 318
SMUL<x><y> Signed Multiply 316
SMULW<y> Signed Multiply Word 320
QADD Saturating Add 242
QDADD Saturating Double and Add 249
QSUB Saturating Subtract 253
QDSUB Saturating Double and Subtract 251
STRD Store Registers Doubleword 349


Scanning for Files That Use the ARMv5TE ISA

Using the above list of opcodes, one can scan the Android source code for ARMv4T-incompatible instruction sequences.

Code:

opcodes="blx clz ldrd pld smlabb smlabt smlatt smlal smlawb smlawt smulbb smulbt smull smultt smulwb smulwt qadd qdadd qsub qdsub strd"

opcodePat="$(echo ${opcodes} | sed -e 's/ /\\\|/g')"

fileList="$(grep -R -i "\(${opcodePat}\) " * 2>/dev/null | grep -v "^Binary file" | sed -e 's/:.*//' | grep -v "CREDITS\|README\|^\(kernel/\)\|\(\.txt\)$" | sort -u)"

for i in ${fileList}; do
echo "* ${i}"
done

Source Files in Android that Use the ARMv5TE ISA

The list of files below may or may not be complete. There might also be some assembly code that is generated with a python script (verification?).


  • bionic/libc/arch-arm/bionic/memcmp.S
  • bionic/libc/arch-arm/bionic/memcmp16.S
  • bionic/libc/arch-arm/bionic/memcpy.S
  • bionic/libc/arch-arm/bionic/strlen.c
  • bionic/libc/kernel/arch-arm/asm/arch/irqs.h
  • bionic/libc/tools/gensyscalls.py
  • bootloader/legacy/nandwrite/init.S
  • bootloader/legacy/usbloader/init.S
  • dalvik/vm/arch/arm/CallEABI.S
  • dalvik/vm/arch/arm/CallOldABI.S
  • dalvik/vm/mterp/armv5/OP_AGET_WIDE.S
  • dalvik/vm/mterp/armv5/OP_APUT_WIDE.S
  • dalvik/vm/mterp/armv5/OP_IGET_WIDE.S
  • dalvik/vm/mterp/armv5/OP_IGET_WIDE_QUICK.S
  • dalvik/vm/mterp/armv5/OP_IPUT_WIDE.S
  • dalvik/vm/mterp/armv5/OP_IPUT_WIDE_QUICK.S
  • dalvik/vm/mterp/armv5/OP_SGET_WIDE.S
  • dalvik/vm/mterp/armv5/OP_SPUT_WIDE.S
  • dalvik/vm/mterp/out/InterpAsm-armv5.S
  • dalvik/vm/oo/Object.h
  • development/emulator/qtools/armdis.cpp
  • development/emulator/qtools/thumbdis.cpp
  • external/elfutils/src/Makefile
  • external/elfutils/src/Makefile.am
  • external/elfutils/src/Makefile.in
  • external/freetype/include/freetype/config/ftconfig.h
  • external/jpeg/jidctfst.S
  • external/neven/Embedded/common/src/b_BasicEm/Math.c
  • external/opencore/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp
  • external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h
  • external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4.h
  • external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h
  • external/opencore/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v5.h
  • external/opencore/codecs_v2/audio/aac/dec/src/pv_normalize.h
  • external/opencore/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_gcc_v5.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_v5.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mac.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_msu.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mult.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_sub.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32_16.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_l.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_armv5.h
  • external/opencore/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_gcc_armv5.h
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.asm
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.asm
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
  • external/opencore/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm.h
  • external/opencore/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h
  • external/opencore/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h
  • external/opencore/codecs_v2/audio/sbc/enc/src/sbcenc_filter.h
  • external/opencore/codecs_v2/video/avc_h264/dec/src/vlc.cpp
  • external/opencore/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
  • external/opencore/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
  • external/opencore/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
  • external/opencore/fileformats/avi/parser/include/pv_avifile_streamlist.h
  • external/opencore/fileformats/avi/parser/src/pv_avifile_streamlist.cpp
  • external/openssl/crypto/bn/bn_prime.c
  • external/qemu/target-arm/translate.c
  • external/qemu/trace.c
  • external/skia/include/corecg/SkFixed.h
  • external/skia/include/corecg/SkMath.h
  • external/skia/libcorecg/Sk64.cpp
  • external/skia/libcorecg/SkMatrix.cpp
  • external/skia/libsgl/effects/SkColorMatrixFilter.cpp
  • external/skia/libsgl/sgl/SkBitmap.cpp
  • external/skia/libsgl/sgl/SkBitmapShader.cpp
  • external/skia/libsgl/sgl/SkGraphics.cpp
  • external/srec/config/en.us/dictionary/c0.6.ok
  • frameworks/base/libs/audioflinger/AudioMixer.cpp
  • frameworks/base/libs/audioflinger/AudioResamplerSinc.cpp
  • frameworks/base/opengl/libagl/iterators.S
  • frameworks/base/opengl/libagl/matrix.h
  • system/core/include/private/pixelflinger/ggl_fixed.h
  • system/core/libpixelflinger/codeflinger/ARMAssembler.cpp
  • system/core/libpixelflinger/codeflinger/ARMAssemblerInterface.cpp
  • system/core/libpixelflinger/codeflinger/disassem.c
  • system/core/libpixelflinger/codeflinger/texturing.cpp
  • system/core/libpixelflinger/rotate90CW_4x4_16v6.S
  • system/core/libpixelflinger/t32cb16blend.S


Discussion

Notes

  • (ASM) In order to return from a subroutine, use methods that are known to work from ARMv4T onwards
    mov pc,lr ==> bx lr

Suggestions

  • User:Cfriedt 20081024 I'm not sure how feasible this is, given that the SMedia 3362 is heavily NDA'd. However, since the arm920t lacks a floating-point unit / DSP core, is it possible to use the SMedia chip for general-purpose math? This would help in the Android platform, at least, for things like audio and video codecs. Aside from an OpenGL ES driver, OpenMoko documentation for the SMedia would be highly appreciated.

Important Links

(Please Update Me)

Documentation

Instruction Set References

Hardware Reference

Communities

See also

External Links