Skip to content

Instantly share code, notes, and snippets.

@pdp7
Last active August 8, 2016 21:33
Show Gist options
  • Save pdp7/440f522ff7060ab9ae72 to your computer and use it in GitHub Desktop.
Save pdp7/440f522ff7060ab9ae72 to your computer and use it in GitHub Desktop.
Linux kernel 3.18.0-29-rpi2 with fbtft modules for Ubuntu 14.04 on Raspberry Pi 2

Description

Downloads

Discussion

How to build kernel package

Add PPA for Raspberry Pi 2 (Nightly Builds)

deb http://ppa.launchpad.net/fo0bar/rpi2-nightly/ubuntu trusty main 
deb-src http://ppa.launchpad.net/fo0bar/rpi2-nightly/ubuntu trusty main 
  • from the RPi2:
root@ubuntu:~# cat /etc/apt/sources.list
deb http://ppa.launchpad.net/fo0bar/rpi2-nightly/ubuntu trusty main 
deb-src http://ppa.launchpad.net/fo0bar/rpi2-nightly/ubuntu trusty main 

deb http://ppa.launchpad.net/fo0bar/rpi2-staging/ubuntu trusty main 
deb-src http://ppa.launchpad.net/fo0bar/rpi2-staging/ubuntu trusty main 

deb http://ports.ubuntu.com/ trusty main restricted universe multiverse
deb-src http://ports.ubuntu.com/ trusty main restricted universe multiverse

deb http://ports.ubuntu.com/ trusty-updates main restricted universe multiverse
deb-src http://ports.ubuntu.com/ trusty-updates main restricted universe multiverse

deb http://ports.ubuntu.com/ trusty-security main restricted universe multiverse
deb-src http://ports.ubuntu.com/ trusty-security main restricted universe multiverse

deb http://ports.ubuntu.com/ trusty-backports main restricted universe multiverse
deb-src http://ports.ubuntu.com/ trusty-backports main restricted universe multiverse

Build Linux kernel 3.18.0-25 with fbtft drivers

root@ubuntu:~# apt-get source -b linux-image-3.18.0-25-rpi2

# suspend after linux-3.18.0 dir exist, add fbtft per https://github.com/notro/fbtft
root@ubuntu:~/linux-3.18.0/drivers/video/fbdev# git clone https://github.com/notro/fbtft.git^C
root@ubuntu:~/linux-3.18.0/drivers/video/fbdev# vi drivers/video/fbdev/Kconfig
root@ubuntu:~/linux-3.18.0/drivers/video/fbdev# vi Kconfig 
root@ubuntu:~/linux-3.18.0/drivers/video/fbdev# vi Makefile 

root@ubuntu:~/linux-3.18.0/drivers/video/fbdev# fg
apt-get source -b linux-image-`uname -r`        (wd: ~)
dh_testroot
dh_clean
# d-i stuff
rm -rf debian.master/d-i-armhf
# Generated on the fly.
rm -f debian.master/d-i/firmware/kernel-image
# normal build junk
rm -rf debian.master/abi/3.18.0-29.30
rm -rf /root/linux-3.18.0/debian/build
rm -f /root/linux-3.18.0/debian/stamps/stamp-*
### <SNIP> ###
*
* Restart config...
*
*
* Support for small TFT LCD display modules
*
Support for small TFT LCD display modules (FB_TFT) [N/m/y] (NEW) m
  FB driver for the AGM1264K-FL LCD display (FB_TFT_AGM1264K_FL) [N/m/?] (NEW) m
  FB driver for the BD663474 LCD Controller (FB_TFT_BD663474) [N/m/?] (NEW) m
  FB driver for the HX8340BN LCD Controller (FB_TFT_HX8340BN) [N/m/?] (NEW) m
  FB driver for the HX8347D LCD Controller (FB_TFT_HX8347D) [N/m/?] (NEW) m 
  FB driver for the HX8353D LCD Controller (FB_TFT_HX8353D) [N/m/?] (NEW) m
  FB driver for the ILI9320 LCD Controller (FB_TFT_ILI9320) [N/m/?] (NEW) m
  FB driver for the ILI9325 LCD Controller (FB_TFT_ILI9325) [N/m/?] (NEW) m
  FB driver for the ILI9340 LCD Controller (FB_TFT_ILI9340) [N/m/?] (NEW) m
  FB driver for the ILI9341 LCD Controller (FB_TFT_ILI9341) [N/m/?] (NEW) m
  FB driver for the ILI9481 LCD Controller (FB_TFT_ILI9481) [N/m/?] (NEW) m
  FB driver for the ILI9486 LCD Controller (FB_TFT_ILI9486) [N/m/?] (NEW) m
  FB driver for the PCD8544 LCD Controller (FB_TFT_PCD8544) [N/m/?] (NEW) m
  FB driver for the RA8875 LCD Controller (FB_TFT_RA8875) [N/m/?] (NEW) m
  FB driver for the S6D02A1 LCD Controller (FB_TFT_S6D02A1) [N/m/?] (NEW) m
  FB driver for the S6D1211 LCD Controller (FB_TFT_S6D1121) [N/m/?] (NEW) m
  FB driver for the SSD1289 LCD Controller (FB_TFT_SSD1289) [N/m/?] (NEW) m
  FB driver for the SSD1306 OLED Controller (FB_TFT_SSD1306) [N/m/?] (NEW) m
  FB driver for the SSD1331 LCD Controller (FB_TFT_SSD1331) [N/m/?] (NEW) m
  FB driver for the SSD1351 LCD Controller (FB_TFT_SSD1351) [N/m/?] (NEW) m
  FB driver for the ST7735R LCD Controller (FB_TFT_ST7735R) [N/m/?] (NEW) m
  FB driver for tinylcd.com display (FB_TFT_TINYLCD) [N/m/?] (NEW) m
  FB driver for the TLS8204 LCD Controller (FB_TFT_TLS8204) [N/m/?] (NEW) m
  FB driver for the UC1701 LCD Controller (FB_TFT_UC1701) [N/m/?] (NEW) m
  FB driver for the uPD161704 LCD Controller (FB_TFT_UPD161704) [N/m/?] (NEW) m
  FB driver for the WATTEROTT LCD Controller (FB_TFT_WATTEROTT) [N/m/?] (NEW) m
  Generic FB driver for TFT LCD displays (FB_FLEX) [N/m/?] (NEW) m
  Module to for adding FBTFT devices (FB_TFT_FBTFT_DEVICE) [N/m] (NEW) m
### <SNIP> ###
  HOSTCC  scripts/dtc/checks.o
  HOSTCC  scripts/dtc/util.o
### <SNIP> ###
  HOSTCC  scripts/sortextable
make[2]: Leaving directory `/root/linux-3.18.0/debian/build/build-rpi2'
make[1]: Leaving directory `/root/linux-3.18.0'
touch /root/linux-3.18.0/debian/stamps/stamp-prepare-tree-rpi2
Debug: config-prepare-check-rpi2
check-config: /root/linux-3.18.0/debian/build/build-rpi2/.config: loading config
check-config: /root/linux-3.18.0/debian.master/config/enforce: loading checks
check-config: 49/49 checks passed -- exit 0
Debug: /root/linux-3.18.0/debian/stamps/stamp-prepare-rpi2
Debug: /root/linux-3.18.0/debian/stamps/stamp-build-rpi2 build_image zImage bldimg zImage
make ARCH=arm CROSS_COMPILE= KERNELVERSION=3.18.0-29-rpi2 CONFIG_DEBUG_SECTION_MISMATCH=y KBUILD_BUILD_VERSION="30" LOCALVERSION= localver-extra= CFLAGS_MODULE="-DPKG_ABI=29" O=/root/linux-3.18.0/debian/build/build-rpi2 -j4 zImage modules 
make[1]: Entering directory `/root/linux-3.18.0'
make[2]: Entering directory `/root/linux-3.18.0/debian/build/build-rpi2'
  CHK     include/config/kernel.release
  GEN     ./Makefile
  CHK     include/generated/uapi/linux/version.h
  Using /root/linux-3.18.0 as source for kernel
  CHK     include/generated/utsrelease.h
make[3]: `include/generated/mach-types.h' is up to date.
  CALL    /root/linux-3.18.0/scripts/checksyscalls.sh
  CC      init/main.o
  HOSTCC  usr/gen_init_cpio
  CC      arch/arm/vfp/vfpmodule.o
  CC      arch/arm/kernel/elf.o
  GEN     usr/initramfs_data.cpio.gz
  AS      arch/arm/kernel/entry-common.o
  AS      usr/initramfs_data.o
  CC      arch/arm/kernel/irq.o
  LD      usr/built-in.o
  CC      arch/arm/mm/dma-mapping.o
### <SNIP> ###
Debug: binary-udebs
Debug: binary-arch-headers
dh_testdir
dh_testroot
dh_installchangelogs -plinux-libc-dev
dh_installdocs -plinux-libc-dev
dh_compress -plinux-libc-dev
dh_fixperms -plinux-libc-dev
dh_installdeb -plinux-libc-dev
flock -w 60 /root/linux-3.18.0/debian/.LOCK dh_gencontrol -plinux-libc-dev --
dh_md5sums -plinux-libc-dev
dh_builddeb -plinux-libc-dev
dpkg-deb: building package `linux-libc-dev' in `../linux-libc-dev_3.18.0-29.30_armhf.deb'.
Debug: binary-arch
 dpkg-genchanges -b >../linux_3.18.0-29.30_armhf.changes
dpkg-genchanges: warning: package linux-cloud-tools-3.18.0-29 in control file but not in files list
dpkg-genchanges: warning: package linux-image-extra-3.18.0-29-rpi2 in control file but not in files list
dpkg-genchanges: warning: package linux-image-3.18.0-29-rpi2-dbgsym in control file but not in files list
dpkg-genchanges: warning: package linux-cloud-tools-3.18.0-29-rpi2 in control file but not in files list
dpkg-genchanges: warning: package linux-udebs-rpi2 in control file but not in files list
dpkg-genchanges: binary-only upload - not including any source code
 dpkg-source --after-build linux-3.18.0
dpkg-source: info: using options from linux-3.18.0/debian/source/options: --diff-ignore --tar-ignore
dpkg-buildpackage: binary only upload (no source included)

Install kernel .deb package

root@ubuntu:~# dpkg -i linux-image-3.18.0-29-rpi2_3.18.0-29.30_armhf.deb
Selecting previously unselected package linux-image-3.18.0-29-rpi2.
(Reading database ... 71260 files and directories currently installed.)
Preparing to unpack linux-image-3.18.0-29-rpi2_3.18.0-29.30_armhf.deb ...
Done.
Unpacking linux-image-3.18.0-29-rpi2 (3.18.0-29.30) ...
Setting up linux-image-3.18.0-29-rpi2 (3.18.0-29.30) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.18.0-29-rpi2 /boot/vmlinuz-3.18.0-29-rpi2
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.18.0-29-rpi2 /boot/vmlinuz-3.18.0-29-rpi2
update-initramfs: Generating /boot/initrd.img-3.18.0-29-rpi2

root@ubuntu:~# ls -ltar /boot/
total 57224
drwxr-xr-x  3 root root    16384 Jan  1  1970 firmware
-rw-------  1 root root  3328120 Apr  5  2015 vmlinuz-3.18.0-20-rpi2
-rw-r--r--  1 root root   119677 Apr  5  2015 config-3.18.0-20-rpi2
-rw-r--r--  1 root root   684446 Apr  5  2015 abi-3.18.0-20-rpi2
-rw-------  1 root root  2343516 Apr  5  2015 System.map-3.18.0-20-rpi2
lrwxrwxrwx  1 root root       19 Apr  6  2015 config.txt -> firmware/config.txt
lrwxrwxrwx  1 root root       20 Apr  6  2015 cmdline.txt -> firmware/cmdline.txt
-rw-------  1 root root  3337648 Jul  5  2015 vmlinuz-3.18.0-25-rpi2
-rw-r--r--  1 root root   119705 Jul  5  2015 config-3.18.0-25-rpi2
-rw-r--r--  1 root root   685516 Jul  5  2015 abi-3.18.0-25-rpi2
-rw-------  1 root root  2346158 Jul  5  2015 System.map-3.18.0-25-rpi2
-rw-------  1 root root  5511744 Feb 19 17:31 vmlinuz-3.13.0-79-generic
-rw-r--r--  1 root root   162263 Feb 19 17:31 config-3.13.0-79-generic
-rw-r--r--  1 root root  1108994 Feb 19 17:31 abi-3.13.0-79-generic
-rw-------  1 root root  2808717 Feb 19 17:31 System.map-3.13.0-79-generic
-rw-r--r--  1 root root  5252648 Mar  2 06:57 initrd.img-3.18.0-20-rpi2
-rw-r--r--  1 root root 13732499 Mar  6 18:00 initrd.img-3.13.0-79-generic
-rw-r--r--  1 root root  5254437 Mar  8 03:21 initrd.img-3.18.0-25-rpi2
-rw-------  1 root root  3334328 Mar  9 11:24 vmlinuz-3.18.0-29-rpi2
-rw-r--r--  1 root root   120364 Mar  9 11:24 config-3.18.0-29-rpi2
-rw-r--r--  1 root root   687502 Mar  9 11:24 abi-3.18.0-29-rpi2
-rw-------  1 root root  2342729 Mar  9 11:24 System.map-3.18.0-29-rpi2
drwxr-xr-x 21 root root     4096 Mar  9 16:40 ..
-rw-r--r--  1 root root  5252817 Mar  9 16:41 initrd.img-3.18.0-29-rpi2
drwxr-xr-x  3 root root     4096 Mar  9 16:41 .

root@ubuntu:~# ls -ltar /boot/firmware/
total 19722
drwxr-xr-x 3 root root   16384 Jan  1  1970 .
drwxr-xr-x 2 root root    4096 Apr  6  2015 overlays
-rwxr-xr-x 1 root root    1311 Apr  6  2015 config.txt
-rwxr-xr-x 1 root root      73 Mar  6 01:24 cmdline.txt
-rwxr-xr-x 1 root root 3622504 Mar  6 18:00 start_x.elf
-rwxr-xr-x 1 root root 4645480 Mar  6 18:00 start_db.elf
-rwxr-xr-x 1 root root  568280 Mar  6 18:00 start_cd.elf
-rwxr-xr-x 1 root root 2664792 Mar  6 18:00 start.elf
-rwxr-xr-x 1 root root    9216 Mar  6 18:00 fixup_x.dat
-rwxr-xr-x 1 root root    9214 Mar  6 18:00 fixup_db.dat
-rwxr-xr-x 1 root root    2366 Mar  6 18:00 fixup_cd.dat
-rwxr-xr-x 1 root root    6161 Mar  6 18:00 fixup.dat
-rwxr-xr-x 1 root root   17900 Mar  6 18:00 bootcode.bin
-rwxr-xr-x 1 root root    5690 Mar  6 18:00 bcm2709-rpi-2-b.dtb
-rwxr-xr-x 1 root root    4423 Mar  6 18:00 bcm2708-rpi-b.dtb
-rwxr-xr-x 1 root root    4702 Mar  6 18:00 bcm2708-rpi-b-plus.dtb
-rwxr-xr-x 1 root root    1447 Mar  6 18:00 LICENCE.broadcom
-rwxr-xr-x 1 root root 3334328 Mar  9 11:24 kernel7.img
-rwxr-xr-x 1 root root 5252817 Mar  9 16:41 initrd7.img
drwxr-xr-x 3 root root    4096 Mar  9 16:41 ..


Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2   15G  6.6G  7.2G  48% /
devtmpfs        458M  4.0K  458M   1% /dev
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none             93M  248K   93M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            462M     0  462M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/mmcblk0p1   64M   20M   45M  31% /boot/firmware

root@ubuntu:/boot/firmware# uname -a
Linux ubuntu 3.18.0-25-rpi2 #26-Ubuntu SMP PREEMPT Sun Jul 5 06:46:34 UTC 2015 armv7l armv7l armv7l GNU/Linux

Boot new kernel and insert fbtft modules

ubuntu@ubuntu:~$ uname -a
Linux ubuntu 3.18.0-29-rpi2 #30 SMP PREEMPT Wed Mar 9 07:57:46 UTC 2016 armv7l armv7l armv7l GNU/Linux

ubuntu@ubuntu:~$ find /lib/modules/3.1
3.13.0-79-generic/ 3.18.0-20-rpi2/    3.18.0-25-rpi2/    3.18.0-29-rpi2/    

ubuntu@ubuntu:~$ find /lib/modules |grep fbtft    
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ra8875.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_watterott.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ili9325.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_agm1264k-fl.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ssd1306.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fbtft_device.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/flexfb.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ili9341.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_uc1701.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_st7735r.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ili9481.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_tinylcd.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ili9340.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_hx8353d.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fbtft.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ssd1289.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_hx8340bn.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_s6d1121.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_bd663474.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ssd1331.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ssd1351.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_s6d02a1.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_pcd8544.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_tls8204.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ili9320.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_ili9486.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_hx8347d.ko
/lib/modules/3.18.0-29-rpi2/kernel/drivers/video/fbdev/fbtft/fb_upd161704.ko

ubuntu@ubuntu:~$ sudo modprobe fb_st7735r

ubuntu@ubuntu:~$ lsmod
Module                  Size  Used by
fb_st7735r             12730  0 
fbtft                  36135  1 fb_st7735r
syscopyarea            12353  1 fbtft
sysfillrect            12531  1 fbtft
sysimgblt              12373  1 fbtft
fb_sys_fops            12381  1 fbtft
snd_soc_bcm2708_i2s    13236  0 
regmap_mmio            12858  1 snd_soc_bcm2708_i2s
i2c_bcm2708            12672  0 
snd_soc_core          143663  1 snd_soc_bcm2708_i2s
snd_compress           17513  1 snd_soc_core
bcm2708_rng            12445  0 
spi_bcm2708            12686  0 
snd_pcm_dmaengine      12927  1 snd_soc_core
snd_bcm2835            23572  0 
snd_pcm                75238  3 snd_bcm2835,snd_soc_core,snd_pcm_dmaengine
snd_timer              26543  1 snd_pcm
snd                    51707  5 snd_bcm2835,snd_soc_core,snd_timer,snd_pcm,snd_compress
fuse                   78694  0 
ubuntu@ubuntu:~$ 

root@ubuntu:~# cat /etc/issue
Ubuntu 14.04.2 LTS \n \l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment