User avatar
FREE WING
Posts: 8
Joined: Tue Mar 21, 2017 1:54 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Tue Mar 21, 2017 2:09 pm

Conjur wrote:Final post on the KeDei v5.0 code.

Below are images of the reverse of the board to show connections and version; and an image of it loading a bmp from SPIFFS.
Hi .

I use KeDei V5.0 LCD module .
So I transplanted the Conjur's program for raspberry pi .
I appreciate very good program and analysis content .

I registered the program in GitHub .
https://github.com/FREEWING-JP/Raspberr ... 35_lcd_v50

Thank you .

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Thu Mar 23, 2017 6:52 pm

fbtft never was a good fit for these keidei displays, but it's successor tinydrm has a much better modularity.
I don't have a keidei displays myself, and I certainly don't want one, but the hacker/maker spirit shown in this thread has spurred me to make it very easy to write a keidei driver that can support multiple versions of the display.

I have looked at some code on @saper_2's github repo and put together a keidei skeleton driver. It probably won't work as-is, but I'm quite certain that some people in this thread should be able to make it work.

Step-by-step and some more:

Code: Select all

# install tinydrm kernel with headers
$ sudo REPO_URI=https://github.com/notro/rpi-firmware BRANCH=tinydrm rpi-update
$ sudo reboot
$ uname -a
Linux raspberrypi 4.10.4-v7+ #1 SMP Wed Mar 22 13:05:23 CET 2017 armv7l GNU/Linux

# if you want me to pull your changes, fork this repo and use your fork instead
$ git clone https://github.com/notro/tinydrm
$ cd tinydrm/
$ make
$ sudo make install && sudo depmod

$ sudo dtc [email protected] -I dts -O dtb -o /boot/overlays/keidei20.dtbo rpi-overlays/keidei20-overlay.dts
Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /[email protected]/__overlay__/[email protected] has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /[email protected]/__overlay__/[email protected] has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property

$ sudo nano /boot/cmdline.txt
drm.debug=0xf

$ sudo nano /boot/config.txt
dtoverlay=keidei20

$ sudo reboot

$ sudo vcdbg log msg 2>&1 | grep keidei
002167.799: Loaded overlay 'keidei20'

$ cat /proc/device-tree/soc/[email protected]/[email protected]/compatible && echo
keidei,keidei_v20

$ cat /sys/bus/spi/devices/spi0.0/modalias
spi:keidei_v20

$ modinfo keidei
filename:       /lib/modules/4.10.4-v7+/extra/keidei.ko
license:        GPL
author:         SOME GUY
description:    keidei DRM driver
alias:          spi:keidei_v20
alias:          spi:keidei_v10
srcversion:     D986815279C88770FB60498
alias:          of:N*T*Ckeidei,keidei_v20C*
alias:          of:N*T*Ckeidei,keidei_v20
alias:          of:N*T*Ckeidei,keidei_v10C*
alias:          of:N*T*Ckeidei,keidei_v10
depends:        tinydrm,drm,mipi-dbi
vermagic:       4.10.4-v7+ SMP mod_unload modversions ARMv7 p2v8

# picked only the relevant modules
$ lsmod
Module                  Size  Used by
keidei                  5752  0
mipi_dbi               10985  1 keidei
tinydrm                13920  2 keidei,mipi_dbi
drm_kms_helper        153025  2 tinydrm,mipi_dbi
drm                   347095  5 keidei,tinydrm,mipi_dbi,drm_kms_helper

# only relevant parts
$ dmesg
[    5.632171] [drm] Initialized
[    5.799206] keidei: loading out-of-tree module taints kernel.
[    5.803341] [drm:mipi_dbi_init [mipi_dbi]] preferred_depth=16, rotation = 0
[    5.803362] [drm:keidei_probe [keidei]]
[    6.056029] [drm:keidei20_command [keidei]] cmd=11
[    6.056051] [drm:keidei20_write [keidei]] 0011:11 / 0011:1b
[    6.196052] [drm:keidei20_command [keidei]] cmd=ee, par=02 01 02 01
[    6.196074] [drm:keidei20_write [keidei]] 00ee:11 / 00ee:1b
[    6.196140] [drm:keidei20_write [keidei]] 0002:15 / 0002:1f
[    6.196170] [drm:keidei20_write [keidei]] 0001:15 / 0001:1f
[    6.196198] [drm:keidei20_write [keidei]] 0002:15 / 0002:1f
[    6.196227] [drm:keidei20_write [keidei]] 0001:15 / 0001:1f
[    6.196256] [drm:keidei20_command [keidei]] cmd=ed, par=00 00 9a 9a 9b 9b 00 00 00 00 ae ae 01 a2 00
[    6.196271] [drm:keidei20_write [keidei]] 00ed:11 / 00ed:1b
[    6.196299] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196337] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196367] [drm:keidei20_write [keidei]] 009a:15 / 009a:1f
[    6.196397] [drm:keidei20_write [keidei]] 009a:15 / 009a:1f
[    6.196427] [drm:keidei20_write [keidei]] 009b:15 / 009b:1f
[    6.196455] [drm:keidei20_write [keidei]] 009b:15 / 009b:1f
[    6.196484] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196533] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196564] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196595] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196626] [drm:keidei20_write [keidei]] 00ae:15 / 00ae:1f
[    6.196656] [drm:keidei20_write [keidei]] 00ae:15 / 00ae:1f
[    6.196687] [drm:keidei20_write [keidei]] 0001:15 / 0001:1f
[    6.196717] [drm:keidei20_write [keidei]] 00a2:15 / 00a2:1f
[    6.196747] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196777] [drm:keidei20_command [keidei]] cmd=b4, par=00
[    6.196793] [drm:keidei20_write [keidei]] 00b4:11 / 00b4:1b
[    6.196822] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196853] [drm:keidei20_command [keidei]] cmd=c0, par=10 3b 00 02 11
[    6.196869] [drm:keidei20_write [keidei]] 00c0:11 / 00c0:1b
[    6.196902] [drm:keidei20_write [keidei]] 0010:15 / 0010:1f
[    6.196935] [drm:keidei20_write [keidei]] 003b:15 / 003b:1f
[    6.196966] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.196998] [drm:keidei20_write [keidei]] 0002:15 / 0002:1f
[    6.197032] [drm:keidei20_write [keidei]] 0011:15 / 0011:1f
[    6.197067] [drm:keidei20_command [keidei]] cmd=c1, par=10
[    6.197083] [drm:keidei20_write [keidei]] 00c1:11 / 00c1:1b
[    6.197117] [drm:keidei20_write [keidei]] 0010:15 / 0010:1f
[    6.197150] [drm:keidei20_command [keidei]] cmd=c8, par=00 46 12 20 0c 00 56 12 67 02 00 0c
[    6.197166] [drm:keidei20_write [keidei]] 00c8:11 / 00c8:1b
[    6.197199] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.197230] [drm:keidei20_write [keidei]] 0046:15 / 0046:1f
[    6.197258] [drm:keidei20_write [keidei]] 0012:15 / 0012:1f
[    6.197288] [drm:keidei20_write [keidei]] 0020:15 / 0020:1f
[    6.197319] [drm:keidei20_write [keidei]] 000c:15 / 000c:1f
[    6.197349] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.197380] [drm:keidei20_write [keidei]] 0056:15 / 0056:1f
[    6.197410] [drm:keidei20_write [keidei]] 0012:15 / 0012:1f
[    6.197440] [drm:keidei20_write [keidei]] 0067:15 / 0067:1f
[    6.197470] [drm:keidei20_write [keidei]] 0002:15 / 0002:1f
[    6.197501] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.197531] [drm:keidei20_write [keidei]] 000c:15 / 000c:1f
[    6.197561] [drm:keidei20_command [keidei]] cmd=d0, par=44 42 06
[    6.197576] [drm:keidei20_write [keidei]] 00d0:11 / 00d0:1b
[    6.197605] [drm:keidei20_write [keidei]] 0044:15 / 0044:1f
[    6.197633] [drm:keidei20_write [keidei]] 0042:15 / 0042:1f
[    6.197661] [drm:keidei20_write [keidei]] 0006:15 / 0006:1f
[    6.197689] [drm:keidei20_command [keidei]] cmd=d1, par=43 16
[    6.197704] [drm:keidei20_write [keidei]] 00d1:11 / 00d1:1b
[    6.197737] [drm:keidei20_write [keidei]] 0043:15 / 0043:1f
[    6.197768] [drm:keidei20_write [keidei]] 0016:15 / 0016:1f
[    6.197798] [drm:keidei20_command [keidei]] cmd=d2, par=04 22
[    6.197814] [drm:keidei20_write [keidei]] 00d2:11 / 00d2:1b
[    6.197844] [drm:keidei20_write [keidei]] 0004:15 / 0004:1f
[    6.197875] [drm:keidei20_write [keidei]] 0022:15 / 0022:1f
[    6.197904] [drm:keidei20_command [keidei]] cmd=d3, par=04 12
[    6.197920] [drm:keidei20_write [keidei]] 00d3:11 / 00d3:1b
[    6.197950] [drm:keidei20_write [keidei]] 0004:15 / 0004:1f
[    6.197981] [drm:keidei20_write [keidei]] 0012:15 / 0012:1f
[    6.198010] [drm:keidei20_command [keidei]] cmd=d4, par=07 12
[    6.198025] [drm:keidei20_write [keidei]] 00d4:11 / 00d4:1b
[    6.198056] [drm:keidei20_write [keidei]] 0007:15 / 0007:1f
[    6.198086] [drm:keidei20_write [keidei]] 0012:15 / 0012:1f
[    6.198116] [drm:keidei20_command [keidei]] cmd=e9, par=00
[    6.198132] [drm:keidei20_write [keidei]] 00e9:11 / 00e9:1b
[    6.198162] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.198191] [drm:keidei20_command [keidei]] cmd=c5, par=08
[    6.198207] [drm:keidei20_write [keidei]] 00c5:11 / 00c5:1b
[    6.198237] [drm:keidei20_write [keidei]] 0008:15 / 0008:1f
[    6.198266] [drm:keidei20_command [keidei]] cmd=36, par=6a
[    6.198282] [drm:keidei20_write [keidei]] 0036:11 / 0036:1b
[    6.198312] [drm:keidei20_write [keidei]] 006a:15 / 006a:1f
[    6.198342] [drm:keidei20_command [keidei]] cmd=3a, par=55
[    6.198357] [drm:keidei20_write [keidei]] 003a:11 / 003a:1b
[    6.198388] [drm:keidei20_write [keidei]] 0055:15 / 0055:1f
[    6.198418] [drm:keidei20_command [keidei]] cmd=2a, par=00 00 01 3f
[    6.198433] [drm:keidei20_write [keidei]] 002a:11 / 002a:1b
[    6.198464] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.198494] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.198524] [drm:keidei20_write [keidei]] 0001:15 / 0001:1f
[    6.198555] [drm:keidei20_write [keidei]] 003f:15 / 003f:1f
[    6.198584] [drm:keidei20_command [keidei]] cmd=2b, par=00 00 01 e0
[    6.198600] [drm:keidei20_write [keidei]] 002b:11 / 002b:1b
[    6.198630] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.198660] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.198691] [drm:keidei20_write [keidei]] 0001:15 / 0001:1f
[    6.198721] [drm:keidei20_write [keidei]] 00e0:15 / 00e0:1f
[    6.336043] [drm:keidei20_command [keidei]] cmd=21
[    6.336067] [drm:keidei20_write [keidei]] 0021:11 / 0021:1b
[    6.336130] [drm:keidei20_command [keidei]] cmd=35, par=00
[    6.336146] [drm:keidei20_write [keidei]] 0035:11 / 0035:1b
[    6.336181] [drm:keidei20_write [keidei]] 0000:15 / 0000:1f
[    6.336489] [drm:drm_minor_register [drm]]
[    6.336760] [drm:drm_minor_register [drm]]
[    6.337002] [drm:drm_minor_register [drm]]
[    6.337652] [drm:drm_minor_register [drm]] new minor registered 0
[    6.338265] [drm:drm_sysfs_connector_add [drm]] adding "Virtual-1" to sysfs
[    6.338511] [drm:drm_sysfs_hotplug_event [drm]] generating hotplug event
[    6.338865] [drm:drm_mode_object_reference [drm]] OBJ ID: 25 (1)
[    6.339023] [drm:drm_setup_crtcs [drm_kms_helper]]
[    6.339141] [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:25:Virtual-1]
[    6.339273] [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:25:Virtual-1] probed modes :
[    6.339541] [drm:drm_mode_debug_printmodeline [drm]] Modeline 29:"480x320" 0 1 480 480 480 480 320 320 320 320 0x48 0x0
[    6.339691] [drm:drm_setup_crtcs [drm_kms_helper]] connector 25 enabled? yes
[    6.339807] [drm:drm_setup_crtcs [drm_kms_helper]] looking for cmdline mode on connector 25
[    6.339920] [drm:drm_setup_crtcs [drm_kms_helper]] looking for preferred mode on connector 25 0
[    6.340040] [drm:drm_setup_crtcs [drm_kms_helper]] found mode 480x320
[    6.340154] [drm:drm_setup_crtcs [drm_kms_helper]] picking CRTCs for 480x320 config
[    6.340345] [drm:drm_setup_crtcs [drm_kms_helper]] desired mode 480x320 set on crtc 27 (0,0)
[    6.340640] [drm:drm_mode_object_reference [drm]] OBJ ID: 25 (2)
[    6.340775] [drm:drm_fbdev_cma_create [drm_kms_helper]] surface width(480), height(320) and bpp(16)
[    6.357070] keidei spi0.0: fb1:  frame buffer device
[    6.416085] [drm:keidei_probe [keidei]] Initialized keidei:spi0.0 @32MHz on minor 0

# clear log
$ sudo dmesg -C

# one second of console output will flood the log with the detailed logging in keidei20_write()
# so remove it when it looks ok
$ con2fbmap 1 1 && sleep 1 && con2fbmap 1 0
$ dmesg | wc -l
2046

# no need to reboot or reinstall modules to test a driver change if the depending modules are loaded
# but 'make install' is necessary to load the correct version on boot
$ cd tinydrm/
$ make
$ sudo rmmod keidei
$ sudo insmod keidei.ko

Links:
https://github.com/notro/tinydrm/wiki/b ... spberry-Pi
https://github.com/notro/tinydrm/blob/master/keidei.c
https://github.com/notro/tinydrm/blob/master/README.md


I see some mention of i2c here, does some versions of the display use i2c?

User avatar
saper_2
Posts: 239
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Thu Mar 23, 2017 8:46 pm

Hi notro
notro wrote:fbtft never was a good fit for these keidei displays, but it's successor tinydrm has a much better modularity.
Oh, I've never heard about it, need to check it :)
notro wrote:
I don't have a keidei displays myself, and I certainly don't want one, but the hacker/maker spirit shown in this thread has spurred me to make it very easy to write a keidei driver that can support multiple versions of the display.
Hahaha, u're right - you certainly don't want the spi one :D
Anyway, I don't see them so much now, there is much more small tft displays with spi interface with proper(compatible) fbtft spi interface (spi to parallel :) )

AS far as I remember, kedei don't change the I/F (3 or 4 in chain SIPO registers) , but for better pcb routing they changed in each version signals locations at shift registers outputs, or they doing a strange things to the display signals :?
notro wrote:
I have looked at some code on @saper_2's github repo and put together a keidei skeleton driver. It probably won't work as-is, but I'm quite certain that some people in this thread should be able to make it work.
My code works only for v1 or v2 , for later versions - they made too many changes in hardware :( , and there is no inits.

For V5 Conjur did great job of: recording init sequence, and writing code for displaying images :)

notro wrote:I see some mention of i2c here, does some versions of the display use i2c?
No, just some people have problems with i2c interface on sys-images from kedei.

doublehp
Posts: 77
Joined: Wed May 02, 2012 1:11 am

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Mar 24, 2017 7:18 am

No, just some people have problems with i2c interface on sys-images from kedei.
In some versions of their ROM, they had removed many critical I2C tools; then, put them back.

They are disabling completely all I2C features on official I2C pins. I have found several workarounds:
viewtopic.php?f=44&t=173272

In short, you can either:
- use a bitbanging daemon like http://abyz.co.uk/rpi/pigpio/pigs.html
or
- use the boot argument /boot/config.txt : dtoverlay=i2c-gpio,i2c_gpio_sda=30,i2c_gpio_scl=31,i2c_gpio_delay_us=5

User avatar
FREE WING
Posts: 8
Joined: Tue Mar 21, 2017 1:54 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Mar 24, 2017 3:13 pm

notro wrote:fbtft never was a good fit for these keidei displays, but it's successor tinydrm has a much better modularity.
I don't have a keidei displays myself, and I certainly don't want one, but the hacker/maker spirit shown in this thread has spurred me to make it very easy to write a keidei driver that can support multiple versions of the display.

I have looked at some code on @saper_2's github repo and put together a keidei skeleton driver. It probably won't work as-is, but I'm quite certain that some people in this thread should be able to make it work.

Step-by-step and some more:
Hi notro .

Very Thank you . You provide tinydrm .
Tentatively, I modified it for KeDei V5.0 module .
The model name is still old (it keidei20, not keidei50) . It is incomplete to release (for Pull request) .
But I confirmed that it works with V 5.0 !

I forked and make branch feature/kedei_35_v50 .
https://github.com/FREEWING-JP/tinydrm/ ... dei_35_v50
https://github.com/FREEWING-JP/tinydrm/ ... 35_lcd_v50

Thank you .

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Mar 24, 2017 5:48 pm

That's cool FREE WING, it didn't take you long to make it work!

It would have been interesting to know the speed of these displays, how many frames per second they can do: https://github.com/notro/tinydrm/wiki/D ... t#modetest

User avatar
FREE WING
Posts: 8
Joined: Tue Mar 21, 2017 1:54 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sat Mar 25, 2017 7:39 am

notro wrote:That's cool FREE WING, it didn't take you long to make it work!

It would have been interesting to know the speed of these displays, how many frames per second they can do: https://github.com/notro/tinydrm/wiki/D ... t#modetest
Hi notro . Thank you !

I tested .
Result: freq: 0.50Hz
* Oh ! KeDei is very slow .
(drm.debug parameter is none .)

Code: Select all

$ ./tests/modetest/modetest -M "keidei_v20" -c
failed to open device 'keidei_v20': No such file or directory

$ ./tests/modetest/modetest -M "keidei" -c
Connectors:
id      encoder status          name            size (mm)       modes   encoders
25      28      connected       Virtual-1       0x0             1       28
  modes:
        name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  480x320 0 480 480 480 480 320 320 320 320 1 flags: ; type: preferred, driver
  props:
        2 DPMS:
                flags: enum
                enums: On=0 Standby=1 Suspend=2 Off=3
                value: 0

$ ./tests/modetest/modetest -M "keidei" -s 25:[email protected] -v
setting mode [email protected] on connectors 25, crtc 27
freq: 0.50Hz
When drm.debug=0xf
SPI freq. is 32MHz .
Buffer transfer is Full size .
Hmm... What is bottleneck ? -> It may be linux/spi/spidev.h overhead .

Code: Select all

[   87.891552] keidei spi0.1: fb1:  frame buffer device
[   87.934529] [drm:keidei_probe [keidei]] Initialized keidei:spi0.1 @32MHz on minor 0

$ ./tests/modetest/modetest -M "keidei" -s 25:[email protected]
[  282.506163] [drm:keidei_enable [keidei]]
[  282.508313] [drm:keidei20_command [keidei]] cmd=2a, par=00 00 01 df
[  282.508328] [drm:keidei20_write8 [keidei]] 2a /  15:11 / 15:1b
[  282.508410] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  282.508518] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  282.508559] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  282.508601] [drm:keidei20_write8 [keidei]] df /  6f:35 / 6f:3f
[  282.508640] [drm:keidei20_command [keidei]] cmd=2b, par=00 00 01 3f
[  282.508654] [drm:keidei20_write8 [keidei]] 2b /  15:31 / 15:3b
[  282.508693] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  282.508732] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  282.508771] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  282.508810] [drm:keidei20_write8 [keidei]] 3f /  1f:35 / 1f:3f
[  282.508850] [drm:keidei20_command [keidei]] cmd=2c, len=307200
[  282.508863] [drm:keidei20_write8 [keidei]] 2c /  16:11 / 16:1b
[  284.480753] [drm:keidei20_command [keidei]] cmd=2a, par=00 00 01 df
[  284.480760] [drm:keidei20_write8 [keidei]] 2a /  15:11 / 15:1b
[  284.480803] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  284.480823] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  284.480879] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  284.480899] [drm:keidei20_write8 [keidei]] df /  6f:35 / 6f:3f
[  284.480918] [drm:keidei20_command [keidei]] cmd=2b, par=00 00 01 3f
[  284.480925] [drm:keidei20_write8 [keidei]] 2b /  15:31 / 15:3b
[  284.480944] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  284.480963] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  284.480981] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  284.481001] [drm:keidei20_write8 [keidei]] 3f /  1f:35 / 1f:3f
[  284.481019] [drm:keidei20_command [keidei]] cmd=2c, len=307200
[  284.481026] [drm:keidei20_write8 [keidei]] 2c /  16:11 / 16:1b
[  286.395632] [drm:keidei20_command [keidei]] cmd=2a, par=00 00 01 df
[  286.395642] [drm:keidei20_write8 [keidei]] 2a /  15:11 / 15:1b
[  286.395685] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  286.395710] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  286.395745] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  286.395765] [drm:keidei20_write8 [keidei]] df /  6f:35 / 6f:3f
[  286.395784] [drm:keidei20_command [keidei]] cmd=2b, par=00 00 01 3f
[  286.395791] [drm:keidei20_write8 [keidei]] 2b /  15:31 / 15:3b
[  286.395811] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  286.395833] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  286.395855] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  286.395875] [drm:keidei20_write8 [keidei]] 3f /  1f:35 / 1f:3f
[  286.395894] [drm:keidei20_command [keidei]] cmd=2c, len=307200
[  286.395901] [drm:keidei20_write8 [keidei]] 2c /  16:11 / 16:1b
[  288.304499] [drm:keidei_disable [keidei]]
[  288.308391] [drm:keidei20_command [keidei]] cmd=2a, par=00 00 01 df
[  288.308401] [drm:keidei20_write8 [keidei]] 2a /  15:11 / 15:1b
[  288.308448] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  288.308509] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  288.308530] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  288.308552] [drm:keidei20_write8 [keidei]] df /  6f:35 / 6f:3f
[  288.308571] [drm:keidei20_command [keidei]] cmd=2b, par=00 00 01 3f
[  288.308578] [drm:keidei20_write8 [keidei]] 2b /  15:31 / 15:3b
[  288.308598] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  288.308619] [drm:keidei20_write8 [keidei]] 00 /  00:15 / 00:1f
[  288.308641] [drm:keidei20_write8 [keidei]] 01 /  00:35 / 00:3f
[  288.308660] [drm:keidei20_write8 [keidei]] 3f /  1f:35 / 1f:3f
[  288.308679] [drm:keidei20_command [keidei]] cmd=2c, len=307200
[  288.308686] [drm:keidei20_write8 [keidei]] 2c /  16:11 / 16:1b
sudo nano /boot/config.txt
dtoverlay=keidei20:speed=16000000
SPI freq. is 16MHz .

Code: Select all

[    5.062074] keidei spi0.1: fb1:  frame buffer device
[    5.123948] [drm:keidei_probe [keidei]] Initialized keidei:spi0.1 @16MHz on minor 0

$ ./tests/modetest/modetest -M "keidei" -s 25:[email protected] -v
setting mode [email protected] on connectors 25, crtc 27
freq: 0.45Hz
freq: 0.45Hz

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sat Mar 25, 2017 2:09 pm

That was indeed very slow.

The only way to speed this up is to send multiple pixels in one spi_write(), but looking at your code, each value is sent with 2 spi_write's, not one as I had suggested.
So if you have to do that to make it work, then we're stuck.
You could try to lower the speed and see if the shift registers would tolerate one value sent as one buffer.
The actual spi transfer speed doesn't matter much when (320 * 240 * 2 * 2) transfers is used to send the framebuffer.

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Wed Mar 29, 2017 2:09 pm

Hi FREE WING,

Is it possible to modify this for version 6.1.3 of the Kedei LCD? And could you do this? my programming skills are not that great..

Regards, wbmk

User avatar
FREE WING
Posts: 8
Joined: Tue Mar 21, 2017 1:54 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Mar 31, 2017 11:58 am

wbmk wrote:Hi FREE WING,

Is it possible to modify this for version 6.1.3 of the Kedei LCD? And could you do this? my programming skills are not that great..

Regards, wbmk
I don't have V 6.1.3 of the KeDei . So I don't know how control that .
If same as V 5.0 . You can use this . Try it !
https://github.com/FREEWING-JP/tinydrm/ ... dei_35_v50

How to install
https://github.com/FREEWING-JP/tinydrm/ ... cd_v50.txt

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Mar 31, 2017 3:17 pm

Hi FREE_WING,

I have tried.. it seems to compile, but it does not display any image..

Maybe i don't understand your install instructions.. do i need to execute everything, or are some lines the expected reply when executed?

Thank, wbmk

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sat Apr 01, 2017 7:10 am

Hi FREE WING,

The installation goes fine until this point..:

sudo dtc [email protected] -I dts -O dtb -o /boot/overlays/keidei50.dtbo rpi-overlays/keidei50-overlay.dts
Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /[email protected]/__overlay__/[email protected] has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /[email protected]/__overlay__/[email protected] has a unit name, but no reg property
Warning (unit_address_vs_reg): Node /[email protected] has a unit name, but no reg property

What do i have to do next to solve this? I don't understand the instructions on how to edit cmdline.txt en config.txt files..?

Can you help me? Thanx!

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sat Apr 01, 2017 7:20 am

Some more info from the command-line..

[email protected]:~ $ sudo fbi -d /dev/fb1 -T 1 -a cat.jpg
using "Droid Sans Mono-16", pixelsize=21,33 file=/usr/share/fonts/truetype/droid/DroidSansMono.ttf
[email protected]:~ $ sudo vcdbg log msg 2>&1 | grep keidei
[email protected]:~ $ cat /proc/device-tree/soc/[email protected]/[email protected]/compatible && echo
cat: /proc/device-tree/soc/[email protected]/[email protected]/compatible: Bestand of map bestaat niet
[email protected]:~ $ cat /sys/bus/spi/devices/spi0.0/modalias
cat: /sys/bus/spi/devices/spi0.0/modalias: Bestand of map bestaat niet
[email protected]:~ $ modinfo keidei
filename: /lib/modules/4.10.4-v7+/extra/keidei.ko
license: GPL
author: SOME GUY
description: keidei DRM driver
alias: spi:keidei_v50
alias: spi:keidei_v20
alias: spi:keidei_v10
srcversion: B5A97F289EE4FD67AC8D6C2
alias: of:N*T*Ckeidei,keidei_v50C*
alias: of:N*T*Ckeidei,keidei_v50
alias: of:N*T*Ckeidei,keidei_v20C*
alias: of:N*T*Ckeidei,keidei_v20
alias: of:N*T*Ckeidei,keidei_v10C*
alias: of:N*T*Ckeidei,keidei_v10
depends: tinydrm,drm,mipi-dbi
vermagic: 4.10.4-v7+ SMP mod_unload modversions ARMv7 p2v8
[email protected]:~ $ lsmod | grep keidei
[email protected]:~ $ dmesg | grep keidei
[email protected]:~ $ sudo dmesg -C
[email protected]:~ $ con2fbmap 1 1 && sleep 1 && con2fbmap 1 0
ioctl FBIOPUT_CON2FBMAP: Invalid argument
[email protected]:~ $ dmesg | wc -l
0
[email protected]:~ $

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sat Apr 01, 2017 8:00 pm

wbmk wrote:[email protected]:~ $ sudo vcdbg log msg 2>&1 | grep keidei
Have you added this to /boot/config.txt:

Code: Select all

dtoverlay=keidei50
This tells the bootloader to load the Device Tree overlay which will add the device.

Some background:
* 'keidei' is a loadable kernel module.
* The 'keidei' module registers a SPI driver
* The DT overlay adds a SPI device that will be bound to the driver, resulting in the probe function being called
wbmk wrote: [email protected]:~ $ cat /sys/bus/spi/devices/spi0.0/modalias
cat: /sys/bus/spi/devices/spi0.0/modalias: Bestand of map bestaat niet
The DT overlay uses reg=1, so the device will be called spi0.1

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sun Apr 02, 2017 6:48 am

hi notro,

thank you for your reply..

i made a typ0 when editing the config.txt

now, i get a litte further..

this is the responce so far..

[email protected]:~ $ sudo fbi -d /dev/fb1 -T 1 -a cat.jpg
using "Droid Sans Mono-16", pixelsize=21,33 file=/usr/share/fonts/truetype/droid/DroidSansMono.ttf
[email protected]:~ $ sudo vcdbg log msg 2>&1 | grep keidei
002104.515: Loaded overlay 'keidei50'
[email protected]:~ $ cat /proc/device-tree/soc/[email protected]/[email protected]/compatible && echo
keidei,keidei_v50
[email protected]:~ $ cat /sys/bus/spi/devices/spi0.0/modalias
cat: /sys/bus/spi/devices/spi0.0/modalias: Bestand of map bestaat niet
[email protected]:~ $ cat /sys/bus/spi/devices/spi0.1/modalias
spi:keidei_v50
[email protected]:~ $ modinfo keidei
filename: /lib/modules/4.10.4-v7+/extra/keidei.ko
license: GPL
author: SOME GUY
description: keidei DRM driver
alias: spi:keidei_v50
alias: spi:keidei_v20
alias: spi:keidei_v10
srcversion: B5A97F289EE4FD67AC8D6C2
alias: of:N*T*Ckeidei,keidei_v50C*
alias: of:N*T*Ckeidei,keidei_v50
alias: of:N*T*Ckeidei,keidei_v20C*
alias: of:N*T*Ckeidei,keidei_v20
alias: of:N*T*Ckeidei,keidei_v10C*
alias: of:N*T*Ckeidei,keidei_v10
depends: tinydrm,drm,mipi-dbi
vermagic: 4.10.4-v7+ SMP mod_unload modversions ARMv7 p2v8
[email protected]:~ $ lsmod | grep keidei
keidei 8618 0
mipi_dbi 10985 1 keidei
tinydrm 13920 2 keidei,mipi_dbi
drm 347095 5 keidei,tinydrm,mipi_dbi,drm_kms_helper
[email protected]:~ $ dmesg | grep keidei
[ 3.677339] keidei: loading out-of-tree module taints kernel.
[ 4.607536] keidei spi0.1: fb1: frame buffer device
[email protected]:~ $ sudo dmesg -C
[email protected]:~ $ con2fbmap 1 1 && sleep 1 && con2fbmap 1 0
[email protected]:~ $ dmesg | wc -l
0
[email protected]:~ $

so, output of the last command is 0.. this does not seem correct... am i doing something wrong??

thanx again sofar..

regards, wbmk

User avatar
FREE WING
Posts: 8
Joined: Tue Mar 21, 2017 1:54 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sun Apr 02, 2017 12:48 pm

wbmk wrote:Hi FREE_WING,

I have tried.. it seems to compile, but it does not display any image..

Maybe i don't understand your install instructions.. do i need to execute everything, or are some lines the expected reply when executed?

Thank, wbmk
You try this first .
https://github.com/FREEWING-JP/Raspberr ... 35_lcd_v50

If this program work fine and display proper your KeDei V 6.1.3 . You can use tinydrm driver .
If not work . You can't use tinydrm driver this time . Because KeDei V6.13 is different from KeDei V5.0 .

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Mon Apr 03, 2017 8:29 pm

Hi,

I run the program (first one), and it seems to run fine..

Got this response:
sudo ./kedei_lcd_v50_pi


File Size: 245814
Offset: 54
Width: 319
Height: 256
BPP: 24



File Size: 245814
Offset: 54
Width: 319
Height: 256
BPP: 24



File Size: 245814
Offset: 54
Width: 319
Height: 256
BPP: 24

But there is no image displayed... it's just lit up white....?

User avatar
saper_2
Posts: 239
Joined: Sun Aug 03, 2014 10:08 am
Location: PL

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Mon Apr 03, 2017 9:34 pm

wbmk wrote:But there is no image displayed... it's just lit up white....?
The answer already has been given:
notro wrote:If this program work fine and display proper your KeDei V 6.1.3 . You can use tinydrm driver .
If not work . You can't use tinydrm driver this time .
So: tinydrm works but your display stay white = your display IS NOT compatible with tinydrm for KeDei SPI display v5.0 and period.

KeDei always incr display revision when change display (hardware wiring/init seq./controller/etc....) - so basically: driver version must match exactly display version and period :)

wbmk
Posts: 7
Joined: Wed Mar 29, 2017 2:05 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sat Apr 08, 2017 6:35 pm

ok, to bad... thanx for the reply though

saitoh00
Posts: 3
Joined: Fri May 22, 2015 9:10 am

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Thu Jun 01, 2017 11:43 pm

Hello, i have the KeDei 3.5 inch 480x320 TFTLCD VERSION 6.2 2016/6/1, really are too slow, but i see videos of games running in this screen, how i can fix the poor fps in this screen?

User avatar
bitbank
Posts: 252
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Jun 02, 2017 4:52 pm

saitoh00 wrote:Hello, i have the KeDei 3.5 inch 480x320 TFTLCD VERSION 6.2 2016/6/1, really are too slow, but i see videos of games running in this screen, how i can fix the poor fps in this screen?
Can you provide a link to the videos you're referring to? If it's my video, the game runs well because my game emulator code talks directly to the display and only transmits the changes. Using other game emulators + fbtft/fbcp will always perform poorly because of their generalized solution to copying the entire frame buffer each frame.

Bottom line - that display has too many pixels and too slow an interface to have a fast refresh rate.
The fastest code is none at all :)

saitoh00
Posts: 3
Joined: Fri May 22, 2015 9:10 am

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Sun Jun 04, 2017 11:25 pm

bitbank wrote:
saitoh00 wrote:Hello, i have the KeDei 3.5 inch 480x320 TFTLCD VERSION 6.2 2016/6/1, really are too slow, but i see videos of games running in this screen, how i can fix the poor fps in this screen?
Can you provide a link to the videos you're referring to? If it's my video, the game runs well because my game emulator code talks directly to the display and only transmits the changes. Using other game emulators + fbtft/fbcp will always perform poorly because of their generalized solution to copying the entire frame buffer each frame.

Bottom line - that display has too many pixels and too slow an interface to have a fast refresh rate.
i cant found the videos that i see the other day, what emulator are u saying?

User avatar
bitbank
Posts: 252
Joined: Sat Nov 07, 2015 8:01 am
Location: Sarasota, Florida
Contact: Website

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Mon Jun 05, 2017 10:56 am

saitoh00 wrote:i cant found the videos that i see the other day, what emulator are u saying?
My main job for 10+ years was writing game emulators for various systems. I wrote mostly coin-op emulators, but as a 'hobby', I also wrote console/handheld game emulators. I'm working on releasing an open-source version of some of this code. It's highly optimized, compact and much easier to modify than the other open-source emulators people use. I've recently added code to send the frames in a more optimal way to SPI-connected LCD displays so that they can get a higher frame rate with a slow interface. This code is not available to the public yet, but you can beta test it if you ask nicely. Here are some videos of it in action:

https://www.youtube.com/channel/UCK8_id ... lYiABg4TBA
The fastest code is none at all :)

saitoh00
Posts: 3
Joined: Fri May 22, 2015 9:10 am

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Tue Jun 06, 2017 1:29 am

:D yeah the videos are yours...:) i search the youtube visited videos and i see your channel, a master of the emulation.

iiAlphaWolf
Posts: 1
Joined: Fri Jun 16, 2017 10:57 pm

Re: KeDei 3.5 inch 480x320 TFT lcd from ali

Fri Jun 16, 2017 11:00 pm

Hey everything is intresting and stuff, i cant help you but you can help me lol. How the heck did you make the screen even work? I put it on my pi i see backlight but no screen i do all codes they tell me still black screen... wth

Return to “Interfacing (DSI, CSI, I2C, etc.)”