Controller Area Network (CAN) on Xavier NX at 1Mbps

Dear Community,
We have developed a custom carrier for the Xavier NX and are now trying to bring up the CAN interface up. We got the interface up for 500kbps but the same is failing at 1Mbps. Has anyone tested the interface at 1Mbps?

We are keen to know if there are slew rate limitations imposed by the software driver that needs to be enabled in the back end. We are using the transceiver NXP# PCA82C251T/YM,118.

Hi roshan,
Can you please tell me the commands you are using to send/receive and for bitrate configurations?
Also, please paste the errors you are seeing.

Thanks,
Shubhi

Hi Shubhi,

I work with Roshan on this.

Once we configure CAN for 1mbps baud, and try to send something, transmission doesn’t happen and the following appears in dmesg :

[ 149.670053] mttcan c310000.mttcan can0: Bitrate set
[ 228.119272] mttcan c310000.mttcan can0: bitrate error 1.0%
[ 228.119421] mttcan c310000.mttcan can0: Bitrate set
[ 233.654596] mttcan_controller_config: ctrlmode 0
[ 233.654624] mttcan c310000.mttcan can0: Bitrate set
[ 256.953469] mttcan c310000.mttcan can0: entered error warning state
[ 256.953800] mttcan c310000.mttcan can0: entered error passive state
[ 256.956108] mttcan c310000.mttcan can0: entered bus off state

Post this, we cant use bus any more. To recover, we need to remove the drivers and reinsert again.

We are configuring can using below commands :

sudo modprobe can
sudo modprobe can_raw
sudo modprobe mttcan
sudo ip link set can0 type can bitrate 1000000
sudo ip link set up can0
candump can0
and
cansend can1 5A1#1122334455667788

We have a CAN line from NX to one CAN port to Xavier AGX.

Attaching complete dmesg for your ref.
desg.log (67.2 KB)

Hi,
Can you please give me output of following from both sides (NX and Xavier):
ip -d -s link show can0

I want to check what is the clock rate set?

Thanks,
Shubhi

Hello Shubhi,

Please find the outputs from both the boards in attached. file. debug-logs.txt (2.1 KB)

Hi,
The clock parent are different in both the systems.
Can you please tell me what BSP version is flashed in both the systems?
Also, did you make any change in kernel dtbs?
In Xavier AGX: pllaon clock is set and In NX: osc clock is set thus the bitrates differ and thus biterrors are coming.
You need to set pllaon clock in NX also for the problem to solve.
Please provide BSP versions details so that I wil check at my end why the clocks differ.

Thanks,
Shubhi

Hello Shubhi,
Xavier AGX is using # R31 (release), REVISION: 1.0, GCID: 13194883, BOARD: t186ref, EABI: aarch64, DATE: Wed Oct 31 22:26:16 UTC 2018

and NX is using # R32 (release), REVISION: 4.3, GCID: 21589087, BOARD: t186ref, EABI: aarch64, DATE: Fri Jun 26 04:34:27 UTC 2020

Yes, we make some changes to dtb, mostly to adapt to our carrier card. Nothing related to CAN or clock settings.

Please let us know in case any additional details are required.

Thanks,
Don.

Hi Michael,
Please use R32.4 in AGX to set osc clock. Or if you want to only update dtb then update mttcan node in dts with following:
pll_source = “osc”;
clocks = <0x4 0x11c 0x4 0xa 0x4 0x9 0x4 0x5b>;
clock-names = “can_core”, “can_host”, “can”, “osc”;

Let me know if you face any issues.

Thanks,
Shubhi

Hi Shubhi,

I see that this clock change is now merged as part of R32.4.3, thanks. One thing I notice is that the CAN controller clock is at 38.4MHz, so when asking for 1Mbit/s bitrate, the achieved bitrate reported back by ip is 1010526 instead of 1000000. There is no way in hardware to clock the Xavier NX CAN controller at exactly 40MHz like on TX2?

Thanks,
Ursula

Hi Shubhi,

Thanks for the suggestion. But how can we ensure this in field ? People may connect any CAN devices together.

Thanks,
Don.

Hi everyone,
To achieve exact 1Mbps:
Here is the documentation available to change CAN parent clock to PLLAON.

https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fclocks.html%23wwpID0E06B0HA

Check “ To use PLLAON as clock source” section

With PLLAON, users will be able to achieve 50MHz CAN core clock rate and 1Mbps exact bitrate settings as well.

To set 40MHz clock rate, I just replied in this thread, please check it out.

Thanks,
Shubhi
Thanks,
Shubhi