I showed how to use pre-built fbtft kernel modules to provide the necessary Linux device driver. However, what if you want to use fbtft modules with a newer version of the Linux kernel?
The BeagleBone Black currently ships with a Linux 3.8 kernel built from Robert C. Nelson’s am33x-v3.8 branch. I do also have fbtft working on the BBB with newer kernels such as TI’s 4.1 branch and mainline 4.4-rc1, but I will focus on Linux 3.8 for this post.
Here is how I built FBTFT for Linux 3.8.13-bone79 kernel:
(for my complete transcript see this GitHub Gist)
Step 1: Clone repo & checkout branch
Clone bb-kernel repo & checkout am33x-v3.8 branch
$ git clone https://github.com/RobertCNelson/bb-kernel
$ cd bb-kernel
$ git checkout am33x-v3.8
Already on ‘am33x-v3.8’
Your branch is up-to-date with ‘origin/am33x-v3.8’.
Step 2: Run build script
Move into the new branch directory & run the build kernel script:
$ ./build_kernel.sh
—————————–
make -j4 ARCH=arm LOCALVERSION=-bone79 CROSS_COMPILE=”ccache /home/afustini/dev/bbb/bb-kernel/dl/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/arm-linux-gnueabihf-” dtbs
—————————–
Script Complete
Step 3: Add fbtft drivers
Add fbtft drivers into Linux kernel source based on instructions from fbtft README.
From within the bb-kernel dir:
$ cd KERNEL/drivers/video
$ git clone https://github.com/notro/fbtft
Cloning into ‘fbtft’…
remote: Counting objects: 1170, done.
remote: Total 1170 (delta 0), reused 0 (delta 0), pack-reused 1170
Receiving objects: 100% (1170/1170), 526.16 KiB | 0 bytes/s, done.
Resolving deltas: 100% (726/726), done.
Checking connectivity… done.
Add to KERNEL/drivers/video/Kconfig:
source “drivers/video/fbtft/Kconfig”
Add to KERNEL/drivers/video/Makefile:
obj-y += fbtft/
Verify files were modified correctly
$ git diff
diff –git a/drivers/video/Kconfig b/drivers/video/Kconfig
index a0c757a..50c5d62 100644
— a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2494,4 +2494,6 @@ config FB_SSD1307
This driver implements support for the Solomon SSD1307
OLED controller over I2C.
+source “drivers/video/fbtft/Kconfig”
+
endmenu
diff –git a/drivers/video/Makefile b/drivers/video/Makefile
index 28bfbca..6bd03af 100644
— a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -174,3 +174,6 @@ obj-$(CONFIG_DISPLAY_TIMING) += display_timing.o
obj-$(CONFIG_OF_DISPLAY_TIMING) += of_display_timing.o
obj-$(CONFIG_VIDEOMODE) += videomode.o
obj-$(CONFIG_OF_VIDEOMODE) += of_videomode.o
+
+obj-y += fbtft/
+
Step 4: Rebuild kernel
Now run the rebuild script to compile the fbtft modules:
$ ./tools/rebuild.sh
+ Detected build host [“Fedora release 22 (Twenty Two)”]
+ host: [x86_64]
+ git HEAD commit: [a50680ea2cc2fc4519353dee4c1cbb47e475d8b2]
The kernel config menu should appear shortly after starting the rebuild script. Follow these screenshots to select the fbtft drivers:
After exit the kernel config menu, the rebuild script should continue:
‘.config’ -> ‘/home/afustini/dev/bbb/bb-kernel/patches/defconfig’
—————————–
make -j4 ARCH=arm LOCALVERSION=-bone79 CROSS_COMPILE=”ccache /home/afustini/dev/bbb/bb-kernel/dl/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin/arm-linux-gnueabihf-” zImage modules
—————————–
scripts/kconfig/conf –silentoldconfig Kconfig
Script Complete
Verify in bb-kernel dir that fbtft modules were compiled:
$ find |grep fbtft |grep ko$
./KERNEL/drivers/video/fbtft/fb_upd161704.ko
./KERNEL/drivers/video/fbtft/fb_ili9486.ko
./KERNEL/drivers/video/fbtft/fb_pcd8544.ko
./KERNEL/drivers/video/fbtft/fb_tls8204.ko
Verify in bb-kernel/deploy that kernel and tarballs were created
$ ls -ltar deploy/
-rwxrwxr-x 1 afustini afustini 5552136 Oct 31 13:01 3.8.13-bone79.zImage
-rw-rw-r– 1 afustini afustini 110207 Oct 31 13:01 config-3.8.13-bone79
-rw-rw-r– 1 afustini afustini 11690719 Oct 31 13:01 3.8.13-bone79-modules.tar.gz
-rw-rw-r– 1 afustini afustini 1263879 Oct 31 13:01 3.8.13-bone79-firmware.tar.gz
-rw-rw-r– 1 afustini afustini 39642 Oct 31 13:01 3.8.13-bone79-dtbs.tar.gz
Step 5: Install new kernel on SD Card (from Linux host)
My SD card already had been imaged with:
- Debian (BeagleBone, BeagleBone Black – 4GB SD) 2015-03-01
- md5: c848627722b7a5f7bc89791cc8949e3b
From within bb-kernel dir
$ sudo ./tools/install_kernel.sh
ERROR: MMC is not defined in system.sh
Edit script to specify which device is your SD card:
$ vi system.sh
Install new kernel onto microSD card:
$ sudo ./tools/install_kernel.sh
Installing 3.8.13-bone79-modules.tar.gz to /dev/sdd2
info: [3.8.13-bone79] now installed…
This script has finished…
For verification, always test this media with your end device…
Step 6: Boot new kernel
Boot BBB with the updated microSD card:
$ dmesg| head
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.8.13-bone79 (XXXX@YYYY) (gcc version 4.7.3 20130328 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 – Linaro GCC 2013.04) ) #4 SMP Sat Oct 31 13:00:55 CDT 2015
$ uname -a
Linux beaglebone 3.8.13-bone79 #4 SMP Sat Oct 31 13:00:55 CDT 2015 armv7l GNU/Linux
$ find /lib/modules/3.8.13-bone79/|grep fbtft
/lib/modules/3.8.13-bone79/kernel/drivers/video/fbtft
/lib/modules/3.8.13-bone79/kernel/drivers/video/fbtft/fb_pcd8544.ko
/lib/modules/3.8.13-bone79/kernel/drivers/video/fbtft/fb_ili9486.ko
/lib/modules/3.8.13-bone79/kernel/drivers/video/fbtft/fbtft.ko
Edit u-boot config file uEnv.txt so the SPIDEV1 loads at boot and HDMI & eMMC are not loaded
cape_disable=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN,BB-BONE-EMMC-2G
cape_enable=capemgr.enable_partno=BB-SPIDEV1
For reference, this is my uEnv.txt
Verify that HDMI & eMMC are not loaded and SPIDEV1 is loaded:
NOTE: My BBB has no need for HDMI or eMMC. It may not be completely necessary to disable, but I did not investigated this.
$ cat /sys/devices/bone_capemgr.9/slots
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O– Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O– Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O– Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-SPIDEV1
Step 7: Load fbtft driver & test display:
Photos of breadboard wiring using SPI1 (CS0, MOSI, SCLK), D/C, RESET.
Load fbtft st7735r driver for adafruit18 (Adafruit 1.8″ TFT LCD display):
$ sudo modprobe fbtft_device busnum=1 name=adafruit18 debug=7 verbose=3 gpios=dc:48,reset:60
Console should now appear on the display. Refer to photos.
NOTE: if you have not already done, so run script to make sure all the free space on SD card can be utilized
$ sudo /opt/scripts/tools/grow_partition.sh
NOTE: apt-get may fail with warning “There is no public key available for the following key IDs”. Fix by running running:
$ sudo apt-get install debian-keyring debian-archive-keyring
$ sudoe apt-get update
Display image file on the display with fbi:
$ sudo apt-get install fbi
$ wget https://kernel.org/theme/images/logos/tux.png
$ sudo fbi -d /dev/fb0 -T 1 -a tux.png
using “DejaVu Sans Mono-16”, pixelsize=16.67 file=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf
Play video clip on the display with mplayer:
$ sudo apt-get install mplayer
$ wget http://hubblesource.stsci.edu/sources/video/clips/details/images/hst_1.mpg
$ sudo mplayer -nolirc -vo fbdev:/dev/fb0 scale=WIDTH:128 hst_1.mpg
Kernel log with verbose debug output for adafruit18:
If using the Adafruit 2.2″ TFT LCD display, then specifyadafruit22a [note: the “a” suffix is important]
$ sudo modprobe fbtft_device busnum=1 name=adafruit22a debug=7 verbose=3 gpios=dc:48,reset:60
fbi and mplayer all work OK for adafruit22a. Kernel log with verbose debug output for adafruit22a:
Links
Comments are not currently available for this post.