MCP2515 CAN freezing problem

Kernel version : jetson-linux 36.3 (JETPACK6.0)
Platform : Jetson Orin Nano Devkit (SD card)

Hello!
Previously, I successfully enabled an additional CAN bus using MCP2515 by following Jetson/L4T/peripheral/ -eLinux.org and the help of this forum. Here is my previous post.

I confirmed that the CAN1 BUS working and left it as is. Half a year later, I got to revisit this and noticed that when I try to initialize CAN1, it cannot be initialized and freezes indefinitely.

$ sudo ip link set can1 up type can bitrate 1000000
# Terminal freezes after this command, This does not happen with can0 which is native CAN

I tried different bitrates, but it didn’t matter. When it freezes, the process cannot be interrupted by Ctrl+C nor cannot be killed with kill -9. Other network related commands like ifnconfig would also freeze as well after the failed CAN initialization. I also noticed that there were no SPI input or output when that command was sent.

The dmesg shows that the mcp251x was successfully initialized while booting. Also, I could see some input and outputs on the SPI port using an oscilloscope.

$ sudo dmesg | grep mcp251x
[   16.831695] mcp251x spi0.0 can1: MCP2515 successfully initialized.

I read other forum posts that had identical symptoms such as “Jetson Orin Nano GPIO Interrupt for MCP2515 on Jetpack 6” or “MCP2515 with Orin Nano: problems with interrupts?”. They seem to point out that the problem was on the interrupt side. But I never changed the interrupt settings or the pinmux from the previous working state.

The following is the modified part from the tegra234-p3768-0000+p3767-xxxx-nv-common.dtsi

		/* SPI1, 40pin header, Pin 19(MOSI), Pin 21(MISO), Pin 23(CLK), Pin 24(CS) */
		spi@3210000{
			status = "okay";
			spi@0 {
//				compatible = "tegra-spidev";
				compatible = "microchip,mcp2515";
				reg = <0x0>;
//				spi-max-frequency = <50000000>;
				spi-max-frequency = <2000000>;
                                interrupt-parent = <&gpio>;
                                interrupts = <TEGRA234_MAIN_GPIO(Q, 5) IRQ_TYPE_LEVEL_LOW>;
                                clocks = <&can_clock>;
                                nvidia,enable-hw-based-cs;
				controller-data {
					nvidia,enable-hw-based-cs;
					nvidia,rx-clk-tap-delay = <0x10>;
					nvidia,tx-clk-tap-delay = <0x0>;
				};
			};
			spi@1 {
				compatible = "tegra-spidev";
				reg = <0x1>;
				spi-max-frequency = <50000000>;
				controller-data {
					nvidia,enable-hw-based-cs;
					nvidia,rx-clk-tap-delay = <0x10>;
					nvidia,tx-clk-tap-delay = <0x0>;
				};
			};

		};

If there are more information needed, I’d be happy to provide.

Thank you.

Hi SpiralCrab,

Is there any error reporting from serial console or dmesg?
If so, please share the full log when you hit the issue.

I would also like to know if the freeze can be recovered by reloading the mcp2515 driver or it can only be recovered by reset manually.

Can MCP2515 work after a clean reboot?
If so, how do you reproduce the issue?
If not, why it can work before but not work currently?

Thanks for the fast reply!

Here are the answers to your questions

Sadly, when ip link set can1 up causes the freeze, dmesg also won’t work as well. So far, ifconfig, dmesg, modprobe -r mcp251x, and ssh from another device to Jetson all fails.

I used dmesg -wto monitor the kernel message before initializing CAN1, but when attempting to initialize CAN1, there were no new kernel message. I did confirm that dmesg -w was working after initializing CAN1 by plugging and unplugging a USB.

here is the dmesg log : dmesg.txt (59.0 KB)

trying to removing and reloading mcp251x didn’t work since modprobe -r mcp251x would also freeze.
reboot would also not work. So I have to manually unplug the power and replug it. Then it would recover.

This symptom is consistent throughout every boot. mcp251x would successfully initialize upon booting, but always fail to initialize CAN1 at ip link set can1 up

The reason for why this issue never happened before is complete mystery for me. Since, the kernel never changed. Only simple updates and upgrades by sudo apt update && sudo apt upgrade -ywere made. The last time that I checked was around 6 months ago. At that time, there were no issue initializing CAN1.

Maybe there’re some log output from serial console.
Please refer to Jetson Nano & NX Style - Serial Debug Console - JetsonHacks to capture them.

I’ve checked the log you shared, there’s no error relating to MCP2515.

Have you checked if it would work after reflashing the original release(which works before)?

If it can work before, then I would suspect it is a HW issue of your MCP2515 module.

Currently I do not have a USB to TTL module. I will get to that in the next week, thanks for the information.

I re-flashed the Jetson Orin Nano, modified jetson-io.py, and did not do any updates or upgrades. But it still fails to initialize CAN1.

I also suspected HW issues so I tried at least 3 different MCP2515 modules. But the results were the same.

My current plan is to get a serial to USB module and check to see if there are any outputs. I’ll update after I test it out.

Thank you.

MCP2515 is not enabled by default.
You have to update the device tree to port them.

Jetson-IO is only used to configure the pinmux for SPI function so that the PINs can work with MCP2515 module through SPI interface.