FT5x_TS with Cubieboard 2

401 views
Skip to first unread message

Leonardo

unread,
Feb 12, 2015, 11:27:52 AM2/12/15
to cubie...@googlegroups.com
Hello everybody. First of all, I'm sorry for the long post, but I want this to become a resource for other beginners like me facing the same problem. I've been trying to get it right for 4 days now. There are many misleading or incomplete solutions out there.

I'm trying to have a FT5316 touch panel working with Cubieboard 2. Here's my fex file:

[ctp_para]
ctp_used = 1
ctp_name = "ft5x_ts"
ctp_twi_id = 1
ctp_twi_addr = 0x38
ctp_screen_max_x = 1024
ctp_screen_max_y = 600
ctp_revert_x_flag = 0
ctp_revert_y_flag = 0
ctp_exchange_x_y_flag = 1
ctp_firm = 1
ctp_int_port = port:PH14<6><default><default><default>
ctp_wakeup = port:PG02<1><default><default><1>
ctp_io_port = port:PH14<0><default><default><default>
ctp_reset = port:PG02<1><default><default><default> 
 
[ctp_list_para]
ctp_det_used = 1
ft5x_ts = 1
gt82x = 0
gslX680 = 0
gt9xx_ts = 0
gt811 = 0

According to the following link and many others, I need to patch the driver.


I'm running the latest version of Cubian (X1). When I try the unpatched driver, which came with Cubian, I get this:

[   18.461470] ===========================ft5x_ts_init=====================
[   18.464334] ctp_fetch_sysconfig_para. 
[   18.473753] ctp_fetch_sysconfig_para: after: ctp_twi_addr is 0x38, dirty_addr_buf: 0x38. dirty_addr_buf[1]: 0xfffe 
[   18.482484] ctp_fetch_sysconfig_para: ctp_twi_id is 1. 
[   18.487225] ctp_fetch_sysconfig_para: screen_max_x = 1024. 
[   18.491732] ctp_fetch_sysconfig_para: screen_max_y = 600. 
[   18.496193] ctp_fetch_sysconfig_para: revert_x_flag = 0. 
[   18.500566] ctp_fetch_sysconfig_para: revert_y_flag = 0. 
[   18.505335] ctp_fetch_sysconfig_para: exchange_x_y_flag = 1. 
[   18.513002] ft5x_ts_init: after fetch_sysconfig_para:  normal_i2c: 0x38. normal_i2c[1]: 0xfffe 
[   18.518624] ctp_init_platform_resource: No power port feature present.
[   18.520101] ctp_reset. 
[   18.625306] ctp_wakeup. 
[   18.766030] ctp_detect: Detected chip ft5x_ts at adapter 1, address 0x38
[   18.772001] ====ft5x_ts_probe begin=====.  
[   18.779899] input: ft5x_ts as /devices/platform/sunxi-i2c.1/i2c-1/1-0038/input/input3
[   18.785075] ctp_set_irq_mode: config gpio to int mode. 
[   18.791060] ctp_set_irq_mode, 225: gpio_int_info, port = 8, port_num = 14. 
[   18.793093]  INTERRUPT CONFIG
[   18.796691] IRQ handler type mismatch for IRQ 60
[   18.799495] current handler: sunxi-gpio
[   18.807113] [<c0015340>] (unwind_backtrace+0x0/0x134) from [<c0094b88>] (__setup_irq+0x3b8/0x404)
...
[   18.936110] [<c0082454>] (sys_init_module+0x78/0x19c) from [<c000ec00>] (ret_fast_syscall+0x0/0x30)
[   18.940971] ft5x_ts 1-0038: ft5x_ts_probe: request irq failed
[   18.956486] ------------[ cut here ]------------
[   18.962015] WARNING: at kernel/irq/manage.c:428 enable_irq+0x3c/0x74()
[   18.964929] Unbalanced enable for IRQ 60
[   18.966797] Modules linked in: ft5x_ts(+) sunxi_cedar_mod mali ump gpio_sunxi
[   18.979457] [<c0015340>] (unwind_backtrace+0x0/0x134) from [<c0037168>] (warn_slowpath_common+0x54/0x64)
...
[   19.115268] [<c0082454>] (sys_init_module+0x78/0x19c) from [<c000ec00>] (ret_fast_syscall+0x0/0x30)
[   19.118864] ---[ end trace 85db90c5c3401102 ]---
[   19.123053] ------------[ cut here ]------------
[   19.128751] WARNING: at kernel/irq/manage.c:1196 __free_irq+0xa0/0x1e8()
[   19.131905] Trying to free already-free IRQ 60
[   19.133751] Modules linked in: ft5x_ts(+) sunxi_cedar_mod mali ump gpio_sunxi
[   19.146308] [<c0015340>] (unwind_backtrace+0x0/0x134) from [<c0037168>] (warn_slowpath_common+0x54/0x64)
...
[   19.289233] [<c0082454>] (sys_init_module+0x78/0x19c) from [<c000ec00>] (ret_fast_syscall+0x0/0x30)
[   19.292840] ---[ end trace 85db90c5c3401103 ]---
[   19.295335] ==singlethread error =
[ 19.299931] ft5x_ts: probe of 1-0038 failed with error -16

That's pretty much the same I saw here:


Then I got the sources: "linux-headers-3.4.79-sun7i" and "linux-source-3.4.79-sun7i". After patching the driver's source code at

/usr/src/linux-source-3.4.79-sun7i/drivers/input/touchscreen/ft5x_ts.c

I wanted to avoid compiling the whole kernel, so I did some googling and came up with the following steps in order to compile just one module.

cd /usr/src/linux-source-3.4.79-sun7i
cp /boot/config-3.4.79-sun7i .config
cp /usr/src/linux-headers-3.4.79-sun7i/Module.symvers ./
make oldconfig
make prepare
make scripts
make modules SUBDIRS=drivers/input/touchscreen/
make modules_install SUBDIRS=drivers/input/touchscreen/

Later I found out modules_install was deploying the module to the wrong path. So I copied it to the right one

cp /lib/modules/3.4.79-sun7i/extra/ft5x_ts.ko /lib/modules/3.4.79-sun7i/kernel/drivers/input/touchscreen/

After rebooting, I get a "Segmentation fault" error when the module loads, and the boot screen hangs forever. I have to unplug the touch panel and reboot again to get back to Cubian. Some people say you should use this code instead:


as it is the proper one for Cubieboard. So I went through all the steps above again using this other source code. I don't get the "Segmentation fault" error anymore, but something like:

...
ctp_wakeup. 
xfer timeout
...

Now I'm stuck. Every other post I could find says that recompiling works fine, but that's not been the case. =(

When I try i2cdetect, I get this:

root@Cubian:/home/cubie# i2cdetect 1
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-1.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

So my device IS there. What else can I do?

Thank you.

Leonardo

unread,
Feb 12, 2015, 3:24:40 PM2/12/15
to cubie...@googlegroups.com
I'm outraged. I was out of ideas. So I started reading the driver's code (the last one I tried)... the interrupt pin was hard coded! It didn't come from the fex file! Unbelievable...

	if (gpio_request(3, "ft5x")) {
		ctp_int_gpio = -1;
		pr_err("failed to request ft5x gpio\n");
		return -1;
	}
	ctp_int_gpio = 3;

And the worst part is that 3 is not even an option, because as we see here:


it corresponds to pin PB18, which is TWI1_CLK. I changed to pin 10 (PH14), as in my fex file and it "worked". I mean, the cursor does some random moves now as I touch. It's still far from perfect, but at least there's hope... I'd appreciate if anyone could help me with this problem now.

Thank you.

Leonardo

unread,
Feb 12, 2015, 9:05:47 PM2/12/15
to 孙鹏, cubieboard
Hi. My fex is a little different:

[gpio_para]
gpio_used = 1
gpio_num = 67
gpio_pin_1 = port:PG03<1><default><default><1>
gpio_pin_2 = port:PB19<1><default><default><1>
gpio_pin_3 = port:PB18<1><default><default><1>
gpio_pin_4 = port:PG06<1><default><default><1>
...
gpio_pin_9 = port:PG00<1><default><default><1>
gpio_pin_10 = port:PH14<1><default><default><1>

PH14 is already set to pin 10. That's why I've decided to changed it right in the source code. It was easier. My gpio_para list follows the image I've linked before.

I'm carefully reading the code now. There must be something I'm not seeing...

2015-02-13 1:57 GMT+00:00 孙鹏 <s...@cubietech.com>:
Hi leonardo
about you question where is "3" from.

if (gpio_request(3, "ft5x")) {
		ctp_int_gpio = -1;
		pr_err("failed to request ft5x gpio\n");
		return -1;
	} 
ctp_int_gpio = 3

Acutally  gpio number 3 is from FEX file  gpio_para

[gpio_para]
gpio_used = 1
gpio_num                 = 2
gpio_pin_1              = port:PH20<1><default><default><1>                          ------>  corresponding  gpio number  1 
gpio_pin_2              = port:PH21<1><default><default><1>                          ------>  corresponding  gpio  number  2

So  here you should change FEx file to :

[gpio_para]
gpio_used = 1
gpio_num                 = 2
gpio_pin_1              = port:PH20<1><default><default><1>                          ------>  corresponding  gpio number  1 
gpio_pin_2              = port:PH21<1><default><default><1>                          ------>  corresponding  gpio  number 2
gpio_pin_2              = port:PH14<default><default><default><default>          ------>  corresponding  gpio  number 3   
 
------------------ Original ------------------
From:  "Leonardo"<leoba...@gmail.com>;
Date:  Fri, Feb 13, 2015 04:24 AM
To:  "cubieboard"<cubie...@googlegroups.com>;
Subject:  [cubieboard] Re: FT5x_TS with Cubieboard 2

--
You received this message because you are subscribed to the Google Groups "Cubieboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cubieboard+...@googlegroups.com.
Visit this group at http://groups.google.com/group/cubieboard.
For more options, visit https://groups.google.com/d/optout.

Leonardo

unread,
Feb 12, 2015, 9:29:42 PM2/12/15
to 孙鹏, cubieboard
That's what I did. I changed 3 to 10 in ft5x_ts.c.

The I2C pins were already set at gpio_para by default. The only thing I did on my fex was to enable twi1_para and change settings at ctp_para.

2015-02-13 0:21 GMT-02:00 孙鹏 <s...@cubietech.com>:
 
 Hi  

Some error imformation  in last mail .  Please refer this mail

As your fex file .  you may change this  
if (gpio_request(3, "ft5x")) {
		ctp_int_gpio = -1;
		pr_err("failed to request ft5x gpio\n");
		return -1;
	} 
ctp_int_gpio = 3 
to

if (gpio_request(10, "ft5x")) {
		ctp_int_gpio = -1;
		pr_err("failed to request ft5x gpio\n");
		return -1;
	} 
ctp_int_gpio = 10;



and By  the way .about I2c PIN you can just set  this in twi1_para of  fex file:             don't need to set in gpio_para
[twi1_para]
twi1_used = 1
twi1_scl = port:PB18<2><default><default><default>
twi1_sda = port:PB19<2><default><default><default>

------------------ Original ------------------
From:  "Leonardo"<leoba...@gmail.com>;
Date:  Fri, Feb 13, 2015 10:05 AM
To:  "孙鹏"<s...@cubietech.com>;
Cc:  "cubieboard"<cubie...@googlegroups.com>;
Subject:  Re: [cubieboard] Re: FT5x_TS with Cubieboard 2

Leonardo

unread,
Feb 12, 2015, 9:50:27 PM2/12/15
to 孙鹏, cubieboard
Hi. Yes, I did it. The driver loads, but there's some problem while reading the points.

[   18.495285] ===========================ft5x_ts_init=====================
[   18.498018] ctp_fetch_sysconfig_para. 
[   18.507429] ctp_fetch_sysconfig_para: after: ctp_twi_addr is 0x38, dirty_addr_buf: 0x38. dirty_addr_buf[1]: 0xfffe 
[   18.511700] ctp_fetch_sysconfig_para: ctp_twi_id is 1. 
[   18.516272] ctp_fetch_sysconfig_para: screen_max_x = 1024. 
[   18.520727] ctp_fetch_sysconfig_para: screen_max_y = 600. 
[   18.525129] ctp_fetch_sysconfig_para: revert_x_flag = 0. 
[   18.529497] ctp_fetch_sysconfig_para: revert_y_flag = 0. 
[   18.534266] ctp_fetch_sysconfig_para: exchange_x_y_flag = 1. 
[   18.541928] ft5x_ts_init: after fetch_sysconfig_para:  normal_i2c: 0x38. normal_i2c[1]: 0xfffe 
[   18.543534] ctp_reset. 
[   18.622685] ctp_wakeup. 
[   18.733653] ctp_detect: Detected chip ft5x_ts at adapter 1, address 0x38
[   18.737199] ====ft5x_ts_probe begin=====.  
[   18.744979] input: ft5x_ts as /devices/platform/sunxi-i2c.1/i2c-1/1-0038/input/input3
[   18.748980] ==ft5x_ts_probe over =


2015-02-13 2:46 GMT+00:00 孙鹏 <s...@cubietech.com>:
Hi lednardo

do you try to patch this?

-       err = request_irq(SW_INT_IRQNO_PIO, ft5x_ts_interrupt, IRQF_TRIGGER_FALLING | IRQF_SHARED, "ft5x_ts", ft5x_ts);
+       err = request_irq(SW_INT_IRQNO_PIO, ft5x_ts_interrupt, IRQF_SHARED, "ft5x_ts", ft5x_ts);
 
------------------ Original ------------------
From:  "Leonardo"<leoba...@gmail.com>;
Date:  Fri, Feb 13, 2015 10:05 AM
To:  "孙鹏"<s...@cubietech.com>;
Cc:  "cubieboard"<cubie...@googlegroups.com>;
Subject:  Re: [cubieboard] Re: FT5x_TS with Cubieboard 2

Leonardo

unread,
Feb 13, 2015, 7:26:55 AM2/13/15
to 孙鹏, cubieboard
Today I realized the touch panel cable (FPB) was damaged. I've plugged it in and out so many times that some tracks were broken... I'm assuming that's why I got those weird moves before. So, as far as I can tell, my biggest tip for those in the same situation is to be aware of the hard coded INT pin number.

I'll get a new panel. If anything changes, I'll post again.
Reply all
Reply to author
Forward
0 new messages