Updating kernel from source
For example, if you are using Ubuntu 14.04, the above command will check out code from "ubuntu-trusty" Git repository.
Once you check out the Git repository, use the following command to install necessary development packages to meet the build dependencies for the kernel source tree.
Having built the kernel, you need to copy it onto your Raspberry Pi and install the modules; this is best done directly using an SD card reader.
First, use sudo cp mnt/fat32/$mnt/fat32/$sudo cp arch/arm/boot/z Image mnt/fat32/$sudo cp arch/arm/boot/dts/*mnt/fat32/ sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/ sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/ sudo umount mnt/fat32 sudo umount mnt/ext4 Another option is to copy the kernel into the same place, but with a different filename - for instance, - rather than overwriting the file.
Then you want to upgrade your kernel version, but still have your modification?
The most natural way is to work with branches and merges. also in some files put original code line after my modified code line !!
Rebasing records the branch backwards, and replays the changes on top of another commit.
make -j4 z Image modules dtbs sudo make modules_install sudo cp arch/arm/boot/dts/*/boot/ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/ sudo cp arch/arm/boot/z Image /boot/$flag splits the work between all four cores, speeding up compilation significantly.On a Raspberry Pi, first install the latest version of Raspbian.Then boot your Pi, plug in Ethernet to give you access to the sources, and log in.You can either do this using Virtual Box (or VMWare) on Windows, or install it directly onto your computer.
For reference, you can follow instructions online at Wikihow.
There are two main methods for building the kernel.