Build and test your kernel
You will modify the Linux kernel in the assignments. To test your modification, you need to build the modified kernel and test it on a real device. The kernel source is already placed in the class VM, and the compiler that can be used to cross-compile the kernel is also placed in it. If you use the class VM, you may skip steps 1-6. Reference: https://source.android.com/source/building-kernels.html1. Get the kernel source
Rungit clone https://android.googlesource.com/kernel/msm.gitto obtain the kernel source code for Nexus 7. It contains changes specific to the chipset used by Nexus 7. The ancestor of Nexus 7's chipset has a model number begins with "MSM", so the repository is named msm.
2. Get the compiler
The compiler which we use to compile the kernel for Nexus 7 is different from the compiler we usually use, because Nexus 7's processor uses an instruction set which is different from PCs. We need a specific compiler. We can obtain the compiler by runninggit clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6
3. Add the compiler to PATH
Suppose you put the compiler at /home/w4118/arm-eabi-4.6. Edit your ~/.bashrc, append this line and reopen the terminal:export PATH=$HOME/arm-eabi-4.6/bin:$PATHIf you place it at another place, modify the $HOME part accordingly.
4. Test if the compiler works
Runarm-eabi-gccif you see
arm-eabi-gcc: fatal error: no input files compilation terminated.then it works.
5. Config build environment
We need to specify that we want to compile the kernel for an ARM processor. We also need to specify that the compiler we are going to use have a prefix arm-eabi-. So append these lines to ~/.bashrc and reopen the terminal:export ARCH=arm export SUBARCH=arm export CROSS_COMPILE=arm-eabi-
6. Configure the kernel source
In the msm directory you just cloned, rungit checkout 365a6e06 make flo_defconfigThe git command gets the kernel source at a specific version. The "make flo_defconfig" command specifies that you want to build a kernel for device flo (codename of Nexus 7 2013).
7. Build the kernel
In the msm directory, runmakeEach time you modified the kernel, you need to run this command again to rebuild the kernel.
7. Check if kernel is built
If the build process completed successfully and arch/arm/boot/zImage presents in the msm directory, the kernel is built.8. Test the kernel
Download ramdisk.img and test_kernel.sh from http://www.cs.columbia.edu/~junfeng/13fa-w4118/hw/ramdisk.img and http://www.cs.columbia.edu/~junfeng/13fa-w4118/hw/test_kernel.sh into the msm directory. Runsh test_kernel.shto test the kernel. Before running test_kernel.sh, make sure that the device appears if you run
adb devicesYou should see a serial number followed with "device". The script first reboots your device into the fastboot mode, and then boots it with your kernel. The ramdisk.img contains a simple file system that is loaded after the kernel is booted. The fastboot utility combines your kernel and the ramdisk.img to produce a boot image. The boot image is then given to the device to boot from.
9. If the kernel does not boot....
If something goes wrong, just press the power button and keep it pressed for ~15 seconds. The device will turn off.
When you turn it back on, it will boot with the original kernel, and everything should be fine.