MOD-ENC28J60 and Linux (Debian/GNU)

Started by leo, December 03, 2012, 05:43:03 PM

Previous topic - Next topic

vinifr

#60
I connected RST, the result is the same, but I saw it in the schematic is with the pull-up.

I tested in a13-olinuxino-wifi and a13-olinuxino-micro,also the same error.
script.fex for wifi: http://dl.dropbox.com/u/22273442/A13/script.fex

I connect this way:
ENC pins --- A13(connector UEXT)
SCK(1) --- SPI2_CLK (9)
MOSI(2) --- SPI2_MOSI (8 )
MISO(3) --- SPI2_MISO (7)
WOL(4) --- no connected
INT(5) --- PIN8 (PB4)
...
3V3(10) --- 3V3(1)
GND(9) --- GND(2)
RST(8 ) --- no connected
CS(7) --- SPI2_CS0(10)
CLKOUT(6) --- no connected

MOD_ENC: http://dl.dropbox.com/u/22273442/A13/MOD-ENC.jpg
Connector UEXT: http://dl.dropbox.com/u/22273442/A13/UEXT.jpg

Log:

[    0.190000] [spi]: sw spi init !!
[    0.190000] [spi]: sw spi init fetch spi0 uning configuration failed
[    0.190000] [spi]: Found 1 spi devices in config files
[    0.190000] [spi]: boards num modalias         max_spd_hz       bus_num  cs   mode
[    0.190000] [spi]: 0          enc28j60         10000000         2        0    0x0   
[    0.190000] [spi]: bus num = 2, spi used = 3
[    0.190000] [spi]: source = sdram_pll_p, src_clk = 408000000, mclk 102000000
[    0.190000] [spi]: allwinners SoC SPI Driver loaded for Bus SPI-2 with 1 Slaves attached
[    0.190000] [spi]: [spi-2]: driver probe succeed, base dc8aa000, irq 12, dma_id 2!
[    2.870000] enc28j60 spi2.0: enc28j60 Ethernet driver 1.01 loaded
[    3.070000] enc28j60 spi2.0: enc28j60 enc28j60 spi_irq param load successfully.
[    3.070000] enc28j60 spi2.0: enc28j60 enc28j60_probe, gpio_addr = 0xdc92a800.
[    3.250000] enc28j60 spi2.0: enc28j60 enc28j60_probe, 1713: gpio_int_info, port = 2, port_num = 4.
[    3.310000] enc28j60 spi2.0: enc28j60 ENC28J60 interrupt configuration
[    3.310000] enc28j60 spi2.0: enc28j60 driver registered

[   19.790000] net eth0: link down
[   19.790000] net eth0: normal mode
[   19.790000] net eth0: normal mode
[   19.810000] net eth0: multicast mode

lorenzo

Hi vinifr,

the link down message is normal, is the initial state of the network..
Try to issue
ifconfig -a
and let me know the result...

vinifr

#62
root@deb-a13:~# ifconfig

eth0      Link encap:Ethernet  Endereço de HW b6:8a:e2:15:79:2e 
          UP BROADCASTMULTICAST  MTU:1500  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          IRQ:28

lo        Link encap:Loopback Local 
          inet end.: 127.0.0.1  Masc:255.0.0.0
          UP LOOPBACKRUNNING  MTU:16436  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan3     Link encap:Ethernet  Endereço de HW 48:02:2a:c5:f1:82 
          inet end.: 192.168.1.4  Bcast:192.168.1.255  Masc:255.255.255.0
          UP BROADCASTRUNNING MULTICAST  MTU:1500  Métrica:1
          RX packets:106 errors:0 dropped:0 overruns:0 frame:0
          TX packets:91 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:13843 (13.5 KiB)  TX bytes:12566 (12.2 KiB)


root@deb-a13:~# ifconfig -a

eth0      Link encap:Ethernet  Endereço de HW b6:8a:e2:15:79:2e 
          UP BROADCASTMULTICAST  MTU:1500  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          IRQ:28

lo        Link encap:Loopback Local 
          inet end.: 127.0.0.1  Masc:255.0.0.0
          UP LOOPBACKRUNNING  MTU:16436  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tunl0     Link encap:Túnel IPIP  Endereço de HW   
          NOARP  MTU:1480  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan3     Link encap:Ethernet  Endereço de HW 48:02:2a:c5:f1:82 
          inet end.: 192.168.1.4  Bcast:192.168.1.255  Masc:255.255.255.0
          UP BROADCASTRUNNING MULTICAST  MTU:1500  Métrica:1
          RX packets:129 errors:0 dropped:0 overruns:0 frame:0
          TX packets:100 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:16315 (15.9 KiB)  TX bytes:15004 (14.6 KiB)


Note: My router has dhcp enabled
Info: my source power is 12V 1A

How is your /etc/network/interfaces?

lorenzo

Hi,

I don't use the /etc/network/interfaces

If you issue
dhclient eth0
what is the result?

Did you also try with:
ifconfig eth0 down
Ifconfig eth0 192.168.1.150 up


Cheers

vinifr

#64
nothing happens  >:(
root@deb-a13:~# dhclient eth0

[   71.670000] net eth0: multicast mode
[   71.680000] net eth0: multicast mode


root@deb-a13:~# ifconfig

eth0      Link encap:Ethernet  Endereço de HW a6:fd:c1:18:c6:23 
          UP BROADCASTMULTICAST  MTU:1500  Métrica:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          IRQ:28

Static ip also does not work.  :o
Could you post your logs of spi2, net and ifconfig messages?

Wow, something is wrong, I think it's my connections. When i put my finger on the chip it is very VERY hot!
how is yours?

lorenzo

Hi,

I don't have the enc28j60 module here with me, I will try tomorrow and let you know..
Spi and enc28j60 messages seem to be ok, I can't see any strange behaviour..

Your interface never switch to running mode? What the terminal shows when you issue dhclient command?
Which is the LED status on the ethernet interface?

vinifr

hi,

I found the problem, ENC28J50 not transmitting anything. I put my laptop as a router and it gets nothing.

I listen for packets via wireshark.

exactly, it does not change for running and only one LED lights.

lorenzo

#67
Hi,

here is my dmesg, but read next post for solution (I hope) to your problem...

Her is my dmesg:


root@debian:~# dmesg | grep spi
[    0.190000] bus: 'spi': registered
[    0.190000] device class 'spi_master': registering
[    2.840000] [spi]: sw spi init !!
[    2.840000] [spi]: sw spi init fetch spi0 uning configuration failed
[    2.850000] [spi]: Found 1 spi devices in config files
[    2.860000] [spi]: boards num modalias         max_spd_hz       bus_num  cs   mode
[    2.870000] [spi]: 0          enc28j60         10000000         2        0    0x0
[    2.880000] Registering platform device 'sun5i-spi.2'. Parent at platform
[    2.890000] device: 'sun5i-spi.2': device_add
[    2.900000] bus: 'platform': add device sun5i-spi.2
[    2.910000] PM: Adding info for platform:sun5i-spi.2
[    2.920000] bus: 'platform': add driver sun5i-spi
[    2.930000] bus: 'platform': driver_probe_device: matched device sun5i-spi.2 with driver sun5i-spi
[    2.940000] bus: 'platform': really_probe: probing driver sun5i-spi with device sun5i-spi.2
[    2.950000] [spi]: bus num = 2, spi used = 3
[    2.960000] [spi]: source = sdram_pll_p, src_clk = 408000000, mclk 102000000
[    2.970000] device: 'spi2': device_add
[    2.980000] PM: Adding info for No Bus:spi2
[    2.990000] device: 'spi2.0': device_add
[    3.000000] bus: 'spi': add device spi2.0
[    3.000000] PM: Adding info for spi:spi2.0
[    3.010000] [spi]: allwinners SoC SPI Driver loaded for Bus SPI-2 with 1 Slaves attached
[    3.020000] [spi]: [spi-2]: driver probe succeed, base dc8aa000, irq 12, dma_id 2!
[    3.030000] driver: 'sun5i-spi.2': driver_bound: bound to device 'sun5i-spi'
[    3.040000] bus: 'platform': really_probe: bound device sun5i-spi.2 to driver sun5i-spi
[   11.610000] bus: 'spi': add driver enc28j60
[   11.680000] bus: 'spi': driver_probe_device: matched device spi2.0 with driver enc28j60
[   11.760000] bus: 'spi': really_probe: probing driver enc28j60 with device spi2.0
[   11.870000] enc28j60 spi2.0: enc28j60 Ethernet driver 1.01 loaded
[   12.120000] enc28j60 spi2.0: enc28j60 enc28j60 spi_irq param load successfully.
[   12.130000] enc28j60 spi2.0: enc28j60 enc28j60_probe, gpio_addr = 0xdd062800.
[   12.210000] enc28j60 spi2.0: enc28j60 enc28j60_probe, 1713: gpio_int_info, port = 2, port_num = 4.
[   12.240000] enc28j60 spi2.0: enc28j60 ENC28J60 interrupt configuration
[   12.260000] enc28j60 spi2.0: enc28j60==ENC28J60_CLEAR_IRQ_NO=
[   12.410000] driver: 'spi2.0': driver_bound: bound to device 'enc28j60'
[   12.460000] bus: 'spi': really_probe: bound device spi2.0 to driver enc28j60


and when I prompt ifconfig eth1 up (enc28j60 eth1 is on interface 1) dmesg shows:


[  135.200000] net eth1: link down
[  135.220000] net eth1: normal mode
[  135.220000] net eth1: normal mode
[  135.230000] net eth1: multicast mode
[  136.130000] net eth1: link up - Half duplex


And here is interrupt table:


root@debian:~# cat /proc/interrupts
           CPU0
  0:          0    sw_vic  axp_mfd
  2:        113    sw_vic  serial
  7:       4488    sw_vic  sun5i-i2c.0
  8:         36    sw_vic  sun5i-i2c.1
12:       5624    sw_vic  sun5i-spi
22:      37116    sw_vic  timer0
27:       1274    sw_vic  dma_irq
28:        153    sw_vic  enc28j60
29:          0    sw_vic  sun4i-ts
32:     239695    sw_vic  sunxi-mmc
37:          0    sw_vic  nand
39:       6344    sw_vic  ehci_hcd:usb2
44:      43065    sw_vic  sunxi lcd0
47:      21489    sw_vic  sunxi scaler0
53:          0    sw_vic  cedar_dev
64:          0    sw_vic  ohci_hcd:usb3
Err:          0

lorenzo

Hi vinifr,

I think I've found the error: in you script.fex file please change

csi_used = 1
to
csi_used = 0


Because CSI uses PE00 pin which conflicts with CS of SPI.

Cheers

vinifr

#69
hi Lorenzo, you will not believe! besides that error csi_used, I made another terrible mistake!!!

I connected the enc IRQ pin on pin 8 (VGA_DIS) instead of the pin 13 (pin8), I mixed with one another. hahah ;D

Is now functioning normally, with LED flashing and flag running:

root@deb-a13:~# ifconfig
eth0      Link encap:Ethernet  Endereço de HW 5e:28:52:e6:be:db 
          inet end.: 192.168.1.7  Bcast:192.168.1.255  Masc:255.255.255.0
          UP BROADCASTRUNNING MULTICAST  MTU:1500  Métrica:1
          RX packets:8799 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7468 errors:0 dropped:0 overruns:0 carrier:0
          colisões:0 txqueuelen:1000
          RX bytes:4911422 (4.6 MiB)  TX bytes:532671 (520.1 KiB)
          IRQ:28


[   25.260000] net eth0: link down
[   25.260000] net eth0: normal mode
[   25.260000] net eth0: normal mode
[   25.260000] net eth0: multicast mode
[   26.250000] net eth0: link up - Half duplex


thanks for help!

Are you using your version enc28j60_v2 or 3?

lorenzo

 :D, yeah sometimes it happens...
I'm using version 3... In version 2 there is a small error in one spi operation function, so it is better to use v3...

You can enjoy your wired network now!  ;D

cheers

vinifr

Another thing, you realize that the chip gets very hot?


lorenzo

No, I didn't notice it (well, actually I've never checked that)... It's strange because it shouldn't have a high power consumption...

I'll try with a stress test and measure the temperature...

I've tried to send a proposal for a sun5i_enc28j60 driver:
https://groups.google.com/forum/?fromgroups=#!topic/linux-sunxi/iaxRsJorVh8

let's see what happens...

cheers

vinifr

I tested your enc28j60_v3, is as good as v2, I have not lost any package! Now we can consider that the ENC28J60 is functional for A13. Good luck with the patch.

The patch I would submit to spi_sunxi.c do not will work because there is not gpio_to_irq() in sun4i-gpio driver. I tested my patch with your enc28j60_v3 and i get "cpu tx data time out!"

How you solved tx data timeout?

lorenzo

The problem was in the spi clock frequency: when I reduced the frequency to 10MHz tx errors happen very very rarely.
I think the problem should be related to crosstalk: you shouldn't suffer of this issue because you have separate wires..

Have you experienced any tx errors? How was your network speed?