Page 1 of 1

mcp2515 overlay

Posted: Thu Jan 26, 2017 1:49 pm
by Altah
Hello,

i wanted to use the mcp2515 with spi2.
That´s why i changed the config entry into

Code: Select all

dtoverlay=spi2-1cs,cs0_pin=43
dtoverlay=mcp2515-can0-spi2,oscillator=16000000,interrupt=25
The "mcp2515-can0-spi2.dts" is a modified copy of the original file.

Code: Select all

/*
 * Device tree overlay for mcp251x/can0 on spi2.0
 */

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
    /* disable spi-dev for spi2.0 */
    fragment@0 {
        target = <&spi2>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
	target = <&spidev0>;
	__overlay__ {
	    status = "disabled";
	};
    };

    /* the interrupt pin of the can-controller */
    fragment@2 {
        target = <&gpio>;
        __overlay__ {
            can0_pins: can0_pins {
                brcm,pins = <25>;
                brcm,function = <0>; /* input */
            };
        };
    };

    /* the clock/oscillator of the can-controller */
    fragment@3 {
        target-path = "/clocks";
        __overlay__ {
            /* external oscillator of mcp2515 on SPI2.0 */
            can0_osc: can0_osc {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency  = <16000000>;
            };
        };
    };

    /* the spi config of the can-controller itself binding everything together */
    fragment@4 {
        target = <&spi2>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can0: mcp2515@0 {
                reg = <0>;
                compatible = "microchip,mcp2515";
                pinctrl-names = "default";
                pinctrl-0 = <&can0_pins>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio>;
                interrupts = <25 0x2>;
                clocks = <&can0_osc>;
            };
        };
    };
    __overrides__ {
        oscillator = <&can0_osc>,"clock-frequency:0";
        spimaxfrequency = <&can0>,"spi-max-frequency:0";
        interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
    };
};

Is the modification done correctly?

I am not sure, because the mcp2515 runs quite good for a while and then suddenly doesn´t receive messages anymore.

Thanks!

Re: mcp2515 overlay

Posted: Sun Jan 29, 2017 11:36 am
by DK9
Whats the output in

Code: Select all

ip -s -d link show can0
  1. When it works as expected
  2. After it stops working