Building the Android kernel for Galaxy Nexus.
The Android/Linux kernel shipped with Android 4.2.2 release on the Galaxy Nexus (and presumably other devices) does not include the cifs.ko module. I like mounting all my samba shares to my android phone as that gives me access to all my media and documents without having to worry about syncing or running out of disk space on my phone.
Fortunately, Google releases full kernel source code for the Nexus devices. This makes it easy to build the kernel ourselves, enabling whatever modules one needs. Once the kernel and modules are built, its a simple matter of transferring the .ko files for the modules we need to the phone and “insmod” them into the kernel.
There are quite a few tutorials online demonstrating how to build a custom kernel from scratch. Unfortunately, most of them focus on replacing the entire kernel. This not being my intent, it took a bit of trial and error to figure our the right way to build a specific version of the kernel, matching the one shipped with the phone exactly. This allows insmoding the kernel modules directly from our build.
This here is a detailed transcript of what needs to be do, derived mainly from source.android.com/source/building-kernels.html.
Firstly, we note that the code name for the GSM Galaxy Nexus is “maguro”. Thus, its binaries are in device/samsung/tuna and kernel source is in kernel/omap.
Lets start by making a new working directory:
| |
Now we can download and install the prebuilt toolchain:
| |
Next, get the kernel binaries. This is needed to obtain the specific commit id of the kernel release:
| |
This generates output like so (example only):
| |
Make a note of the 7-digit commit id, here it is 9f818de.
Go back to the working directory, get the kernel source tree and checkout the correct commit:
| |
This completes the setup. We can now simply configure the kernel as per our needs:
| |
For example the changes made were:
| |
| |
Now simply build the kernel, and extract the errant modules:
| |