简体   繁体   中英

android cross compile,ndk,toolchain

I want to build a kernel module for android. And i know i use the cross compile.Inside the kernel,i think i can use some general cross compile,such as arm-none-linux-gnueabi-gcc.Is my idea correct?Or any other cross compile for android,u can prompt to me?And any artile about how to build the environment in the ubuntu for the cross compile? Secondly,whenever i compile the module,how can i load it into the kernel as the module? At last,anyone explain the relationship among NDK,cross compile and toolchain? thx

Well, this is kind of a big question, but I will try and answer what I know at least. I believe a particular hardware manufacturer will have an Android "Bundle" which will contain a complete set of working software. This will include the toolchain, Linux kernel source, u-boot booter, and the whole Android system. In my case, Freescale provided the Android bundle for the particular processor and evaluation boards they provide.

As far as terminology goes, "cross compiler" would be included in the "toolchain". The term "toolchain" encompasses the entirety of cross compiler, cross libraries and such. Each toolchain is built for a host (ie. Linux, cygwin, etc) and target processor (arm, mips, PowerPC etc).

Building Linux for Android is really no different that just building Linux. It would be advisable to use the same toolchain to build Linux that was used to build the rest of the Android system. To build Linux, set the environment variables of "ARCH=arm" and "CROSS_COMPILE=arm-none-linux-gnueabi-" (or the prefix to the actual cross compiler you are using). Note the ending "-" it is important in the cross compile prefix.

The following link goes over how to set up the development environment.

Android Development environment set up.

Note, Ubuntu 10.04 to 11.04 works well. It is advisable to stay within one of these versions.

Putting the Linux kernel onto the target is completely target dependent. For the Freescale that I am using, it expects to find Linux kernel on the SD card at offset 0x800 blocks (each block is 512 bytes on the SD card). I use the following to write to the SD card raw:

sudo dd if=uImage of=/dev/sdb bs=1M seek=1; sync

As far as the NDK goes, I don't have experience with it at all. My understanding of it, it is an interface for Android Java apps to call-out to 'C' and 'CPP' code for timing critical functions. What I don't know is the advantage this has over the JNI interface, and how it is different to the JNI interface.

I hope you find this useful and helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM