In this article we will explain how to compile the kernel for a raspberrypi3, there is no difference with the compilation of a standard kernel except for the name of the image in /boot/
We download the kernel sources
cd /usr/src
git clone --depth=1 https://github.com/raspberrypi/linux
git clone --depth=1 https://github.com/raspberrypi/linux
The kernel image must be named kernel7 for the rasp firmware to read it:
cd linux
KERNEL=kernel7
KERNEL=kernel7
We generate the initial config:
make bcm2709_defconfig
We configure the parameters and compile:
make menuconfig
make -j4 zImage modules dtbs
make -j4 zImage modules dtbs
We install the modules, firmware and kernel image:
make -j4 modules_install
cp arch/arm/boot/dts/.dtb /boot/
mkdir -p /boot/overlays/ 2>/dev/null
cp arch/arm/boot/dts/overlays/.dtb* /boot/overlays/
cp arch/arm/boot/dts/overlays/README /boot/overlays/
cp arch/arm/boot/zImage /boot/$KERNEL.img
cp arch/arm/boot/dts/.dtb /boot/
mkdir -p /boot/overlays/ 2>/dev/null
cp arch/arm/boot/dts/overlays/.dtb* /boot/overlays/
cp arch/arm/boot/dts/overlays/README /boot/overlays/
cp arch/arm/boot/zImage /boot/$KERNEL.img