WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Touchscreen 3.5" display support for Raspberry Pi 2B
« on: August 04, 2020, 01:39:33 PM »
Hi,

I am trying to use a 3.5" touchscreen with Raspberry Pi 2B (and more models in future) which was functional with Raspbian OS after running this script - https://github.com/goodtft/LCD-show/blob/master/LCD35-show

I understand a bunch of what's going on, but lack the know-how in context of TC. Can you guys help me come up with a piCore specific version of this script? Would that be an efficient way to get it working? Or should I work my way in a reverse fashion i.e. see what would any such screen will need and provide those values out of that repo/script? Or maybe create a custom tcz extension if it just requires certain files at certain locations?

Touch Screen Controller - XPT2046 (https://www.electronicscomp.com/3.5-inch-tft-lcd-touch-screen-display-for-raspberry-pi?search=raspberry%20pi)

As of now, the display's backlight turns on and nothing else, so need to get both the display itself + touchscreen support working. Past topics that came up in search indicate some support was there in v7 with a similar screen, so can I get lucky with piCore-v11?
« Last Edit: August 04, 2020, 02:08:37 PM by ashfame »

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi
« Reply #1 on: August 04, 2020, 01:58:18 PM »
I can follow, that its `ADS7846 Touchscreen` and it uses a specific boot overlay (not sure what a boot overlay is)

1) Boot overlay - https://github.com/goodtft/LCD-show/blob/master/usr/tft35a-overlay.dtb
I guess the boot overlay can be copied over to overlays directory in partition 1?

2) config.txt changes
All good here, & this is where it references the overlay file

3) Copy over some config file (calibration and one invoking fbturbo)
a) https://github.com/goodtft/LCD-show/blob/master/usr/99-calibration.conf-35-90
b) https://github.com/goodtft/LCD-show/blob/master/usr/99-fbturbo.conf
Where should these files be placed or copied to?

4) modify bootcode
From https://github.com/goodtft/LCD-show/blob/master/usr/cmdline.txt
I think these 3 is what I need to add: `fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo`

5) Replace inittab file
Original script copies its version over the OS' version, what should I do here?
https://github.com/goodtft/LCD-show/blob/master/usr/inittab

6) .have_installed file
Is this needed or used? It sets some resistance for the touch via GPIO pins? `gpio:resistance:35:90:480:320`

7) evdev install and configure
Is this present in TC repos or base already? How do I do this?
Script installs this from its own deb file & copy over its config. Not sure what to choose.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1095
Re: Touchscreen 3.5" display support for Raspberry Pi
« Reply #2 on: August 04, 2020, 02:32:21 PM »
These screens are extremely difficult to get setup right, and you will have to figure out how to tinycore all of the commands.   Without reading too much, I've made some comments below.  You also have to understand where you are putting files and how persistence works in piCore.

I can follow, that its `ADS7846 Touchscreen` and it uses a specific boot overlay (not sure what a boot overlay is)

1) Boot overlay - https://github.com/goodtft/LCD-show/blob/master/usr/tft35a-overlay.dtb
I guess the boot overlay can be copied over to overlays directory in partition 1?

2) config.txt changes
All good here, & this is where it references the overlay file

Boot overlays are on the boot partition in the overlay folder.  Just put that file in the overlay folder.

Quote
3) Copy over some config file (calibration and one invoking fbturbo)
a) https://github.com/goodtft/LCD-show/blob/master/usr/99-calibration.conf-35-90
b) https://github.com/goodtft/LCD-show/blob/master/usr/99-fbturbo.conf
Where should these files be placed or copied to?

My guess is that these are not needed, but they are udev files.  To make this work seamlessly, you would need to create an extension with these, and then have an extension script that causes udev to reload rules.  I would save this until the later stages until at least things are showing up on the screen.  But take a look in the files and see what is being done by udev.

Quote
4) modify bootcode
From https://github.com/goodtft/LCD-show/blob/master/usr/cmdline.txt
I think these 3 is what I need to add: `fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo`
Just add to cmdline.txt or cmdline3.txt (depending on which rpi board you have)  Although I don't think ProFont is included in the kernel

Quote
5) Replace inittab file
Original script copies its version over the OS' version, what should I do here?
https://github.com/goodtft/LCD-show/blob/master/usr/inittab
More than likely, put this stuff in /opt/bootlocal.sh

Quote
6) .have_installed file
Is this needed or used? It sets some resistance for the touch via GPIO pins? `gpio:resistance:35:90:480:320`
No idea.  Not a standard command that I know of.

Quote
7) evdev install and configure
Is this present in TC repos or base already? How do I do this?
Script installs this from its own deb file & copy over its config. Not sure what to choose.
evdev is a kernel module, and should be on the base system.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #3 on: August 04, 2020, 02:42:23 PM »
hi ashfame,

Not exactly what you want but this guy has done it for piCorePlayer which is based on piCore. It might  have some clues for you.

http://www.pughx2.com/picore3.html

Note: This is not for windows just cli.

The problem of writing piCore scripts is there is about 47 3.5" screens. Waveshare has 3 or 4 originals, then there are the clones and knockoffs. Even Waveshare has revisions of the same screen. Some are DSI, some are HDMI, some connect through GPIO. The scripts are also available from multiple sites, all at different version levels. On Raspbian these scripts clobber your system by overwriting files rather than adding bits of code!!

Good luck.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #4 on: August 08, 2020, 04:20:36 AM »
Hi Greg,

The problem of writing piCore scripts is there is about 47 3.5" screens. Waveshare has 3 or 4 originals, then there are the clones and knockoffs. Even Waveshare has revisions of the same screen. Some are DSI, some are HDMI, some connect through GPIO. The scripts are also available from multiple sites, all at different version levels. On Raspbian these scripts clobber your system by overwriting files rather than adding bits of code!

I see the problem & can understand the nightmare it is to support all of them based on detection, hence manually supplying everything correctly is needed. My project would eventually aim to support a few cheap screens, but this 3.5" is crucial so that I atleast have one screen to just recommend for people to buy & setup their own device. I have been at it for several days now, but no luck getting it working. I do understand a lot more to get it done though, so I am hopeful :)

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi
« Reply #5 on: August 08, 2020, 04:35:28 AM »
Hi Paul

These screens are extremely difficult to get setup right, and you will have to figure out how to tinycore all of the commands.

I have been at it for days and here is what I have uncovered, hoping to get some guidance to figure this out further :)

I placed the overlay file as done in script: tft35a-overlay.dtb and tft35a.dtbo in overlays folder
Specified to use that overlay in config.txt after enabling all required dtparam(s):
Code: [Select]
hdmi_force_hotplug=1
dtparam=i2c_arm=on
dtoverlay=tft35a:rotate=90

Placed the config files under /usr/local/share/X11/xorg.conf.d but the Xserver doesn't start and I get the error "failed in waitforX"

As of now, I haven't done anything regarding the /etc/inittab script as I didn't see anything in it that would be relevant in the TinyCore context. If you can take a peek inside it (https://github.com/goodtft/LCD-show/blob/master/usr/inittab) & confirm, that would be something we can completely rule out.

And lastly, I haven't done anything on the evdev front, assuming the kernel module is already loaded and functional. Let me know if I am missing something here.



I was comparing the difference between config files of raspbian os with this script executed (where screen works) with my remastered version of picore and I realized, I don't have /dev/fb1 showing up, just /dev/fb0 which is my hdmi screen at the moment. So that makes me wonder the overlay didn't provide the needed info for the hardware to the kernel, which is likely to be the root cause here.

I checked the permissions of overlay file and they seem to be consistent with other overlay files, except the difference of ownership & permissions (777 tc:staff) when compared it with raspbian OS files (755 root:root) but that can't be it. Do you have any idea or pointers as to what I should be looking at?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1095
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #6 on: August 08, 2020, 04:45:16 AM »
Have you included the tft kernel modules?

There is no provided extension, you would need to get the modules from the module tar file.  These are likely in driver/staging/fbtft

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #7 on: August 08, 2020, 06:04:18 AM »
Paul, I had no clue what you meant but I figured out this much:

Got the modules downloaded from http://tinycorelinux.net/11.x/armv7/releases/RPi/src/kernel/modules.tar.gz
Inside that, under modules/lib/modules/4.19.81-piCore-v7/kernel/drivers/staging/fbtft, I see these:
Code: [Select]
fb_agm1264k-fl.ko  fb_hx8357d.ko  fb_ili9341.ko  fb_s6d02a1.ko  fb_ssd1331.ko    fbtft.ko         fb_watterott.ko
fb_bd663474.ko     fb_ili9163.ko  fb_ili9481.ko  fb_s6d1121.ko  fb_ssd1351.ko    fb_tinylcd.ko    flexfb.ko
fb_hx8340bn.ko     fb_ili9320.ko  fb_ili9486.ko  fb_sh1106.ko   fb_st7735r.ko    fb_tls8204.ko
fb_hx8347d.ko      fb_ili9325.ko  fb_pcd8544.ko  fb_ssd1289.ko  fb_st7789v.ko    fb_uc1701.ko
fb_hx8353d.ko      fb_ili9340.ko  fb_ra8875.ko   fb_ssd1306.ko  fbtft_device.ko  fb_upd161704.ko

I guess I just need to pick the right one (not sure which one that would be? all of them?) and then make an extension to make it available on boot at /lib/modules/4.19.81-piCore-v7/kernel/drivers/staging/fbtft/

I will try copying over all those extensions and see what happens.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #8 on: August 08, 2020, 06:20:13 AM »
No change. /dev/fb1 is still missing.
I am guessing I am missing a step to instruct the kernel to load these modules?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1095
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #9 on: August 08, 2020, 06:31:53 AM »
Look at modules loaded by running lsmod

And look at dmesg for clues.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #10 on: August 08, 2020, 07:13:56 AM »
Ok, will keep looking.

Can you confirm I did the right thing by copying over all the modules?
Also, modules placed over there are auto-loaded?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14613
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #11 on: August 08, 2020, 07:28:01 AM »
You need the command “sudo depmod -a” after you copy them.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #12 on: August 08, 2020, 08:00:45 AM »
Thanks Juanito, I will try loading them that way. And where would be the persistent way of loading them at every boot?

Is there a list of modules where I can add this? or use bootlocal.sh?

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1095
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #13 on: August 08, 2020, 08:40:06 AM »
Need to build an extension with the modules and add it to onboot.lst.  Or put it in your initrd if you are remastering.

Depmod is automatically ran for extensions when they load by tce-load.

Offline ashfame

  • Full Member
  • ***
  • Posts: 112
Re: Touchscreen 3.5" display support for Raspberry Pi 2B
« Reply #14 on: August 08, 2020, 10:24:17 AM »
ok, I am adding it via a custom extension so I will take it modules are indeed being loaded. But considering the modules are so many directories deep, does it really look for kernel modules with each file being copied and load it if its one?