Jump to content

Adding enc28j60 ethernet on orange pi pc


Recommended Posts

Hello,

 

I am trying to connect an enc28j60 ethernet port to spi0.0 on an orange pi pc, running armbian (debian stretch 4.19.5).

 

I have the jumpers all connected in what I believe is the correct pattern. I compiled a device tree (overlay?) for the enc28j60 on h3, the dtbo file now exists in /boot/overlay-user/spi-enc28j60.dtbo.

/dts-v1/;
/plugin/;

/ {
	compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";

	/* This fragment is required only if the IRQ pin requires internal pull-up */
	fragment@0 {
		target = <&pio>;
		__overlay__ {
			enc28j60_pins: enc28j60_pins {
				pins = "PA7";
				function = "irq";
				bias-pull-up;
			};
		};
	};

	fragment@1 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			enc28j60 {
	                        compatible = "microchip,enc28j60";
	                        reg = <0>;
	                        interrupt-parent = <&pio>;
	                        interrupts = <0 7 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */
	                        spi-max-frequency = <12000000>;
	                        status = "okay";
	                        /* These are required only if internal pull-up is used for the IRQ pin */
				pinctrl-names = "default";
	                        pinctrl-0 = <&enc28j60_pins>;
			};
		};
	};
};

and I configured the /boot/armbianEnv.txt. (I just recently added spi-jedec-nor/spi-add-cs1 just for the hell of it to test).

verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=1b49372a-ea5b-42f6-9e60-036606066891
rootfstype=ext4
overlays=spi-add-cs1 spi-jedec-nor spi-spidev
param_spidev_spi_bus=0
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

But the device still does not come up. I get a dmesg of "spidev spi0.0: probing from DT" and no errors anymore. And I configured the /etc/hosts/interfaces file, but ip a just shows an "unknown" state instead of up or down.

 

All the tutorials (for raspberry pi's on raspbian... seriously only 2 people have ever tried this on orange pi/armbian?) I can find only show these few steps. And I can't even think of how to go about troubleshooting this. I am kind of new though so maybe I am missing something. What else should I try?

Link to comment
Share on other sites

2 hours ago, Cache said:

maybe I am missing something

You seems that have missed that overlays placed in /boot/overlay-user/ folder still need to be declared in /boot/armbianEnv.txt using variable "user_overlays=spi-enc28j60" .

Link to comment
Share on other sites

13 hours ago, martinayotte said:

You seems that have missed that overlays placed in /boot/overlay-user/ folder still need to be declared in /boot/armbianEnv.txt using variable "user_overlays=spi-enc28j60" .

I corrected that and now eth1 shows as an interface. Thank you!

 

Link to comment
Share on other sites

On 7/9/2019 at 1:15 PM, Cache said:

have the jumpers all connected in what I believe is the correct pattern

Verify this, it might be one of the pins is wrong.  What eth board are you using?

Link to comment
Share on other sites

On 7/10/2019 at 7:02 AM, martinayotte said:

What "dmesg | grep eth" is reporting ?

 

enc28j60 spi0.0: enc28j60 Ethernet driver 1.02 loaded
net eth1: link up - Half duplex
net eth1: enc28j60 driver registered
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
net eth1: link up - Half duplex
IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready

There's about a hundred "link up - half duplex" messeges, I truncated for sanity. 

dmesg | grep -i spi:

Quote

enc28j60 Ethernet driver 1.02 loaded

dmesg | grep -i spi was outputing something about a chipselect 0 already in use error, I removed sun8i-h3-spi-spidev.dtbo from the /boot/dtb/ directory and that seems to have solved it. But I am not sure I fully understand what it the error was other than possibly two modules fighting over the same spi pins. But I could be way off, the pins are correct as far as I can tell, but someone was saying that one of them (the cs?) is often misconfigured to be used on other pins. Hopefully that issue is solved, although I wasn't getting those errors before, not sure why they suddenly popped up.

 

On 7/12/2019 at 8:56 PM, TonyMac32 said:

Verify this, it might be one of the pins is wrong.  What eth board are you using?

This. But the ethernet port itself reads 18/20.
It's an enc28j60, not sure what the board it's on is called. But as far as I understand they are pretty generic and (used to be) commonly used. According to the diagrams I found online everything matches (triple checked!).

Orange Pi's Pinout <--- previous link broke?
Can't find an official diagram but follows this pinout

 

-- I plugged up the ethernet port to a laptop and listening wireshark I can't see any traffic when pinging or making dhcp requests. Ifup just ends in no dhcp offers received, and a static address can't reach anything when plugged up to a switch. Should I assume this is a board/armbian configuration issue or could it just be a networking problem? 

 

Edited by Cache
fixing link
Link to comment
Share on other sites

I don't know if it's helpful but I also still show a dummy0 as an interface.  From what I can tell it's not useful but is related to a (kernel) module that runs at startup.

Link to comment
Share on other sites

I have one of the GEEEKPi hats, was using it with my ESP32 board, same thing different shape.  What I don't have are any OPi's laying around, but I have some other H2/3/5 boards.  It should support full duplex, shouldn't it?  maybe it's resetting over and over for some reason.

Link to comment
Share on other sites

It doesn't let me set it to full duplex, gives me a not supported error. And I can't configure the network but I believe the switch is set to auto-negotiate.

But my current idea is that the spi pins need to be configured differently. It's currently set to 'pins = "PA7"'. And from what I understand this may need to be changed. Not entirely sure though.

Edited by Cache
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines