WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Configuring goodix touch panel  (Read 4248 times)

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Configuring goodix touch panel
« on: January 17, 2021, 01:26:30 PM »
Hello, I'm trying to configure a 'goodix' i2c touch screen on my Pi4B, piCore 12.0 armv7l-- I've seen jgrulichs post but from my understanding reading this and elsewhere, the 'new' way to configure these I2c devices is to use 'dtoverlay=___' in config.txt instead of some kind of magic modprobe string to specify the appropriate device tree overlay driver.

I have the following relevant modules loaded, among many:
Code: [Select]
touchscreen-5.4.51-piCore-v7l.tcz (which contains goodix.ko)
i2c-tools.tcz
libinput.tcz
wiringpi.tcz
pigpio.tcz

And I added the following in config.txt;
Code: [Select]
dtparam=i2c_arm=on
dtparam=i2s=on
dtparam=spi=on
dtoverlay=goodix

But the touchscreen still doesn't work. The script to setup this touchscreen on Raspbian, as near as I can tell, does the same things.

After booting with this config, the following files are created in the device tree;
Code: [Select]
/sys/firmware/devicetree/base/soc/gpio@7e200000/goodix_pins/brcm,function
/sys/firmware/devicetree/base/soc/gpio@7e200000/goodix_pins/brcm,pins
/sys/firmware/devicetree/base/soc/gpio@7e200000/goodix_pins/brcm,pull
/sys/firmware/devicetree/base/soc/gpio@7e200000/goodix_pins/name
/sys/firmware/devicetree/base/soc/gpio@7e200000/goodix_pins/phandle


These files contain a single line each, that looks like gibberish in nano... I'd guess, that setup still isn't correct. So I tried specifying the GPIO pins explicitly, e.g. dtoverlay=goodix,interrupt=4,reset=17 however their content remained identical. I also tried dtoverlay=i2c1 for kicks.
Code: [Select]
brcm,function: @^@^@^@^@^@^@^@
brcm,pins: ^@^@^@^D^@^@^@^Q
brcm,pull: ^@^@^@^B^@^@^@^B
name: goodix_pins^@
phandle: ^@^@^@

Looking at other threads for I2c generally on piCore (including the DS3231 RTC which I will setup next) I was able to use i2c-tools with only the touchscreen connected and verify it's detected on I2c.
Code: [Select]
sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- 5d -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

So it seems I've got a problem with my setup. But I'm not really sure where else to look or go from here-- any suggestions or other docs I could look at would be greatly appreciated.
« Last Edit: January 17, 2021, 01:31:29 PM by xenodius »

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: Configuring goodix touch panel
« Reply #1 on: January 18, 2021, 12:05:01 AM »
Update... Checked out touch on Rasbian in a bit more detail, where the panel works... i2cdetect -y 1 returns 'reserved' UU at address 10, instead of only an address 50. Maybe an SPI problem... will inspect the device tree overlay file and report if I find a solution.

Also I wasn't clear in my first post, I am trying to get just the touch panel of a makerplane 1100 nit 5" inch touchscreen hdmi display to work.
« Last Edit: January 18, 2021, 12:08:10 AM by xenodius »

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: Configuring goodix touch panel
« Reply #2 on: January 18, 2021, 02:45:05 PM »
After far more snooping around than I've detailed here, I got it working... just not on boot. Previously I had attempted to load goodix manually, with modprobe, which did not work. I had assumed the reason this didn't work was because it needed the device tree overlay goodix.dtbo specified in config.txt by 'dtoverlay=goodix' to inform the kernel 'goodix.ko' driver how to work, e.g. which GPIO pinout to use. Unforuntately 'dtdebug=1' is not useful here without 'vcdbg log msg'...
Code: [Select]
tc@box:~$ modprobe goodix
modprobe: module goodix not found in modules.dep

However rereading some of Paul_123's posts here about other modules I noticed the 'insmod' command, and it turns out all I had to do to get the touch panel to work was:
Code: [Select]
sudo insmod /usr/local/lib/modules/5.4.51-piCore-v7l/kernel/drivers/input/touchscreen/goodix.ko
However adding this line to my other startup scripts in ~/.X.d, or to /opt/bootlocal.sh results in an error, and X cannot start, so I need to SSH in and re-enter insmod this way to get it to work. Not sure yet how to workaround the error or precisely why it occurs;
Code: [Select]
failed in waitforX

« Last Edit: January 18, 2021, 03:03:01 PM by xenodius »

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: Configuring goodix touch panel
« Reply #3 on: January 18, 2021, 03:30:45 PM »
Ok, well with the 30min edit limit I'll have to live with the shame of my little mistakes staying up here indefinitely... =) Hope that an echo-chamber thread like this where I'm just talking to myself is not discouraged, possibly it will help someone else in the future.

Calling insmod from bootlocal.sh works when I remove the redundant sudo.   ::) So for future searchers, in the end all I had to do to get the touch panel working after installing the appropriate modules was:
Code: [Select]
echo "insmod /usr/local/lib/modules/5.4.51-piCore-v7l/kernel/drivers/input/touchscreen/goodix.ko" >> /opt/bootlocal.sh
filetool.sh -b
« Last Edit: January 18, 2021, 03:45:35 PM by xenodius »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11515
Re: Configuring goodix touch panel
« Reply #4 on: January 18, 2021, 05:24:46 PM »
Hi xenodius
While  bootlocal.sh  runs as root, making  sudo  unnecessary, I don't think I've ever heard of it causing a problem.

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: Configuring goodix touch panel
« Reply #5 on: January 18, 2021, 08:32:04 PM »
Well you're right, I changed it back just to test and it works fine. I assumed it was 'real' because it happened twice then resolved after I edited bootlocal... I cannot explain it, but in two other of many dozens of reboots, it's booted to the same 'failed in waitforX' error without starting X. Every time that's happened calling startx again from the terminal repeated the error. But in those cases it was fixed by simply resetting, with no changes. I'd blame stray neutrinos flipping bits, except for the likelihood of getting the same error several times...  :o

Cheers =) Thanks to help and history on this forum in which your name was often involved, I've completed my project... the smartest dash and tuner, for one of the most powerful ebikes! Now just have to trim some fat extensions without breaking them for the sake of boot time 8)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11515
Re: Configuring goodix touch panel
« Reply #6 on: January 18, 2021, 09:11:07 PM »
Hi xenodius
... However adding this line to my other startup scripts in ~/.X.d, or to /opt/bootlocal.sh results in an error, and X cannot start, ...
If you had a typo, and you were copy/pasting the command, that might explain it.

Offline xenodius

  • Newbie
  • *
  • Posts: 43
Re: Configuring goodix touch panel
« Reply #7 on: January 20, 2021, 12:48:50 AM »
That's a believable guess, although I've gotten into the habit of writing known commands in notepad++, or logging once I find the right command, for sanity checks and to later copy via SSH in part for that reason... I am pretty sure it wasn't misspelled... I did get this error on boot today, after making no changes, and it resolved by reboot with no changes as previously;

Code: [Select]
/usr/local/sbin/sshd: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
wpa_passphrase: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory
Failed in waitforX
Previously I only noticed the 'Failed in waitforX' line, but I had long ago redirected stdout for my wifi.sh startup in /opt/bootlocal.sh to a log file for debugging until recently  ::) Still odd that it only happens sometimes... maybe the variable time to detect/connect to my wifi allows it to happen only rarely, before other package(s) are loaded?