building android kernel 3.4 - android

I am facing issues in building the android kernel. I tried the following steps from the following link ( http://source.android.com/source/building-kernels.html )
I donot have the AOSP. I am just trying to compile the kernel
Source: git clone https://android.googlesource.com/kernel/goldfish.git
I placed the tool chain in the following directory
/home/chid/goldfish/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin
I set the path as follows
export PATH=$(pwd)/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin:$PATH
pwd: /home/chid/goldfish
set the environment variables as follows.
export ARCH=x86
export SUBARCH=x86
export CROSS_COMPILE=i686-linux-android-
setup the config file as
make arch=x86 goldfish_defconfig
gave make as follows.
make -j6
But it tells me a "cannot find" error.
Error:
/home/chid/goldfish/scripts/gcc-version.sh: line 25: /home/chid/goldfish/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/i686-linux-android-gcc: No such file or directory
Can you tell me what I am missing? I ensured that the above mentioned file is present and the path is set correctly. Is there something else I need to take care of?

You got the toolchain as the following?
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6
Have you tried to launch gcc directly?
$ /home/chid/goldfish/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/i686-linux-android-gcc
How about ldd?
$ ldd /home/chid/goldfish/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/i686-linux-android-gcc
In vagrant precise32 Ubuntu image, no problems at all.
$ ldd i686-linux-android-4.6/bin/i686-linux-android-gcc
linux-gate.so.1 => (0xb77c7000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7619000)
/lib/ld-linux.so.2 (0xb77c8000)
$ i686-linux-android-4.6/bin/i686-linux-android-gcc
i686-linux-android-gcc: fatal error: no input files
compilation terminated.
$ sh goldfish/scripts/gcc-version.sh i686-linux-android-4.6/bin/i686-linux-android-gcc
0406
You might need to have another Linux environment to execute gcc.

Related

Cross Compile the Kernel

I am trying to achieve something similar to this
https://github.com/volatilityfoundation/volatility/wiki/Android#initialize-the-android-build-environment.
Below is the environment I am using:
Ubuntu 14.04, Android Studio 2.3, Android NDK r14, emulator -api22.
I am facing difficulties at step Cross Compile the Kernel.
I am targeting the goldfish kernel 3.10
following are the step I followed. Any help would be really appreciated.
method 1:
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=~/android-ndk/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
The tutorial suggesting that we have to run the next command as
make goldfish_armv7_defconfig
but when I checked the directory "android-source/arch/arm/configs/" there is no such config file there. Some tutorials suggesting that we can just copy and paste the file from kernel 2.6, so I did the same thing, and after that add
CONFIG_MODULES=y
CONFIG_MODULES_UNLOAD=y
CONFIG_MODULES_FORCE_UNLOAD=y
But futher
$ make
results in error:
arch/arm/mm/mmu.c: In function 'build_mem_type_table':
arch/arm/mm/mmu.c:470:18: error: 'L_PTE_MT_VECTORS' undeclared (first use in this function)
vecs_pgprot |= L_PTE_MT_VECTORS;
^
arch/arm/mm/mmu.c:470:18: note: each undeclared identifier is reported only once for each function it appears in
arch/arm/mm/mmu.c: At top level:
arch/arm/mm/mmu.c:637:23: warning: 'early_pte_alloc_and_install' defined but not used [-Wunused-function]
static pte_t * __init early_pte_alloc_and_install(pmd_t *pmd,
^
make[1]: *** [arch/arm/mm/mmu.o] Error 1
make: *** [arch/arm/mm] Error
methos 2:
Everything is same as in method 1, I just changed single variable
export ARCH=arm64
And run
make ranchu_deconfig
But I got the same error.
method 3:
$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=~/android-ndk/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
$ make ranchu_defconfig
$ vim .config # added this to .config file
CONFIG_MODULES=y
CONFIG_MODULES_UNLOAD=y
CONFIG_MODULES_FORCE_UNLOAD=y
$ make
This command run successfully: zImage found.
But when I run the emulator using the below command
root#ubuntu:~/Android/Sdk/tools# ./emulator -avd Nexus5x22 -kernel ~/android-source2/android-source/arch/arm/boot/zImage -show-kernel –verbose
I am getting the error of "Linux kernel too old to run ram disk":
ram disk error
Google's Android Kernel is messed up. They forgot to define L_PTE_MT_VECTORS when they back ported this patch.
The solution is to just add it here.

Error while Including third party module in kivy app

I am trying to import some third party module like pygoogle in my app when i run app in computer using kivy it works fine but when i make apk using buildozer it crashes every time then i find that i have to go in python-for-android and run this command to include module ./distribute.sh -m "pil ffmpeg kivy" but i still get error that
root#kali:~# cd ~/.buildozer/android/platform/python-for-android
root#kali:~/.buildozer/android/platform/python-for-android# ls
COPYING dist docs README.rst src
cythonizer.py distribute.sh LICENSE recipes tools
root#kali:~/.buildozer/android/platform/python-for-android# ./distribute.sh -m "pil ffmpeg kivy"
Check build dependencies for Kali
Avoid check build dependencies, unknow platform Kali
Check environment
No ANDROIDSDK environment set, abort
root#kali:~/.buildozer/android/platform/python-for-android#
I am using KAli Linux and please solve this someone ...it will be very helpfull to me
Try pasting the pygoogle folder in your app's directory, at the same level as main.py. Also, from the error, it looks like you need to set the ANDROIDSDK environment variable. See the docs.
I had a similar problem, and simply setting the ANDROIDSDK environment variable didn't sort it, but the following did.
Try the following and then run the ./distribute.sh -m "pil ffmpeg kivy" command from the same terminal(as the environment vars will only have been set for that terminal and any child processes), or alternatively, add these lines to your ~/.bashrc file for them to be permanent:
export ANDROIDSDK=/path/to/android-sdk
export ANDROIDNDK=/path/to/android-ndk
export ANDROIDNDKVER=rX
export ANDROIDAPI=X
# example
export ANDROIDSDK="/home/tito/code/android/android-sdk-linux_86"
export ANDROIDNDK="/home/tito/code/android/android-ndk-r7"
export ANDROIDNDKVER=r7
export ANDROIDAPI=14
Examples taken from here. I recommend having a look.

Building webrtc library

I am trying to build webrtc android demo application. I was following README applied by the project. First thing was mentioned about gclient but when i tried to run it "no external or internal command". Then i got this link according to the this link i cloned the depot_tool repository but when at the step when i try to run gclient i got this
So after hours of trying i am not able to run it. if any one has experience with this WebRTC library please provide some help. Any guidance? Any Hlep will be appreciated
I heard few things were changed from svn to GIT. We tried building webRTC to windows7 using visual studio. See if you can use any parts on this.
Get depot_tools software and extract to a location (set this path in environment variable).
cd to depot_tools directory and hit 'gclient' (this should take sometime)
Install python 2.7 and put it path.
create a folder of your choice for webRTC and open command prompt there.
Now hit, gclient config http://webrtc.googlecode.com/svn/trunk
then, gclient sync.
Then set GYP_GENERATORS=msvs environment variable (use ninja if you want that).
Also set msvs_version=2012 (depending on your visual studio version)
now run, gclient runhooks --force
This should generate solutions files for your folder. fireup the libjingle/webrtc.sln files and start building it. I'm not sure if it builds as is. But we had hicupps with that.
See this link on WebRTC native development if you haven't already. From my personal experience building this tricky job initially.
Also note that links might be deprecated as they moved to git, don't know if they are still maintaining it.
How to compile WEBRTC On ubuntu
download script and run:
https://cs.chromium.org/chromium/src/build/install-build-deps.sh
./build/install-build-deps.sh --no-chromeos-fonts
Now download depot tools
$ git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
Put it in Path
$ export PATH=`pwd`/depot_tools:"$PATH"
Define your settings:
export GYP_DEFINES="target_arch=x64 host_arch=x64 build_with_chromium=0 use_openssl=0 use_gtk=0 use_x11=0 include_examples=0 include_tests=1 fastbuild=1 remove_webcore_debug_symbols=1 include_pulse_audio=0 include_internal_video_render=0 clang=1 "
make file to download the source
mkdir webrtc-checkout
cd webrtc-checkout
I chose branch 50 you can change it
gclient config https://chromium.googlesource.com/external/webrtc.git#branch-heads/50 --name=src
gclient sync --force --with_branch_heads
gclient sync --force --with_branch_heads --nohooks
cd src
git checkout branch-heads/50
gclient runhooks
ninja -C ./out/Release
Collect your LIB & Include file to use it in your project
mkdir ../lib/
find ./ -name "*.o" -and -not -name do_not_use -and -not -name protoc -and -not -name genperf -exec ar crs ../lib/libwebrtc.a {} +
mkdir ../include
find ./ -name *.h -exec cp --parents '{}' ../include ';'

Building Valgrind for Android

Building valgrind-3.8.1 on ubuntu 12.04 with ndk-r6 or ndk-r8d failed with following error:
...
cc1: Error: not rekognized option "-marm"
priv/main_globals.c:1:0: Error: wrong Value (cortex-a8) for -mtune=switch
...
My build-script:
export NDKROOT=/home/stefan/android-ndk-r6-crystax-2
export HWKIND=generic
PATH=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$PATH
PATH=$PATH:$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux-androideabi/4.4.3
export CROSS_COMPILE=arm-linux-androideabi-
export AR=${CROSS_COMPLIE}ar
export LD=${CROSS_COMPLIE}ld
export CC=${CROSS_COMPLIE}gcc
export CXX=${CROSS_COMPLIE}g++
export CPP=${CROSS_COMPLIE}cpp
./autogen.sh CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm -DANDROID_HARDWARE_$HWKIND" CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm"
./configure --prefix=/data/local/Inst --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/tmp
And finally
make
:)
Any ideas? THANKS
Also i would accept builded binaries ;))
For how to build Valgrind for Android (ARM) see: https://stackoverflow.com/a/19255251/313113
For how to run your app through Valgrind see: https://stackoverflow.com/a/19235439/313113
Follow the instructions on this page :
http://valgrind.org/docs/manual/dist.readme-android.html
You don't compile valgrind as embbeded for your application, but you compile a arm-compatible valgrind binary on your computer, linked with the android-ndk library, and then you can ship valgrind on some folder on your device or simulator. That's around 130 Mb of data.
Note that the device must be rooted.
Then, whenever you want to run valgrind with your android app, you will have to attach valgrind to the app. For that, look here : How to start an android app with valgrind

Building FIPS module for android

I am working on an android project that requires the cryptographic libraries that are present in the application to be FIPS certified. To my knowledge there are no FIPS validated JAVA security libraries. Boucy Castle is good but its not validated. After reading some forum posts, I found out that OpenSSL's FIPS module can be used with the help of NDK.
Right now I am trying to build the fips-openssl module for Android, to do that I have created a script for the environment variables for cross compiling.
I am using openssl-fips, and ndk-r8 for this project. I followed the fips guideline I found on google. I hope this gives a clear picture of what I am trying to do.
#! /bin/sh
export ANDROID_NDK="~/Android/android-ndk-r8"
export FIPS_SIG="${ANDROID_NDK}/incore"
export GCC_C1="/usr/lib/gcc/i686-pc-linux-gnu/4.7.0/"
export PATH=$PATH:"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin";
export MACHINE=armv71
export ARCH=arm.
export CROSS_COMPILE="arm-linux-androideabi-"
export SYSTEM=android
#export RELEASE=2.6.32.GMU
export ANDROID_DEV="$ANDROID_NDK/platforms/android-14/arch-arm/usr"
export HOSTCC=/usr/bin/gcc
when doing the make this is the error that i get.
arm-linux-androideabi-gcc: error trying to exec 'cc1': execvp: No such file or directory
make[1]: *** [cryptlib.o] Error 1
make[1]: Leaving directory `/home/abhiram/fips/openssl-fips-1.2.3/crypto'
make: *** [build_crypto] Error 1
When i do a "find", the cc1 executable is present in this specific directory.
find . -name cc1
./toolchains/mipsel-linux-android-4.4.3/prebuilt/linux-x86/libexec/gcc/mipsel-linux-android/4.4.3/cc1
./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux-androideabi/4.4.3/cc1
./toolchains/x86-4.4.3/prebuilt/linux-x86/libexec/gcc/i686-android-linux/4.4.3/cc1
Looks like the problem is in the export statement, there is a blank space where a dash should be in the PATH line. Change this:
export PATH=$PATH:"${ANDROID_NDK}/toolchains/arm-linux-androideabi 4.4.3/prebuilt/linux-x86/bin";
to this:
export PATH=$PATH:"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin";
Also, your find shows that the cc1 executable is not in the path, so add its location to the path export as well:
export PATH=$PATH:"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin":"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux-androideabi/4.4.3/";
Right now I am trying to build the fips-openssl module for Android, to do that I have created a script for the environment variables for cross compiling.
OpenSSL provides a script for Android, if you are interested. You can find it on the OpenSSL wiki: FIPS Library and Android.
when doing the make this is the error that i get:
arm-linux-androideabi-gcc: error trying to exec 'cc1'
It looks like your PATH does not include the cross-compile toolchain.
How are you invoking the script? You need to include a leading dot (".") to ensure the changes are applied to the current shell (and not the sub-shell that executes the script (which simply exits)).
Here' the first step of OpenSSL's build procedures for Android located at FIPS Library and Android. Notice the leading dot:
$ . .setenv-android.sh
The results of running the script set a bunch of variables used by the OpenSSL build system:
$ . ./setenv-android.sh
ANDROID_NDK_ROOT: /opt/android-ndk-r9
ANDROID_EABI: arm-linux-androideabi-4.6
ANDROID_API: android-14
ANDROID_SYSROOT: /opt/android-ndk-r9/platforms/android-14/arch-arm
ANDROID_TOOLCHAIN: /opt/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin
FIPS_SIG:
CROSS_COMPILE: arm-linux-androideabi-
ANDROID_DEV: /opt/android-ndk-r9/platforms/android-14/arch-arm/usr
"${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux-androideabi/4.4.3/"
I don't believe this is needed.
export ANDROID_NDK="~/Android/android-ndk-r8"
According to the folks on the Android NDK user list, you should set both ANDROID_NDK_ROOT and ANDROID_SDK_ROOT. The various NDK and SDK tools use those environmental variables. I suppose the SDK value would be "~/Android/android-sdk" for your installation.
See Recommended NDK Directory? for details.
I also think you should be using ANDROID_SYSROOT. Its not used by the NDK or SDK tools; rather, its used by OpenSSL and passed as sysroot during compile.

Categories

Resources