Interfacing

Banana Pi + Enc28j60 (SPI Interface)

35 12568
It is in the first partition of the SD card. If you use Raspbian OS, it is in the directory of bananapi of the first partition.

n3m  
Post Last Edited by n3m at 2014-9-11 10:22

Post Last Edited by n3m at 2014-9-11 10:13

Reply 11# tony_zhang
thanks! I found out just now how this works when i was playing around with the allmighty sunxtoolkit
I will give you a feedback shortly.
Reply 8# sashijoseph
worked! thanks a lot! now I know how to handle the sunx -

I get the following dmesg output:

  1. [   72.879870] [spi-inf] Found 1 spi devices in config files
  2. [   72.886660] [spi-inf] boards num modalias         max_spd_hz       bus_num  cs   mode
  3. [   72.893707] [spi-inf] 0          enc28j60         10000000         0        0    0x0   
  4. [   72.898748] [spi-inf] sun7i_spi_probe: spi0 dma type: normal
  5. [   72.902354] [spi-inf] bus num = 0, spi used = 3
  6. [   72.912239] [spi-inf] sun7i_spi_probe: spi0 cs bitmap: 0x3
  7. [   72.921471] [spi-inf] sun7i_spi_set_mclk: spi0 source = sdram_pll_p, src_clk = 432000000, mclk 86400000
  8. [   72.927789] sun7i-spi sun7i-spi.0: master is unqueued, this is deprecated
  9. [   72.936662] [spi-inf] sun7i_spi_probe: reuuimlla's SoC SPI Driver loaded for Bus SPI0 with 2 Slaves at most
  10. [   72.946126] [spi-inf] sun7i_spi_probe: spi0 driver probe succeed, base f02f6000, irq 42, dma_id_rx 24, dma_id_tx 24
  11. [   72.972853] enc28j60 spi0.0: enc28j60 Ethernet driver 1.01 loaded
  12. [   72.982002] net eth1: enc28j60 driver registered
  13. [   73.038447] net eth1: link down
  14. [   73.041025] net eth1: multicast mode
  15. [   73.043633] net eth1: multicast mode
  16. [   73.047217] net eth1: multicast mode
Copy the Code
setting eth1 up with ifconfig and setting appropriate routes did work as well but there is no connection.
pinging the router results in lost packages. Any suggestions?

setting the frequency higher than 12MHz resulted in failing to load the eth module. Did anybody ever manage to get the native spibus working with 100Mhz?

Reply 12# n3m
N3m have you set the interrupt edge to "falling" ?

n3m  
Post Last Edited by n3m at 2014-9-12 15:39

Reply 13# sashijoseph
No I did not do that since basic operations should work anyways.

My current setup with 2 enc:
Both adapters get successfully registered:
IRQ wiring : adapter0->GPIO24(pin 18) and adapter1->GPIO25(pin 22)
/proc/interrupt/

  1. 162:          0          0  gpio-sunxi  enc28j60
  2. 189:          1          0  gpio-sunxi  enc28j60
Copy the Code
this is my fex:

  1. [spi_devices]
  2. spi_dev_num = 2

  3. [spi_board0]
  4. modalias = "enc28j60"
  5. max_speed_hz = 12000000
  6. bus_num = 0
  7. chip_select = 0
  8. mode = 0
  9. full_duplex = 0
  10. manual_cs = 0
  11. irq_gpio = 1

  12. [spi_board1]
  13. modalias = "enc28j60"
  14. max_speed_hz = 12000000
  15. bus_num = 0
  16. chip_select = 1
  17. mode = 0
  18. full_duplex = 0
  19. manual_cs = 0
  20. irq_gpio = 2

  21. [gpio_para]
  22. gpio_used = 1
  23. gpio_num = 2
  24. gpio_pin_1 = port:PH02<5><default><default><default>
  25. gpio_pin_2 = port:PI17<5><default><default><default>
Copy the Code
dmesg

  1. [   37.777933] [spi-inf] Found 2 spi devices in config files
  2. [   37.784733] [spi-inf] boards num modalias         max_spd_hz       bus_num  cs   mode
  3. [   37.791774] [spi-inf] 0          enc28j60         12000000         0        0    0x0   
  4. [   37.798806] [spi-inf] 1          enc28j60         12000000         0        1    0x0   
  5. [   37.803786] [spi-inf] sun7i_spi_probe: spi0 dma type: normal
  6. [   37.807496] [spi-inf] bus num = 0, spi used = 3
  7. [   37.811938] [spi-inf] sun7i_spi_probe: spi0 cs bitmap: 0x3
  8. [   37.820636] [spi-inf] sun7i_spi_set_mclk: spi0 source = sdram_pll_p, src_clk = 432000000, mclk 86400000
  9. [   37.827418] sun7i-spi sun7i-spi.0: master is unqueued, this is deprecated
  10. [   37.836400] [spi-inf] sun7i_spi_probe: reuuimlla's SoC SPI Driver loaded for Bus SPI0 with 2 Slaves at most
  11. [   37.845851] [spi-inf] sun7i_spi_probe: spi0 driver probe succeed, base f0364000, irq 42, dma_id_rx 24, dma_id_tx 24
  12. [   37.889041] enc28j60 spi0.0: enc28j60 Ethernet driver 1.01 loaded
  13. [   37.899424] net eth1: enc28j60 driver registered
  14. [   37.904697] enc28j60 spi0.1: enc28j60 Ethernet driver 1.01 loaded
  15. [   37.913591] net eth2: enc28j60 driver registered
Copy the Code
the problem remains the same for both adapters

n3m,since you have enabled interrupts,I think it would be better to configure the edge as well.

Even a basic TX operation would use the INT pin to signal the host(BPi) that a TX operation has taken place and then the host would clear the interrupt flag and proceed with whatever needs to be done.If the host does not detect an interrupt I don't think it will automatically fall back to polling the particular interrupt flag.

If interrupts were not enabled in the first place then the ENC would probably work with polling.

So please set the interrupt edge in /sys and see if it makes a difference.

IRQ wiring : adapter0->GPIO24(pin 18) and adapter1->GPIO25(pin 22)

gpio_pin_1 = port:PH02<5><default><default><default>
gpio_pin_2 = port:PI17<5><default><default><default>


Seems this is not correct.
Pin 18 would be PH21 and the correct line would be
port:PH21<6><default><default><default>

Pin 22 would be PI16
port:PI16<5><default><default><default>

n3m  
Post Last Edited by n3m at 2014-9-13 11:29

Reply 15# sashijoseph
"If interrupts were not enabled in the first place then the ENC would probably work with polling.
So please set the interrupt edge in /sys and see if it makes a difference."

I agree. I changed the lines as you suggested, but I cannot set the gpio in /sys/class/gpio/export like I did with the rpi.
Even root may not export anything. "Write error: Invalid argument"
write privileges are given for dir and export itself.

The number to export would be 245 for PH21  and  272 for PI16.
Try and see....

reference : http://sunxi.org/GPIO

in the script.bin I provide in the images, the gpio_para is set to be same with rapspberry Pi. You can just echo 25 > export and echo 24 > export to enable them. And set interrupts

Be sure you run as root

You have to log in before you can reply Login | Sign Up

Points Rules