0

I'm forced to use port /dev/spidev0.0 with a camera that I'm not able to configure at this time. Hence I need to change my current configuration where I'm using ENC28J60 on /dev/spidev0.0 and move it on a different port: /dev/spidev1.0 or /dev/spidev1.2 (spidev1.1/CE pin is used as an interrupt source from the camera itself). I googled for info but the only useful reference is this thread on RPi forum:

https://www.raspberrypi.org/forums/viewtopic.php?t=191180

that talks only about changing CE pin in terms of redefining (?) the overlay that's something I'm not proficient in. Someone managed to use a different port for ENC28J60 and can guide me in this process?

BTW I'm using Raspbian 9 (stretch) on a RPi3A+ (I would like to make it work on RPi0W also if possible)

2

As far as I can tell from /boot/overlays/README you need to add the following entry in /boot/config.txt (and remove or comment out any existing enc28j60 entry).

dtoverlay=enc28j60-spi2

From your forum link that should use chip enable 0.

The relevant part of the README is:

Name:   enc28j60-spi2
Info:   Overlay for the Microchip ENC28J60 Ethernet Controller on SPI2
Load:   dtoverlay=enc28j60-spi2,<param>=<val>
Params: int_pin                 GPIO used for INT (default 39)

        speed                   SPI bus speed (default 12000000)
  • Wow! Thnx. Hope it works.. I'll let you know. – weirdgyn Oct 23 '19 at 11:54
  • What GPIO pins is 39? It's not a big problem since it can be changed but RPI has not 39 GPIO pins and pin 39 is a GND pin ... – weirdgyn Oct 24 '19 at 9:45
  • another question... which spi is spi2? in all the docs I've looked into I found only reference of spi0 and spi1. – weirdgyn Oct 24 '19 at 9:54
  • uhm looks like spi2 is only available on compute module not in standard RPi. – weirdgyn Oct 24 '19 at 10:03
  • Pi actually has GPIO 0-53. Most Pis only have GPIO 0-27 connected to the outside of the board. – joan Oct 24 '19 at 10:10
0

Following joan hint I found a possibile solution into making a new .dts (enc28j60-spi1-overlay):

// Overlay for the Microchip ENC28J60 Ethernet Controller - SPI1
// Interrupt pin: 25
/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

    fragment@0 {
        target = <&spi1>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;

            status = "okay";

            eth1: enc28j60@0{
                compatible = "microchip,enc28j60";
                reg = <0>; /* CE0 */
                pinctrl-names = "default";
                pinctrl-0 = <&eth1_pins>;
                interrupt-parent = <&gpio>;
                interrupts = <25 0x2>; /* falling edge */
                spi-max-frequency = <12000000>;
                status = "okay";
            };
        };
    };

    fragment@1 {
        target = <&gpio>;
        __overlay__ {
            eth1_pins: eth1_pins {
                brcm,pins = <25>;
                brcm,function = <0>; /* in */
                brcm,pull = <0>; /* none */
            };
        };
    };

    __overrides__ {
        int_pin = <&eth1>, "interrupts:0",
                  <&eth1_pins>, "brcm,pins:0";
        speed   = <&eth1>, "spi-max-frequency:0";
    };
};

And compiling it with:

sudo dtc -I dts -O dtb -o /boot/overlays/enc28j60-sp1.dtbo enc28j60-spi1-overlay.dts

And finally enabling it in /boot/config.txt:

dtparam=spi=on          #enable spi
dtoverlay=spi1-1cs      #enable spi1 (and CE0, CE1)
dtoverlay=enc28j60-spi1 #enable enc28j60 module on spi1 port

I tested it on my LAN and it seems to works fine (not worse than using default spi0 port).

I found a pretty similar solution here:

https://www.raspberrypi.org/forums/viewtopic.php?t=224915

You can use it also but beware it assign by default enc28j60 interrupt to pin 39 and this will not work on standard RPi boards (such pin is user availabe only on Compute Module).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.