New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for tft 3.6" ili9325 #254

Open
ont opened this Issue Mar 3, 2015 · 83 comments

Comments

Projects
None yet
@ont

ont commented Mar 3, 2015

I recently bought 3.6 " lcd screen for my raspberry b+ but I can't figure out how to use it with one of your drivers.
front
back

I successfully install custom image with precompiled kernel from win32_screem.rar. Custom image is raspbian with 3.6.11 linux kernel:

root@raspberrypi:/# uname -a
Linux raspberrypi 3.6.11 #5 PREEMPT Sun Nov 9 19:00:34 CST 2014 armv6l GNU/Linux

There is some magical tft driver which is compiled into the kernel (no .ko files on device).
By searching in /sys dir I found this references

root@raspberrypi:/# find -name '*932*'
./sys/bus/platform/devices/ili9325.0
./sys/bus/platform/drivers/ili9325
./sys/bus/platform/drivers/ili9325/ili9325.0
./sys/devices/platform/ili9325.0

root@raspberrypi:/sys/bus/platform/devices/ili9325.0/graphics/fb0# ls -la
total 0
drwxr-xr-x 3 root root    0 Nov  9 08:37 .
drwxr-xr-x 3 root root    0 Nov  9 08:37 ..
-rw-r--r-- 1 root root 4096 Nov  9 10:20 bits_per_pixel
-rw-r--r-- 1 root root 4096 Nov  9 10:20 blank
-rw-r--r-- 1 root root 4096 Nov  9 10:20 console
-rw-r--r-- 1 root root 4096 Nov  9 10:20 cursor
-r--r--r-- 1 root root 4096 Nov  9 10:20 dev
lrwxrwxrwx 1 root root    0 Nov  9 10:20 device -> ../../../ili9325.0
-rw-r--r-- 1 root root 4096 Nov  9 10:20 mode
-rw-r--r-- 1 root root 4096 Nov  9 10:20 modes
-r--r--r-- 1 root root 4096 Nov  9 10:20 name
-rw-r--r-- 1 root root 4096 Nov  9 10:20 pan
drwxr-xr-x 2 root root    0 Nov  9 08:37 power
-rw-r--r-- 1 root root 4096 Nov  9 10:20 rotate
-rw-r--r-- 1 root root 4096 Nov  9 10:20 state
-r--r--r-- 1 root root 4096 Nov  9 10:20 stride
lrwxrwxrwx 1 root root    0 Nov  9 10:20 subsystem -> ../../../../../class/graphics
-rw-r--r-- 1 root root 4096 Nov  9 10:20 uevent
-rw-r--r-- 1 root root 4096 Nov  9 10:20 virtual_size

Some info from this frame buffer:

name --> ILI9325
bits_per_pixel -->  16
modes --> U:400x240p-0
virtual_size --> 400,240
root@raspberrypi:/# fbset -i -fb /dev/fb0 

mode "400x240"
    geometry 400 240 400 240 16
    timings 0 0 0 0 0 0 0
    rgba 5/11,6/5,5/0,0/0
endmode

Frame buffer device information:
    Name        : ILI9325
    Address     : 0xdc804000
    Size        : 192512
    Type        : PACKED PIXELS
    Visual      : TRUECOLOR
    XPanStep    : 0
    YPanStep    : 0
    YWrapStep   : 0
    LineLength  : 800
    Accelerator : No

The problem is that I have no success with your fb_ili9325 driver. It results with errors in dmesg and white screen. I try this commands:

modprobe fbtft_device name=ili9325
modprobe fbtft_device name=fb_ili9325

I figure out wich pins is used by this lcd (# is in use):

   3.3v  1 # . 2
         3 . . 4
         5 . # 6   ground
 GPCLK   7 # . 8
         9 . . 10
 GPIO0  11 # # 12  PCM_CLK / PCM0
        13 . . 14
 GPIO3  15 # # 16  GPIO4
        17 . # 18  GPIO5
  MOSI  19 # . 20
  MISO  21 # # 22  GPIO6
  SCLK  23 # # 24  CS0
        25 . # 26  CS1

Absence of one of this pins results (in most cases) in white flashing screen.
How to detect purposes of each of this pins? Can you help me with correcting your ili9325 diver?

@notro

This comment has been minimized.

Owner

notro commented Mar 3, 2015

They obviously use the fb_ili9325 driver, but with a custom init sequence.
Add this to /boot/cmdline.txt and dmesg will give you more info:

fbtft_device.debug=7
@ont

This comment has been minimized.

ont commented Mar 4, 2015

I read https://github.com/notro/fbtft/blob/master/fbtft_device.c more carefully. As I understand a correct command for my display should be one of this variants:

modprobe fbtft_device name=hy28b debug=7
modprobe fbtft_device name=itdb28 debug=7
modprobe fbtft_device name=itdb28_spi debug=7

For each of this commands module is successfully loaded (no error "ERROR: could not insert 'fbtft_device': Invalid argument") but lcd screen is still white.

Dmesg contains no errors for hy28b. For itdb28 there are:

[  150.773288] fb_ili9325 fb_ili9325.0: fbtft_verify_gpios()
[  150.773312] fb_ili9325 fb_ili9325.0: Missing info about 'dc' gpio. Aborting.
[  150.773415] fb_ili9325: probe of fb_ili9325.0 failed with error -22

For itdb28_spi there is message about led pin:

[   77.014483] fb_ili9325 spi0.0: fbtft_register_backlight()
[   77.014511] fb_ili9325 spi0.0: fbtft_register_backlight(): led pin not set, exiting.
[   77.015526] graphics fb1: fb_ili9325 frame buffer, 240x320, 150 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 32 MHz

For each command I do full device reboot. SPI is enabled in raspi-config. And in /boot/config.txt line is present:

dtparam=spi=on
@notro

This comment has been minimized.

Owner

notro commented Mar 4, 2015

You have to enable debug output on the custom image to see the setup they have used.
I said level 7, but that isn't good if the console is set to use the tft, so use 3 instead:
fbtft_device.debug=3

If that doesn't give you anything, they might be using Device Tree. If so try this (it should work but it's a long time since I tried this argument to fbtft):
fbtft.debug=3

@ont

This comment has been minimized.

ont commented Mar 5, 2015

Still no luck... Nothing appeared in dmesg output. My current cmdline.txt of custom kernel:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbtft_device.debug=3 bcm2708_fb.debug=3 bcm2708.debug=3 fbtft.debug=3

Output of /proc/cmdline is more intresting and contains references to bcm2708_fb:

dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x10 bcm2708.serial=0xc1db745d smsc95xx.macaddr=B8:27:EB:DB:74:5D bcm2708.disk_led_gpio=47 bcm2708.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbtft_device.debug=3 bcm2708_fb.debug=3 bcm2708.debug=3 fbtft.debug=3

Full list of kernel modules (lsmod):

Module                  Size  Used by
snd_bcm2835            16304  0 
snd_pcm                77560  1 snd_bcm2835
snd_page_alloc          5145  1 snd_pcm
snd_seq                53329  0 
snd_seq_device          6438  1 snd_seq
snd_timer              19998  2 snd_pcm,snd_seq
snd                    58503  5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
leds_gpio               2235  0 
led_class               3562  1 leds_gpio

And some blacklisted modules (/etc/modprobe.d/raspi-blacklist.conf):

blacklist spi-bcm2708
blacklist i2c-bcm2708
blacklist snd-soc-pcm512x
blacklist snd-soc-wm8804

Grepping for bcm2708_fb gives this output:

./sys/devices/platform/bcm2708_fb/modalias
./sys/devices/platform/bcm2708_fb/uevent
./boot/cmdline.txt  -- my bcm2708_fb.debug=3
./boot/start.elf
./boot/start_cd.elf
./boot/start_x.elf
./lib/modules/3.12.28+/modules.builtin
./var/log/dmesg
./var/log/Xorg.0.log.old
./var/log/Xorg.0.log
./var/log/syslog
./var/log/kern.log
./var/log/messages
./var/log/dmesg.0
root@raspberrypi:/sys/devices/platform/bcm2708_fb/subsystem/drivers# ls
alarmtimer    bcm2708_sdhci  bcm2835_AUD2  bcm2835_AUD6     ili9325
arm-pmu       bcm2708_vcio   bcm2835_AUD3  bcm2835_AUD7     leds-gpio
bcm2708_dma   bcm2835_AUD0   bcm2835_AUD4  bcm2835_thermal
bcm2708_gpio  bcm2835_AUD1   bcm2835_AUD5  dwc_otg

This is also may be interesting (uname -a returns 3.6.11)

root@raspberrypi:/lib/modules/3.12.28+# cat modules.builtin
....
kernel/drivers/video/bcm2708_fb.ko
....

modules.builtin doesn't contain references to ili9325

@notro

This comment has been minimized.

Owner

notro commented Mar 5, 2015

I suggest you contact the seller to get the correct setup.

@keerttttt

This comment has been minimized.

keerttttt commented Mar 23, 2015

I want to buy the same screen. What is the framerate, is it okay?

@ont

This comment has been minimized.

ont commented Mar 24, 2015

Frame rate is good. Visually there is no flickering when I run glxheads mesa-utils test program. It is hard to test with real videos because decoding of usual video codecs eats all cpu of raspberry pi and frame rate is near zero.

@keerttttt

This comment has been minimized.

keerttttt commented Mar 24, 2015

Why does it eat 100% CPU? It has gpu video decoding right?
Op 24 mrt. 2015 17:31 schreef "ont" notifications@github.com:

Frame rate is good. Visually there is no flickering when I run glxheads
mesa-utils test program. It is hard to test with real videos because
decoding of usual video codecs eats all cpu of raspberry pi and frame rate
is near zero.


Reply to this email directly or view it on GitHub
#254 (comment).

@ont

This comment has been minimized.

ont commented Mar 25, 2015

I don't research this question yet. Fast googling reveal this link https://wiki.matthiasbock.net/index.php/Hardware-accelerated_video_playback_on_the_Raspberry_Pi I simply try to open *.mp4 file with vlc player. Seems that vlc doesn't use gpu out of the box.

@aparaske

This comment has been minimized.

aparaske commented Mar 28, 2015

Did you have any luck using this with NRF24L01 (SPI device). I can see that there's traces coming from both CS0 and CS1. Does that mean that the display uses both? The display would be useless to me if I can't use another SPI device.

@ont

This comment has been minimized.

ont commented Apr 2, 2015

Yes, this display uses both CS0 and CS1 pins. Also I have problems with control of some non-SPI GPIO pins when I use custom raspbian image. Possibly you need to build SPI interface from free GPIO pins manually.

@aparaske

This comment has been minimized.

aparaske commented Apr 2, 2015

Do you know if it has been done before? I've looked and haven't found anything.

@keerttttt

This comment has been minimized.

keerttttt commented Apr 28, 2015

I got this datasheet for this device from the manufacturer, with the wiring that is used. With this information (by the way, i think it is a ILI9327 device), is it possible to get this thing working with fbtft?

See the pdf:

http://www.ranked.nl/pi-36-raspberry.pdf

@ont

This comment has been minimized.

ont commented Apr 28, 2015

@keerttttt very interesting! But this scheme lack information about pins on J2 (44-9327-08). Are you sure that this device is ILI9327? Here is datasheet for it http://www.datasheet-pdf.com/datasheet/ILITECHNOLOGY/837831/ILI9327.pdf.html (www.mcufriend.com is broken at this moment). Also, if you interested, I can provide timeseries data recorded by digital analyzer (http://www.aliexpress.com/item/1sets-New-Arrival-USB-Logic-Analyze-24M-8CH-MCU-ARM-FPGA-DSP-debug-tool/1960280884.html). Yeah it has only 8 channels... So I intend to record data in two stages.

@ont

This comment has been minimized.

ont commented Apr 28, 2015

Oh, my mistake... I missed small rst, wr, rs, d1, d2, d3, ... labels at PI-26 scheme block.

@nopnop2002

This comment has been minimized.

nopnop2002 commented May 16, 2015

http://www.ranked.nl/pi-36-raspberry.pdf

This page can't be indicated.
I'd like to see a data seat, too.

This module uses both of GPIO8 (SPIO CE0) and GPIO7 (SPIO CE1).
It's my guess, but I think this module isn't SPI i/f, it's 8 bits parallel i/f .

@ont

This comment has been minimized.

ont commented May 17, 2015

@nopnop2002 if i understand correctly what is drawn in pdf:

              3.3v   1 # . 2
                     3 . . 4
                     5 . # 6   ground
              [cs]   7 # . 8
                     9 . . 10
              [wr]  11 # # 12  [rs]
                    13 . . 14
              [d1]  15 # # 16  [d2]
                    17 . # 18  [d3]
              [d4]  19 # . 20
              [d6]  21 # # 22  [d5]
              [d7]  23 # # 24  [d8]
                    25 . # 26  [rst]

Original pdf: https://yadi.sk/i/fsk5Cddsggfh9
Strange order of d5 and d6 (also I can't see d4)... And seems that [rs] is actually command/data switch.

@V1R11

This comment has been minimized.

V1R11 commented May 20, 2015

I also have one of this screen and found a comment on a chinese forum that this will work on this screen http://imagewriteriij.blogspot.jp/2014/01/raspberry-pi-9-lcd-1.html since my knowledge is limited on this I hope you guys could get something out that I will get benefit of later.

@keerttttt

This comment has been minimized.

keerttttt commented May 22, 2015

Okay, i've used the sheet in the pdf: https://yadi.sk/i/fsk5Cddsggfh9
And it works! so i can confirm that this is the correct pinout!

But, ofcourse only with the specified kernel or image... So, Notro, would it be possible to make it work with fbtft? It should be possible right? It's parallel driven...

I'm not good enough with low level programming and C to do such a thing... :(

@notro

This comment has been minimized.

Owner

notro commented May 23, 2015

So, Notro, would it be possible to make it work with fbtft? It should be possible right? It's parallel driven...

If it uses a WR signal to latch in the data, I guess it should work.

@keerttttt

This comment has been minimized.

keerttttt commented May 24, 2015

I'm trying this standard kernel driver for now, but i can't seem to find any way to flip the screen or rotate it 180 degrees. Is there any way to do so in Raspbian? (I know it's bit of topic, but still)...

Xrandr is not working:
Rotation: xrandr: output default cannot use rotation "inverted" reflection "none"

Or orientation:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 149 (RANDR)
Minor opcode of failed request: 2 (RRSetScreenConfig)
Serial number of failed request: 14
Current serial number in output stream: 14

@notro

This comment has been minimized.

Owner

notro commented May 24, 2015

I have never tried randr, but many of the fbtft drivers support hardware rotation. Which driver are you using and are you using a DT overlay or fbtft_device?

@MDM63

This comment has been minimized.

MDM63 commented May 29, 2015

Hello. I have the same display. keerttttt could you be so kind and tell us how exactly you got your display to work with the standard kernel image? What fbtft_device name you used and/or how did you connect the display? This would be very much appreciated.

@keerttttt

This comment has been minimized.

keerttttt commented Jun 1, 2015

I did not get it to work with the standard kernel. Better yet, i didn't even try it. I'm using the kernel from the chinese image, but i used my own sd card raspbian installation for the rest. So i changed only the kernel.

@sfemping

This comment has been minimized.

sfemping commented Jun 13, 2015

I also have a couple of these displays and am stuck with the precompiled kernel and no way to make support for Pi2 work, or any other interesting developments.

notro, I know you're trying to get away from end device support, but please do you have any more pointers as to how we can identify how mcufriend (website now gone, no support) are initialising what appears to be a ili9325 driver?

I've had a go with the fbtft_device.debug=7 and fbtft_device.debug=3 but got nothing that I could find that was relevant in dmesg output.

Also tried fbtft.debug=3 (I'm assuming output should appear in dmesg log?...)

There must be quite a few people with these displays... I wonder if this is why they're going cheap! ;-)

Thanks again for all your efforts and development.

@notro

This comment has been minimized.

Owner

notro commented Jun 14, 2015

If debug=7 and the like doesn't work, they must have disabled it.
I see 2 ways to get to the init sequence:

  1. Attach a SPI protocol analyzer to the SPI bus and capture the output
  2. Disassemble the driver
    objdump -Dr fb_ili9325.ko
    Look at the init_display function to get the register values.
    I suggest doing this on a regular fb_ili9325 first so you can compare with the source.
    I have never done this myself.
@ont

This comment has been minimized.

ont commented Jun 14, 2015

My small addition:

  1. It is really great idea! And I hardly try to do that. But at current point I have no luck with my 8 channel 24 Mhz logic analyzer. After some research it is clear that this display transfer data at greater frequencies. Now I am waiting for delivery of 16 channel 200 Mhz logic analyzer. It will arrive within a month.
  2. The most terrible thing about this custom driver is that it is compiled into custom kernel image. I could not find any *.ko files related to this driver. And linux kernel image is very huge.
@notro

This comment has been minimized.

Owner

notro commented Jun 14, 2015

The win32_screem.rar kernel is not using a fbtft driver:

$ binwalk -Me kernel.img

Scan Time:     2015-06-14 17:02:20
Target File:   /home/pi/kernel.img
MD5 Checksum:  1daa4dddff863c8bd7ce8e0bd3720b5f
Signatures:    332

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
50604         0xC5AC          gzip compressed data, maximum compression, from Unix, NULL date (1970-01-01 00:00:00)


Scan Time:     2015-06-14 17:02:45
Target File:   /home/pi/_kernel.img.extracted/C5AC
MD5 Checksum:  3c9a394321437299f02610b71e5c75cb
Signatures:    332

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
2025993       0x1EEA09        Certificate in DER format (x509 v3), header length: 4, sequence length: 1284
2026113       0x1EEA81        Certificate in DER format (x509 v3), header length: 4, sequence length: 1288
2027193       0x1EEEB9        Certificate in DER format (x509 v3), header length: 4, sequence length: 1284
2499693       0x26246D        Certificate in DER format (x509 v3), header length: 4, sequence length: 4355
3776636       0x39A07C        Linux kernel version "3.6.11 (lgh@lgh-ThinkPad-T420) (gcc version 4.7.1 20120402 (prerelease) (crosstool-NG 1.15.2) ) #5 PREEMPT Sun Nov 9 19:00:34 CS"
3784712       0x39C008        gzip compressed data, maximum compression, from Unix, NULL date (1970-01-01 00:00:00)
4586124       0x45FA8C        Unix path: /proc/sys/kernel/hung_task_timeout_secs" disables this message.
4678783       0x47647F        Unix path: /misc/vc04_services/interface/vchiq_arm/vchiq_core.c
4687723       0x47876B        Unix path: /misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
4690251       0x47914B        Unix path: /misc/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
4690607       0x4792AF        Unix path: /misc/vc04_services/interface/vchiq_arm/vchiq_shim.c
4690691       0x479303        Unix path: /misc/vc04_services/interface/vchiq_arm/vchiq_util.c
4745015       0x486737        Unix path: /S70/S75/505V/F505/F707/F717/P8
4759705       0x48A099        Copyright string: "Copyright(c) Pierre Ossman"
4775786       0x48DF6A        Unix path: /char/broadcom/vc_cma/vc_cma.c
5275648       0x508000        CRC32 polynomial table, little endian


Scan Time:     2015-06-14 17:04:01
Target File:   /home/pi/_kernel.img.extracted/_C5AC.extracted/39C008
MD5 Checksum:  6d756fd2dde0e49ae137abb6a902c4f4
Signatures:    332

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
26080         0x65E0          MPFS filesystem, Microchop, version 61.121, 17162 file entries
26098         0x65F2          MPFS filesystem, Microchop, version 95.77, 21839 file entries
69785         0x11099         MPFS filesystem, Microchop, version 61.121, 17162 file entries
69800         0x110A8         MPFS filesystem, Microchop, version 95.80, 21327 file entries
69825         0x110C1         MPFS filesystem, Microchop, version 95.88, 21569 file entries

$ strings _kernel.img.extracted/C5AC | grep 9325
ili9325_probe
ili9325_video_alloc
ili9325_pages_alloc
ili9325_init
li9325_
li9325
li9325_
li9325_
li9325_i
li9325_c
li9325_
li9325_w
li9325_
li9325_
li9325_
li9325_v{
ili9325_
dbcm2708_ili9325
li9325
li9325_
li9325_d
ili9325
%s: unable to kzalloc for ili9325
%s: unable to ili9325_video_alloc
%s: unable to kmalloc for ili9325_page
%s: unable to kmalloc for ili9325_page oldbuffer
%s: unable to ili9325_pages_init
                                                                                                                                                          ILI9325

fb_ili9325 does not have these strings.

@sfemping

This comment has been minimized.

sfemping commented Jun 14, 2015

Thanks notro for taking a look into it, appreciate your expertise!

What a shame, seems like they built support, locked it away and then disappeared off the face of the planet...

Nice little 3.6" displays in themselves, but bit of a dead-end if there's no way to get it working beyond their one precompiled support. :-(

@notro

This comment has been minimized.

Owner

notro commented Jun 14, 2015

You're welcome. It was an interesting challenge.

I forgot to google those strings. This seems to be the driver they used as their base: https://searchcode.com/codesearch/view/64781754/
But it doesn't help with the init sequence.
I guess @ont will solve this when he gets his analyzer.

@berryelectronics

This comment has been minimized.

berryelectronics commented Jul 11, 2015

@samuraijap Now it works! That is great! 👍

But somehow it seems like it needs longer to refresh the screen. Did you managed to get the console on the screen? "con2fbmap 1 1" didnt helped me.
Could be because im using an older image but the desktop is really laggy. Going to download the latest image and test it then

EDIT: to others: startx and it will work

@keerttttt

This comment has been minimized.

keerttttt commented Jul 11, 2015

Ok, so the framerate/display speed is slower then with the normal included kernel? Or not?

Great to see it is working! :)

@berryelectronics

This comment has been minimized.

berryelectronics commented Jul 11, 2015

@keertttt i was using the original image With update upgrade and rpi-update. Frameratr felt like 1-2fps. Desktop took around 5 -7 seconds to built up.
But atleast it works now With the New kernel ^^

@keerttttt

This comment has been minimized.

keerttttt commented Jul 11, 2015

Hm, if we could improve this, it would be great. What are the possibilities
in this?
Op 11 jul. 2015 5:38 PM schreef "berryelectronics" <notifications@github.com

:

@keertttt i was using the original image With update upgrade and
rpi-update. Frameratr felt like 1-2fps. Desktop took around 5 -7 seconds to
built up.
But atleast it works now With the New kernel ^^


Reply to this email directly or view it on GitHub
#254 (comment).

@ont

This comment has been minimized.

ont commented Jul 11, 2015

My observations:

  1. /dev/fb0 from original driver works 1.5-2.0x faster, but not too fast (i can see refreshing process when I fill it with random data)
  2. system with 3.6.11 kernel with original driver works faster (it is only my feelings).
  3. glxgears and glxheads works very fast on original kernel

My idea: they are using caching for drawing area and updating only changed pixels. Also authors of original driver may do some low-level system optimization.

@notro, @samuraijap what do you think about this?

@keerttttt

This comment has been minimized.

keerttttt commented Jul 11, 2015

On the original driver, full image change took about 1 sec (top to bottom).
Faster than this should be possible right?
Op 11 jul. 2015 7:12 PM schreef "ont" notifications@github.com:

My observations:

  1. /dev/fb0 from original driver works 1.5-2.0x faster, but not too fast
    (i can see refreshing process when I fill it with random data)
  2. system with 3.6.11 kernel with original driver works faster (it is
    only my feelings).
  3. glxgears and glxheads works very fast on original kernel

My idea: they are using caching for drawing area and updating only
changed pixels. Also authors of original driver may do some low-level
system optimization.

@notro, @samuraijap what are you thinking about this?


Reply to this email directly or view it on GitHub.

@notro

This comment has been minimized.

Owner

notro commented Jul 11, 2015

@ont
Maybe the original driver writes directly to the gpio register, bypassing gpiolib.
FBTFT did this before it went into mainline Linux: https://github.com/notro/fbtft/blob/master/fbtft-io.c#L133
This Pi specific optimization was removed since the kconfig symbol enabling it is not present there: http://lxr.free-electrons.com/source/drivers/staging/fbtft/fbtft-io.c#L128

@samuraijap

This comment has been minimized.

samuraijap commented Jul 14, 2015

What should I do?...

@berryelectronics

This comment has been minimized.

berryelectronics commented Jul 14, 2015

A Question : Why cant we simply take the "original" kernel and copy the settings and configs to the new kernel?

@ont

This comment has been minimized.

ont commented Jul 15, 2015

@samuraijap: you and @notro are most experienced users in this thread. I guess you can help with good ideas about improving drawing speed of driver...

After some research I can confirm that original driver is using cache and redraw only changed pixels. I take data traffic and replay each 0x2a, 0x2b and 0x2c commands from it. Each frame in provided gif is taken after 1000 of 0x2c commands. Data traffic was generated by glxgears example program. Black pixels are not changed and not redrawn during gears rotation.
out
The most interesting fact is that each 0x2a + 0x2b + 0x2c triple draws exactly one pixel... In my opinion it is not the best approach to redraw... And even with that cache realization glxgears shows near 12 fps.

Question: @notro, is it possible to implement such cache in your current code?

@notro

This comment has been minimized.

Owner

notro commented Jul 23, 2015

Sending each pixel (2 bytes) using 5 bytes is not very efficient unless a few pixels are updated and they are spread all over the frame.

Kernel memory are divided in 4k pages.
When an app writes to /dev/fb1 (mmap), fbdev collects all video memory pages that have been updated. After a fps/100 second delay, FBTFT converts this into the first horizontal line touched and the last line touched. Then the driver sends the area between those line to the display.
So if the top left and bottom right pixel are changed, the whole display is updated. If only the first pixel is changed, 6 lines are sent.

Caching technicues tends to be very application specific. And keeping a cache up to date and scan for changes is very cpu intensive. Without a dedicated parallel interface on the Pi, these kinds of displays doesn't work very well, especially at this resolution. For mostly static content and few changes in the vertical direction it can work well.
There is one thing that might have been optimized and that is cursor support. Instead of updating the whole width of the display, only the width of the cursor could be updated. But I don't know how well supported this is. I haven't looked into it.

If you want the real fps, use debug=32 and each update will print some performance numbers to the kernel log. See https://github.com/notro/fbtft/wiki/Performance
See this to clear up FBTFT confusing use of fps: https://github.com/notro/fbtft/wiki/FPS

@samuraijap

This comment has been minimized.

samuraijap commented Jul 24, 2015

Is it abnormally slow draw because fbtft doesn't operate a register directly?

When correcting that, it goes good.

@quocanhcgd

This comment has been minimized.

quocanhcgd commented Sep 29, 2015

I have one but i can't setup it with rasp B+. please guide me step by step.

@hansjny

This comment has been minimized.

hansjny commented Oct 7, 2015

I am in the same situation quoncanhcgd. Will post if I figure it out.

@berryelectronics

This comment has been minimized.

berryelectronics commented Oct 9, 2015

@quocanhcgd @hansjny : @ont had great instructions not that long ago. But here is it in a nutshell.

1.Update & Upgrade the Pi's Kernel and Image. (rpi-update)

  1. Call this command :

modprobe fbtft_device name=flexpfb rotate=180 fps=60 gpios=dc:18,reset:7,wr:17,cs:4,db00:22,db01:23,db02:24,db03:10,db04:25,db05:9,db06:11,db07:8

  1. Call this command :

modprobe flexfb width=240 height=432 buswidth=8 init=-1,0xE9,0x20,-1,0x11,-2,100,-1,0x3A,0x55,-1,0xD1,0x00,0x6B,0x19,-1,0xD0,0x07,0x07,0x80,-1,0x36,0x48,-1,0xC1,0x10,0x10,0x02,0x02,-1,0xC0,0x00,0x35,0x00,0x00,0x01,0x02,-1,0xC5,0x01,-1,0xD2,0x01,0x22,-1,0xC8,0x01,0x52,0x37,0x10,0x0D,0x01,0x04,0x51,0x77,0x01,0x01,0x0d,0x08,0x80,0x00,-1,0xEA,0x80,-1,0x29,-3

If everything works, you can add them both into the /etc/modules file.

@StoneAgeSkillz

This comment has been minimized.

StoneAgeSkillz commented Oct 10, 2015

Can u post a step by step instructions from clear install? I'm trying this the whole day with no succes. Now i'm frustrated and in temptation to smash it against wall... Also using B+.

@StoneAgeSkillz

This comment has been minimized.

StoneAgeSkillz commented Oct 10, 2015

Sorry for this poopstorm, kinda laged and poof, many posts.

@ghost

This comment has been minimized.

ghost commented Nov 5, 2015

The @berryelectronics sequences above work for me. The flexfb wiki page says it's obsolete, though. Is it possible to use the init with a specific (mainline) driver or should there be a new driver for ili9327? The source I'm looking at has hardcoded init procedures.

Is this information going up to the Linus tree somehow?

@ont

This comment has been minimized.

ont commented Nov 17, 2015

@realblades look at this patch #341
I create this code long ago for easy loading of driver. After applying this patch you will be able to load module with

modprobe fbtft_device name=mcufriend rotate=90 debug=3
@nguyenhunga5

This comment has been minimized.

nguyenhunga5 commented Dec 13, 2015

@ont can you sent new kernel?
my email: nguyenthanhhung19872004@gmail.com thank you so much!

@pieis2pi

This comment has been minimized.

pieis2pi commented Dec 20, 2015

Should I be doing something different for a model B (not plus)? The screen goes from white to black upon running the second modprobe line, but does not show anything else.

@1ucian

This comment has been minimized.

1ucian commented Dec 29, 2015

Is it possible to get this running on the Pi Zero? I have been trying and I can't get it to boot.
Thanks!

@sfemping

This comment has been minimized.

sfemping commented Jan 4, 2016

@1ucian, yes, it works fine on Pi Zero once you've soldered the headers on. Make sure you've updated to latest firmware and raspbian distribution. Not sure if it'd work with the original pre-packaged kernel image though, you'd need to use a standard distribution and then use the berryelectronics commands above. There are other tweaks in this thread which will enable the display in landscape or portrait mode.

@rogerjak

This comment has been minimized.

rogerjak commented Jan 19, 2016

Should the @berryelectronics commands work with a RPi B+ without extension header?
If not, what is this "extension header"? I tried everything in this thread, but nothing works, after issuing the commands the screen do change, but only into garbage :(

@MartinBriza

This comment has been minimized.

MartinBriza commented Feb 28, 2016

@rogerjak On my pi2 B the modprobe commands guys provided above work more than fine. You just have to have a recent-ish version of kernel provided in raspbian. running the two modprobe commands should create a /dev/fb1 file - you can test if it works right by writing some random data in the file, by using cat /dev/urandom > /dev/fb1 for example.
However, the framerate is very bad.
Regarding "header extensions" - you need them only to reach the pins because the USB ports are in the way.

@rhoderik

This comment has been minimized.

rhoderik commented May 2, 2016

Hi! I have one of this mcufriend 3,6" tft. Looking around the web, I found how one arduino library improved the framerate on parallel screens like this. They checked every pixel before sending it to the screen. If there are at least 40 pixels of the same color, they would send the write instruction without changing the data pins as many times as pixels they want to write. That way, they claim an 16 Megapixels per second for an 16Mhz arduino (if the 16 Megapixels were the same color). So bad I don't remember where i found it!
[edit]
Ooops! I found it! http://andybrown.me.uk/2013/06/08/a-generic-16-bit-lcd-adaptor-for-the-arduino/

@rboot071

This comment has been minimized.

rboot071 commented Oct 4, 2016

hi i want yo use this lcd for rpi2 what should id do?! i really need this and i dont have time for see topics!!

@rhoderik

This comment has been minimized.

rhoderik commented Oct 4, 2016

As @berryelectronics said a little above:

@quocanhcgd @hansjny : @ont had great instructions not that long ago. But here is it in a nutshell.

1.Update & Upgrade the Pi's Kernel and Image. (rpi-update)

Call this command : 

modprobe fbtft_device name=flexpfb rotate=180 fps=60 gpios=dc:18,reset:7,wr:17,cs:4,db00:22,db01:23,db02:24,db03:10,db04:25,db05:9,db06:11,db07:8

Call this command :

modprobe flexfb width=240 height=432 buswidth=8 init=-1,0xE9,0x20,-1,0x11,-2,100,-1,0x3A,0x55,-1,0xD1,0x00,0x6B,0x19,-1,0xD0,0x07,0x07,0x80,-1,0x36,0x48,-1,0xC1,0x10,0x10,0x02,0x02,-1,0xC0,0x00,0x35,0x00,0x00,0x01,0x02,-1,0xC5,0x01,-1,0xD2,0x01,0x22,-1,0xC8,0x01,0x52,0x37,0x10,0x0D,0x01,0x04,0x51,0x77,0x01,0x01,0x0d,0x08,0x80,0x00,-1,0xEA,0x80,-1,0x29,-3

If everything works, you can add them both into the /etc/modules file.

But if you don't have time to read... I doubt you will go so far.

@berryelectronics

This comment has been minimized.

berryelectronics commented Oct 9, 2016

I might make a small python script which also installs fbcon. Comes really
handy with low resolution screens. You loose a bit of sharpness of the text
but some programms have size limits bigger than the screens resolution.

But are those panels still a thing on aliexpress?

rhoderik notifications@github.com schrieb am Di., 4. Okt. 2016, 20:03:

As @berryelectronics https://github.com/berryelectronics said a little
above:

@quocanhcgd https://github.com/quocanhcgd @hansjny
https://github.com/hansjny : @ont https://github.com/ont had great
instructions not that long ago. But here is it in a nutshell.

1.Update & Upgrade the Pi's Kernel and Image. (rpi-update)

Call this command :

modprobe fbtft_device name=flexpfb rotate=180 fps=60
gpios=dc:18,reset:7,wr:17,cs:4,db00:22,db01:23,db02:24,db03:10,db04:25,db05:9,db06:11,db07:8

Call this command :

modprobe flexfb width=240 height=432 buswidth=8
init=-1,0xE9,0x20,-1,0x11,-2,100,-1,0x3A,0x55,-1,0xD1,0x00,0x6B,0x19,-1,0xD0,0x07,0x07,0x80,-1,0x36,0x48,-1,0xC1,0x10,0x10,0x02,0x02,-1,0xC0,0x00,0x35,0x00,0x00,0x01,0x02,-1,0xC5,0x01,-1,0xD2,0x01,0x22,-1,0xC8,0x01,0x52,0x37,0x10,0x0D,0x01,0x04,0x51,0x77,0x01,0x01,0x0d,0x08,0x80,0x00,-1,0xEA,0x80,-1,0x29,-3

If everything works, you can add them both into the /etc/modules file.

But if you don't have time to read... I doubt you will go so far.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#254 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AMCBvOI8S-Al1mQkNbS35nbhRYkg8SNxks5qwpUFgaJpZM4Do3js
.

Matjas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment