Skip to content

MCP251x failes setup CAN-bus communication with error=110 #4183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
timok90 opened this issue Mar 1, 2021 · 3 comments
Closed

MCP251x failes setup CAN-bus communication with error=110 #4183

timok90 opened this issue Mar 1, 2021 · 3 comments

Comments

@timok90
Copy link

timok90 commented Mar 1, 2021

My project uses the mcp2515 chip to communicate via CAN-bus.
After kernel update following failure occurs:

~ $ dmesg | grep -i spi
[    7.567794] mcp251x spi0.0: MCP251x didn't enter in conf mode after reset 
[    7.567855] mcp251x spi0.0: Probe failed, err=110
[    7.567948] mcp251x: probe of spi0.0 failed with error -110 

My overlay configuration is:

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=500000

My current kernel version is:
Linux 5.10.11-v7l+ #1399 SMP Thu Jan 28 12:09:48 GMT 2021 armv7l GNU/Linux

os:
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"

and additionally I use the can-utils package.

@pelwell
Copy link
Contributor

pelwell commented Mar 4, 2021

This sounds like a hardware problem - have you double-checked all of your wiring?

@timok90
Copy link
Author

timok90 commented Mar 15, 2021

I've checked it but with no changes. Rework all the wiring helped. So, it was a wiring issue.

@Elhkiati2000
Copy link

Elhkiati2000 commented Feb 16, 2024

I encountered the same error while attempting to use the mcp2515 chip for CAN-bus communication over SPI 1-0/1/2 on the RPi 3B+. Communication over SPI 0-0/1cs is successful using the "mcp2515-can0.dtbo" and "mcp2515-can1.dtbo" overlays. I've also successfully tested SPI 0 with the newly introduced overlay "mcp2515.dtbo" found in the Raspberry OS, which functions correctly. However, attempting to use the chip with SPI1-0/1/2cs results in the same error.

Below is the description of the "mcp2515.dtbo" overlay located in /boot/overlays/README:

Name:   mcp2515
Info:   Configures the MCP2515 CAN controller on spi0/1/2
        For devices on spi1 or spi2, the interfaces should be enabled
        with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
Load:   dtoverlay=mcp2515,<param>=<val>
        Params: spi<n>-<m>              Configure device at spi<n>, cs<m> (boolean, required)
        oscillator                                  Clock frequency for the CAN controller (Hz)
        speed                                       Maximum SPI frequence (Hz)
        interrupt                                  GPIO for interrupt signal
  • The connections are :

INT -- 22 (GPIO 25)
SCK -- 40 (GPIO 21 , SPI1 SCLK)
SI -- 38 (GPIO 20 , SPI1 MOSI)
SO -- 35 (GPIO 19 , SPI1 MISO)
CS -- 36 (GPIO 16 , SPI1 CS2)
GND -- 6 (GND)
VCC - 1 (3V3)

  • The content of /boot/config.txt file is as follows :

dtparam=spi=on
dtoverlay=spi1-3cs,cs0_spidev=disabled,cs1_spidev=disabled
dtoverlay=mcp2515,spi12=16,oscillator=16000000,speed=10000000,interrupt=25

  • The decompiled content of the "mcp2515.dtbo" file located in /boot/overlays, resulting in "mcp2515.dts", is as detailed below:

`/dts-v1/;

/ {
compatible = "brcm,bcm2835";

fragment@0 {
	target = <0xffffffff>;

	__dormant__ {
		status = "disabled";
	};
};

fragment@1 {
	target = <0xffffffff>;

	__dormant__ {
		status = "disabled";
	};
};

fragment@2 {
	target-path = "spi1/spidev@0";

	__dormant__ {
		status = "disabled";
	};
};

fragment@3 {
	target-path = "spi1/spidev@1";

	__dormant__ {
		status = "disabled";
	};
};

fragment@4 {
	target-path = "spi1/spidev@2";

	__dormant__ {
		status = "disabled";
	};
};

fragment@5 {
	target-path = "spi2/spidev@0";

	__dormant__ {
		status = "disabled";
	};
};

fragment@6 {
	target-path = "spi2/spidev@1";

	__dormant__ {
		status = "disabled";
	};
};

fragment@7 {
	target-path = "spi2/spidev@2";

	__dormant__ {
		status = "disabled";
	};
};

fragment@8 {
	target = <0xffffffff>;

	__overlay__ {
		mcp2515_pins {
			brcm,pins = <0x19>;
			brcm,function = <0x00>;
			phandle = <0x01>;
		};
	};
};

fragment@9 {
	target-path = "/clocks";

	__overlay__ {
		mcp2515-osc {
			#clock-cells = <0x00>;
			compatible = "fixed-clock";
			clock-frequency = <0xf42400>;
			phandle = <0x02>;
		};
	};
};

fragment@10 {
	target = <0xffffffff>;
	phandle = <0x03>;

	__overlay__ {
		status = "okay";
		#address-cells = <0x01>;
		#size-cells = <0x00>;

		mcp2515@0 {
			compatible = "microchip,mcp2515";
			reg = <0x00>;
			pinctrl-names = "default";
			pinctrl-0 = <0x01>;
			spi-max-frequency = <0x989680>;
			interrupt-parent = <0xffffffff>;
			interrupts = <0x19 0x08>;
			clocks = <0x02>;
			phandle = <0x04>;
		};
	};
};

__overrides__ {
	spi0-0 = [00 00 00 00 2b 30 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 30 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 30 5f 30 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 30 2d 30 2d 6f 73 63 00];
	spi0-1 = [00 00 00 00 2b 31 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 31 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 30 5f 31 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 30 2d 31 2d 6f 73 63 00];
	spi1-0 = [00 00 00 00 2b 32 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 30 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 31 5f 30 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 31 2d 30 2d 6f 73 63 00];
	spi1-1 = [00 00 00 00 2b 33 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 31 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 31 5f 31 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 31 2d 31 2d 6f 73 63 00];
	spi1-2 = [00 00 00 00 2b 34 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 32 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 31 5f 32 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 31 2d 32 2d 6f 73 63 00];
	spi2-0 = [00 00 00 00 2b 35 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 30 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 32 5f 30 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 32 2d 30 2d 6f 73 63 00];
	spi2-1 = [00 00 00 00 2b 36 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 31 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 32 5f 31 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 32 2d 31 2d 6f 73 63 00];
	spi2-2 = [00 00 00 00 2b 37 00 00 00 00 03 74 61 72 67 65 74 3a 30 3d 00 ff ff ff ff 00 00 00 04 72 65 67 3a 30 3d 32 00 00 00 00 01 6e 61 6d 65 3d 6d 63 70 32 35 31 35 5f 73 70 69 32 5f 32 5f 70 69 6e 73 00 00 00 00 02 6e 61 6d 65 3d 6d 63 70 32 35 31 35 2d 73 70 69 32 2d 32 2d 6f 73 63 00];
	oscillator = [00 00 00 02 63 6c 6f 63 6b 2d 66 72 65 71 75 65 6e 63 79 3a 30 00];
	speed = <0x04 0x7370692d 0x6d61782d 0x66726571 0x75656e63 0x793a3000>;
	interrupt = [00 00 00 01 62 72 63 6d 2c 70 69 6e 73 3a 30 00 00 00 00 04 69 6e 74 65 72 72 75 70 74 73 3a 30 00];
};

__symbols__ {
	mcp2515_pins = "/fragment@8/__overlay__/mcp2515_pins";
	clk_mcp2515_osc = "/fragment@9/__overlay__/mcp2515-osc";
	mcp2515_frag = "/fragment@10";
	mcp2515 = "/fragment@10/__overlay__/mcp2515@0";
};

__fixups__ {
	spidev0 = "/fragment@0:target:0";
	spidev1 = "/fragment@1:target:0";
	gpio = "/fragment@8:target:0\0/fragment@10/__overlay__/mcp2515@0:interrupt-parent:0";
	spi0 = "/fragment@10:target:0\0/__overrides__:spi0-0:21\0/__overrides__:spi0-1:21";
	spi1 = "/__overrides__:spi1-0:21\0/__overrides__:spi1-1:21\0/__overrides__:spi1-2:21";
	spi2 = "/__overrides__:spi2-0:21\0/__overrides__:spi2-1:21\0/__overrides__:spi2-2:21";
};

__local_fixups__ {

	fragment@10 {
		__overlay__ {
			mcp2515@0 {
				pinctrl-0 = <0x00>;
				clocks = <0x00>;
			};
		};
	};

	__overrides__ {
		spi0-0 = <0x07 0x19 0x25 0x42>;
		spi0-1 = <0x07 0x19 0x25 0x42>;
		spi1-0 = <0x07 0x19 0x25 0x42>;
		spi1-1 = <0x07 0x19 0x25 0x42>;
		spi1-2 = <0x07 0x19 0x25 0x42>;
		spi2-0 = <0x07 0x19 0x25 0x42>;
		spi2-1 = <0x07 0x19 0x25 0x42>;
		spi2-2 = <0x07 0x19 0x25 0x42>;
		oscillator = <0x00>;
		speed = <0x00>;
		interrupt = <0x00 0x10>;
	};
};

};
`
Additionally, I've tested the "mcp2515-can2-overlay.dtbo" and "mcp2515-can0-1.dtbo" overlays mentioned in issue #1804 , which resulted in the same error. I've double-checked the wiring, and it appears to be correct. Can someone assist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants