百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

fbcp-ili9341

> 编程语言
开源

一个运行速度极快的驱动程序,用于基于 SPI 的 LCD 显示器,适用于 Raspberry Pi A、B、2、3、4 和 Zero

1.8K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个运行速度极快的驱动程序,用于基于 SPI 的 LCD 显示器,适用于 Raspberry Pi A、B、2、3、4 和 Zero

Feb 2024 Update

The era of fbcp-ili9341 has come to an end. Fbcp-ili9341 was built on top of the Raspberry Pi's VideoCore DispmanX API.

However, this API has been deprecated by the Raspberry Pi Foundation for a while now, and finally obsolete (=unavailable) on Raspberry Pi 5 and onwards.

The later Raspberry Pi distros no longer have DispmanX active by default even for Pi0-Pi4, but instead Raspberry Pi has moved over to the newer KMS driver compositor stack, which has a different abstraction for integrating SPI display drivers. Other people are developing SPI display drivers for the Pi that are compatible with the KMS stack. Head on to this Raspberry Pi forum thread to learn more.

This repository is good to be considered archived/stale, although I am not marking it Archived using the GitHub feature, since that feature apparently would also make the issue tracker read-only. Feel free to continue discussing issues on the tracker.

Introduction

This repository implements a driver for certain SPI-based LCD displays for Raspberry Pi A, B, 2, 3, 4 and Zero.

The work was motivated by curiosity after seeing this series of videos on the RetroManCave YouTube channel:

  • RetroManCave: Waveshare 3.5" Raspberry Pi Screen | Review
  • RetroManCave: Waveshare 3.2" vs 3.5" LCD screen gaming test | Raspberry Pi / RetroPie
  • Elecrow 5 Inch LCD Review | RetroPie & Raspberry Pi

In these videos, the SPI (GPIO) bus is referred to being the bottleneck. SPI based displays update over a serial data bus, transmitting one bit per clock cycle on the bus. A 320x240x16bpp display hence requires a SPI bus clock rate of 73.728MHz to achieve a full 60fps refresh frequency. Not many SPI LCD controllers can communicate this fast in practice, but are constrained to e.g. a 16-50MHz SPI bus clock speed, capping the maximum update rate significantly. Can we do anything about this?

The fbcp-ili9341 project started out as a display driver for the Adafruit 2.8" 320x240 TFT w/ Touch screen for Raspberry Pi display that utilizes the ILI9341 controller. On that display, fbcp-ili9341 can achieve a 60fps update rate, depending on the content that is being displayed. Check out these videos for examples of the driver in action:

  • fbcp-ili9341 frame delivery smoothness test on Pi 3B and Adafruit ILI9341 at 119Hz
  • Latency and tearing test #2: GPIO input to display latency in fbcp-ili9341 and tearing modes
  • Latency and tearing test: KeDei 3.5" 320x480 HDMI vs Adafruit 2.8" PiTFT ILI9341 240x320 SPI
  • fbcp-ili9341 ported to ILI9486 WaveShare 3.5" (B) SpotPear 320x480 SPI display
  • Quake 60 fps inside Gameboy Advance (ILI9341)
  • First implementation of a statistics overlay: fbcp-ili9341 SPI display driver on Adafruit PiTFT 2.8"
  • Initial proof of concept video: fbcp-ili9341 driver first demo

How It Works

Given that the SPI bus can be so constrained on bandwidth, how come fbcp-ili9341 seems to be able to update at up to 60fps? The way this is achieved is by what could be called adaptive display stream updates. Instead of uploading each pixel at each display refresh cycle, only the actually changed pixels on screen are submitted to the display. This is doable because the ILI9341 controller, as many other popular controllers, have communication interface functions that allow specifying partial screen updates, down to subrectangles or even individual pixel levels. This allows beating the bandwidth limit: for example in Quake, even though it is a fast pacing game, on average only about 46% of all pixels on screen change each rendered frame. Some parts, such as the UI stay practically constant across multiple frames.

Other optimizations are also utilized to squeeze out even more performance:

  • The program directly communicates with the BCM2835 ARM Peripherals controller registers, bypassing the usual Linux software stack.
  • A hybrid of both Polled Mode SPI and DMA based transfers are utilized. Long sequential transfer bursts are performed using DMA, and when DMA would have too much latency, Polled Mode SPI is applied instead.
  • Undocumented BCM2835 features are used to squeeze out maximum bandwidth: SPI CDIV is driven at even numbers (and not just powers of two), and the SPI DLEN register is forced in non-DMA mode to avoid an idle 9th clock cycle for each transferred byte.
  • Good old interlacing is added into the mix: if the amount of pixels that needs updating is detected to be too much that the SPI bus cannot handle it, the driver adaptively resorts to doing an interlaced update, uploading even and odd scanlines at subsequent frames. Once the number of pending pixels to write returns to manageable amounts, progressive updating is resumed. This effectively doubles the maximum display update rate. (If you do not like the visual appearance that interlacing causes, it is easy to disable this by uncommenting the line #define NO_INTERLACING in file config.h)
  • A dedicated SPI communication thread is used in order to keep the SPI bus active at all times.
  • A number of other micro-optimization techniques are used, such as batch updating rectangular spans of pixels, merging disjoint-but-close spans of pixels on the same scanline, and latching Column and Page End Addresses to bottom-right corner of the display to be able to cut CASET and PASET messages in mid-communication.

The result is that the SPI bus can be kept close to 100% saturation, ~94-97% usual, to maximize the utilization rate of the bus, while only transmitting practically the minimum number of bytes needed to describe each new frame.

Tested Devices

The driver has been checked to work (at least some point in the past) on the following systems:

  • Raspberry Pi 3 Model B+ with Raspbian Stretch (GCC 6.3.0)
  • Raspberry Pi 3 Model B Rev 1.2 with Raspbian Jessie (GCC 4.9.2) and Raspbian Stretch (GCC 6.3.0)
  • Raspberry Pi Zero W with Raspbian Jessie (GCC 4.9.2) and Raspbian Stretch (GCC 6.3.0)
  • Raspberry Pi 2 Model B
  • Raspberry Pi B Rev. 2.0 (old board from Q4 2012, board revision ID 000e)

although not all boards are actively tested on, so ymmv especially on older boards. (Bug fixes welcome, use https://elinux.org/RPi_HardwareHistory to identify which board you are running on)

Tested Displays

The following LCD displays have been tested:

  • Adafruit 2.8" 320x240 TFT w/ Touch screen for Raspberry Pi with ILI9341 controller
  • Adafruit PiTFT 2.2" HAT Mini Kit - 320x240 2.2" TFT - No Touch with ILI9340 controller
  • Adafruit PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi with HX8357D controller
  • Adafruit 128x96 OLED Breakout Board - 16-bit Color 1.27" w/microSD holder with SSD1351 controller
  • Waveshare 3.5inch RPi LCD (B) 320*480 Resolution Touch Screen IPS TFT Display with ILI9486 controller
  • maithoga 3.5 inch 8PIN SPI TFT LCD Color Screen with Adapter Board ILI9486 with ILI9486L controller
  • BuyDisplay.com 320x480 Serial SPI 3.2"TFT LCD Module Display with ILI9341 controller
  • Arduino A000096 1.77" 160x128 LCD Screen with ST7735R controller
  • Tontec 3.5" 320x480 LCD Display with MZ61581-PI-EXT 2016.1.28 controller
  • Adafruit 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD with ST7789 controller
  • Pirate Audio 240x240, 1.3inch IPS LCD display HAT for Raspberry Pi with ST7789 controller
  • WaveShare 240x240, 1.3inch IPS LCD display HAT for Raspberry Pi with ST7789VW controller
  • WaveShare 128x128, 1.44inch LCD display HAT for Raspberry Pi with ST7735S controller
  • KeDei 3.5 inch SPI TFTLCD 480*320 16bit/18bit version 6.3 2018/4/9 with MPI3501 controller
  • Unbranded 2.8" 320x240 display with ILI9340 controller

Installation

Check the following sections to set up the driver.

Boot configuration

This driver does not utilize the notro/fbtft framebuffer driver, so that needs to be disabled if active. That is, if your /boot/config.txt file has lines that look something like dtoverlay=pitft28r, ..., dtoverlay=waveshare32b, ... or dtoverlay=flexfb, ..., those should be removed.

This program neither utilizes the default SPI driver, so a line such as dtparam=spi=on in /boot/config.txt should also be removed so that it will not cause conflicts.

Likewise, if you have any touch controller related dtoverlays active, such as dtoverlay=ads7846,... or anything that has a penirq= directive, those should be removed as well to avoid conflicts. It would be possible to add touch support to fbcp-ili9341 if someone wants to take a stab at it.

Building and running

Run in the console of your Raspberry Pi:

sudo apt-get install cmake
cd ~
git clone https://github.com/juj/fbcp-ili9341.git
cd fbcp-ili9341
mkdir build
cd build
cmake [options] ..
make -j
sudo ./fbcp-ili9341

Note especially the two dots .. on the CMake line, which denote "up one directory" in this case (instead of referring to "more items go here").

See the next section to see what to input under [options].

If you have been running existing fbcp driver, make sure to remove that e.g. via a sudo pkill fbcp first (while running in SSH prompt or connected to a HDMI display), these two cannot run at the same time. If /etc/rc.local or /etc/init.d contains an entry to start up fbcp at boot, that directive should be deleted.

Configuring build options

There are generally two ways to configure build options, at CMake command line, and in the file config.h.

On the CMake command line, the following options can be configured:

If you have a display Add-On Hat

When using one of the displays that stack on top of the Pi that are already recognized by fbcp-ili9341, you don't need to specify the GPIO pin assignments, but fbcp-ili9341 code already has those. Pass one of the following CMake directives for the hats:

  • -DADAFRUIT_ILI9341_PITFT=ON: If you are running on the Adafruit 2.8" 320x240 TFT w/ Touch screen for Raspberry Pi (or the Adafruit PiTFT 2.2" HAT Mini Kit - 320x240 2.2" TFT - No Touch display, which is compatible), pass this flag.
  • -DADAFRUIT_HX8357D_PITFT=ON: If you have the Adafruit PiTFT - Assembled 480x320 3.5" TFT+Touchscreen for Raspberry Pi display, add this line.
  • `-DFREEPLAYTE

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言