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.

I’m experiencing similar issue with new BalenaOS versions. We have balenaOS 2.46.1+rev3 that is working ok with PiCAN board but for some reason can’t get newer balenaOS versions to work.

Even if can interface is recognized and adapters are visible, there is no CAN-traffic. With some versions we can’t even initialize CAN-adapters so can0 and can1 are missing.

When I send with PCAN-USB from PC, I looked to bus with an CAN-bus capable oscilloscope, triggered to start of frame and it seems that ACK is missing. So exactly same symptoms as thread starter had, as if PiCAN is not sending anything and is not doing ACK.

I tested with newest BalenaOS and only ran GitHub - balena-io-playground/balena-pican2-testbench: A test application for the PiCAN2-duo HAT. The 2 CAN buses are connected to each other, so that we can perform automated tests on a single device. and was not able to receive or send any traffic. In the github, RX-seems to be broken, it calls for python3 which is missing. Even when commented out, RX seems to be missing can-interface. Only 1 can is recognized even when PiCAN2 has 2 interfaces. But TX at least reports that it’s sending and has an visible can-interface if I get an ssh-connection to it. But nothing comes out of the CAN-bus, looked with scope and there were no signals at all. So all this with test software mentioned above.

Is is possible for Balena staff to look into this if there is something broken in new BalenaOS versions that they don’t anymore work with PiCAN2 ?

Best regards,

Henkka