ghbolivar / android-on-freerunner

Automatically exported from code.google.com/p/android-on-freerunner
0 stars 0 forks source link

NDK portage #142

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I'm a android developer (i'm trying to port a native SIP stack to android
(http://code.google.com/p/csipsimple)).

I was wondering if you planned a NDK for android on freerunner (and more
widely on armv4)?

The availability of the NDK could be something really interesting to get
more apps available on the FreeRunner.

(If no ndk is planned I'll probably start by compiling my native library
within a android kernel build, I saw that you really well documented the
wiki :) )

(That's an evolution not a bug).

Original issue reported on code.google.com by r3gis...@gmail.com on 22 May 2010 at 8:51

GoogleCodeExporter commented 9 years ago
Due to limitde resources my guess is that this will not get done in any sort of
resonable time frame.

Original comment by larlin...@gmail.com on 22 May 2010 at 9:09

GoogleCodeExporter commented 9 years ago
If this ever gets done, we need to notify developers of softkeyboard project 
over here:
http://code.google.com/p/softkeyboard/issues/detail?id=355

Original comment by skliarie@gmail.com on 22 May 2010 at 8:22

GoogleCodeExporter commented 9 years ago
New reslease of interesting application FBReaderj could not work without NDK. 
Looks
to http://www.fbreader.org/mantis/view.php?id=347 for detail.

Original comment by Alexandr...@gmail.com on 23 May 2010 at 9:37

GoogleCodeExporter commented 9 years ago
Just for clarification: which parts of the NDK would need porting to AoF? If, 
as of now, the NDK is only partly usable with AoF, this might explain the 
issues discussed in ticket #141 - the app in question is a native app which, 
after compilation, starts up on AoF but crashes on certail (essential) 
operations.

Original comment by mich...@vonglasow.com on 28 Jul 2010 at 6:38

GoogleCodeExporter commented 9 years ago
...btw, a wiki page clarifying the limits of using NDK for developing for AoF 
would help...

Original comment by mich...@vonglasow.com on 28 Jul 2010 at 6:39

GoogleCodeExporter commented 9 years ago
If somebody wants to draft up a how-to and send it to the mailing list we can 
add it to the wiki.

Original comment by hmu...@gmail.com on 29 Jul 2010 at 10:02

GoogleCodeExporter commented 9 years ago
After some research and discussion on the mailing list:

The main problem is that official Android devices are built on an ARMv5 
processor or later, while Freerunner is ARMv4T-based. So the main task is to 
make sure all code is ARMv4T-compatible.

Navit already provides an ARMv4T build of their application, which they do 
using the NDK and calling arm-eabi-gcc with an additional -march=armv4t command 
line argument. 

So, the mechanism to compile ARMv4T code is there, the only problem might be if 
the NDK comes with precompiled libraries which get deployed to the phone. It's 
possible Navit can bypass this issue as it is a cross-platform app which does 
not make extensive use of the Android API.

To sum up the issues in detail:

- Get compiler to produce ARMv4T code - DONE
- Ensure precompiled code is ARMv4T-compatible - OPEN: check if and where such 
code exists, if source is available, and recompile
- Recompile applications - OPEN to the developer of each application (or 
compile it yourself if source is available)

Original comment by mich...@vonglasow.com on 4 Sep 2010 at 7:46

GoogleCodeExporter commented 9 years ago
Hello,

I managed to enhance android-ndk-r4b, using the AoF sources, so it can compile 
jni for ARMv4T and would like to make it public. I can zip the enhanced ndk and 
put it somewhere.

Original comment by hfman...@gmail.com on 2 Oct 2010 at 9:59

GoogleCodeExporter commented 9 years ago
Hello,
Please, could you give some more explanation. I would like to get some 
application, depending from ndk, to work. Is it possible to do with your 
zip-file and how?

Original comment by Alexandr...@gmail.com on 2 Oct 2010 at 10:18

GoogleCodeExporter commented 9 years ago
@hfmanson : I would be really interested in such a enhanced NDK. If you provide 
it to me, I can publish it on my svn. 
I already publish a forked version of the NDK with some minor modification 
allowing to put a higher priority to project includes compared to android's 
one. 
So you can send me your zip file (r3gis.3r at gmail.com) and I'll publish that 
on my svn if you agree.

@comment #7: AFAIK navit don't use directly the ndk but launch the command by 
hand. Besides they must use .so from a valid system to be able to link 
correctly. As I have no device and didn't find any way to get needed lib (I 
have no phone with armv4t on it), I was not able to make modification in the 
ndk. 
Besides, using NDK would be really comfortable, all the more so as latest 
version now support multiple CPU targets (x86, armeabi and armeabi-v7a)... With 
hfmanson contribution, sounds we could make it support armv4t... would be 
fantastic !

Original comment by r3gis...@gmail.com on 2 Oct 2010 at 10:25

GoogleCodeExporter commented 9 years ago
Hello Alexandre,

I already succesfully compiled apk packages containing JNI such as 
http://xmp.sourceforge.net/

The size of my enhanced ndk is 99MB, a little bit too large to attach, can I 
upload it to some FTP site?

Here are instructions for building and using the NDK:

$(AOF) is path to Android for Freerunner sources
$(NDK) is path to NDK android-ndk-r4b
$(SDK) is path to Android SDK 
$(PDK) is path to pdk (see below)

- build pdk, see ($NDK)/development/pdk/README
- unpack (AOF)/dist/android_pndk-freerunner-eng.user.yyyymmdd.hhmmss.tar.gz to 
$(PDK)
- add line
  TARGET_ARCH_for_armeabi-v4t := armv4t
  to file ($NDK)/build/core/setup-abi.mk
- copy ($AOF)/prebuilt/linux-x86/toolchain/armv4t-android-eabi-4.2.1 directory 
to $(NDK)/build/prebuilt
- create new directory $(NDK)/build/platforms/android-3/arch-armv4t/usr
- copy ($PDK)/lib directory to $(NDK)/build/platforms/android-3/arch-armv4t/usr
  or
  copy ($AOF)/out/target/product/freerunner/system/lib directory to $(NDK)/build/platforms/android-3/arch-armv4t/usr
- copy ($PDK)/include directory to 
$(NDK)/build/platforms/android-3/arch-armv4t/usr
- in $(NDK) directory unpack armv4t-eabi-4_2_1.tar.gz
- replace line
  final String sharedLibraryABI = "armeabi";
  with
  final String sharedLibraryABI = "armeabi-v4t";
  in file ($AOF)/frameworks/base/services/java/com/android/server/PackageManagerService.java

- update AoF build
- in jni projects in jni/ directory create Application.mk with contents:
  APP_PLATFORM := android-3
  APP_ABI      := armeabi-v4t

On the freerunner one can replace /system/framework/services.jar by remounting 
/system read-write with:
mount -o remount /dev/block/mtdblock6 /system
and then on a Linux terminal:
$(SDK)/tools/adb push 
$(AOF)/out/target/product/freerunner/system/framework/services.jar 
/system/framework/services.jar

Original comment by hfman...@gmail.com on 2 Oct 2010 at 10:36

GoogleCodeExporter commented 9 years ago
enhanced ndk attachments

armv4t-eabi-4_2_1.tar.gz
services.jar

Original comment by hfman...@gmail.com on 2 Oct 2010 at 10:54

Attachments:

GoogleCodeExporter commented 9 years ago
enhanced ndk link from easyshare at 
http://www.easy-share.com/1912505256/ndk-enhanced.zip

Original comment by hfman...@gmail.com on 2 Oct 2010 at 12:31

GoogleCodeExporter commented 9 years ago
Hi everybody!
I would like to thank hfmanson for his contribution. It worked fine for me, I 
have compiled and ran JNI application on Freerunner.
I have just downloaded, unpacked and added to PATH enchanced NDK, then pushed 
services.jar to freerunner (I found it easier to: #adb shell mount -o remount 
/dev/block/mtdblock6 /system
instead of typing it in Freerunner terminal), finally created Application.mk 
and that's it!

Original comment by Yuriy.Kulikov.87@gmail.com on 25 Jan 2011 at 12:16

GoogleCodeExporter commented 9 years ago
Things appear to be working well. Can/should the NDK port be included in the 
default source tree for AoF?

Original comment by niels.he...@gmail.com on 25 Jan 2011 at 12:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Yes, I believe, it should be included in Cupcake as well as Froyo.
In case of Freerunner, NDK is especially interesting - there is a nice 
connector with SPI and UART on it. For example I am trying to connect new 
hardware to Freerunner (hope get it working fine within few weeks). We have 
been able to use USB Host mode as well.

Original comment by Yuriy.Kulikov.87@gmail.com on 7 Feb 2011 at 12:47

GoogleCodeExporter commented 9 years ago
Some tips which could be useful for somebody who will use NDK on Freerunner.
log.h could be copied from 
android-ndk-r4b/build/platforms/android-3/arch-arm/usr 
to
android-ndk-r4b/build/platforms/android-3/arch-armv4t/usr/include/bionic/libc 
in order to debug using the log in Eclipse.
One of the best uses for NDK on Freerunner is getting the access to UART and 
SPI on debug interface.

Original comment by Yuriy.Kulikov.87@gmail.com on 15 Mar 2011 at 1:13