Xavier is not communicating with another device via canbus interface


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.


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 : GitHub - Aravindseenu/CAN-communication-on-Nvidia-AGX-xavier

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.

Hi shgarg,
I tried to follow the instructions in (https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/clocks.html#wwpID0E06B0HA), section “To use PLLAON as clock source”. And the clock (under /sys/kernel/debug/bpmp/debug/clk/can1/parent) seems to be set to “pll-c”.
But when I connect it to the test computer, the result is still the same, it doesn’t work. And also baudrate still seems like that:

bitrate 1010526 sample-point 0.736

I made the following adjustments:

  • I decompile the “tegra194-a02-bpmp-p2888-a04.dtb” file with dtc tool and I changed the “tegra194-a02-bpmp-p2888-a04.dts” file like this:

clock@can1 {
allow_fractional_divider = <0x1>;
allowed-parents = <0x121 0x5b 0x13a 0x5e>;
clk-id = <0x9>;

clock@can2 {
allow_fractional_divider = <0x1>;
allowed-parents = <0x121 0x5b 0x13a 0x5e>;
clk-id = <0xb>;

  • I edit the tegra194-p2888-0001-p2822-0000.dtb file like this:

mttcan@c310000 {
pll_source = “pllaon”;
clocks = <…>,
<&bpmp_clks TEGRA194_CLK_PLLAON>; /New entry/
clock-names = , , , …, “pllaon”;

  • I build the kernel DTB and flashed it.

What do you think is the reason for this? What can I do something else?

So can you see if parent clock is changed to pllaon?
cat /sys/kernel/debug/bpmp/debug/clk/can1/parent
Make CAN1 up on network and then check sysfs node.

Hi eeren,
Excuse me, have you solved the problem? I’ve been trying to use AGX Xavier for development testing recently, and I’ve had the same problem as you.
The inability to accurately set the bitrate of CAN communications directly results in the inability to communicate with external devices.
By the way, I can’t find the “tegra194-a02-bpmp-p2888-a04.dtb” file.

In tegra194-p2888-0001-p2822-0000.dtb, clock contents of mttcan should look like this: please verify.
pll_source = “pllaon”;
clocks = <0x4 0x11c 0x4 0xa 0x4 0x9 0x4 0x5e>;
clock-names = “can_core”, “can_host”, “can”, “pllaon”;

Hi SeanWu,
No, I still could not fix the problem.
I made the changes described in https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/clocks.html#wwpID0E06B0HA, but it didn’t work. The clock (under /sys/kernel/debug/bpmp/debug/clk/can1/parent) seems to be set to “pll-c”. I think we should see something different here. Frankly, I don’t know if I need to make any other changes. I haven’t been able to deal with this problem as I haven’t been to work for a while. If you found a solution, can you share it with me?

I don’t remember exactly what directory tegra194-a02-bpmp-p2888-a04.dtb is in. But I can look at it on Thursday and tell you where it is.

Hi eeren,
Thank you for your reply.
By the way, I’m talking about this problem with others. If I found The way to Solution the problem, I will share it with you as soon as possible.
If you get some ideas . Please share it with me.

Hi SeanWu,
Is the problem solved?
You can find tegra194-a02-bpmp-p2888-a04.dtb in Linux_for_Tegra/bootloader if you have downloaded our jetpack and unpacked it.

Hi shgarg,
I’m glad to hear from you.
Recently, I have been busy with other parts of my work, so I don’t have time to deal with this part of the problem for the time being. When I start to deal with this part of the problem, I will contact you as soon as possible!

I failed to check the can communication with transcivers, but loopback is ok, why?

I’m sorry, what, what jetpack?

it’s NVIDIA SDK Manager | NVIDIA Developer to setup your development environment.
JetPack is SDK that install to your target, the latest release is now JetPack-4.6. please also refer to JetPack Archive | NVIDIA Developer for all available release.