Wednesday, May 16, 2018

Compile Raspberry Pi Desktop Linux Kernel

Compile Raspberry Pi Desktop Linux Kernel



What is Raspberry Pi Desktop? Raspberry Pi Desktop is Raspbian OS, a Debian Linux specially made for Raspberry Pi. The desktop version is a port on x86, made it a lightweight desktop OS. (Note: RPi is an ARM platform)

Since RPi Desktop is Linux. This is a simple tutorial on how to compile Linux kernel.
There are many reasons why you need to recompile the linux kernel, but before you compile, you should know that recompile kernel need a lot of hard disk space (10Gb) and long waiting time (4 hours, depends on the machines).

1. Prerequisites to compile kernel
1b. Update firmware
2. Download the source
3. Kernel configuration
4. compile
5. install

Prerequisites



# apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc


Update firmware



# rpi-update (update firmware and kernel source?)


Download kernel source


Original Linux kernel from http://kernel.org/, Raspbian kernel source can be git clone from git://github.com/raspberrypi/linux.git. The clone size (with history) is quite large (about 3-4Gb), to save time and disk space use shallow clone (git 1.7 or above).

$ cd /usr/src
# git clone --depth 1 git://github.com/raspberrypi/linux.git (about 1.5Gb)
(The version I get 4.14.37.)
# cd linux; make nconfig
(or you can use the old # make menuconfig)

Configuration


The is the most difficult part, different machine, different user may need different configuration. The configuration will be save as .config file. There is a copy of the kernel config in /boot/config-. Can use it as a reference.
There are few thousands of items to be configured, I don't know all of them.
Compile
After configuration.

# make bzImage
# make modules
# make modules_install

(This will take a long time, may be 2-6 hours)

Installation


# make install

This will copy the kernel image to /boot directory, create the initrd image and update grub bootloader.
After this you can reboot, see if you can boot the new kernel successfully.

No comments: