BalenaFin not working with CANbus, same setup on Raspberry Pi does

Hi, I’m having some issues with the balenaFin and the PICAN2 canbus shield.

I am trying to get the shield to send can messages to a usb adapter on my pc to no avail, which however works correctly when using a standard Raspberry Pi.

This is my setup:

  • Raspberry Pi 3 Model B v1.2 2015

  • balenaFin 1.1 with Compute Module 3+L 2018

  • PiCAN2 Duo CAN-Bus Board

  • OS: 2020-02-13-raspbian-buster-lite

  • USBCAN: PCAN-USB FD

  • PC: 5.4.18-1-MANJARO

I have tried sending first SPI messages to see if there was a problem there, but both devices are able to send messages that I can see on a logic analyzer.

I have then tried sending CAN messages using both cansend and python-can, and using the adapter with candump and a logic analyzer to verify these messages.

The Raspberry works as expected, and I am able to see the messages pass on both devices when using both methods.

The balenaFin fails to send anything, there are no CAN messages going out, nor is there any activity on the SPI lines when the CAN message is being sent.

When I try to send a message from the pc to the balenaFin, there is no ACK and the adapter’s ERROR LED turns on. A message from the pc to the Raspberry Pi works correctly.

I have configured the /boot/config.txt file following the instructions as follows, and use the same file for both the Raspberry Pi and the balenaFin:

 dtparam=spi=on

 # SPI
 #dtoverlay=spi-bcm2835

 # CAN
 dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
 dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24
 dtoverlay=spi-bcm2835-overlay

I have uncommented the SPI section while commenting out the CAN section to test the SPI and viceversa to test the CAN.

Since the software side is the same, this seems to be a hardware configuration issue.
Any input on the possible causes for this behaviour would be greatly appreciated.
Thanks!

Hi,

We have this demo repo (https://github.com/balena-io-playground/vehicle-control-demo) where we used a FIN with a CAN adapter, we used an older version of the PiCAN board though. Maybe this can give some hints on why it is not working. I’ll also ping the fin team in case they have any more ideas.

Hi,
The fin team got back to me with another repository (https://github.com/balena-io-playground/balena-pican2-testbench), where they used the PiCAN2 Duo CAN-Bus Board. There was also an internal discussion about it and according to the fin team the relevant outcome was: the reason it wasn't working is that a 120 ohm resistor was missing between the 2 channel of the bus, and this protocol needs impedence in order to work. I hope this helps.

I am curious if @alvaroferran tested the resistor placement and if there was any impact. Hard for me to believe that the on board transceiver for the PiCAN 2 would have any impedance check before transmitting.

Even if it did, it wouldn’t explain why there was no SPI traffic between the Fin and the PiCAN when using cansend.