notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.85k stars 494 forks source link

ILI9320 vs ILI9341 #6

Closed tinogoehlert closed 11 years ago

tinogoehlert commented 11 years ago

Hello, i've received an LCD driven by an ILI9320. Is this IC compatible to the ILI9341 your project already supports? if not, i would like to take care of that one and contribute it to your project.

notro commented 11 years ago

No, I believe the init codes are different.

I'm currently writing a generic driver that can receive the init sequence as an argument when loading the driver. This will hopefully limit the need to write lots of drivers for different controllers and displays. If I'm successfull, it will be ready in a week or so. But nevertheless the init sequence is needed. So, some research and testing is needed.

I will add a comment here when I know how the generic driver turns out.

tinogoehlert commented 11 years ago

since i already have all the equipment i need to drive it technically with the Pi, i could provide you some of my research data when i start playing around with it. There is already a framebuffer driver out there.

http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/video/ili9320.h http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/drivers/video/backlight/ili9320.c

do you use googletalk or something? if you want to chat about this topic a little bit :-)

notro commented 11 years ago

That is just a backlight driver, not a framebuffer driver.

I have made that generic driver, but haven't made an image yet: https://github.com/notro/fbtft/wiki/flexfb There some info there about the ili9320 init sequence.

do you use googletalk or something? if you want to chat about this topic a little bit :-)

No, I don't

notro commented 11 years ago

I have uploaded a new image with the generic driver: https://github.com/notro/fbtft/wiki

tinogoehlert commented 11 years ago

Thank you very much :)

notro commented 11 years ago

Did you get anything working with the IILI9320?

tinogoehlert commented 11 years ago

sadly not, my dayjob dominates my time atm :-(

notro commented 11 years ago

hy28afb has ILI9320 support. It uses a 'Start byte' for SPI mode. If yours doesn't, you can use the flexfb driver. The new image will be relased on Friday

tinogoehlert commented 11 years ago

From the Datasheet:

"The SPI interface operation enables from the falling edge of nCS and ends of data transfer on the rising edge of nCS. The start byte is transferred to start the SPI interface and the read/write operation and RS information are also included in the start byte. When the start byte is matched, the subsequent data is received by ILI9320."

Sounds like my display uses start bytes :-(

Here are the Links:

Datasheet:

http://www.densitron.com/uploadedFiles/Displays/Support/ILI9320AN_V0.92.pdf

and here are some app notes wich could be used to generate the configuration for the flexfb driver?

http://www.densitron.com/uploadedFiles/Displays/Support/ILI9320AN_V0.92.pdf

Sorry for my dumb questions, but i didn't have worked with displays before.

tinogoehlert commented 11 years ago

sorry, copy paste error ..

here is the right datasheet link

http://www.techtoys.com.hk/Displays/TY240240320/ILI9320.pdf

notro commented 11 years ago

Sounds like my display uses start bytes

Yes, the ILI9320 apparently does that when using the SPI interface. Some controllers has 2 SPI modes, where one of them uses a Start byte.

If you have a display with SPI interface, you can try the hy28afb driver:

sudo modprobe fbtft_device name=hy28afb rotate=0
sudo modprobe hy28afb
FRAMEBUFFER=/dev/fb1 startx

Wiring: https://github.com/notro/fbtft/wiki/LCD-Modules#hy28a

tinogoehlert commented 11 years ago

hello, i've currently wired everything up and tried this module, because i've recogniced it's exactly that type :)

i can communicate with it, here is the dmesg:

[ 98.010836] fbtft_device: SPI devices registered: [ 98.010878] fbtft_device: spidev spi0.0 500kHz 8 bits mode=0x00 [ 98.010896] fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00 [ 98.010905] fbtft_device: 'fb' Platform devices registered: [ 98.010924] fbtft_device: bcm2708_fb id=-1 pdata? no [ 98.010971] fbtft_device: Deleting spi0.0 [ 98.013496] spi spi0.0: setup: want 32000000 Hz; bus_hz=250000000 / cdiv=8 == 31250000 Hz; mode 3: cs 0x0000000C [ 98.013531] spi spi0.0: setup: cd 0: 32000000 Hz, bpw 8, mode 0x3 -> CS=0000000c CDIV=0008 [ 98.013663] fbtft_device: GPIOS used by 'hy28afb': [ 98.013679] fbtft_device: 'reset' = GPIO25 [ 98.013689] fbtft_device: 'led' = GPIO18 [ 98.013698] fbtft_device: SPI devices registered: [ 98.013712] fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00 [ 98.013725] fbtft_device: hy28afb spi0.0 32000kHz 8 bits mode=0x03 [ 103.897088] hy28afb spi0.0: setup: want 2000000 Hz; bus_hz=250000000 / cdiv=125 == 2000000 Hz; mode 3: cs 0x0000000C [ 104.317119] graphics fb1: hy28afb frame buffer, 240x320, 150 KiB video memory

but i have a white screen all the time, is it a brightnes adjustment issue?

i've already tried all two commands in the wiki (adafruit display example)

i've currently use the current pins:

3V3 GND CS MISO MOSI SCKL RESET

tinogoehlert commented 11 years ago

oh, and thanks a very lot for your help and this project :)

notro commented 11 years ago

but i have a white screen all the time, is it a brightnes adjustment issue?

A white screen means it's not initialized properly. I should be black.

You could slow down the speed too see if that helps, and turn on debug output to see what the Device code is:

sudo modprobe fbtft_device name=hy28afb speed=16000000
sudo modprobe hy28afb debug=3
dmesg
... Device code: ??

Another thing you could try is that doesn't work, is to change the device id from 0 to 1:

sudo modprobe fbtft_device name=hy28afb speed=16000000 startbyte=$((2#01110100))

Remember to unload the module, before trying it with new arguments. It won't take effect if the module is already loaded.

sudo rmmod fbtft_device hy28afb

The --first-time argument will tell you if the module is already loaded:

sudo modprobe --first-time fbtft_device name=hy28afb

Do you have a link to a product page for this display?

tinogoehlert commented 11 years ago

here is the output (16mhz):

[ 55.019012] spi spi0.0: setup: want 16000000 Hz; bus_hz=250000000 / cdiv=16 == 15625000 Hz; mode 3: cs 0x0000000C [ 55.019046] spi spi0.0: setup: cd 0: 16000000 Hz, bpw 8, mode 0x3 -> CS=0000000c CDIV=0010 [ 55.019174] fbtft_device: GPIOS used by 'hy28afb': [ 55.019190] fbtft_device: 'reset' = GPIO25 [ 55.019201] fbtft_device: 'led' = GPIO18 [ 55.019208] fbtft_device: SPI devices registered: [ 55.019222] fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00 [ 55.019234] fbtft_device: hy28afb spi0.0 16000kHz 8 bits mode=0x03 [ 66.913360] [ 66.913360] [ 66.913360] hy28afb: hy28afb_init() [ 66.913448] hy28afb spi0.0: hy28afb_probe() [ 66.913698] hy28afb spi0.0: fbtft_request_gpios: 'reset' = GPIO25 [ 66.913722] hy28afb spi0.0: fbtft_request_gpios: 'led' = GPIO18 [ 66.913737] hy28afb spi0.0: hy28afb_init_display() [ 66.913750] hy28afb spi0.0: fbtft_reset() [ 67.039790] hy28afb spi0.0: setup: want 2000000 Hz; bus_hz=250000000 / cdiv=125 == 2000000 Hz; mode 3: cs 0x0000000C [ 67.039882] hy28afb spi0.0: Device code: 0x0000 [ 67.496973] hy28afb spi0.0: Elapsed time for display update: 94.821010 ms (fps: 10, lines=320) [ 67.497002] hy28afb spi0.0: fbtft_register_backlight() [ 67.500107] graphics fb1: hy28afb frame buffer, 240x320, 150 KiB video memory, 4 KiB buffer memory, fps=20, spi0.0 at 16 MHz [ 67.500143] hy28afb spi0.0: fbtft_backlight_update_status: polarity=1, power=0, fb_blank=0

display starts white.. when i load the driver it turns black.. than it goes back white after a second

tinogoehlert commented 11 years ago

the reseller was an ebay merchant from hongkong

tinogoehlert commented 11 years ago

awww damnit..

i've accidently connected the 5v (pin1) to the 5v from the raspberry.. could it be that it has fired 5v to one of the pi's ports and grilled it? :-/

edit:

tried another pi, same effect

notro commented 11 years ago

display starts white.. when i load the driver it turns black.. than it goes back white after a second

The driver turns the backlight off when it's starts and turns it back on when it has finished initializing.

Device code: 0x0000

This should be 0x9320 for an ILI9320 controller, when MISO is connected.

Do you have a schematic for the display module?

tinogoehlert commented 11 years ago

Sadly, i don't have any schematics exept these i've found from the original.. Maybe the replicate is simply defect. I have an original 3,2 saintsmart laying around so i can try it and check the pi side.. I will measure the miso, mosi and clock lines for the 2,8 and see if something is comming throught. Do you have a tip for another 2,8 inch display? Thanks for helping out :)

Another possible way is to wire the 2,8 inch to an arduino, i've found a sketch for it so it should'nt take too long to test it via 5v.

notro commented 11 years ago

Another possible way is to wire the 2,8 inch to an arduino, i've found a sketch for it so it should'nt take too long to test it via 5v.

It would help to know that the display is in working order.

vahidnoori commented 10 years ago

hi. i am going to config display inanbo t28-9320-v11 by raspbbery but i have some question :1.this display work by parallel can i use spi to parallel converter(introduced by valdodov) ??? 2.i am new in OS can you help me by guide step by step what do i do to inastall driver on rasbian? my display datasheet is : https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCUQFjAA&url=http%3A%2F%2Fwww.inanbo.com%2Fdownfile%2Ftft%2F28%2FINANBO-T28-ILI9320-V11.pdf&ei=26jkUt6yFbTesATE8oHQBw&usg=AFQjCNHXhG--gDSPXmt2XJI_VH8UN6a4Bw&bvm=bv.59930103,d.cWc

notro commented 10 years ago

1.this display work by parallel can i use spi to parallel converter(introduced by valdodov) ???

valdodov's circuit won't work with FBTFT. You have to use this: https://github.com/notro/fbtft/wiki/SPI-interface-circuit

2.i am new in OS can you help me by guide step by step what do i do to inastall driver on rasbian?

Install driver: https://github.com/notro/fbtft/wiki#wiki-install

I advice you to try it in 8-bit parallel mode first, before attempting the SPI circuit. sudo modprobe fbtft_device custom name=fb_ili9320 gpios=reset:XX,cs:XX,wr:XX,dc:XX,db00:XX....db07:XX debug=3 See: https://github.com/notro/fbtft/wiki/fbtft_device

On the display set IM0=1. Connect DB10-DB17 as db00-db07 Also set IM3=0 : I80

If you go the SPI route: sudo modprobe fbtft_device custom name=fb_ili9320 speed=8000000 gpios=reset:XX,dc:XX debug=3

vahidnoori commented 10 years ago

hi . thanks for your guide . but i designed valdodov spi to parallel converter . can u help me about driver(for ili9320) ? how can i make driver for this circuit?

On Tue, Jan 28, 2014 at 12:41 AM, notro notifications@github.com wrote:

1.this display work by parallel can i use spi to parallel converter(introduced by valdodov) ???

valdodov's circuit won't work with FBTFT. You have to use this: https://github.com/notro/fbtft/wiki/SPI-interface-circuit

2.i am new in OS can you help me by guide step by step what do i do to inastall driver on rasbian?

Install driver: https://github.com/notro/fbtft/wiki#wiki-install

I advice you to try it in 8-bit parallel mode first, before attempting the SPI circuit. sudo modprobe fbtft_device custom name=fb_ili9320 gpios=reset:XX,cs:XX,wr:XX,dc:XX,db00:XX....db07:XX debug=3 See: https://github.com/notro/fbtft/wiki/fbtft_device

On the display set IM0=1. Connect DB10-DB17 as db00-db07 Also set IM3=0 : I80

If you go the SPI route: sudo modprobe fbtft_device custom name=fb_ili9320 speed=8000000 gpios=reset:XX,dc:XX debug=3

Reply to this email directly or view it on GitHubhttps://github.com/notro/fbtft/issues/6#issuecomment-33423277 .

notro commented 10 years ago

I'm sorry, but I haven't got the time to look into the details to make that work.

vahidnoori commented 10 years ago

ok thanks. but one question . there is no connection for RS pin of TFT .why? what is connection of RS?

On Sat, Feb 1, 2014 at 4:01 PM, notro notifications@github.com wrote:

I'm sorry, but I haven't got the time to look into the details to make that work.

Reply to this email directly or view it on GitHubhttps://github.com/notro/fbtft/issues/6#issuecomment-33870341 .

notro commented 10 years ago

there is no connection for RS pin of TFT .why?

What are referring to as "there"?

vahidnoori commented 10 years ago

in this circuit :https://github.com/notro/fbtft/wiki/SPI-interface-circuit there are no connection for RS of TFT . what is RS connection in this circuit? thanks

On Mon, Feb 3, 2014 at 9:38 PM, notro notifications@github.com wrote:

there is no connection for RS pin of TFT .why?

What are referring to as "there"?

Reply to this email directly or view it on GitHubhttps://github.com/notro/fbtft/issues/6#issuecomment-33982012 .

notro commented 10 years ago

RS is straight through. RS is directly connected to the FBTFT 'dc' gpio.

vahidnoori commented 10 years ago

i dont know your word . where should be connected RS pin of my TFT exactly ? in your circuit there is no RS .

On Tue, Feb 4, 2014 at 3:51 PM, notro notifications@github.com wrote:

RS is straight through. RS is directly connected to the FBTFT 'dc' gpio.

Reply to this email directly or view it on GitHubhttps://github.com/notro/fbtft/issues/6#issuecomment-34054137 .

notro commented 10 years ago

I have updated the circuit.

vahidnoori commented 10 years ago

thanks for your guide . but what is 'dc' pin? 'DC/RS' pin go to TFT ,but 'dc'?

On Tue, Feb 4, 2014 at 5:08 PM, notro notifications@github.com wrote:

I have updated the circuit.

Reply to this email directly or view it on GitHubhttps://github.com/notro/fbtft/issues/6#issuecomment-34059518 .

notro commented 10 years ago

'dc' is the pinname used by FBTFT in the gpios parameter: https://github.com/notro/fbtft/wiki/fbtft_device#wiki-parameters

nagheid commented 9 years ago

I am facing a similar issue with the Adafruit 2.8" (ILI9341). The screen is completely white. I followed the debug steps above but don't have a "Device code" value:

$ sudo modprobe --first-time fbtft_device name=adafruit28 gpios=reset:23,dc:18 debug=3

$ dmesg [ 925.566958] fbtft_device: SPI devices registered: [ 925.567009] fbtft_device: spidev spi0.1 64000kHz 8 bits mode=0x00 [ 925.567025] fbtft_device: 'fb' Platform devices registered: [ 925.567080] fbtft_device: bcm2708_fb id=-1 pdata? no [ 925.570520] fbtft_device: GPIOS used by 'adafruit28': [ 925.570564] fbtft_device: 'reset' = GPIO23 [ 925.570580] fbtft_device: 'dc' = GPIO18 [ 925.570591] fbtft_device: SPI devices registered: [ 925.570609] fbtft_device: spidev spi0.1 64000kHz 8 bits mode=0x00 [ 925.570627] fbtft_device: fb_ili9341 spi0.0 32000kHz 8 bits mode=0x00 [ 925.604261] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned. [ 925.607623] fb_ili9341 spi0.0: fbtft_gamma_parse_str() str= [ 925.607672] fb_ili9341 spi0.0: 1F 1A 18 0A 0F 06 45 87 32 0A 07 02 07 05 00 [ 925.607672] 00 25 27 05 10 09 3A 78 4D 05 18 0D 38 3A 1F [ 925.607794] fb_ili9341 spi0.0: fbtft_request_gpios: 'reset' = GPIO23 [ 925.607839] fb_ili9341 spi0.0: fbtft_request_gpios: 'dc' = GPIO18 [ 925.607862] fb_ili9341 spi0.0: fbtft_verify_gpios() [ 925.607880] fb_ili9341 spi0.0: init_display() [ 925.607898] fb_ili9341 spi0.0: fbtft_reset() [ 925.856616] fb_ili9341 spi0.0: set_var() [ 925.925610] fb_ili9341 spi0.0: Display update: 2182 kB/s (68.724 ms), fps=0 (0.000 ms) [ 925.925652] fb_ili9341 spi0.0: set_gamma() [ 925.925909] fb_ili9341 spi0.0: fbtft_register_backlight() [ 925.925938] fb_ili9341 spi0.0: fbtft_register_backlight(): led pin not set, exiting. [ 925.927025] graphics fb1: fb_ili9341 frame buffer, 240x320, 150 KiB video memory, 16 KiB DMA buffer memory, fps=20, spi0.0 at 32 MHz

Your help will be greatly appreciated!

notro commented 9 years ago

If you have this: https://www.adafruit.com/product/1601 you should use name=pitft

nagheid commented 9 years ago

I have this: https://www.adafruit.com/products/1770

notro commented 9 years ago

Ok, the name is correct then. White display means that the display controller isn't initialized. In this case probably because of miswiring unless Adafruit has changed the controller/panel.

This is the default pin assignments:

                    { "reset", 25 },
                    { "dc", 24 },
                    { "led", 18 },

https://github.com/raspberrypi/linux/blob/rpi-3.18.y/drivers/staging/fbtft/fbtft_device.c#L262

nagheid commented 9 years ago

I followed this for the wiring: https://learn.adafruit.com/user-space-spi-tft-python-library-ili9341-2-8/wiring

So that's why I set custom gpios value in my command: $ sudo modprobe --first-time fbtft_device name=adafruit28 gpios=reset:23,dc:18 debug=3

Not sure about a led pin though as the adafruit wiring guide (linked above) didn't require such connection. So I left that empty

And I read on another issue that setting speed to 32000000 caused come problem so I tried with speed 16000000 but no luck

On other threads, the screen was mistakenly connected to the microcontroller's 5V pin but mine is connected to the 3.3V (3V3) as expected.

Any ideas on further debugging?

Also, thanks a lot for your prompt replies!

notro commented 9 years ago

@DougieLawson have you tried this display lately?

DougieLawson commented 9 years ago

It's tomorrow's project. Today I'm building a kernel to get my Wolfson audio card running on a B rev2 with the 3.18 kernel.

nagheid commented 9 years ago

Meanwhile, I'll try rewiring the DC and RST pins to the fbtft defaults and test again. Will keep you posted.

DougieLawson commented 9 years ago

@notro I downloaded the latest 3.18.11+-v7 kernel and tried this on my 2B.

config.txt has

dtparam=i2c_arm=on
max_usb_current=1
gpu_mem=128
start_x=1
dtoverlay=rpi-display,rotate=90```

I wired it with lite==GPIO18, DC==gpio23 RST==gpio24 

Tested with con2fbmap and FRAMEBUFFER=/dev/fb1 startx and it worked perfectly.
notro commented 9 years ago

Thanks Dougie. That was clever using the rpi-display overlay.

DougieLawson commented 9 years ago

I read the code and that overlay was the closest match. It's the one I'd have used as a template if I'd needed to make my own overlay. I think I understand this DT and overlay stuff now.

notro commented 9 years ago

And suddenly it dawned on me: This will load an ads7846 device as well... Probably not a big deal unless spi0.1 is needed. The ads7846 driver doesn't check to see if anything is connected, so probing will succeed and it sets up an interrupt on gpio25. cat /proc/interrupts will show if any interrupts are triggered, but I don't think it will.

DougieLawson commented 9 years ago
root@eagle ~ # cat /proc/interrupts
           CPU0       CPU1       CPU2       CPU3
 16:          0          0          0          0   ARMCTRL  16  bcm2708_fb dma
 24:       6471          0          0          0   ARMCTRL  24  DMA IRQ
 25:       2827          0          0          0   ARMCTRL  25  DMA IRQ
 32:    1549059          0          0          0   ARMCTRL  32  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 49:          0          0          0          0   ARMCTRL  49  3f200000.gpio:bank0
 50:          0          0          0          0   ARMCTRL  50  3f200000.gpio:bank1
 65:         18          0          0          0   ARMCTRL  65  ARM Mailbox IRQ
 66:     498274          0          0          0   ARMCTRL  66  VCHIQ doorbell
 75:          1          0          0          0   ARMCTRL  75
 79:          0          0          0          0   ARMCTRL  79  3f804000.i2c
 80: 2524810498          0          0          0   ARMCTRL  80  3f204000.spi
 84:      54932          0          0          0   ARMCTRL  84  mmc0
 99:    1018276     315120     312999      51354   ARMCTRL  99  arch_timer
505:          0          0          0          0  pinctrl-bcm2835  25  ads7846
FIQ:              usb_fiq
IPI0:          0          0          0          0  CPU wakeup interrupts
IPI1:          0          0          0          0  Timer broadcast interrupts
IPI2:    1966358   18894542   16494151    7862332  Rescheduling interrupts
IPI3:          7         11          8          8  Function call interrupts
IPI4:          1          5          0          0  Single function call interrupts
IPI5:          0          0          0          0  CPU stop interrupts
IPI6:          0          0          0          0  IRQ work interrupts
IPI7:          0          0          0          0  completion interrupts
Err:          0
root@eagle ~ #

Do we need a new DT overlay?

notro commented 9 years ago

There's no interrupt triggered, so as long as the pin is floating the driver just sits idle. But it's not desirable to have such a setup.

Do we need a new DT overlay?

I have only made overlays for Pi display HATs/shields that I have and none of the other displays. If I were to use a display that doesn't have an overlay, I would use fbtft_device.

/boot/config.txt

dtparam=spi=on

/etc/modules

fbtft_device name=adafruit28 gpios=reset:24,dc:23,led:18