vatsal
September 11, 2025, 4:35am
21
I found the issue: the interrupt pins defined in the overlay DTS were different at both locations. The correct DTS for the overlays is
/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/interrupt-controller/irq.h>
&{/} {
metadata {
title ="Enable SPI2 MCP2515 (CAN) support on 40 Pin GPIO Header";
compatible = "vicharak,rk3399-axon", "rockchip,rk3399";
category = "misc";
exclusive = "spi2", "GPIO2_B1", "GPIO2_B2", "GPIO2_B3", "GPIO2_B4",
"GPIO4_D6";
description = "Enable MCP2515 on SPI2 with 12 MHz Crystal Oscillator.
INT=22";
};
can_mcp2515_osc: can-mcp2515-osc {
status = "okay";
compatible = "fixed-clock";
clock-frequency = <12000000>;
#clock-cells = <0>;
};
};
&pinctrl {
mcp2515_int_pin {
mcp2515_int_pin: mcp2515_int_pin {
rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
};
&spi2 {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
can_mcp2515: can-mcp2515@0 {
status = "okay";
compatible = "microchip,mcp2515";
reg = <0>;
interrupt-parent = <&gpio4>;
interrupts = <RK_PD6 IRQ_TYPE_EDGE_FALLING>;
spi-max-frequency = <10000000>;
clocks = <&can_mcp2515_osc>;
vdd-supply = <&vcc3v3_sys>;
xceiver-supply = <&vcc3v3_sys>;
pinctrl-names = "default";
pinctrl-0 = <&mcp2515_int_pin>;
};
};
Another important point is that you must connect the pins correctly and provide the proper power supply as mentioned in the IC’s documentation. Any incorrect pin connection will cause errors when probing the MCP251x driver.
If you face any problems, please let me know.
vatsal
September 11, 2025, 4:40am
22
I have connected the MCP2525 IC pins to Vicharak GPIO as follows:
CAN2_MOSI → GPIOT_RXN27
CAN2_MISO → GPIOR_174
CAN2_CS → GPIOT_RXP27
CAN2_SCK → GPIOR_173
Where should I connect CAN2_INT (to which GPIO)?
Hello @Avi_Shihora @vatsal any updates on this
vatsal
September 12, 2025, 9:48am
25
You are testing the MCP2515 IC using the SoC GPIOs Header , so your pin connections should be as follows:
INT → GPIO4_D6 → Pin 37 on SoC
SCK → GPIO2_B3 → Pin 7 on SoC
MOSI → GPIO2_B2 → Pin 29 on SoC
MISO → GPIO2_B1 → Pin 31 on SoC
CS → GPIO2_B4 → Pin 33 on SoC
For your reference, all of these pins are already defined in the DTS overlays for SPI2 on the processor.
Please note that the pins GPIOT_RXN27, GPIOR_174, GPIOT_RXP27, and GPIOR_173 are FPGA pins. These are only useful when working with Periplex . They are not used when running applications directly on the SoC (processor).
For Soc pinout guide , Documentation references : Vaaman GPIO Description | Vicharak
For FPGA pinout guide , Documentation references : documentaion:Vaaman GPIO Description | Vicharak
Refer this pdf for more information : https://docs.vicharak.in/_static/files/Vaaman0.3_Pinout_Guide_Rev0.3.pdf
Thank you, I will use the SoC GPIO header pins and check.
I used the following DTSO file:
/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/interrupt-controller/irq.h>
&{/} {
metadata {
title =“Enable SPI2 MCP2515 (CAN) support on 40 Pin GPIO Header”;
compatible = “vicharak,rk3399-axon”, “rockchip,rk3399”;
category = “misc”;
exclusive = “spi2”, “GPIO2_B1”, “GPIO2_B2”, “GPIO2_B3”, “GPIO2_B4”,
“GPIO4_D6”;
description = “Enable MCP2515 on SPI2 with 12 MHz Crystal Oscillator. INT=22”;
};
can_mcp2515_osc: can-mcp2515-osc {
status = "okay";
compatible = "fixed-clock";
clock-frequency = <12000000>;
#clock-cells = <0>;
};
};
&pinctrl {
mcp2515_int_pin {
mcp2515_int_pin: mcp2515_int_pin {
rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_none>;
};
};
};
&spi2 {
status = “okay”;
#address-cells = <1>;
#size-cells = <0>;
can_mcp2515: can-mcp2515@0 {
status = "okay";
compatible = "microchip,mcp2515";
reg = <0>;
interrupt-parent = <&gpio4>;
interrupts = <RK_PD6 IRQ_TYPE_EDGE_FALLING>;
spi-max-frequency = <10000000>;
clocks = <&can_mcp2515_osc>;
vdd-supply = <&vcc3v3_sys>;
xceiver-supply = <&vcc3v3_sys>;
pinctrl-names = "default";
pinctrl-0 = <&mcp2515_int_pin>;
};
};
After that, I ran the following commands:
cpp -nostdinc -undef -x assembler-with-cpp -E
-I /usr/src/linux-headers-$(uname -r)/include
-I /usr/lib/modules/$(uname -r)/build/include
rk3399-vaaman-spi2-mcp2515.dtso -o rk3399-vaaman-spi2-mcp2515.dtsi
dtc -I dts -O dtb rk3399-vaaman-spi2-mcp2515.dtsi -o rk3399-vaaman-spi2-mcp2515.dtbo
sudo cp rk3399-vaaman-spi2-mcp2515.dtbo /boot/overlays-$(uname -r)/
sudo u-boot-update
sudo reboot
After rebooting, I checked with the following commands, but can0
was not showing up:
dmesg | grep mcp2515
ls /dev/spidev*
Output:
/dev/spidev0.0 /dev/spidev2.0
ip link | grep can
vatsal
September 15, 2025, 5:12am
28
What is the dmesg
log when you insert the mcp251x.ko
module? Please provide it as a file named dmesg.txt
by running the following command:
sudo dmesg > dmesg.txt
Please check the dmesg file
vatsal
September 15, 2025, 9:23am
31
First, insert the mcp251x.ko
module the same way you did before. After that, I will check the dmesg
log to identify the error you faced during insmod
. You have done this step in the past, so please insert the module manually and then send me the dmesg
log, because right now I don’t see any messages related to mcp251x
in your dmesg
Okay I will check it again and let you know