I am trying to test the CAN interface in loopback mode before connecting and testing with a vehicle and am only able to communicate with the MCP2515 on initialization.
The dmesg on boot appears to show the module initially loads correctly:
[ 4.142861] CAN device driver interface
[ 4.163648] mcp251x spi0.0 can0: MCP2515 successfully initialized.
$ip -s -d link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can <LOOPBACK> state ERROR-ACTIVE restart-ms 0
bitrate 500000 sample-point 0.875
tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
can0: flags=193<UP,RUNNING,NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
license: GPL v2
description: Microchip 251x CAN driver
author: Chris Elston <[email protected]>, Christian Pellegrin <[email protected]>
vermagic: 4.14.85-v7+ SMP mod_unload modversions ARMv7 p2v8
parm: mcp251x_enable_dma:Enable SPI DMA. Default: 0 (Off) (int)
I have scoped the SPI interface to the MCP2515 and can see the initialization occur, I receive the following:
However, I am unable to communicate using the can-utils after the initial initialization communication.
I have candump open in another terminal window to test loopback mode and see nothing when using cansend.
$cansend can0 012#1122334455667788
A scope view of the SPI interface shows no communication occurring when using cansend or candump.
I can remove the module but am unable to reload the LKM from /lib/modules/
$sudo rmmod mcp251x
$sudo insmod /lib/modules/4.14.85-v7+/kernel/drivers/net/can/spi/mcp251x.ko
[ 480.252757] mcp251x spi0.0: Cannot initialize MCP2515. Wrong wiring?
[ 480.252795] mcp251x spi0.0: Probe failed, err=19
I did originally power the CAN shield from the 5V source of the RPI, I quickly noted this was incorrect and tied VDD of the MCP2515 to 3.3V instead. I used pigpio tools to verify if the GPIO were damaged and it reported all pins were OK.
I even tested using a new RPi3 out of the box and the same behavior was seen.
I also have a 120 Ohm termination resistor between CAN_H and CAN_L of the MCP2551, but no differences were seen.
I do not believe this is required in loopback mode anyway.
Does anyone have any insight as to what maybe occurring?
Any help would be much appreciated.