• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Android kernel Module (.KO)

JMC31337

Newbie
Feb 17, 2011
16
0
This is Android Module Kernel Driver info is for the Photon 4g, but the info could easily be modded to fit your individual needs

1) Format an sdcard to ext3
2) copy the phones kernel stuff to sdcard
see:[Guide] Quick start compiling guides-cm9-kernels - xda-developers
pre-setup
Okay first of all you need to complete the above tutorial up to the getting source. so you wont have to do the building portion.
3)get an Android Ubuntu .img and install it to your android (as we will be building kernels on modules on the phone for the phone)

If you got Ubuntu installed and it can see your ext3 sdcard your good to go!

Note: one portion of the ubuntu.sh script has a mount -t ext2 CHANGE THIS TO EXT3
for the devpts mounting...
AND AFTER UBUNTU IS INSTALLED change the DEPMOD portion of the build script (FOR EACH DEPMOD)
DEPMOD=out/host/linux-x86/bin/depmod

to whatever file its under with Ubuntu

i think if memory serves correctly its

/etc/sbin/depmod

apt-get upgrade
apt-get install all these:
git-core gnupg sun-java6-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
from:Building Kernel from source - CyanogenMod Wiki

If java complains about not found keep going as the phone has java and javac installed with ubuntu

once the kernel is built (watch your output directory as /external_sd because of ubuntu) and modules built we can compile a quick hello world like this

ANDMOD.C
Code:
#include <linux/module.h>
#include <linux/kernel.h>

int init_module(void)
{
printk("<1> 1111");
return 0;
}

void cleanup_module(void)
{
printk("<1> 999999");
}
Makefile
Code:
KERNELDIR := /external_sd/Photon/kernel/tegra-temp
obj-m := andmod.o

all:; make -C $(KERNELDIR) M=$(PWD) modules

clean: make -C $(KERNELDIR) M=$(PWD) clean
run make and check the symbols
root@localhost:/external_sd# make
make -C /external_sd/Photon/kernel/tegra-temp M=/external_sd modules
make[1]: Entering directory `/external_sd/Photon/kernel/tegra-temp' make -C /external_sd/Photon O=/external_sd/Photon/kernel/tegra-temp/. modules
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/external_sd/Photon/kernel/tegra-temp'


root@localhost:/external_sd# strings andmod.ko
<1> 999999
<1> 1111
depends=
vermagic=2.6.32.9 SMP preempt mod_unload modversions ARMv7
~module_layout
printk
andmod
rU(hr

root@localhost:/external_sd#insmod andmod.ko

4060.939072] nvmap_release: pid=19329, org_pid=19329
[ 4063.812310] 1111

rmmod andmod.ko

[ 4111.178690] nvmap_release: pid=19583, org_pid=19583
[ 4115.682776] 999999




sorry if this tutorial sucks
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones