dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Doing CAN using mcp2510

Tue May 03, 2016 4:13 pm

Hi

I'm trying to play with can controller using mcp2510 chip.
I created the overlay for this chip (based on mcp2515):

Code: Select all

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

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835", "brcm,bcm2836", "brcm,bcm2708", "brcm,bcm2709";
    /* disable spi-dev for spi0.0 */
    fragment@0 {
        target = <&spi0>;
        __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 mcp2510 on SPI0.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 = <&spi0>;
        __overlay__ {
            /* needed to avoid dtc warning */
            #address-cells = <1>;
            #size-cells = <0>;
            can0: mcp2510@0 {
                reg = <0>;
                compatible = "microchip,mcp2510";
                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";
    };
};
But the driver returns this:

Code: Select all

[ 2930.200078] mcp251x spi0.0: could not find pctldev for node /soc/interrupt-controller@7e00b200, deferring probe
I don't know what this means.
There is no can0 interface in ip link command output.
Could someone explain what I'm missing here?
Also do You think we should have separated overlay for the mcp2510 chip (there is only one for mcp2515).

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Doing CAN using mcp2510

Wed May 04, 2016 12:25 pm

have you compiled DT overlay? have you enabled it in config.txt?
which kernel version are you using?

P.S. why do you want to use mcp2510? it is outdated, mcp2515 is definitely better. mcp2510 isn't cheaper or easier to buy.

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Doing CAN using mcp2510

Wed May 04, 2016 2:06 pm

edo1 wrote:have you compiled DT overlay? have you enabled it in config.txt?
Yes. Yes

Code: Select all

                        mcp2510@0 {
                                reg = <0x0>;
                                interrupts = <0x19 0x2>;
                                pinctrl-0 = <0x1>;
                                compatible = "microchip,mcp2510";
                                clocks = <0x2>;
                                spi-max-frequency = <0x989680>;
                                phandle = <0x39>;
                                pinctrl-names = "default";
                                linux,phandle = <0x39>;
                                interrupt-parent = <0xa>;
                        };
which kernel version are you using?
4.6.0-rc6-v7+
P.S. why do you want to use mcp2510? it is outdated, mcp2515 is definitely better. mcp2510 isn't cheaper or easier to buy.
This one I got. I quite sure there'll be the same problem ;)

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Doing CAN using mcp2510

Thu May 05, 2016 5:43 pm

is it mainline kernel or raspberry kernel?

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Doing CAN using mcp2510

Thu May 05, 2016 6:10 pm

It's from Raspberry linux repo.

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Doing CAN using mcp2510

Thu May 05, 2016 6:35 pm

I have no issues with raspberry 4.4 tree (and mcp2515, but it shouldn't matter), could you check it?

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Doing CAN using mcp2510

Thu May 05, 2016 7:27 pm

OK I will try that tomorrow and post my results. Thanks!

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Doing CAN using mcp2510

Fri May 06, 2016 3:03 pm

The same thing:

Code: Select all

mcp251x spi0.0: could not find pctldev for node /soc/interrupt-controller@7e00b200, deferring probe
I wonder if this might be something with my wiring...

staroselskii
Posts: 1
Joined: Fri Jul 01, 2016 2:38 pm

Re: Doing CAN using mcp2510

Fri Jul 01, 2016 2:41 pm

Hello there!

I'm getting exactly the same error on 4.4.8 on Raspberry Pi 3. Have you overcome the issue anyhow? It'd be great to hear if you did.

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Doing CAN using mcp2510

Mon Jul 04, 2016 8:36 am

staroselskii wrote:I'm getting exactly the same error on 4.4.8 on Raspberry Pi 3.
which DT overlay are you using?

dienet
Posts: 11
Joined: Sat Mar 19, 2016 10:58 am

Re: Doing CAN using mcp2510

Fri Jul 29, 2016 8:40 pm

staroselskii wrote:Hello there!

I'm getting exactly the same error on 4.4.8 on Raspberry Pi 3. Have you overcome the issue anyhow? It'd be great to hear if you did.
I did not.

edo1
Posts: 136
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Doing CAN using mcp2510

Mon Aug 01, 2016 6:58 pm

I think there is something wrong with your device tree overlay.
Try to use mcp2515-can0-overlay.dts from current kernel
https://github.com/raspberrypi/linux/bl ... verlay.dts
(you need to replace mcp2515 with mcp2510 on line 58)

Return to “Troubleshooting”