BBB CAN BUS not receive message

Hi,

I will try to enable CAN BUS in my BeeagleBone Black but when I sent message to BBB I didn’t receive message and didn’t generate errors in CAN Interface, the system doesn’t detect message.

For enable CAN, I used these options:
Add this lines in uEnv.txt

uboot_overlay_addr5=/lib/firmware/BB-CAN1-00A0.dtbo
cape_disable=bone_capemgr.disable_partno=BB-UART1
cape_enable=bone_capemgr.enable_partno=BB-CAN1

And when start system detect drivers:

[   47.481839] CAN device driver interface
[   47.663340] c_can_platform 481cc000.can: c_can_platform device registered (regs=a289968a, irq=48)
[   47.707740] c_can_platform 481d0000.can: c_can_platform device registered (regs=21010f46, irq=49)
[   51.303945] pvrsrvkm: loading out-of-tree module taints kernel.
[   51.519457] [drm] Initialized pvr 1.17.4948957 20110701 for 56000000.gpu on minor 1
[   52.948525] PM: bootloader does not support rtc-only!
[   56.650839] remoteproc remoteproc1: 4a334000.pru is available
[   56.662793] remoteproc remoteproc2: 4a338000.pru is available
[  144.670808] c_can_platform 481d0000.can can1: setting BTR=1c05 BRPE=0000
[  144.685573] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
[  148.830311] can: controller area network core
[  148.830511] NET: Registered protocol family 29
[  148.886227] can: raw protocol

In terminal, I config PINs P9.24 and P9.26 with CAN:

config-pin p9.24 can
config-pin p9.26 can

And enable interface
sudo /sbin/ip link set can1 up type can bitrate 500000
After enable CAN Interface in ifconfig, I showed the interface.

can1: 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
        device interrupt 49

To read CAN BUS message, I used the installed CAN utilities in system and command candump can1 and didn’t receive something. If I try to send, I had the same problem, another device connected to CANBUS didn’t receive the message.

For test to discard a BUS problem, I configured P9.24 and P9.26 as a UART and listen by minicom /dev/ttyS1 and receive information but incorrect parse characters.

What could be the problem? Am I missing a step? The CAN speed is the same in all devices and I tested CAN0 (P9.19 / P9.20), CAN1 ( P9.24 / P9.26 ). I have installed AM335x 12.2 2023-10-07 4GB eMMC IoT Flasher

Thanks,

Assuming the PIN are muxed correctly it should work.

What CAN transceiver are you using ? Is it properly enabled ?
Have you got the correct termination resistors on the CAN bus ?

Have you got access to a scope ?

As Benedict suggested, check the CAN transceiver. Also, double check the bitrates.

One trick I’ve found useful is to have a 3rd known good CAN device on the bus. If there are only 2 devices and one isnt working properly then the other one will retry a number of times then give up - so the bus goes dead and it’s difficult to know what’s going on. A 3rd device will acknowledge a message, so the sending device will stay on line allowing you to debug with a scope or bus analyser or whatever.

1 Like

Hi Benedict,

I used the transceiver SN65HVD230. For test CAN protocol in BeagleBone Black I connected PINs P9.24 and P9.26 to SN65HVD230 and connect CAN termination to Computer CAN Generator ICP CON i-7656-H1. If connect two devices directly, do I need termination resistors?

Thanks,

Yes you should always have two termination resistors, one at each end of the bus.

Most probably you should remove cape manager lines from uEnv.txt
and do not use config-pin because BB-CAN1-00A0.dtbo overlay already have all required pin configs, you can re-check overlay source, usually it’s located here /opt/source/bb.org-overlays/src/arm/BB-CAN1-00A0.dts

If this will not help - post output from command sudo beagle-version

It appears that the overlay is not being loaded.

The file /lib/firmware/BB-CAN1-00A0.dtbo does not exist in the am335x-debian-12.2-iot-armhf-2023-10-07-4gb image. The clue is in your config-pin commands - the overlay should disable these pins so attempting to configure them with config-pin should produce an error.

There are a couple of fixes:
One is to cd into /opt/source/overlay-utils/ and type make. This will build the contents of this directory, including can[01].dtsi. Copy the can[01]dtbo files into /lib/firmware or wherever you want and reference these in your uEnv.txt instead.

Another is to do a git pull somewhere in /opt/source - I dont know where, someone else may chime in here. This will pull in the sources for the BB-CAN[01]-00A0.dtbo files. make and make install should then put these in the correct location to make your existing setup work. Dont forget though that the config-pin commands aren’t needed.

A 3rd option is to use the am335x-debian-12.2-minimal-armhf-2023-10-07-2gb image, if this is suitable for your needs. This is already set up to work with your existing configuration.
[edit] Sorry, I put you wrong - the 12.2 minimal image does NOT have the files (BB-CAN[01]-00A0.dtbo). It’s the 11.8 minimal image that has these. So I would assume that the 11.8 IOT image probably has them as well.

Hi,

Thanks for yours comments.
I put the resistors system in but it still doesn’t wo
I tested the OS am335x-debian-12.2-iot-armhf-2023-10-07-4gb.img, I compile the files can[0-1] .dts and add to uEnv.txt.

uboot_overlay_addr4=/lib/firmware/can0.dtbo
uboot_overlay_addr5=/lib/firmware/can1.dtbo

After reboot BBB, I saw that can dtbo libraries have been loaded.

UBOOT: Loaded Overlay:[can0]
UBOOT: Loaded Overlay:[can1]
uboot_overlay_options:[uboot_overlay_addr4=/lib/firmware/can0.dtbo]
uboot_overlay_options:[uboot_overlay_addr5=/lib/firmware/can1.dtbo]

And I reviewed the PIN status:

P9.24                             97 fast rx  up  2 can 1 rx         can@481d0000 (can1)
P9.26                             96 fast rx  up  2 can 1 tx         can@481d0000 (can1)

After this change, I enabled can interface and configured bitrate and send CAN signal and the same, I don’t receive something.

Now, I’m waiting to a workmate can analyse the CAN signals with an oscilloscope because I think the all test configurations were good.

Thanks,

I see you’ve configured both can0 and can1. Can you use both of these? If you have 2 bus transceivers, then you could send and receive using the one bbb, instead of using a separate device. This makes it easy to ensure both sender and receiver are configured the same, and you can use cangen/candump to transfer can frames between the 2 interfaces.

It is a very interesting your proposal.
I connected the ports directly, Rx to Tx and Tx to Rx:

  • P9.24 → P.9.20
  • P9.26 → P9.19
P9.20 / cape i²c sda 94 fast rx up 2 can 0 tx can@481cc000 (can0)
P9.19 / cape i²c scl 95 fast rx up 2 can 0 rx can@481cc000 (can0)
P9.26 96 fast rx up 2 can 1 tx can@481d0000 (can1)
P9.24 97 fast rx up 2 can 1 rx can@481d0000 (can1)

Is correct that the 4 pins are ‘fast rx’?

I enabled port with comands:

sudo /sbin/ip link set can0 up type can bitrate 500000 
sudo /sbin/ip link set can1 up type can bitrate 500000

and tried sending and receiving:

cangen can0
candump can1

The candump didn’t show the messages.

If I review statistics, I see the transmitted frames but the received frames didn’t increase.

       40 transmitted frames (TXF)
        6 received frames (RXF)
        0 matched frames (RXMF)

In the link status, I found this:
CAN 0
can state ERROR-PASSIVE (berr-counter tx 0 rx 127) restart-ms 0
CAN 1
can state BUS-OFF (berr-counter tx 248 rx 0) restart-ms 0

I investigated more and I restarted BBB and disconnected the pins. When I enabled the CAN, the CAN state were can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0.
I think this is the problem. What can produce the error activation?

Thanks,

I’m not sure whether directly connecting the can rx/tx pins would work. I meant for you to still use the SN65HVD230 transceiver module - one module on each port, with the the canH and canL lines connected together.

The ERROR-PASSIVE state on can0 is probably because it received no ack from the receiver.

You should disable the interfaces after an error using sudo ifconfig can1 down then reenable using your sudo /sbin/ip link set ... command. This saves having to reboot.

You can’t connect pins directly like that. You must always use a transceiver chip.

On 12.5-6.1 with pin configuration like this:

P9.26                             96 fast rx  up  2 can 1 tx         can@481d0000 (can1)
P9.24                             97 fast rx  up  2 can 1 rx         can@481d0000 (can1)

always can configure only like can0:

can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP group default qlen 10 link/can

How can it be configured as can1 as it was in 11?

Hello,

After reading that I could not directly connect the CAN0 and CAN1 ports, I bought two SN65HVD230 transceivers. I created a CAN BUS with the two 120 Ohms resistors at each end and between the resistors, I connected the two transceivers. One transceiver is connected to the CAN 0 interface and another transceiver is connected to the CAN1 interface. I enabled the interfaces with the same speed and when I generated a message from one CAN interface, the other CAN disconnects due to errors.

Thanks,

Do you see identical results when you reverse the functions of the 2 can ports?

The fact that the receiver gets errors would suggest that the 2 devices are at least communicating in some way. Please post the error.
You mentioned earlier that you configured one of the ports as a serial port and that it did send data but it was corrupt - this is a bit of a red flag for me. Perhaps investigate this further. Try reconfigureing the ports as a serial port and figure out whether the data really is corrupt and why. This may point to your problem.

Is it possible to post a photo of your setup?

Hello,

Finally, I was able to send information between CAN0 and CAN1 via the CAN BUS.
I have contacted the supplier of the rest of the CAN equipment that needs to be connected and they have told me that the equipment works with CAN FD. I see from other forum posts that the BBB does not support CAN FD. It’s true? Is it a limitation of the processor, board or the operating system?

Thanks

It is a hardware limitation. If you need CAN FD you will either need to use another board, or get a CAN FD module.

So while the equipment works with CAN FD is it a requirement or are they just saying that the controller in the equipment is CAN FD capable ? If the equipment only requires non CAN FD messages then the BBB should work fine, assuming nothing else on the bus talks CAN FD messages.