mrburns42
Posts: 25
Joined: Thu Jan 24, 2013 7:00 pm

TFT Drivers Under Jessie

Thu Jun 30, 2016 12:22 pm

I have a 3.2 inch LCD for the PI. Ironically, the Model Name is "Plug and Play" . It is not. It works with some Wheezy images from the Internet, but I want to install just the drivers under Jessie.

I followed the instructions at:

http://futurice.com/blog/id-like-to-hav ... d-on-my-pi

However, when I rebooted, it was not working and I got a failed to load modules error in dmesg. I could find nothing specific in the logs as to what caused the errors. However, if I remove both of the two lines that I added to /etc/modules, then the fail message goes away. Below is my current modules file.

Code: Select all

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
#spi-bcm2708
#fbtft_device name=flexfb gpios=dc:22,reset:21 speed=48000000
#flexfb width=320 height=240 buswidth=8 init=-1,0xCB,0x39,0x2C,0x00,0x34,0x02,-$
#ads7846_device model=7846 cs=1 gpio_pendown=17  speed=1000000 keep_vref_on=1 s$

If I take the commands out of /etc/modules and run with after boot with modprobe then it works.

Code: Select all

sudo modprobe -v fbtft_device name=flexfb gpios=dc:22,reset:21 speed=48000000

sudo modprobe  -v flexfb width=320 height=240 buswidth=8 init=-1,0xCB,0x39,0x2C,0x00,0x34,0x02,-1,0xCF,0x00,0XC1,0X30,-1,0xE8,0x85,0x00,0x78,-1,0xEA,0x00,0x00,-1,0xED,0x64,0x03,0X12,0X81,-1,0xF7,0x20,-1,0xC0,0x23,-1,0xC1,0x10,-1,0xC5,0x3e,0x28,-1,0xC7,0x86,-1,0x36,0x28,-1,0x3A,0x55,-1,0xB1,0x00,0x18,-1,0xB6,0x08,0x82,0x27,-1,0xF2,0x00,-1,0x26,0x01,-1,0xE0,0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,0x0E,0x09,0x00,-1,0XE1,0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,0x08,0x0F,0x0C,0x31,0x36,0x0F,-1,0x11,-2,120,-1,0x29,-1,0x2c,-3
The only thing I can think of is that perhaps the SPI driver is not loaded yet and that is what is causing the drivers return errors.

The touch screen portion of the display, I loaded as an overlay as the link quoted above told me to do. That functions, but still needs some calibration.

Questions:
1. Instructions say that Device Tree has to be enabled in raspi-config. Yet my version, which is supposed to be up to date, has no such option under Advanced. Where do I enable it?
2. Is there an overlay driver for a flexfb TFT LCD?
3. Is there a way to force the spi_bcm2708 driver to load before it attempts to load the flexfb drivers for the LCD? The command spi_bcm2708 was added to /etc/modules like was done in the Wheezy version, but that seemed to have no effect. So either it is ignored, or the driver is already loaded? (It is commented out above, because I wanted to verify that some other portion of code is loading it.)
4. Done Jessie work with all versions of PI? The one that I am using is a early revision Model B. (Note: reset for these is normally pin 25, I have to change it to pin 21, since there was a pinout change after the early revision of Model B.)

Thanks.
--- Steve

DirkS
Posts: 10759
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: TFT Drivers Under Jessie

Thu Jun 30, 2016 12:46 pm

mrburns42 wrote:1. Instructions say that Device Tree has to be enabled in raspi-config. Yet my version, which is supposed to be up to date, has no such option under Advanced. Where do I enable it?

You're probably using kernel version 4.4.y. Device tree has to be enabled, and the option has been removed from raspi-config a while ago.
2. Is there an overlay driver for a flexfb TFT LCD?
There is no such thing as a 'flexfb TFT LCD'. This was a 'catch all' for TFTs that did not have any dedicated drivers.
3. Is there a way to force the spi_bcm2708 driver
Enable SPI in raspi-config. Don't add any spi related stuff in /etc/modules
4. Done Jessie work with all versions of PI?
Yes, I have it running happily in a Model B rev 0002[/quote]

Instructions / options on how to install your screen depends on exactly what make / model you have.
Do you have a link to the screen? or maybe a hi-res image of the front and the back?

mrburns42
Posts: 25
Joined: Thu Jan 24, 2013 7:00 pm

Re: TFT Drivers Under Jessie

Thu Jun 30, 2016 6:03 pm

Thanks for the reply Dirk.
I bought the LCD from Ebay. The seller is worthless for support. I believe he bought from Banggood.

http://www.banggood.com/3_2-Inch-TFT-LC ... 11516.html

I found this link on the web and tried to follow what they did:

http://www.gooligum.com.au/blog-section/TFT-28-setup

My /etc/modules is now:

Code: Select all

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
spi-bcm2708
fbtft_device
I have to keep the spi-bcm2708 or it fails to load the module.

I added /etc/modprobe.d/fbtst.conf. It contains one line below:

Code: Select all

options fbtft_device name=flexfb gpios=dc:22,reset:21 speed=48000000 width=320 height=240 buswidth=8 init=-1,0xCB,0x39,0x2C,0x00,0x34,0x02,-1,0xCF,0x00,0XC1,0X30,-1,0xE8,0x85,0x00,0x78,-1,0xEA,0x00,0x00,-1,0xED,0x64,0x03,0X12,0X81,-1,0xF7,0x20,-1,0xC0,0x23,-1,0xC1,0x10,-1,0xC5,0x3e,0x28,-1,0xC7,0x86,-1,0x36,0x28,-1,0x3A,0x55,-1,0xB1,0x00,0x18,-1,0xB6,0x08,0x82,0x27,-1,0xF2,0x00,-1,0x26,0x01,-1,0xE0,0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,0x0E,0x09,0x00,-1,0XE1,0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,0x08,0x0F,0x0C,0x31,0x36,0x0F,-1,0x11,-2,120,-1,0x29,-1,0x2c,-3
The original modprobe commands were done in two pieces. I tried to concatenate these together, but I guess I did it wrong. Only a portion of these options are being used. Below is what I get from dmesg when I grep for flex:

Code: Select all

pi@raspberrypi:~ $ dmesg | grep flex
[    4.391890] fbtft_device:  GPIOS used by 'flexfb':
[    4.471666] fbtft_device:      flexfb spi0.0 48000kHz 8 bits mode=0x00
pi@raspberrypi:~ $ dmesg | grep fbtft
[    4.265300] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    4.304810] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[    4.329684] fbtft_device:  SPI devices registered:
[    4.341968] fbtft_device:      ads7846 spi0.1 500kHz 8 bits mode=0x00
[    4.348498] fbtft_device:  'fb' Platform devices registered:
[    4.381793] fbtft_device:      soc:fb id=-1 pdata? no
[    4.391890] fbtft_device:  GPIOS used by 'flexfb':
[    4.396767] fbtft_device:    'dc' = GPIO22
[    4.400894] fbtft_device:    'reset' = GPIO21
[    4.421669] fbtft_device:  SPI devices registered:
[    4.426569] fbtft_device:      ads7846 spi0.1 500kHz 8 bits mode=0x00
[    4.471666] fbtft_device:      flexfb spi0.0 48000kHz 8 bits mode=0x00


If I log into the PI and run the second modprobe command shown my post above, then display starts working. So I am closer, but still not all the way there.

mrburns42
Posts: 25
Joined: Thu Jan 24, 2013 7:00 pm

Re: TFT Drivers Under Jessie

Fri Jul 01, 2016 5:47 pm

FIXED!!!! I found the answer in another topic.

http://appdictive.dk/blog/projects/2015 ... pberry_pi/

In that topic scroll down until you get to the comments by Luca Lucy Bernardi . There you will find all the steps.

1. Remove anything added to /etc/modules
2. Create /etc/modules-load.d/fbtft.conf Add these lines:

Code: Select all

spi-bcm2835
flexfb
fbtft_device
3. Create /etc/modprobe.d/fbtft.conf Add these lines:

Code: Select all

options  fbtft_device name=flexfb gpios=dc:22,reset:21 speed=48000000
options flexfb width=320 height=240 buswidth=8 init=-1,0xCB,0x39,0x2C,0x00,0x34,0x02,-1,0xCF,0x00,0XC1,0X30,-1,0xE8,0x85,0x00,0x78,-1,0xEA,0x00,0x00,-1,0xED,0x64,0x03,0X12,0X81,-1,0xF7,0x20,-1,0xC0,0x23,-1,0xC1,0x10,-1,0xC5,0x3e,0x28,-1,0xC7,0x86,-1,0x36,0x28,-1,0x3A,0x55,-1,0xB1,0x00,0x18,-1,0xB6,0x08,0x82,0x27,-1,0xF2,0x00,-1,0x26,0x01,-1,0xE0,0x0F,0x31,0x2B,0x0C,0x0E,0x08,0x4E,0xF1,0x37,0x07,0x10,0x03,0x0E,0x09,0x00,-1,0XE1,0x00,0x0E,0x14,0x03,0x11,0x07,0x31,0xC1,0x48,0x08,0x0F,0x0C,0x31,0x36,0x0F,-1,0x11,-2,120,-1,0x29,-1,0x2c,-3 
Remember that each options command MUST be on unique single line in the file!
4. Reboot

Please note: I had already tried several other install files on that particular image of Jessie. Doing uname -A, I got 4.0.7+. Since that seemed old, I took a new SD card and installed another clean image of Jessie. uname -A now shows 4.4.11+ If you have problems with the above steps, you may have to update the kernel. It appears that this kernel has the needed flexfb driver, so all that is required are the additions of the configuration.
Also, this PI is an old version with RESET on GPIO 21, newer PIs have this on GPIO25, so adjust your configuration accordingly.

DirkS
Posts: 10759
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: TFT Drivers Under Jessie

Sat Jul 02, 2016 11:56 am

Great! Just one change I would make:
It should be sufficient to enable SPI in config.txt (manually or using raspi-config).
You should not have the line 'spi-bcm2835' in /etc/modules.

mrburns42
Posts: 25
Joined: Thu Jan 24, 2013 7:00 pm

Re: TFT Drivers Under Jessie

Tue Jul 05, 2016 11:50 am

In etc/modules, there is no spi driver. However, in /etc/modules-load.d/fbtft.conf, the line spi-bcm2835 seems to be required. The spi driver has to be loaded before it attempts to load the flexfb driver. If I remove the spi-bcm2835 then the LCD fails to work and dmesg contains.

Code: Select all

[    5.302846] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    5.354603] flexfb: module is from the staging directory, the quality is unknown, you have been warned.
[    5.380174] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[    5.423636] bcm2708_fb soc:fb: soc:fb id=-1 pdata? no
[    5.431108] fbtft_device: spi_busnum_to_master(0) returned NULL
[    5.439191] fbtft_device: failed to register SPI device
[I did not figure out the spi-bcm2835 was needed there. Luca Bernardi discovered that. I just cribbed off his instructions. ]

Return to “Troubleshooting”