1

I have a Raspberry Pi model 4B V1.4 running:

Linux raspberrypi 5.10.42-v7l+ #1422 SMP Tue Jun 8 13:03:05 BST 2021 armv7l GNU/Linux

I want to connect an ENC28J60 spi ethernet adapter on spi1. Using SPI1_CE1 and interrupt on GPIO5.

I have tried to follow the instructions given here, but modified for my hardware setup: https://raspberrypi.stackexchange.com/a/104911/106761

First I copied the enc28j60 overlay file for spi2 from here: https://github.com/raspberrypi/linux/blob/rpi-4.14.y/arch/arm/boot/dts/overlays/enc28j60-spi2-overlay.dts

Then changed the contents to match my settings:

// Overlay for the Microchip ENC28J60 Ethernet Controller
// Interrupt pin: 39
/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 = <1>; /* CE1 */
                                pinctrl-names = "default";
                                pinctrl-0 = <&eth1_pins>;
                                interrupt-parent = <&gpio>;
                                interrupts = <39 0x2>; /* falling edge */
                                spi-max-frequency = <12000000>;
                                status = "okay";
                        };
                };
        };

        fragment@1 {
                target = <&gpio>;
                __overlay__ {
                        eth1_pins: eth1_pins {
                                brcm,pins = <39>;
                                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";
        };
};

Then to use the overlay file I compiled and moved it with the command:

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

Then added the following to /boot/config.txt:

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
dtoverlay=spi1-1cs
dtparam=spi=on
dtoverlay=enc28j60-spi1,int_pin=5
#gpio=17=a4

After a reboot I get then try to verify that the gpio signals are correct with the command:

raspi-gpio get 17; raspi-gpio get 19-21; raspi-gpio get 5
GPIO 17: level=0 fsel=0 func=INPUT pull=DOWN
GPIO 19: level=0 fsel=3 alt=4 func=SPI1_MISO pull=DOWN
GPIO 20: level=0 fsel=3 alt=4 func=SPI1_MOSI pull=DOWN
GPIO 21: level=0 fsel=3 alt=4 func=SPI1_SCLK pull=DOWN
GPIO 5: level=1 fsel=0 func=INPUT pull=UP

I expected GPIO17 to be alt4 here and have tested adding, "gpio=17=a4" to /boot/config.txt. When I then try the command

raspi-gpio get 17

I get the expected result

GPIO 17: level=1 fsel=3 alt=4 func=SPI1_CE1_N pull=DOWN

However that still does not work. I have also tried to debug with the following command:

sudo vcdbg log msg

which produces the following output:

007284.630: dtb_file 'bcm2711-rpi-4-b.dtb'
007290.276: brfs: File read: /mfs/sd/bcm2711-rpi-4-b.dtb
007290.293: Loading 'bcm2711-rpi-4-b.dtb' to 0x100 size 0xc042
007302.977: brfs: File read: 49218 bytes
007314.358: brfs: File read: /mfs/sd/overlays/overlay_map.dtb
007377.407: brfs: File read: 1559 bytes
007379.606: brfs: File read: /mfs/sd/config.txt
007380.007: dtparam: i2c_arm=on
007388.563: brfs: File read: 1862 bytes
007399.241: brfs: File read: /mfs/sd/overlays/spi1-1cs.dtbo
007408.278: Loaded overlay 'spi1-1cs'
007408.299: dtparam: spi=on
007448.156: brfs: File read: 1523 bytes
007461.603: brfs: File read: /mfs/sd/overlays/enc28j60-spi1.dtbo
007468.085: Loaded overlay 'enc28j60-spi1'
007468.096: dtparam: int_pin=5
007468.572: dtparam: audio=on
007498.567: brfs: File read: 1148 bytes
007511.775: brfs: File read: /mfs/sd/overlays/vc4-fkms-v3d.dtbo
007529.231: Loaded overlay 'vc4-fkms-v3d'
007569.087: brfs: File read: 1446 bytes
007570.709: brfs: File read: /mfs/sd/cmdline.txt
007570.752: Read command line from file 'cmdline.txt':
007570.767: 'console=tty1 root=PARTUUID=af4c75fe-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles'
008648.405: brfs: File read: 143 bytes
009243.785: brfs: File read: /mfs/sd/kernel7l.img
009243.806: Loading 'kernel7l.img' to 0x8000 size 0x675a48
009243.830: Device tree loaded to 0x2eff3800 (size 0xc76c)
009249.694: gpioman: gpioman_get_pin_num: pin SDCARD_CONTROL_POWER not defined
012642.554: vchiq_core: vchiq_init_state: slot_zero = 0xded80000, is_master = 1
016247.739: brfs: File read: 6773320 bytes

If i type "ifconfig" there is no eth1 available. Someone mentioned that it was necessary to remove console=tty1 from "/boot/cmdline.txt". Which I have also tried but no luck.

I am not sure what else to try.

0

I had issue with this board: https://wiki.52pi.com/index.php/Pi_Zero_Enc28j60_Network_Adapter_Module_SKU:_EP-0088 which also uses ENC28J60. Mine had jumper pins connected incorrectly. I could not see eth device. I reconnected them as per images on board wiki. That solved the issue.

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.