danitool / openwrt-pkgs

my custom OpenWrt packages: lirc and others
GNU General Public License v2.0
9 stars 4 forks source link

Try to make it work on AR9331 #5

Open Soundtrack9407 opened 7 years ago

Soundtrack9407 commented 7 years ago

Hi danitool,

GL-iNet 6416(based on AR9331), chaos calmer, kernel 3.18.44(728-MIPS-ath79-add-gpio-irq.patch has been apply)

root@soundtrack:~# cat /sys/kernel/debug/gpio GPIOs 0-29, ath79: ...... gpio-20 (lirc_gpio_generic ir) out lo gpio-21 (lirc_gpio_generic ir) in lo ...... everything seems normally, but when I test the receiver( execute "irw" ), some error has happen:

[  262.340000] CPU 0 Unable to handle kernel paging request at virtual address 00000000, epc == 00000000, ra == 83112744
[  262.350000] Oops[#1]:
[  262.350000] CPU: 0 PID: 1953 Comm: cat Not tainted 3.18.44 #1
[  262.350000] task: 839a5838 ti: 82d84000 task.ti: 82d84000
[  262.350000] $ 0   : 00000000 fffffff8 00000000 2d9523a6
[  262.350000] $ 4   : 80395e9c 00000015 00000001 00000000
[  262.350000] $ 8   : 3b9aca00 c4653600 059682f0 00000008
[  262.350000] $12   : 0000cce6 77f643a0 00000000 00000000
[  262.350000] $16   : 83077700 83110000 83110000 830f8b00
[  262.350000] $20   : 83ae8780 803b0000 82d85e18 82d85ef0
[  262.350000] $24   : 00000000 77f04ff0
[  262.350000] $28   : 82d84000 82d85cc0 00000000 83112744
[  262.350000] Hi    : 000002c6
[  262.350000] Lo    : 000bab4c
[  262.350000] epc   : 00000000   (null)
[  262.350000]     Not tainted
[  262.350000] ra    : 83112744 0x83112744
[  262.350000] Status: 1000fc03 KERNEL EXL IE
[  262.350000] Cause : 10800008
[  262.350000] BadVA : 00000000
[  262.350000] PrId  : 00019374 (MIPS 24Kc)
[  262.350000] Modules linked in: ath9k ath9k_common pppoe ppp_async iptable_nat ath9k_hw ath pppox ppp_generic nf_nat_ipv4 nf_conntrack_ipv6 nf_conntrack_ipv4 mac80211 ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_id xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_CT uvcvideo slhc nf_reject_ipv4 nf_nat_masquerade_ipv4 nf_nat_ftp nf_nat nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack_ftp nf_conntrack iptable_raw iptable_mangle iptable_filter ip_tables crc_ccitt compat lirc_gpio_generic videobuf2_vmalloc videobuf2_memops videobuf2_core i2c_dev ledtrig_usbdev xt_set ip_set_list_set ip_set_hash_netiface ip_set_hash_netport ip_set_hash_netnet ip_set_hash_net ip_set_hash_netportnet ip_set_hash_mac ip_set_hash_ipportnet ip_set_hash_ipportip ip_set_hash_ipport ip_set_hash_ipmark ip_set_hash_ip ip_set_bitmap_port ip_set_bitmap_ipmac ip_set_bitmap_ip ip_set nfnetlink ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 nf_log_common ip6table_raw ip6table_mangle ip6table_filter ip6_tables x_tables ip6_tunnel tunnel6 ipv6 dma_shared_buffer arc4 crypto_blkcipher input_polldev ohci_platform ohci_hcd ehci_platform ehci_hcd gpio_button_hotplug usbcore nls_base usb_common
[  262.350000] Process cat (pid: 1953, threadinfo=82d84000, task=839a5838, tls=77fec440)
[  262.350000] Stack : 0fc00000 80100964 81082218 800cf3d4 fffff14c 80393178 83077700 fffffff0
[  262.350000]    83b76540 80241970 803940f0 803f0000 00000000 83b76540 83b76540 830f8b00
[  262.350000]    831131c4 83b76540 83ae8780 00000000 83ae8788 80100e7c 82d85e10 83442ee0
[  262.350000]    83ae8780 82d85d98 00000000 82d85ef0 83ae8780 83b76540 82d85e10 80100d58
[  262.350000]    83ae8780 800faa6c 83b76540 82d85e10 00000000 80106fe4 82d85e10 82d85e60
[  262.350000]    ...
[  262.350000] Call Trace:
[  262.350000] [<80100964>] exact_lock+0x10/0x24
[  262.350000] [<800cf3d4>] get_page_from_freelist+0xe8/0x5b8
[  262.350000] [<80241970>] lirc_dev_fop_open+0xfc/0x1cc
[  262.350000] [<80100e7c>] chrdev_open+0x124/0x164
[  262.350000] [<80100d58>] chrdev_open+0x0/0x164
[  262.350000] [<800faa6c>] do_dentry_open.isra.16+0x20c/0x330
[  262.350000] [<80106fe4>] may_open+0xbc/0x12c
[  262.350000] [<80109a08>] do_last.isra.58+0x89c/0xb58
[  262.350000] [<80107b74>] link_path_walk+0x88/0x7d4
[  262.350000] [<80109ee8>] path_openat+0x224/0x584
[  262.350000] [<8010ae48>] do_filp_open+0x3c/0xa4
[  262.350000] [<80075ab0>] __do_page_fault+0x1dc/0x390
[  262.350000] [<801164c0>] __alloc_fd+0x80/0x16c
[  262.350000] [<800fc020>] do_sys_open+0x18c/0x238
[  262.350000] [<800ee4c4>] SyS_mprotect+0x1cc/0x204
[  262.350000] [<80062b5c>] handle_sys+0x11c/0x140
[  262.350000]
[  262.350000]
[  262.350000] Code: (Bad address in epc)
[  262.350000]
[  262.670000] ---[ end trace cf85ba6bd26cb558 ]---
======================================

After that rmmod lirc_gpio_generic module was failed, and I still couldn't receiver any signal from IR receiver. What should I do to fix this error?

Thanks. Soundtrack

danitool commented 7 years ago

It might be a problem with the IRQs implementation in the kernel, it is supposed the package lirc-gpio-generic comes with a couple of patches for fixing IRQ/GPIO in AR7xx. Try to rebuild your firmware, first make a kernel clean:
make target/linux/clean
and then compile the firmware again
make

Soundtrack9407 commented 7 years ago

I already tried to check the kernel patch and rebuilt my firmware, but the error still exists. Last 2 days I try to understand demo(lirc_gpio_generic.c), for example: /* Translate our GPIO number into absolute number */ gpio_out_pin = gpio_out_pin + base; gpio_in_pin = gpio_in_pin + base; but base = 0, it's an error? Everything seems OK...... [ 13.140000] lirc_gpio_generic: Found GPIO chip, label = ath79, base = 0 [ 13.590000] lirc_gpio_generic: auto-detected active high receiver on GPIO pin 21 [ 13.590000] lirc_gpio_generic IN: ath79, base = 0, offset = 21 [ 13.600000] lirc_gpio_generic OUT: ath79, base = 0, offset = 20 [ 13.600000] lirc_gpio_generic lirc_gpio_generic.0: lirc_dev: driver lirc_gpio_generic registered at minor = 0 [ 13.610000] lirc_gpio_generic: driver registered!

Thank you. Soundtrack

danitool commented 7 years ago

I think the problem is at the gpio-irq driver itsel, I picked up the patches for AR7xx from https://github.com/GBert/openwrt-misc/tree/master/gpio-test/src/patches-3.18

Check them. I tested lirc-gpio-generic only with AR7240. You could also try to remove the patch I provided with the package. In theory with latest Openwrt versions IRQs for gpios were fixed, but it wasn't my case (the reason of providing the patch).

If the problem persists you better should contact with AR71xx developers from Openwrt/LEDE teams.

Soundtrack9407 commented 7 years ago

Hi danitlool,

Thanks for your advice. I have a good news, I use bb branch driver on CC platform boldly, and it worked. So I think that the problem is lirc_gpio_generic.c(cc branch) code. In addition, According to the datasheet, AR9331 has the same serial port(GPIO9,10) with AR7240. Now, it can only open device(cat /dev/lirc0) and receivce some current signal but not IR signal. [13997.460000] lirc_gpio_generic: 6lirc_gpio_generic: freed IRQ 60 [14008.510000] lirc_gpio_generic: cleaned up module [14073.390000] lirc_gpio_generic: manually using active low receiver on GPIO pin 9 [14073.400000] lirc_gpio_generic lirc_gpio_generic.0: lirc_dev: driver lirc_gpio_generic registered at minor = 0 [14073.410000] lirc_gpio_generic: driver registered! [15909.080000] lirc_gpio_generic: AIEEEE: 1 1 585bd17c 585bd14f 59a31 528f3 [16036.460000] lirc_gpio_generic: AIEEEE: 0 0 585bd1fb 585bd17c b66b6 5b04e [16701.260000] lirc_gpio_generic: cleaned up module [16711.670000] lirc_gpio_generic: to_irq 60 [16712.630000] lirc_gpio_generic: auto-detected active high receiver on GPIO pin 9 [16712.630000] lirc_gpio_generic lirc_gpio_generic.0: lirc_dev: driver lirc_gpio_generic registered at minor = 0 [16712.640000] lirc_gpio_generic: driver registered! [16724.720000] lirc_gpio_generic: Interrupt 60 obtained [16724.720000] lirc_gpio_generic: in init_timing_params, freq=38000 pulse=13157, space=13158 [16733.100000] lirc_gpio_generic: 6lirc_gpio_generic: freed IRQ 60

danitool commented 7 years ago

There are minor differences between both drivers, the one from CC is supposed to toggle the gpio at lower level like the original rpi driver did. The driver from BB uses the legacy gpio libraries, they also should work ok.

A few days ago I tested successfully the CC driver in the last LEDE snapshot. I took the driver and LIRC software as is, and it worked quite fine (only receiver tested) in a brcm63xx board.

Right now I have no idea what's going on with ar71xx.

danitool commented 7 years ago

Hi, it turns out that the gpio driver hadn't _.toirq in the gpiochip structure and was causing the kernel error. Now lirc-gpio-generic driver should work for ar71xx in commit : https://github.com/danitool/openwrt-pkgs/commit/42573d9c8dc14fd589dd8eb4b74151a25f9739ea

Tested succesfully in AR7240 platform.

Regards.