WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Touchscreen 3.5" display support for Raspberry Pi 2B  (Read 8166 times)

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #15 on: August 08, 2020, 11:53:07 AM »
As long as you put the file under /usr/local/lib/modules/piCore-4.19.81-v7/kernel/.......


Then yes,  that is the job of depmod.  depmod creates a database if you will.   The kernel and udev call others module utilities that reference this database to find and load the modules.

Use lsmod to see all of the currently loaded modules
« Last Edit: August 08, 2020, 12:01:41 PM by Paul_123 »

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #16 on: August 08, 2020, 02:21:41 PM »
This is my 100th post, & I was hoping for some good news after my last post and boy the small screen started working!  ;D ;D

I really appreciate the folks here, so helpful :)

News: Display works, touch doesn't - so that's what's next to figure out now.
Also, the screen only starts working once the Xserver starts, so in my case that takes good 45secs+ to see anything. Would be great to get it working early if that's possible and not too much work. Even a splash screen of some sort would be great.



Also, I placed the kernel modules under /lib/modules/..... rather than /usr/local/lib/modules/..... in my custom tcz extension. Hope that's not a big deal.

Lastly, did I really need all the kernel modules under staging/fbtft/* ? Or that's better for supporting diff types of screens? (my project will eventually be used by others, so I hope to support a few screens depending on what people can purchase in their part of the world)

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 402
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #17 on: August 08, 2020, 05:49:50 PM »
Weird you don't see it in console mode. What gets displayed initially on the console is also dependant on when the screen software gets loaded. To get full console messages you need a screen that has the driver built into the kernel like the official RPi 7" screen (and compatible, Waveshare 4.3 DSI I think?)

Have you see this script? Its a good example because they cover most of the varying options for a limited number of screens.

https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/adafruit-pitft.sh

Screen rotation is another variable. Some require 90, some 270, some none. Then some screen mounting brackets are upside down. The rotation commands are usually just for the screen, it does not also rotate the touch function. So you need to calibrate the touch screen after you get the right screen orientation.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #18 on: August 09, 2020, 01:40:26 AM »
Thanks Greg! That actually makes sense. Putting together the modules within the kernel will get them loaded early. For now, I simply moved the custom extension on top of onboot.lst

Perhaps just placing the files in partition 1 would be faster? Or it would have to be about compiling the kernel?

I will explore that option down the road iteratively. Hoping to announce the MVP of the project soon, mid-August is my target.

Is calibration for touch sensitivity? or for screen placement? I noticed at times (not always) my screen goes a little over the top, like a negative top offset for screen. Title bar is mostly clipped.

Edit: Thanks for the script as well, I took a quick look & will have to go deep in it to understand what's going on. Will do when I am around to add support for more screens.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #19 on: August 09, 2020, 09:04:12 AM »
Hi ashfame
... Putting together the modules within the kernel will get them loaded early. For now, I simply moved the custom extension on top of onboot.lst

Perhaps just placing the files in partition 1 would be faster? Or it would have to be about compiling the kernel? ...
Extensions only get loaded near the end of  /etc/tc-config.  The drivers would be available earlier if you placed them inside the
initrd  under  /lib/modules/...../drivers/fbtft  for example.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #20 on: August 09, 2020, 01:41:19 PM »
If the screen is an SPI interface, then loadigng the driver sooner is of no help, since it will require initialization, normally using a python script.

Not sure if you ever gave us the link to your specific display.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #21 on: August 09, 2020, 03:29:34 PM »
Hi Paul_123
The suggestion was made because ashfame mentioned recompiling the kernel. I thought repacking the  initrd  might be faster and easier.
... then loadigng the driver sooner is of no help, since it will require initialization, normally using a python script. ...
I see the  initrd  has  micropython  in it. Couldn't that script be added to  /usr/bin  or  /usr/local/bin ? Then call that script from  /etc/init.d/rcS
between the  /bin/mount -a  and  /etc/init.d/tc-config  commands.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #22 on: August 10, 2020, 02:05:23 AM »
Hi Rich, Paul,

I linked the display earlier in first post, here's the link https://www.electronicscomp.com/3.5-inch-tft-lcd-touch-screen-display-for-raspberry-pi?search=raspberry%20pi It connects via GPIO pins directly, no separate connector is required.

I will try putting the modules directly in partition 1 so that when the filesystem is unpacked from there, modules are already there to load (I guess that will be fast enough). Compiling kernel isn't something I am willing to get into. I wanna publish this project by the end of this week & then work on it iteratively.

Two things that I need help with:

1) How do I get the touch working? Please guide me here.
2) Did I do the right thing by copying over all files under kernel/drivers/staging/fbtft or I only need specific ones?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #23 on: August 10, 2020, 11:03:18 AM »
You only needed one or two drivers out fbtft.   Just look at lsmod, see which ones are loaded, then remove the rest.

What driver do you have loaded for the touchscreen.  I'm only familiar with touchscreen supports with a standard framebuffer...... (I'm not sure how it works in Xorg)

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #24 on: August 10, 2020, 02:01:59 PM »
Thanks for the lsmod tip! For touchscreen, I don't know if I have any, how do I figure out?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1063
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #25 on: August 10, 2020, 02:11:19 PM »
If it was working on a RaspiOS image, you can look there.   But it seems to use the

ADS7846 driver.    The drivers are in drivers/input/touchscreen/


Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #26 on: August 12, 2020, 08:22:19 AM »
Hi Paul,

That definitely was the module needed for the touchscreen to function, but it detects the wrong place of touch when I use it, so I guess it requires some sort of calibration.

But I already have this calibration config which worked perfectly for Raspbian OS, so it should be same for every other OS, right?

Code: [Select]
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ADS7846 Touchscreen"
        Option  "Calibration"   "3936 227 268 3880"
        Option  "SwapAxes"      "1"
EndSection

The file is definitely in use, because I tried flipping value of `SwapAxes` and that took effect.

I looked up tutorials and every one seems to be using a calibrator application that returns them the right parameters to use. But I imagine calibration parameters would only vary with different hardware units but one device should have the same parameters no matter on what OS its used on, right?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #27 on: August 12, 2020, 08:45:44 AM »
Hi ashfame
... But I already have this calibration config which worked perfectly for Raspbian OS, so it should be same for every other OS, right? ...
You could check Tinycore and Raspbian  Xorg.0.log  files to see if they both agree on screen size and DPI:
Code: [Select]
tc@box:~$ grep size /var/log/Xorg.0.log | grep " x "
(**) NVIDIA(0): Virtual screen size configured to be 1920 x 1080
tc@box:~$ grep DPI /var/log/Xorg.0.log
(--) NVIDIA(0): DPI set to (95, 94); computed from "UseEdidDpi" X config
tc@box:~$

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #28 on: August 12, 2020, 10:52:20 AM »
Hi Rich,

Thanks for the tip! I tried and they both detects the same.

Code: [Select]
(II) FBTURBO(0): Virtual size is 480x320 (pitch 480)
(==) FBTURBO(0): DPI set to (96,96)

Do you what those 4 parameters are, that are specified for Calibration option? Perhaps I can try to change them manually to see?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #29 on: August 12, 2020, 09:39:07 PM »
Hi ashfame
... Do you what those 4 parameters are, that are specified for Calibration option? ...
Code: [Select]
Option "Calibration" "min-x max-x min-y max-y"Found here:
https://www.x.org/releases/X11R7.5/doc/man/man4/evdev.4.html