PDA

View Full Version : [Help] Compiling Drivers for Chrooted Environment



Gazos
2013-11-19, 15:00
Hi,

First of all a thanks to anyone who lends a hand on this one!!

I am trying to compile drivers for a chrooted (Kali Linux) environment on a Galaxy Tab2 (P5100) as well as other devices. I seem to have hit a stumbling block as the information on building kernel source with imported drivers seems to be sparse and I have cobbled together bits and pieces from multiple forums however no success! If I manage to successfully complete this insane task I play to fully document the process as a guide here and on a blog.

I will lay out the stages below from where I am at.

Tablet = Samsung Galaxy Tab 2 - P5100 Model
ROM: CyanogenMod 10.1.3-p5100
Device: USB Alfa AWUS036H (RTL8187L driver)
Development Environment: Ubuntu 12.04 64 bit

I have successfully configured a Kali Linux Chrooted Environment

Commands issued on ubuntu to compile the drivers, please tell me where I am going wrong:

##Install agcc compilers and tools
cd /tmp
wget https://neurodroid.googlecode.com/git/nrn/agcc
wget https://neurodroid.googlecode.com/git/nrn/agcc-vfp
sudo mv agcc* /usr/local/bin
sudo chmod +x /usr/local/bin/agcc*
sudo apt-get install vim vim-common make cmake lzop gcc git python

##SDK & NDK Tools installed at ~/android-adt/ndk & ~/android-adt/sdk
##Update the build path with the SDK and NDK tools
PATH=~/android-adt/sdk/platform-tools:~/android-adt/sdk/tools:~/android-adt/ndk:$PATH
cd ~/android-adt/ndk/build/tools

#remove any previously built toolchain
rm -rf ${HOME}/android-toolchain
#create new toolchain for android 4.2
./make-standalone-toolchain.sh --arch=arm --ndk-dir=${HOME}/android-adt/ndk --install-dir=${HOME}/android-toolchain --platform=android-17 --system=linux-x86_64
PATH=~/android-toolchain/bin:$PATH

##Get the kernel for the ROM (Galaxy Tab 2 p5100, cyanmodgen 10.2)
cd ~
git clone https://github.com/CyanogenMod/andro...espresso10.git

##Modify the make file in the kernel
cd android_kernel_samsung_espresso10
nano Makefile
##Change the CFLAGS_MODULE line and add -fno-pic

##Compile the kernel source
make ARCH=arm clean
make ARCH=arm cyanogenmod_p5100_defconfig
make -j4 ARCH=arm CROSS_COMPILE=arm-linux-androideabi-

Now this is as far as I seem to be able to get without any errors, some warning however! The last step does produce the zImage but I want the *.ko drivers for RTL8187

So what is the next step? Download the source drivers from Realtek copy them too ~/android_kernel_samsung_espresso10/drivers/net/wireless? then what?

Any help would be greatly appreciated!!

Thanks

Gazos

m4xx3d0ut
2013-12-11, 20:12
You don't really need to produce a kernel module to do this. If you did you would need to make sure module loading is supported by your kernel, or recompile to enable it.

What I did for nexus 7 and nexus 5 was enable it in the kernel config before compiling. You can cd to you kernel source then run

$ make menuconfig

Then you can enable it yourself. Here's a pastebin of a n7 config with rtl8187 enabled that you can use for reference.
http://pastebin.com/h2a0WzY0
Make sure you set your options to "y" not "m" so it compiles statically.

After your options are set compile your kernel.

When you have your zimage you need to extract your boot.img from your device and use boot.IMG tools (Google it) to split the image, swap in your zimage, then remake the image. You may then flash it to your device with fastboot.

Then with your awus adapter connected, open up a root terminal and type

$ ifconfig wlan1 up

Since a chroot shares the running kernel this will work from an android shell as well as one in your chroot.

Hope that helps.