Verdin iMX8MM CAN problem

Im trying to test CAN interface but Im having issue with CAN on my development kit.
ip a doesn’t list can0 interface.

This is dmesg | grep mcp output:

[    4.835136] mcp25xxfd spi2.0: Failed to switch to mode 2 in time
[    4.841254] mcp25xxfd spi2.0: Failed to switch into loopback mode
[    4.847515] mcp25xxfd spi2.0: Probe failed, err=110
[    4.852610] mcp25xxfd: probe of spi2.0 failed with error -110

Verdin iMX8MM SoM is using MCP2517 IC. Have anyone else come accross this?

Greetings @spasoye,

Before I comment on this further, based on your kernel version it would appear you’re running TorizonCore 4.0. Is this correct?

Though I will say that we did far more testing of CAN on TorizonCore 5.X and later then back on 4.0. So if you are on 4.0 If you could try again on 5.X that would be appreciated. Also in addition to confirming the TorizonCore version if you could also state any device-tree/kernel modifications you may have made.

Also just to add ip a on TorizonCore 5.X does list can0 interface in my setup with no modifications.

Best Regards,
Jeremias

Okay, I made mistake. At some point I pulled out carrier board CAN_TX and CAN_RX jumpers and forgot to return them.
I returned the jumpers and got successfull initialization, dmesg output:

[    7.783067] mcp25xxfd spi2.0: MCP2517 successfully initialized.

But I got another problem.
I followed this article, successfully built and run can-sample container.
I can see can0 interface when I run ip a and I can bring interface up. The things goes south when I try to send message:

## cansend can0 123#deadbeef

candump can0 returns nothing. This is dmesg | grep mcp output:

[    7.783067] mcp25xxfd spi2.0: MCP2517 successfully initialized.
[  931.540650] mcp25xxfd spi2.0: Controller unexpectedly switched from mode 0 to 6
[  970.649227] mcp25xxfd spi2.0 can0: CAN Bus error experienced
[  970.651946] mcp25xxfd spi2.0 can0: CAN Bus error experienced

@jeremias.tx same happens on TorizonCore 4 and TorizonCore 5. I havent done any changes to device tree yet.
I guess Im doing something wrong.

Hi @spasoye,

Are you using a proper CAN cabling/wiring with 120 ohm termination resistors at each side?
Do you have other CAN nodes connected in the same CAN bus?

This message is OK:

 [  931.540650] mcp25xxfd spi2.0: Controller unexpectedly switched from mode 0 to 6

But this messages you’ve shown indicates errors in the CAN bus:

 [  970.649227] mcp25xxfd spi2.0 can0: CAN Bus error experienced
 [  970.651946] mcp25xxfd spi2.0 can0: CAN Bus error experienced

Best regards,
André Curvello

It works if I connect PCAN adapter to CAN_H and CAN_L pins with termination resistor and run
candump can0 on my PC. Guess I misunderstood whole point of loopback.

Thanks @andrecurvello.tx

Hi @spasoye,

The “advisable” way of using CAN is, at least, with the CAN terminators in a given CAN bus, if you are working with the CAN Transceiver directly, which exposes the CAN_H and CAN_L.

Good to know that it’s working now!

Best regards,
André Curvello