-1

I added this to the /boot/config.txt and now I have two CAN interfaces #CAN bus controllers dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25 dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24

dtoverlay=spi-bcm2835

and when below command is given sudo ip link set up can0 type can bitrate 500000

the terminal hangs/stuck. even can't open ifconfig. Need to reboot every time and unable to link up the CAN. Could you please help

2 Answers 2

1

I assume here your CAN driver's name is mcp2515. You can confirm that by looking at the device tree file or by checking the lsmod output.

First, see if the device driver actually loads using lsmod | grep mcp2515. I think it will load the SPI driver as a dependency, check if that is the case.

Second, look at the kernel log for error messages from your driver, e.g. with sudo dmesg | grep mcp2515. See if these messages make sense (they often do) and try to fix any reported errors.

Third, if the driver is reported as loaded by lsmod, use modinfo mcp2515 or browse /sys/module/mcp2515/parameters/ to see what parameters it has and what are the values.

Edit: according to the link you have found, this is a kernel issue with two possible fixes:

  • downgrade to kernel 5.4

  • patch the mcp251x.c driver, replacing ret = mcp251x_hw_wake (spi); by ret = mcp251x_hw_reset (spi);. Alternatively, it is suggested to remove the disable_irq(spi->irq); from the mcp251x_hw_wake() funciton.

6
  • Unable to link/configure the CAN bus. I'm using OS 5.10.79-v7+. Upon boot up, "failed to load overlay dtoverlay=spi-bcm2835" is displayed on the edge of the screen Commented Nov 23, 2021 at 1:23
  • 1
    same problem is observed here forum.armbian.com/topic/14909-orange-pi-mcp2515-ip-up-freezes Commented Dec 10, 2021 at 4:02
  • @TheerthaBV Interesting. Did the fixes help? Commented Dec 10, 2021 at 12:05
  • i'm not from LINUX background. So, i'm on my way into LINUX and its structure. As it progresses i'll understand the things and will try to do the changes. Right now, CAN link is not established in the Raspberry PI 3B+ Commented Dec 13, 2021 at 3:20
  • I believe It's not possible to downgrade the kernel to 5.4 (let me know if you have the info or link about this) Commented Dec 13, 2021 at 3:26
1

This is caused by can: mcp251x: only reset hardware as required in Linux 5.5 which will result in a deadlock if an interrupt occurs when the device is opened. One way for this to happen is to have the wrong interrupt GPIO configured so that the interrupt is always active.

I've created a patch can: mcp251x: fix deadlock if an interrupt occurs during mcp251x_open to fix this.

When it no longer hangs, check that you're also not getting high CPU usage and 100000+ interrupts/second when idle because that implies you have the wrong GPIO configured as the interrupt for the device.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.