T113的SPIDEV只能发送几次,就卡住了?
-
使用spidev_test进行测试,发现前面几次可以成功收发,使用示波器可以观察到正确的波形, 然后spidev_test应用就卡住了,试过程如下,为了避免console被卡住,把测试放在后台:
#spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [1] 1114 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [2] 1116 [1] Done spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [3] 1117 [2] Done spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [4] 1118 [3] Done spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [5] 1120 [4] Done spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [6] 1121 [5] Done spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678& [7] 1122 [6] Done spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz)
spidev_test应用被卡住,没有数据输出,应该是spi的驱动没有返回
# ps PID USER COMMAND 1 root init [3] 2 root [kthreadd] 3 root [rcu_gp] 4 root [rcu_par_gp] 5 root [kworker/0:0-eve] 6 root [kworker/0:0H-kb] 7 root [kworker/u4:0-ev] 8 root [mm_percpu_wq] 9 root [ksoftirqd/0] 10 root [rcu_preempt] 11 root [migration/0] 12 root [cpuhp/0] 13 root [kdevtmpfs] 14 root [kworker/u4:1-ev] 16 root [rcu_tasks_kthre] 26 root [kworker/0:1-eve] 420 root [oom_reaper] 421 root [writeback] 455 root [kblockd] 529 root [kworker/u4:2-ev] 593 root [ion_system_heap] 615 root [watchdogd] 710 root [cfg80211] 714 root [spi0] 725 root [kswapd0] 737 root [vsync proc 0] 738 root [vsync proc 1] 795 root [uas] 835 root [rc0] 862 root [irq/40-mmc0] 864 root [irq/202-4020000] 866 root [kworker/0:2-eve] 867 root [irq/41-mmc1] 873 root [kworker/0:3-eve] 888 root [mmc_complete] 892 root [kworker/0:1H-kb] 901 root [ipv6_addrconf] 916 root [krfcommd] 953 root [usb-hardware-sc] 956 root [goodix_wq] 969 root [kworker/0:2H-kb] 970 root [jbd2/mmcblk0p5-] 971 root [ext4-rsv-conver] 1009 root /sbin/syslogd -n 1013 root /sbin/klogd -n 1024 root /sbin/udevd -d 1092 root /usr/bin/swupdate -v -w -r /var/www/swupdate -p 8080 1093 root -bash 1099 root /usr/bin/swupdate-progress -w -r 1105 root /usr/bin/swupdate -v -w -r /var/www/swupdate -p 8080 1122 root spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 1124 root ps # cat /proc/1122/status Name: spidev_test Umask: 0022 State: R (running) Tgid: 1122 Ngid: 0 Pid: 1122 PPid: 1093 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 256 Groups: 0 10 VmPeak: 1352 kB VmSize: 1352 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 132 kB VmRSS: 132 kB RssAnon: 28 kB RssFile: 104 kB RssShmem: 0 kB VmData: 168 kB VmStk: 132 kB VmExe: 8 kB VmLib: 964 kB VmPTE: 8 kB VmSwap: 0 kB CoreDumping: 0 THP_enabled: 0 Threads: 1 SigQ: 0/726 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 CapInh: 0000000000000000 CapPrm: 0000003fffffffff CapEff: 0000003fffffffff CapBnd: 0000003fffffffff CapAmb: 0000000000000000 NoNewPrivs: 0 Speculation_Store_Bypass: unknown Cpus_allowed: 3 Cpus_allowed_list: 0-1 voluntary_ctxt_switches: 0 nonvoluntary_ctxt_switches: 1398
硬件平台是 MQ-R(T113), dts中配置如下,只
使用了CLK, CS, MISO, MOSI4根线sun8iw20p1-t113-100ask-t113-pro.dts
------------------------------------------- spi0_pins_a: spi0@0 { pins = "PC2", "PC4", "PC5"; /*clk mosi miso*/ function = "spi0"; drive-strength = <10>; }; spi0_pins_b: spi0@1 { pins = "PC3"; function = "spi0"; drive-strength = <10>; bias-pull-up; /* only CS should be pulled up */ }; spi0_pins_c: spi0@2 { pins = "PC2", "PC3", "PC4", "PC5"; function = "gpio_in"; drive-strength = <10>; }; &spi0 { clock-frequency = <100000000>; pinctrl-0 = <&spi0_pins_a &spi0_pins_b>; pinctrl-1 = <&spi0_pins_c>; pinctrl-names = "default", "sleep"; /*spi-supply = <®_dcdc1>;*/ spi_slave_mode = <0>; spi0_cs_number = <1>; spi0_cs_bitmap = <1>; status = "okay"; spi_board0@0 { device_type = "spi_board0"; compatible = "rohm,dh2228fv"; spi-max-frequency = <0x5f5e100>; reg = <0x0>; spi-rx-bus-width = <0x01>; spi-tx-bus-width = <0x01>; status = "okay"; }; };
在D1s平台上测试也有类似的问题,各位大侠,是否遇到这个情况, 请指点一下,谢谢!
-
echo 255 > /sys/module/spi_sunxi/parameters/debug 开调试看一下
-
@yuzukitsuru 谢谢大侠回复
# echo 255 > /sys/module/spi_sunxi/parameters/debug # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 [ 96.048082] spi_set_clk()532 - set spi clock 100000000, mclk 1000000 [ 96.055418] spi_set_clk()532 - set spi clock 100000000, mclk 100000000 [ 96.062767] spi_set_clk()532 - set spi clock 1000000, mclk 100000000 spi mode: 0x0[ 96.071087] sunxi_spi_transfer_one()1637 - [spi0] begin transfer, txbuf 684e7dd8, rxbuf 989b57fc, len 8 bits per word: 8 max speed: 1000000 Hz (1000 KHz) [ 96.083098] sunxi_spi_mode_check()1313 - [spi0] Single mode Full duplex tx & rx [ 96.095818] sunxi_spi_transfer_one()1674 - [spi0] dump reg: [ 96.102085] 0x04025000: 00010001 00000083 00002044 00000000 [ 96.108655] 0x04025010: 00001700 00000032 00200020 00000000 [ 96.115268] 0x04025020: 00000000 00000002 00002000 00000000 [ 96.121632] 0x04025030: 00000008 00000008 00000008 00000000 [ 96.128206] sunxi_spi_dma_transfer()1551 - [spi0] rx and tx -> by ahb [ 96.135668] sunxi_spi_cpu_writel()1417 - t->len = 8 [ 96.141155] 000: 31 32 33 34 35 36 37 38 [ 96.145935] sunxi_spi_cpu_readl()1386 - t->len = 8 [ 96.145945] sunxi_spi_handler()1728 - [spi0] irq status = 1033 [ 96.157855] sunxi_spi_handler()1744 - [spi0] SPI TC comes [ 96.164245] 000: ff ff ff ff ff ff ff ff [ 96.168751] sunxi_spi_transfer_one()1685 - [spi0] dump reg: [ 96.175279] 0x04025000: 00010001 00000083 00002044 00000000 [ 96.181640] 0x04025010: 00000000 00000032 00200020 00000000 [ 96.188197] 0x04025020: 00000000 00000002 00002000 00000000 [ 96.194687] 0x04025030: 00000000 00000000 00000000 00000000 TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........
重复几十次测试,没有卡住, 我就要下面命令加大收发数据量,也不会卡住
spi-pipe --device=/dev/spidev0.0 -b 8 -n 256 -s 1000000 < /dev/zero
然后我再把调试关闭,重复几次,很快就复现原来的问题
# echo 0 > /sys/module/spi_sunxi/parameters/debug # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz) TX | 31 32 33 34 35 36 37 38 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | 12345678 RX | FF FF FF FF FF FF FF FF __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ | ........ # spidev_test -D /dev/spidev0.0 -v -s 1000000 -p 12345678 spi mode: 0x0 bits per word: 8 max speed: 1000000 Hz (1000 KHz)
卡住了,后面没有输出了
我用示波器观察,最后一次卡住时,也是有波形的,感觉spi的驱动没有收到传输结束中断,调试输出可能会影响到中断的设置时序,请大侠帮助分析分析,谢谢!
在T113/D1s上都可以重现,我对比了一下它们驱动sunxi_spi.c是相同的
T113的软件版本
https://gitee.com/weidongshan/buildroot_100ask_t113-pro -
@zhongtao1701 我也有碰到了同样的问题 spi原厂驱动有问题
-
你好,请问最后的原因找到了吗?是因为中断的问题而导致进程卡死的吗。如果找到原因了麻烦解答一下,谢谢。
-
@zhongtao1701 你好,请问最后的原因找到了吗?是因为中断的问题而导致进程卡死的吗。如果找到原因了麻烦解答一下,谢谢。
-
D1s上spi操作有同样的问题,而且spi驱动里的函数执行卡死后,没有任何结束进程的方式。不知道全志解决这个spi驱动的问题了没有
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号