steffensq
Posts: 6
Joined: Thu Oct 22, 2015 4:07 pm

Damaged CAN Interface?

Mon Jan 21, 2019 8:16 pm

Hello,

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.

/boot/config.txt includes:

dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25

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
clock 8000000
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

$ifconfig can0

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

$modinfo mcp251x

filename: /lib/modules/4.14.85-v7+/kernel/drivers/net/can/spi/mcp251x.ko
license: GPL v2
description: Microchip 251x CAN driver
author: Chris Elston <[email protected]>, Christian Pellegrin <[email protected]>
srcversion: C0A2AE041D252B41A611B5B
alias: of:N*T*Cmicrochip,mcp2515C*
alias: of:N*T*Cmicrochip,mcp2515
alias: of:N*T*Cmicrochip,mcp2510C*
alias: of:N*T*Cmicrochip,mcp2510
alias: spi:mcp2515
alias: spi:mcp2510
depends: can-dev
intree: Y
name: mcp251x
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:

Image

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.

Thanks,
Steffen
Attachments
Capture.PNG
Capture.PNG (10.72 KiB) Viewed 1118 times

tempest766
Posts: 105
Joined: Sun Jan 07, 2018 3:44 pm

Re: Damaged CAN Interface?

Tue Jan 22, 2019 5:47 am

do you have it connected to an active and terminated bus, or are you doing (software loopback)? I'm pretty certain that the transceiver won't do anything unless it detects a bus connection.

If it were me I'd use an oscilloscope to check the bus and determine if the cansend is broadcasting out the pattern. Then I'd hook up another pi as a test receiver. not sure how useful your loopback tests really are.

I went through these same issues with PPC embedded boards some years ago and eventually had to tune the quanta value so that the bit patterns were properly recognized on the bus.

Make sure your bus is properly terminated.

steffensq
Posts: 6
Joined: Thu Oct 22, 2015 4:07 pm

Re: Damaged CAN Interface?

Wed Jan 23, 2019 7:41 pm

do you have it connected to an active and terminated bus, or are you doing (software loopback)? I'm pretty certain that the transceiver won't do anything unless it detects a bus connection.
Software loopback, but the bus is still terminated with 120 Ohm resistor between CAN_H and CAN_L.
I originally tested the bus with it connected to my car's OBDII port before I started attempting to communicate using the software loopback.
If it were me I'd use an oscilloscope to check the bus and determine if the cansend is broadcasting out the pattern. Then I'd hook up another pi as a test receiver. not sure how useful your loopback tests really are.
I'd prefer not to purchase another CAN module to create a test receiver. This is my last resort.
I am using a logic analyzer on the SPI interface between the RPi and MCP2515.
I can see communication on initialization of the driver, but cansend does not broadcast anything on the SPI bus and in turn the CAN bus.

windigo
Posts: 1
Joined: Tue Feb 19, 2019 1:36 pm

Re: Damaged CAN Interface?

Tue Feb 19, 2019 1:50 pm

I have the same problem with 3B+ and Stretch. I have the Canberry Dual V2.1 Single Channel card with termination jumper solderd (I have 2, replacing the card did not help). I also have a live bus and not just loopback which should confirm all the can sends, with several devices capable of confirming it.

It looks like the MCP2515 connection over SPI works ok, but there are problems on the CAN side, as the board gets into bus-off quickly (1 sec) after first cansend. The other devices work fine. What looks suspicious is the clock output of /sbin/ip -s -d which is shown as 80000000 when my oscillator is set to 16000000.

Return to “Interfacing (DSI, CSI, I2C, etc.)”