Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: ashfame on August 04, 2020, 04: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?
-
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.
-
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.
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.
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
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
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.
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.
-
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.
-
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 :)
-
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):
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?
-
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
-
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:
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.
-
No change. /dev/fb1 is still missing.
I am guessing I am missing a step to instruct the kernel to load these modules?
-
Look at modules loaded by running lsmod
And look at dmesg for clues.
-
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?
-
You need the command “sudo depmod -a” after you copy them.
-
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?
-
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.
-
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?
-
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
-
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)
-
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.
-
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.
-
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.
-
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.
-
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.
-
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?
-
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)
-
Thanks for the lsmod tip! For touchscreen, I don't know if I have any, how do I figure out?
-
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/
-
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?
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?
-
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:
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:~$
-
Hi Rich,
Thanks for the tip! I tried and they both detects the same.
(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?
-
Hi ashfame
... Do you what those 4 parameters are, that are specified for Calibration option? ...
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
-
hi Rich, thanks for finding this out!
Option "Calibration" "min-x max-x min-y max-y"
That makes the default config I have wrong, as the middle 2 numbers are smaller ones indicating they are minimum coordinate values. I will try flipping them but I wonder how does it even function correctly in Raspbian ???
-
Hi ashfame
... but I wonder how does it even function correctly in Raspbian ???
Maybe they used:
Option "InvertX" "1"
The link I provided doesn't give any details on how the inversion is implemented.
-
Hi Rich
Did you manage to get the seven working? Can you share the working solution?
-
Hi ajggray
I don't own a Pi.