Xavier is not communicating with another device via canbus interface

Hi,

I want to test Xavier’s canbus interface. I made the following adjustments for canbus.

sudo busybox devmem 0x0c303000 32 0x0000C400
sudo busybox devmem 0x0c303008 32 0x0000C458
sudo busybox devmem 0x0c303010 32 0x0000C400
sudo busybox devmem 0x0c303018 32 0x0000C458

sudo modprobe can
sudo modprobe can-raw
sudo modprobe can-dev
sudo modprobe mttcan

sudo ip link set can0 type can bitrate 500000
sudo ip link set can1 type can bitrate 500000

sudo ip link set up can0
sudo ip link set up can1

I did loopback testing for can0 and can1, and it worked, but this only allows us to see if the controller is working. I want to test canbus interface by communicating with another device. but I have some questions and problems about it.

  1. I connected the can0_rx line to the can1_tx line and sent the data “cansend can1 123 # abcdabcd” from the can1 bus from the terminal. I saw data from the oscilloscope on the can0_rx line. but when I sent it again, I could not see data on the canbus line. I see it once again when I restart Xavier and do the same things again. but the second time I can’t see data again. I have to restart Xavier every time to see data. so I tried “sudo ip link set can1 type can restart-ms 100” command. but that didn’t work either. So, can I test can0 and can1 line without tranciever in between?

  2. I want to communicate with xavier another device via canbus. For this I connected the lines can1_rx and can1_tx to a tranciever. I connected the can_high and can_low lines at the exit of tranciever to the test computer with Ixxat usb-to-can converter. I tried communicating to between the test computer and xavier with the minimon program. but I am getting a “tranciever pending” error from the program. I also do not see any data when I look from the oscillator. What do you think is the reason for this? Could there be a problem with acknowledge? How can I communicate to between test computer and xavier via canbus interface using tranciever?

Hi eeren,
You cannot connect CAN0 to CAN1 without transceiver. Only CAN0_TX to CAN0_RX is possible.
For communication with other device: can you see if bitrates set are same for both the CAN nodes on the bus. You can check Xavier bitrate from ip -d -s link show can0 if you made can0 up on network.
Also, provide dmesg error logs to us.

Thanks,
Shubhi

Hello @eeren_edm
I can understand your problem, For your first question
try replacing sudo ip link set can0 type can bitrate 500000 with sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on you should see the msg working properly.

try following this repo for your quires : https://github.com/Aravindseenu/CAN-communication-on-Nvidia-AGX-xavier.git

when the connections are proper ,you should be able to communicate with test computer.
use cansend and candump commands

I connected both the can0 and can1 lines to the tranciever and it worked. But when I connect it to the test computer, the result is still the same, it doesn’t work. Could there be a problem with acknowledge?

And when I do “sudo ip link set can1 type can bitrate 1000000”, I expect the bitrate to be 1000000. However, when I look at it with the command “ip -d -s link show can1”, I don’t see that it matches exactly. What is the reason of this?

~$ ip -d -s link show can1
9: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 1010526 sample-point 0.736
tq 52 prop-seg 6 phase-seg1 7 phase-seg2 5 sjw 1
mttcan: tseg1 2…255 tseg2 0…127 sjw 1…127 brp 1…511 brp-inc 1
mttcan: dtseg1 1…31 dtseg2 0…15 dsjw 1…15 dbrp 1…15 dbrp-inc 1
clock 38400000
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

Hi eeren,
since clock is not pllaon, you will not get exact 1Mbps bitrate. That’s why communication is failing with other device. If you want exact bitrate, please change parent CAN clock to pllaon.
https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/clocks.html#wwpID0E06B0HA