Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

RockPi4B with MCP2515

Featured Replies

Hello all,

 

I am trying to interface with the MCP2515 on SPI2 of the RockPi4B on Armbian 22.08.6 Bullseye with Linux 5.15.74-rockchip64 and encountering some issues. 

 

The rockpi4B pins that I am using to connect to the MCP2515

INT - GPIO2_A7

MOSI - GPIO2_B2

MISO - GPIO2_B1

CLK - GPIO2_B3

CS - GPIO2_B4 

 

When using the overlay file that I have shown below, the output for "dmesg | grep mcp": 

[    6.662536] rockchip-pinctrl pinctrl: unable to find group for node mcp2515_int_pin

 

I have been able to get the MCP2515 to initialize successfully, but only if I comment out the pinctrl-0 reference to the mcp2515_int_pin in the overlay. Doing this I can bring up the device but I am only able to send/receive a few messages before candump shows it's not transmitting any messages until I bring down and up the can0 device where it will do the same thing. The interesting thing is, when the device doesn't communicate I can still see that the can0 device is still in the "Error-Active" mode, so theoretically I should still be able to interface with it. 

 

So, I am led to believe the issue I am encountering is due to that comment line to pinctrl-0 in the overlay. Just not sure of the solution to this. I have looked about just about every forum that makes reference to the MCP2515 and have not found any promising solutions. I have tried changing the target on fragment@0 to <&gpio>, <&gpio2>, etc. 

 

Here is a look at the DTS overlay I am using for the MCP2515:

//This devicetree overlay is used for RS485 CAN HAT.
/dts-v1/;
/plugin/;

/ {
        compatible = "rockchip,rockpi","rockchip,rk3399", "rockchip,rk3399-pinctrl";

        fragment@0 {
                target = <&pinctrl>;

                __overlay__ {
                        mcp2515_int_pin: mcp2515_int_pin {
                                rockchip,pins = <2 7 0 &pcfg_pull_none>;
                        };
                };
        };

        fragment@1 {
                target-path = "/";
                __overlay__ {
                        can_mcp2515_osc: can-mcp2515-osc {
                                compatible = "fixed-clock";
                                clock-frequency = <16000000>;
                                #clock-cells = <0>;
                        };
                };
        };

        fragment@2 {
                target = <&spi2>;

                __overlay__ {
                        status = "okay";
                        max-freq = <10000000>;
                        #address-cells = <1>;
                        #size-cells = <0>;

                        can_mcp2515: can-mcp2515@0 {
                                status = "okay";
                                compatible = "microchip,mcp2515";
                                reg = <0>;
                                interrupt-parent = <&gpio2>;
                                interrupts = <7 2 8>;
                                spi-max-frequency = <10000000>;
                                clocks = <&can_mcp2515_osc>;
                                vdd-supply = <&vcc3v3_sys>;
                                xceiver-supply = <&vcc3v3_sys>;
                                pinctrl-names = "default";
                                pinctrl-0 = <&mcp2515_int_pin>;
                        };
                };
        };
};

 

And my armbianEnv.txt: 

verbosity=1
bootlogo=false
overlay_prefix=rockchip
fdtfile=rockchip/rk3399-rock-pi-4b.dtb
rootdev=UUID=fa2cbc7c-56d1-448b-9ab3-fe864e21fbc5
rootfstype=ext4
overlays=spi-spidev
param_spidev_spi_bus=1
user_overlays=spi1-mcp2515-can0-overlay
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

Here's a link to my armbianmonitor -u: https://paste.armbian.com/azameworos

 

I would like to mention I not very skilled with Linux based devices so please bear with me.

 

Any help would be greatly appreciated!

 

Best,

Austin

I have the same issue. After I added an additional label in fragment@0 (I am using different pins):

fragment@0 {
        target = <&pinctrl>;

        __overlay__ {
            mcp2515 {
                mcp2515_int_pin: mcp2515_int_pin {
                rockchip,pins = <4 29 0 &pcfg_pull_none>;
                };
            };
        };        
    };

it can boot without problem.

But the behaviour is still the same, only a few CAN messages can be send.
 

My problem was solved, when I decreased the max spi frequency to 1000000. So my final dts is here:

What this will cause on transfer speed, I don't know.

 

//This devicetree overlay is used for mcp2515 CAN HAT.
/dts-v1/;
/plugin/;

/ {
	compatible = "rockchip,rockpi","rockchip,rk3399";

	fragment@0 {
		target = <&pinctrl>;

		__overlay__ {
			mcp2515_pins {
				mcp2515_int_pin: mcp2515_int_pin {
				rockchip,pins = <4 29 0 &pcfg_pull_none>;
				};
			};
		};		
	};

	fragment@1 {
		target-path = "/";

		__overlay__ {
			can_mcp2515_osc: can-mcp2515-osc {
				compatible = "fixed-clock";
				clock-frequency = <16000000>;
				#clock-cells = <0>;
			};
		};
	};

	fragment@2 {
		target = <&spi1>;

		__overlay__ {
			status = "okay";
			max-freq = <1000000>;
			#address-cells = <1>;
			#size-cells = <0>;

			can_mcp2515: can-mcp2515@0 {
				status = "okay";
				compatible = "microchip,mcp2515";
				reg = <0>;
				interrupt-parent = <&gpio4>;
				interrupts = <29 2>;
				spi-max-frequency = <1000000>;
				clocks = <&can_mcp2515_osc>;
				vdd-supply = <&vcc3v3_sys>;
				xceiver-supply = <&vcc3v3_sys>;
				pinctrl-names = "default";
				pinctrl-0 = <&mcp2515_int_pin>;
			};
		};
	};
};

 

spi1-mcp2515-can0-overlay.dts

Hi.

Somebody share working image.

 

In my case can0 don't create. 

 

$ dmesg | grep spi
[    2.359503] rockchip-spi ff1d0000.spi: registered master spi1
[    2.359902] spi spi1.0: setup mode 0, 8 bits/w, 10000000 Hz max --> 0
[    2.360579] rockchip-spi ff1d0000.spi: registered child spi1.0
[    2.360635] rockchip-spi ff1d0000.spi: chipselect 0 already in use
[    2.360650] spi_master spi1: spi_device register error /spi@ff1d0000/spidev
[    2.360696] spi_master spi1: Failed to create SPI device for /spi@ff1d0000/spidev

 

 lsmod | grep mcp
mcp251x                28672  0
can_dev                45056  1 mcp251x

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.