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 on a custom-made PCB. I can confirm that the custom PCB that is made works reliably on a raspberry pi device with no issues, I only began encountering issues when trying with the RockPi.
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?
Also, I would like to mention the reason I am using SPI2 instead of SPI1 is that the RockPi that I have has the SPI flash module installed which causes canbus fault messages.
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 am not very skilled with Linux based devices so please bear with me.
Any help would be greatly appreciated!
Best,
Austin