[Nexus 4 Q&A, Help & Troubleshooting] rourion:
Hello All,

Short question: I've successfully booted a custom kernel whose .config file has the appropriate (CONFIG_MODULES=y, CONFIG_MODULES_UNLOAD=y, CONFIG_MODULES_FORCE_UNLOAD=y) are all set. However, running lsmod gives the error: /proc/modules no such file/directory and insmod gives a 'function not implemented' error. Did I not actually boot into the kernel I just made? The reason I ask is that the Phone details kernel version remains the same and loadable modules aren't supported, despite the steps outlined below.

Phone details:

Model: Nexus 4

Android Version: 4.2.2

Kernel Version: 3.4.0-perf-g7ce11cd android-build@vpbs1.mtv.corp.google.com #1 Tue Jan 29 11:41:33 PST 2013

Build Number: JDQ39

Long explanation: I'm new to working with custom kernels and really anything beyond rooting the device - so apologies for any simple mistakes I make. I'm working on a project that requires me to create a custom kernel that supports module loading, unloading, and force unloading. I've been trying to do this manually (I'd like to learn the process). I've mostly used the following guides to get to this point:

What I want to do (except with a real phone) https://code.google.com/p/volatility/wiki/AndroidMemoryForensics

http://xdaforums.com/nexus-4/general/howto-build-nexus-4-kernel-t2021202

http://xdaforums.com/nexus-4/general/nexus-4-guide-unlock-bootloader-root-t2266654

http://xda-university.com/as-a-developer/getting-started-building-a-kernel-from-source

I've completed the process outlined in the first link with the goldfish emulator, but now I want to test it out on my rooted Nexus 4 device.

Setup

:

Download Google SDK

git clone toolchain (http://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6)

adb pull /proc/config.gz from phone

git clone kernel source (https://android.googlesource.com/kernel/msm)

git clone AnyKernel folder source (https://github.com/koush/AnyKernel.git)

Unlock bootloader & setup CWM v. 6.0.4.7

Setup Notes

Here's where I think I may be messing up: the kernel source step. So once I clone the kernel source, I switch into what I believe to be the appropriate branch. I've tried all of the msm-mako-3.4-jb branches except for the kgsl one at this point. I think possibly my error is coming from grabbing the wrong kernel -- but I wasn't sure how else to do it since I'm working with an older 4.2.2 model.

Here are the msm-mako-3.4-jb branches I can switch to (I'm assuming I need jb because I am running 4.2.2):

View attachment 3377399

For the AnyKernel folder structure, I modified the updater-script's mount command to mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system"); (solution here: http://xdaforums.com/showthread.php?t=1875460) because I was receiving a 'mount expects 4 args, got 3 error'.

Making the Kernel

As far as that goes, I executed the following commands without errors:

make ARCH=arm SUBARCH=arm CROSS_COMPILE=~/toolchain/arm-linux-androideabi- menuconfig (using the config file I pulled from the phone)

make ARCH=arm SUBARCH=arm CROSS_COMPILE=~/toolchain/arm-linux-androideabi- (succesfully creates the zImage and 2 .ko files (scsi_wait_scan.ko and adsprpc.ko))

copy the zImage to AnyKernel/kernel and the two .ko files to AnyKernel/system/lib/modules

zip the directors from AnyKernel and place zip on sdcard

adb reboot recovery

once in CWM, advanced > wipe davlik cache and afterwards install zip > choose zip from /sdcard > mykernel.zip

This process appears to successfully execute to me (screenshot below) and then I hit reboot system now for the changes to take place. At this point I check lsmod and insmod again and receive the same errors. I've reached this step 4 times with some of the different msm-mako-3.4-jb kernel sources (mr1, mr1-fr, mr1.1, and mr2).

View attachment 3377400

Sorry for the long post and thank you if you've taken the time to read it all! I'd appreciate it if anyone could help me out. Please ask if there are any details I left out that might help the issue.