Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Network programming Linux enc28j60驱动程序在传输时总是超时_Network Programming_Linux Device Driver_Beagleboneblack - Fatal编程技术网

Network programming Linux enc28j60驱动程序在传输时总是超时

Network programming Linux enc28j60驱动程序在传输时总是超时,network-programming,linux-device-driver,beagleboneblack,Network Programming,Linux Device Driver,Beagleboneblack,我已经将一个带有SPI接口的ENC28J60模块连接到运行Linux 3.8的Beaglebone Black开发板上,但我无法让设备发送(或接收)任何东西。每次尝试发送都会超时并增加发送错误 最初,Linux内核附带的驱动程序不允许我打开链接。经过一系列调试后,我发现如果在主板初始化过程中等待一定时间,我可以找到链接。驱动程序的补丁位于enc28j60\u check\u link\u status功能中,大致如下所示 unsigned long timeout = jiffies + 1

我已经将一个带有SPI接口的ENC28J60模块连接到运行Linux 3.8的Beaglebone Black开发板上,但我无法让设备发送(或接收)任何东西。每次尝试发送都会超时并增加发送错误

最初,Linux内核附带的驱动程序不允许我打开链接。经过一系列调试后,我发现如果在主板初始化过程中等待一定时间,我可以找到链接。驱动程序的补丁位于
enc28j60\u check\u link\u status
功能中,大致如下所示

  unsigned long timeout = jiffies + 1*HZ;                                                                                                                                                             
  while ((enc28j60_phy_read(priv, PHSTAT2) & PHSTAT2_LSTAT) == 0) {                                                                                                              
    if (time_after(jiffies, timeout)) {                                                                                                                                                         
      if (netif_msg_drv(priv))                                                                                                                                                                                                                                                                                              
        break;                                                                                                                                                                              
      }                                                                                                                                                                                           
      schedule();                                                                                                                                                                                 
    }
现在,我可以像这样可靠地加载驱动程序和配置接口

ifconfig rename3 down
ethtool -s rename3 msglvl 0xffff
ethtool -s rename3 speed 10 duplex full
ifconfig rename3 up
我已经定制了ENC28J60的驱动程序,以便在搜索问题根源的同时执行一系列额外的
printk
。在打开接口后,我得到以下信息

Feb  1 00:22:48 arm kernel: [  100.001942] enc28j60: HELLO WORLD
Feb  1 00:22:48 arm kernel: [  100.002092] enc28j60: enc28j60_net_open() enter
Feb  1 00:22:48 arm kernel: [  100.002119] enc28j60: enc28j60_hw_disable() enter
Feb  1 00:22:48 arm kernel: [  100.002315] enc28j60: enc28j60_hw_init() enter
Feb  1 00:22:48 arm kernel: [  100.002342] enc28j60: enc28j60_hw_init() - FullDuplex
Feb  1 00:22:48 arm kernel: [  100.002366] enc28j60: enc28j60_soft_reset() enter
Feb  1 00:22:48 arm kernel: [  100.006957] enc28j60: nolock_rxfifo_init() enter
Feb  1 00:22:48 arm kernel: [  100.007117] enc28j60: erxrdpt_workaround() enter
Feb  1 00:22:48 arm kernel: [  100.007373] enc28j60: nolock_txfifo_init() enter
Feb  1 00:22:48 arm kernel: [  100.007807] enc28j60: chip RevID: 0x06
Feb  1 00:22:48 arm kernel: [  100.009680] enc28j60: enc28j60_phy_write() enter
Feb  1 00:22:48 arm kernel: [  100.010950] enc28j60: enc28j60_phy_write() enter
Feb  1 00:22:48 arm kernel: [  100.011335] enc28j60: enc28j60_phy_write() enter
Feb  1 00:22:48 arm kernel: [  100.014973] enc28j60 Hw initialized.
Feb  1 00:22:48 arm kernel: [  100.014973] HwRevID: 0x06
Feb  1 00:22:48 arm kernel: [  100.014973] Cntrl: ECON1 ECON2 ESTAT  EIR  EIE
Feb  1 00:22:48 arm kernel: [  100.014973]        0x03  0x80  0x01  0x00  0x00
Feb  1 00:22:48 arm kernel: [  100.014973] MAC  : MACON1 MACON3 MACON4
Feb  1 00:22:48 arm kernel: [  100.014973]        0x0d   0x33   0x00
Feb  1 00:22:48 arm kernel: [  100.014973] Rx   : ERXST  ERXND  ERXWRPT ERXRDPT ERXFCON EPKTCNT MAMXFL
Feb  1 00:22:48 arm kernel: [  100.014973]        0x0000 0x19ff 0x0000  0x19ff  0xa1    0x00    0x05ee
Feb  1 00:22:48 arm kernel: [  100.014973] Tx   : ETXST  ETXND  MACLCON1 MACLCON2 MAPHSUP
Feb  1 00:22:48 arm kernel: [  100.014973]        0x1a00 0x1fff 0x0f     0x37     0x10
Feb  1 00:22:48 arm kernel: [  100.015073] enc28j60: enc28j60_set_hw_macaddr() enter
Feb  1 00:22:48 arm kernel: [  100.015105] enc28j60: rename3: Setting MAC address to ee:31:66:60:5a:52
Feb  1 00:22:48 arm kernel: [  100.015530] enc28j60: enc28j60_hw_enable() enter
Feb  1 00:22:48 arm kernel: [  100.015556] enc28j60: enc28j60_hw_enable() enabling interrupts.
Feb  1 00:22:48 arm kernel: [  100.015578] enc28j60: enc28j60_phy_write() enter
Feb  1 00:22:48 arm kernel: [  100.017800] enc28j60: enc28j60_check_link_status() enter
Feb  1 00:22:48 arm kernel: [  100.020726] enc28j60: enc28j60_check_link_status() PHSTAT1: 1800, PHSTAT2: 0200
Feb  1 00:22:48 arm kernel: [  100.020760] enc28j60:enc28j60_check_link_status() polling PHSTAT2_LSTAT != 0
Feb  1 00:22:48 arm kernel: [  100.069286] enc28j60:enc28j60_check_link_status() reg/link now 1536/1024
Feb  1 00:22:48 arm kernel: [  100.069319] enc28j60:enc28j60_check_link_status() have link! setting carrier on
Feb  1 00:22:48 arm kernel: [  100.069362] net rename3: link up - Full duplex
Feb  1 00:22:58 arm kernel: [  109.989281] enc28j60: enc28j60_send_packet() enter
Feb  1 00:22:58 arm kernel: [  109.989329] enc28j60: enc28j60_send_packet() enter
Feb  1 00:22:58 arm kernel: [  109.989411] enc28j60: enc28j60_tx_work_handler() enter
Feb  1 00:22:58 arm kernel: [  109.989437] enc28j60: enc28j60_hw_tx() enter
Feb  1 00:22:58 arm kernel: [  109.989459] enc28j60: Tx Packet Len:70
Feb  1 00:22:58 arm kernel: [  109.989481] enc28j60: enc28j60_hw_tx - packet len:70
Feb  1 00:22:58 arm kernel: [  109.989517] pk data: 00000000: 33 33 00 00 00 02 ee 31 66 60 5a 52 86 dd 60 00  33.....1f`ZR..`.
Feb  1 00:22:58 arm kernel: [  109.989548] pk data: 00000010: 00 00 00 10 3a ff fe 80 00 00 00 00 00 00 ec 31  ....:..........1
Feb  1 00:22:58 arm kernel: [  109.989576] pk data: 00000020: 66 ff fe 60 5a 52 ff 02 00 00 00 00 00 00 00 00  f..`ZR..........
Feb  1 00:22:58 arm kernel: [  109.989605] pk data: 00000030: 00 00 00 00 00 02 85 00 21 65 00 00 00 00 01 01  ........!e......
Feb  1 00:22:58 arm kernel: [  109.989633] pk data: 00000040: ee 31 66 60 5a 52                                .1f`ZR
Feb  1 00:22:58 arm kernel: [  109.989655] enc28j60: enc28j60_packet_write() enter
Feb  1 00:22:58 arm kernel: [  109.990379] enc28j60: enc28j60_packet_write() after control byte ERWPT:0x1a01
Feb  1 00:22:58 arm kernel: [  109.990406] enc28j60: spi_write_buf() enter
Feb  1 00:22:58 arm kernel: [  109.990571] enc28j60: enc28j60_packet_write() spi_write returns 0
Feb  1 00:22:58 arm kernel: [  109.990761] enc28j60: enc28j60_packet_write() after write packet ERWPT:0x1a47, len=70
Feb  1 00:23:18 arm kernel: [  129.979247] enc28j60: enc28j60_tx_timeout() enter
Feb  1 00:23:18 arm kernel: [  129.979313] net rename3: enc28j60 tx timeout

我通过在
spi\u read\u buf
中调用
spi\u sync
来缩小范围。了解Linux网络驱动程序或Microchip的ENC28J60的人知道我应该研究什么来解决这个问题吗

仅供参考,内核中有函数跟踪程序。您可以实时检查函数调用,无需任何额外的printf。谢谢您提供的信息@AndyShevchenko。我找到了。这就是你说的吗?似乎没有一种方法可以仅仅跟踪这个模块,这似乎是一个有用的功能。不,我指的是我知道这是一个旧线程,但你曾经成功过吗?我之所以这么问,是因为我和以前的3.8内核同舟共济。我没有:(我放弃了,转到了另一个模块。如果你能弄明白这一点,我很想知道,因为我仍然有一些这样的模块。