-
Notifications
You must be signed in to change notification settings - Fork 2
Build kernel and fbtft drivers
This guide shows how to build the kernel on the Raspberry Pi itself (takes 8-9 hours).
Cross compiling on a faster machine is possible. See http://elinux.org/RPi_Kernel_Compilation.
First Install kernel sources
SPI is disabled on this distro. Comment out blacklisting.
/etc/modprobe.d/raspi-blacklist.conf
#blacklist spi-bcm2708
cd drivers/video/
git clone https://github.com/notro/fbtft.git
# Let make/kbuild see the directory and config options.
echo "obj-y += fbtft/" >> Makefile
sed -i 's/endmenu/source "drivers\/video\/fbtft\/Kconfig"\n\nendmenu/' Kconfig
# Make the header file available
ln fbtft/fbtft.h ../../include/linux/fbtft.h
For most purposes, fbtft_device can be used instead (ref: Boot console).
Make the kernel aware of the connected display.
This info is contained in arch/arm/mach-bcm2708/bcm2708.c
Add this to the include section so the structures are available:
#include <linux/fbtft.h>
Example SPI config
static struct spi_board_info bcm2708_spi_devices[] = {
{
.modalias = "adafruit22fb",
.max_speed_hz = 32000000,
.bus_num = 0,
.chip_select = 0,
.mode = SPI_MODE_0,
.platform_data = &(struct fbtft_platform_data) {
.gpios = (const struct fbtft_gpio []) {
{ "reset", 25 },
{ "backlight", 23 },
{},
},
}
}, {
.modalias = "spidev",
.max_speed_hz = 500000,
.bus_num = 0,
.chip_select = 1,
.mode = SPI_MODE_0,
}
};
Example Platform device
static struct platform_device itdb28fb_device = {
.name = "itdb28fb",
.id = 0,
.dev = {
.platform_data = &(struct fbtft_platform_data) {
.gpios = (const struct fbtft_gpio []) {
{ "reset", 17 },
{ "dc", 1 },
{ "wr", 0 },
{ "cs", 21 },
{ "db00", 9 },
{ "db01", 11 },
{ "db02", 18 },
{ "db03", 23 },
{ "db04", 24 },
{ "db05", 25 },
{ "db06", 8 },
{ "db07", 7 },
{ "led", 4 },
{},
},
},
},
};
void __init bcm2708_init(void)
{
[snip]
bcm_register_device(&itdb28fb_device);
[snip]
}
Copy configuration from the running kernel
cd /usr/src/linux
zcat /proc/config.gz > .config
Enable fbtft in menuconfig
make menuconfig
- Device Drivers ---> Graphics support --->
- < > Support for small TFT LCD display modules (NEW) --->
m - compiles as a loadable module
y - copiles it into the kermel image (shown as a star *) - Choose driver(s)
Console options
- Device Drivers ---> Graphics support ---> Console display driver support --->
To enable rotation support for the console:
[*] Framebuffer Console Rotation
By default two console fonts is available: VGA8x8 and VGA8x16
To enable more fonts:
[*] Select compiled-in fonts
[ ] VGA 8x8 font (NEW)
-*- VGA 8x16 font
[ ] Mac console 6x11 font (not supported by all drivers) (NEW)
[ ] console 7x14 font (not supported by all drivers) (NEW)
[ ] Pearl (old m68k) console 8x8 font (NEW)
[ ] Acorn console 8x8 font (NEW)
[ ] Mini 4x6 font (NEW)
[ ] Sparc console 8x16 font (NEW)
[ ] Sparc console 12x22 font (not supported by all drivers) (NEW)
[ ] console 10x18 font (not supported by all drivers) (NEW)
# default build targets: vmlinux, modules, zImage.
# This takes between 8 and 9 hours. Overnight job?
make
# Install modules
make modules_install
# Install kernel
make zinstall
# Reboot into the new kernel
shutdown -r now