2

I downloaded a Linux kernel "linux-4.1.13.tar.xz" from kernel.org that I want to compile it for Raspberry Pi.

Is it possible?

1
  • 4
    I am down-voting for the lack of research. That question indeed has an answer, not on this site but — complete — on elinux.org and the Raspberry Pi foundation web site as well, just about the Raspberry Pi.
    – user29510
    Commented Jul 3, 2016 at 9:17

2 Answers 2

1

The following comes from raspberrypi.org ... there is more, but I am just posting the minimum to answer the question.

There are two main methods for building the kernel. You can build locally on a Raspberry Pi which will take a long time; or you can cross-compile, which is much quicker, but requires more setup.

LOCAL BUILDING

On a Raspberry Pi first install the latest version of Raspbian from the downloads page. Then boot your Pi, plug in Ethernet to give you access to the sources, and log in.

First get the sources, which will take some time:

git clone --depth=1 https://github.com/raspberrypi/linux

Add missing dependencies:

sudo apt-get install bc

Configure the kernel - as well as the default configuration you may wish to configure your kernel in more detail or apply patches from another source to add or remove required functionality:

Run the following commands depending on your Raspberry Pi version.

RASPBERRY PI 1 (OR COMPUTE MODULE) DEFAULT BUILD CONFIGURATION

cd linux
KERNEL=kernel
make bcmrpi_defconfig

RASPBERRY PI 2/3 DEFAULT BUILD CONFIGURATION

cd linux
KERNEL=kernel7
make bcm2709_defconfig

Build and install the kernel, modules and Device Tree blobs; this step takes a long time...

make -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img

Note: On a Raspberry Pi 2/3, the -j4 flag splits the work between all four cores, speeding up compilation significantly.

0
1

This official wiki page tracks differences between mainline and the RPI fork: https://github.com/raspberrypi/linux/wiki/Upstreaming

It shows that the differences are mainly in defconfigs, dtb and drivers.

Since Raspberry Pi has its own Linux fork, using a vanilla kernel will likely not work, or some functionality will be missing (unless you reapply some of the changes which are present in the fork).

Why don't you just make your changes on top of the RPI fork?

Related: Which kernel source is required to compile for Raspberry Pi?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.