LOCAL BUILDING

On a Raspberry Pi first install the latest version of Raspbian or Ubuntu Mate 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 git libncurse5-dev 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 DEFAULT BUILD CONFIGURATION

$ cd linux
$ KERNEL=kernel7
$ make bcm2709_defconfig

MODIFYING DEFAUL KERNEL CONFIGURATIONS

$ make menuconfig

At this time you would want to navigate to

Device Drivers -> Graphic Support -> Direct Rendering Manager

Enable

Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)
Display Link (NEW)

BUILD KERNEL COMMANDS

Build and install the kernel, modules and Device Tree blobs; this step takes a lot of time…

$ make 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, adding -j4 (make -j4 zImage modules dtbs) splits the work between all four cores, speeding up compilation significantly.

 

XORG CONFIGURATIONS

Using your edit (nano) we will now edit xorg.conf file to resemble something like below

$ sudo nano /etc/X11/xorg.conf

you can copy and paste if you like

Section "Device"
Identifier "displaylink"
Driver "fbturbo"
Option "fbdev" "/dev/fb1"
Option "ShadowFB" "off"
EndSection

Section "Device"
Identifier "Raspberry Pi FBDEV"
Driver "fbturbo"
Option "fbdev" "/dev/fb0"
Option "ShadowFB" "off"
EndSection

Section "Monitor"
Identifier "AOC1"
EndSection

Section "Monitor"
Identifier "AOC2"
EndSection

Section "Screen"
Identifier "screen"
Device "displaylink"
Monitor "AOC2"
EndSection

Section "Screen"
Identifier "screen1"
Device "Raspberry Pi FBDEV"
Monitor "AOC1"
EndSection

Section "ServerLayout"
Identifier "default"
Screen 0 "screen1" 0 0
Screen 1 "screen" LeftOf "screen1"
EndSection

 

now it’s time to reboot and check if everything is working!