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.
Related
I'm trying to compile a kernel (Goldfish) to later insert some modules. I know that I need to enable module support, module loading, and unloading. I'm using OSX Mavericks.
So far I have checked out goldfish from git, and have done the following:
make ARCH=arm goldfish_armv7_defconfig
No problems there. Now when I do:
make ARCH=arm CROSS_COMPILE=/Volumes/untitled/WORKING_DIRECTORY/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin/arm-eabi- menuconfig
I get the following:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: * [scripts/kconfig/mconf] Error 1
make: * [menuconfig] Error 2
Is there a way that I can enable modules another way? Maybe go into a file and do it manually?
If I just run (which I'm supposed to run after to get a zImage):
make ARCH=arm SUBARCH=arm CROSS_COMPILE=/Volumes/untitled/WORKING_DIRECTORY/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin/arm-eabi -j16
The kernel compiles and I can run it via an emulator, but obviously I can't upload kernel modules.
module loading is disabled by default in android kernel.
Enable it using CONFIG_MODULES=y in your config file.
Open scripts/kconfig/lxdialog/check-lxdialog.sh
Replace ldflags() with this
ldflags()
{
for ext in so a dylib ; do
for lib in ncursesw ncurses curses ; do
#$cc -print-file-name=lib${lib}.${ext} | grep -q /
#if [ $? -eq 0 ]; then
if [ -f /usr/lib/lib${lib}.${ext} ]; then
echo "-l${lib}"
exit
fi
done
done
exit 1
}
Now make menuconfig should work. The problem seems to be the result of a bug with clang on OS X. The -print-file-name option doesn't work correctly.
Alternatively, you could open .config file in a text editor and set
CONFIG_MODULES=y
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.
I'm having compiling error while trying to build the SeAndroid 4.2 project.
I'm using Ubuntu 12.04 and gcc4.4
I followed the tutorial on SeAndroid Wiki and downloaded the whole source and after I tried to build a kernel.
seandroid-tegra3-grouper-3.1-jb-mr1.1 because I'm using a Asus TF700T device (with tegra chipset).
As mentioned on SeAndroid wiki page, I type
export PREFIX=/path/to/my/aospclone
cd $PREFIX/kernel/tegra
git checkout seandroid-tegra3-grouper-3.1-jb-mr1.1
make ARCH=arm tegra3_android_defconfig
make ARCH=arm CROSS_COMPILE=$PREFIX/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
The build completes correctly.
Then I'm trying to build my seandroid like :
cd $PREFIX
source build/envsetup.sh
lunch full_grouper-userdebug
make -j8
Then after 20 or 30 minutes of compiling, I got an error
...
system/core/init/init.c: In function 'service_start':
system/core/init/init.c:283:80: error: 'scon' undeclared (first use in this function)
system/core/init/init.c:283:80: note: each undeclared identifier is reported only once for each function it appears in
make: *** [out/target/product/generic/obj/EXECUTABLES/init_intermediates/init.o] Error 1
make: *** Waiting for unfinished jobs....
...
What could be the problem? I tried searching but couldn't find anything useful.
I'm trying to compile GMP for android (arm) but I'm received a very strange error. First, I set up a few things as described another SO question here:
export NDKROOT=/prod/ndk
$NDKROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 -- install-dir=$NDKROOT/android_armeabi
export CC="$NDKROOT/android_armeabi/bin/arm-linux-androideabi-gcc --sysroot=$NDKROOT/android_armeabi/sysroot"
export CXX="$NDKROOT/android_armeabi/bin/arm-linux-androideabi-g++ --sysroot=$NDKROOT/android_armeabi/sysroot"
export AR="$NDKROOT/android_armeabi/bin/arm-linux-androideabi-ar"
export SYSROOT="$NDKROOT/android_armeabi/sysroot"
export PATH="$NDKROOT/android_armeabi/bin":$PATH
Then I simply run ./configure --enable-cxx --prefix=/local/to/where/i/want/to/install --host=arm-none-linux-gnueabi and configuration goes well, with the following being part of the output:
Version: GNU MP 5.1.1
Host type: arm-none-linux-gnueabi
ABI: standard
Install prefix: /location/to/where/i/want/to/install
Compiler: /prod/ndk/android_armeabi/bin/arm-linux-androideabi-gcc -- sysroot=/prod/ndk/android_armeabi/sysroot -std=gnu99
Static libraries: yes
Shared libraries: yes
Up to here it goes well, but when I run make, I receive the following error:
ismpf.cc: In function 'std::istream& operator>>(std::istream&, mpf_ptr)':
ismpf.cc:48:43: error: 'struct lconv' has no member named 'decimal_point'
make[2]: *** [ismpf.lo] Error 1
make[2]: Leaving directory `~/Downloads/gmp-5.1.1/cxx'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `~/Downloads/gmp-5.1.1'
make: *** [all] Error 2
So my first problem is there. Any ideas?
Just out of curiosity, I tried to rerun the same exact configure command as above but using sudo ahead of it. After a few seconds I receive the following:
configure: error: Oops, mp_limb_t is 64 bits, but the assembler code
in this configuration expects 32 bits.
There is the second (and really weird problem that arises).
Just out of curiosity again, I tried to reboot and clear all the variables we created, and simply run the command that the GMP manual recommends:
./configure --prefix=/location/ --enable-cxx --host=arm-linux-androideabi
The ./configure runs, the make goes well, but all 9/9 tests fail when I do make check. Can anybody point me in the right direction with these errors, or about how to try and correctly compile GMP for android? Any help is immensely appreciated.
Unsetting the CFLAGS env var solved the problem for me.
i have downloaded the latest android ndk r8b on my ubuntu 12.10 beta 2 .
i have included the ndk directory in the PATH variable (when i write ndk-b in terminal and hit tab it auto-completes it) .
but when i try :
cd android-ndk/samples/san-angeles/jni
ndk-build
i get this error:
make: /home/mixpro/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
make: /home/mixpro/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
Compile thumb : sanangeles <= importgl.c
make: /home/mixpro/Android/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
make: *** [/home/mixpro/Android/android-ndk/samples/san-angeles/obj/local/armeabi/objs/sanangeles/importgl.o] Error 127
when checking the /android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin directory using ls i get:
arm-linux-androideabi-addr2line arm-linux-androideabi-g++
arm-linux-androideabi-gdbtui arm-linux-androideabi-size
arm-linux-androideabi-c++filt arm-linux-androideabi-gcc-4.6.x-google
arm-linux-androideabi-gprof arm-linux-androideabi-strings
arm-linux-androideabi-cpp arm-linux-androideabi-gcov
arm-linux-androideabi-readelf arm-linux-androideabi-elfedit
arm-linux-androideabi-gdb arm-linux-androideabi-run
meaning there is no arm-linux-androideabi-gcc in the directory
I am afraid that somehow you got arm-linux-androideabi-addr2line arm-linux-androideabi-gcc deleted. On linux, it is just a symlink to arm-linux-androideabi-gcc-4.6.x-google, so it's very easy to restore it. But maybe, to be on the safe side, it's worthwhile to reinstall NDK.
you should create symbolic link like this : ln -s /usr/bin/arm-linux-gnueabi-gcc-4.7 "/home/sofien/Bureau/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc"