WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: fbtft  (Read 27983 times)

Offline szymtro

  • Newbie
  • *
  • Posts: 9
fbtft
« on: July 23, 2015, 12:47:49 PM »
except this topic:
http://forum.tinycorelinux.net/index.php/topic,18358.msg112022.html#msg112022

There is nothing about running any other display on rpi+tinycore.

So this is my idea for ataching lcd(I am using something similar to itdb02-3.2, it has ssd1289 lcd chip and hardware is set to 16bit parallel).
I'm noob in linux world so excuse me for mistakes.

My hardware is rpi B+ and the lcd is wired this way:
reset:26,dc:2,wr:3,db00:18,db01:23,db02:24,db03:25,db04:12,db05:16,db06:20,db07:21,db08:4,db09:17,db10:27,db11:22,db12:5,db13:6,db14:13,db15:19

Standard kernel(3.12.36 or 3.18.10) that is included in 6.0 or 6.1 version of tc does not iinclude fbtft(actualy fbtft is included in staging directory in 3.18.10 but is not compiled).
So it means that we need to compile kernel and that is not easy for noob's.

So here is the compiled kernel and image for rootfs:
http://www.trocki.pl/szymon/tinycore/fbtft_3.12.36/
http://www.trocki.pl/szymon/tinycore/fbtft_3.18.10/

there are 2 important files: kernel_fbtft.img and rootfs_fbtft.img, both are uncopresed.
Copy them into fat partition of working mmc.
Then change config.txt to include this:
Code: [Select]
initramfs rootfs_fbtft.img followkernel
kernel=kernel_fbtft.img
and create fbtft.sh on that fat partition - this file is responsible for modprobe the propper fbtft_device, for example:
Code: [Select]
/sbin/modprobe fbtft_device name=sainsmart32 fps=16 rotate=90 width=320 height=240 gpios=reset:26,dc:2,wr:3,db00:18,db01:23,db02:24,db03:25,db04:12,db05:16,db06:20,db07:21,db08:4,db09:17,db10:27,db11:22,db12:5,db13:6,db14:13,db15:19after that You can simply reboot rpi or add this:
Code: [Select]
fbcon=map:10to commandline.txt to change conslole to fb1(our lcd)
and then simply reboot pi.
After few seconds display should change from white(default after power on) to black and immediatelly teher should be boot process visible(including booting 6.0...) everything in color.

But thats not all.
Some ouf Us might need X, so after installing TC.tcz please change last line of .profile file in /home/tc directory to this:
Code: [Select]
FRAMEBUFFER=/dev/FB1 startx
And thats all


Offline szymtro

  • Newbie
  • *
  • Posts: 9
Re: fbtft
« Reply #1 on: July 27, 2015, 01:54:04 PM »
3.18.10 for rpi 2:
http://www.trocki.pl/szymon/tinycore/fbtft_3.18.10_v7/

fbtft.sh for waveshare spotspear 4.0 (a):
Code: [Select]
/sbin/modprobe flexfb  width=320  height=480  regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x28,-1,0x11,-1,0x29,-3
/sbin/modprobe fbtft_device debug=3 rotate=90 name=flexfb speed=16000000 gpios=reset:25,dc:24

Offline nowhinjing

  • Newbie
  • *
  • Posts: 30
Re: fbtft
« Reply #2 on: October 03, 2015, 05:05:46 AM »
Hi,

I am hoping you may be able to help me.

I have prepared an image using your revised kernel, modified as appropriate for my Waveshare Touchpear 3.5 inch screen. I know that these parameters are OK as the same screen is working well under Raspbian using the same parameters.

When I boot using the image I prepared, the lcd screen starts light, and then goes dark as you would expect. However the switch from HDMI to the LCD screen never happens.

Examination of the kernel log using dmseg gives:
Code: [Select]
[    2.367426] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
[    2.375903] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x3f204000 (irq 80)
[    2.380104] bcm2708_i2c_init_pinmode(1,2)
[    2.380132] bcm2708_i2c_init_pinmode(1,3)
[    2.382968] bcm2708_i2c bcm2708_i2c.1: BSC1 Controller at 0x3f804000 (irq 79) (baudrate 100000)
[    2.418146] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    2.418182] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.421596] smsc95xx v1.0.4
[    2.439236] zram0: detected capacity change from 0 to 235405312
[    2.449146] random: mkswap urandom read with 59 bits of entropy available
[    2.457088] Adding 229884k swap on /dev/zram0.  Priority:-1 extents:1 across:229884k SSFS
[    2.483369] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-bcm2708_usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:f0:2a:aa
[    2.574284] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
[    2.576331] flexfb: module is from the staging directory, the quality is unknown, you have been warned.
[    2.586498] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
[    2.587981] fbtft_device:  SPI devices registered:
[    2.588009] fbtft_device:      spidev spi0.0 500kHz 8 bits mode=0x00
[    2.588027] fbtft_device:      spidev spi0.1 500kHz 8 bits mode=0x00
[    2.588039] fbtft_device:  'fb' Platform devices registered:
[    2.588062] fbtft_device:      bcm2708_fb id=-1 pdata? no
[    2.588127] fbtft_device: Deleting spi0.0
[    3.003533] random: nonblocking pool is initialized
[    3.234211] graphics fb1: flexfb frame buffer, 480x320, 300 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 16 MHz
[    3.234259] fbtft_device:  GPIOS used by 'flexfb':
[    3.234273] fbtft_device:    'reset' = GPIO25
[    3.234284] fbtft_device:    'dc' = GPIO24
[    3.234295] fbtft_device:  SPI devices registered:
[    3.234313] fbtft_device:      spidev spi0.1 500kHz 8 bits mode=0x00
[    3.234328] fbtft_device:      flexfb spi0.0 16000kHz 8 bits mode=0x00
[    3.696730] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    3.903751] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    8.710228] i2c /dev entries driver
[    8.740286] smsc95xx 1-1.1:1.0 eth0: hardware isn't capable of remote wakeup
[   10.392140] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1
tc@box:/$
which would suggest that the correct modules are being loaded.

However modprobe fbcon gives module not found ...

Any suggestions would be most welcome - it is driving me potty !

The image I am using can be downloaded here www.pughx2.com/assets/px2/files/fbtft-img.img

Help !

NWJ
« Last Edit: October 03, 2015, 05:36:07 AM by nowhinjing »

Offline nowhinjing

  • Newbie
  • *
  • Posts: 30
Re: fbtft
« Reply #3 on: October 03, 2015, 05:44:35 AM »
... sorry, the image download link should be http:wwwpughx2.com/assets/px2/files/fbtft-img.zip

extension zip not img

Offline szymtro

  • Newbie
  • *
  • Posts: 9
Re: fbtft
« Reply #4 on: October 05, 2015, 02:55:07 PM »
Have You added this:
Code: [Select]
fbcon=map:10in to the commandline.txt?

Offline nowhinjing

  • Newbie
  • *
  • Posts: 30
Re: fbtft
« Reply #5 on: October 06, 2015, 01:19:27 AM »
Yes, followed your instructions to the letter.

Also tried fbcon=map:1, fbcon=map:0, fbcon=map:01, - all same result.

Thanks for your time.

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: fbtft
« Reply #6 on: October 06, 2015, 06:05:14 AM »
You need to load the kernel drivers first.

Use these simple script:

Code: (bash) [Select]
echo "dtparam=i2c=on,spi=on
dtoverlay=ads7846,speed=1000000,penirq=17,penirq_pull=2,swapxy=1,xmin=200,xmax=3900,ymin=200,ymax=3900,pmax=255,xohms=60" >> /mnt/mmcblk0p1/config.txt
echo "fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo" >> /mnt/mmcblk0p1/command.txt
echo "modprobe flexfb  width=320  height=480  regwidth=16 init=-1,0xb0,0x0,-1,0x11,-2,250,-1,0x3A,0x55,-1,0xC2,0x44,-1,0xC5,0x00,0x00,0x00,0x00,-1,0xE0,0x0F,0x1F,0x1C,0x0C,0x0F,0x08,0x48,0x98,0x37,0x0A,0x13,0x04,0x11,0x0D,0x00,-1,0xE1,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0xE2,0x0F,0x32,0x2E,0x0B,0x0D,0x05,0x47,0x75,0x37,0x06,0x10,0x03,0x24,0x20,0x00,-1,0x36,0x28,-1,0x11,-1,0x29,-3
modprobe fbtft_device debug=3 rotate=90 name=flexfb speed=16000000 gpios=reset:25,dc:24" >> /opt/bootlocal.sh

Backup, reboot and you'll get the shell on the TFT just after the kernel driver is loaded.
« Last Edit: October 06, 2015, 06:12:51 AM by jgrulich »

Offline nowhinjing

  • Newbie
  • *
  • Posts: 30
Re: fbtft
« Reply #7 on: October 06, 2015, 09:08:45 AM »
thanks, will try this tomorrow...

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: fbtft
« Reply #8 on: October 06, 2015, 09:41:39 AM »
Kernel Touch-TFT modules for piCore-7.0alpha6 may be found here:
http://grulich.eu/files/tft.tcz

Offline nowhinjing

  • Newbie
  • *
  • Posts: 30
Re: fbtft
« Reply #9 on: October 07, 2015, 06:44:59 AM »
I'm confused.

I made the changes as outlined by jgrulich, no difference exactly the same result - screen starts light, goes dark but the console remains on HDMI and does not switch to the LCD screen.

Now this is where it gets interesting. I downloaded PiCore-7.0alpha6, downloaded tft.tcz, put it in tce/optional, made all the mods as suggested and rebooted.

Guess what, exactly the same. dmesg shows that the drivers are being loaded but the console never swaps from HDMI to LCD.

What can I try now ?

Any help would be much appreciated.

Best Regards to all.

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: fbtft
« Reply #10 on: October 07, 2015, 08:04:25 AM »
When the TFT goes dark during startup, than it means it's initiated correctly. The only issue is to switch the output.
Try to use:
Code: (bash) [Select]
echo "00000000000000000000000000000000001111111111111111111111111112222222222222222222222222233333333333333333333333333344444444444444444444455555555555555555555566666666666666666666777777777777777777788888888888888888899999999999999999999999" > /dev/fb1
It displays color line at the left top of the TFT.
If it reports some error, than feedback.

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: fbtft
« Reply #11 on: October 07, 2015, 08:32:51 AM »
Share the output of this:
Code: (bash) [Select]
dmesg | grep fb1

Offline szymtro

  • Newbie
  • *
  • Posts: 9
Re: fbtft
« Reply #12 on: October 07, 2015, 03:04:37 PM »
jgrulich, he already shared:
Code: [Select]
[    3.234211] graphics fb1: flexfb frame buffer, 480x320, 300 KiB video memory, 4 KiB DMA buffer memory, fps=20, spi0.0 at 16 MHz
But this screen uses faked spi - on the board there are logic ic(counters and registers) that emulate spi interface.
It might happen that someting is to fast - but then it shouldn't get to the "turn screen black"

Offline nowhinjing

  • Newbie
  • *
  • Posts: 30
Re: fbtft
« Reply #13 on: October 08, 2015, 05:51:45 AM »
First of all my sincere thanks to jgrulich and szymtro for taking the time to help me with this, your efforts are really appreciated, guys.

We may be getting somewhere, executing the echo command as suggested by jgrulich does indeed give a 1 px coloured line on the top left of the LCD screen. There is no error message generated.

Next step ?

Best regards to all.

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: fbtft
« Reply #14 on: October 08, 2015, 06:05:09 AM »
Great, it means that the driver fb1 is working correctly.
Check if the cmdline.txt is like this:
Code: (bash) [Select]
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/ram0 elevator=deadline rootwait quiet nortc loglevel=3 tz=CET-2 noembed fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo
Guess that there is missing space in front of first fbcon.
« Last Edit: October 08, 2015, 06:25:47 AM by jgrulich »