Jetson AGX Orin CAN FD bad frames

Hello,

Setup:
I am using a Jetson AGX Orin Developer Kit Carrier board tegra234-p3737-0000+p3701-0000.
I bought two CAN FD transceivers and connected both jetson CANs (can4 and can5 in my case) between them.

I set the clock to be 80MHz (recompiling the driver) and these config:

$ sudo ip link set can4 up type can bitrate 1000000 sample-point 0.6 dbitrate 5000000 dsample-point 0.625 fd on loopback off
$ ip -details link show can4
20: can4: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0 
    can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
	  bitrate 1000000 sample-point 0.600 
	  tq 12 prop-seg 23 phase-seg1 24 phase-seg2 32 sjw 1
	  mttcan: tseg1 2..255 tseg2 0..127 sjw 1..127 brp 1..511 brp-inc 1
	  dbitrate 5000000 dsample-point 0.625 
	  dtq 12 dprop-seg 4 dphase-seg1 5 dphase-seg2 6 dsjw 1
	  mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
	  clock 80000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 parentbus platform parentdev c310000.mttcan

Same for can5.

Problem:
When I try to send a FD frame,

$ cansend can4 123##1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

it is truncated in the Control Field, in the BRS more or less (sniffing with a logic analyzer):

However, in loopback mode on

$ sudo ip link set can4 up type can bitrate 1000000 sample-point 0.6 dbitrate 5000000 dsample-point 0.625 fd on loopback on

the frame is fully and correctly generated:

and if I do not set can5 to loopback mode, it sends ACK! So it is not a matter of my hardware nor the capabilities of the CAN, not even CAN misconfiguration. It seems it is a matter of the Jetson CAN Controller.

Notes:
I have tried other configurations and other clocks. Some of them work and some others don’t. I need that configuration (sample-point 0.6 and dsample-point 0.625) working.

  • Clock 200MHz, sample-point 0.75 and dsample-point 0.75 works.
  • Clock 200MHz, sample-point 0.6 and dsample-point 0.625 does NOT work.
  • Clock 80MHz, sample-point 0.75 and dsample-point 0.75 does NOT work.

Can you recreate this problem? Are you able to communicate with my CAN parameters?

Thank you,
Ignasi

Hello,

Thanks for visiting the NVIDIA Developer forums.

Your topic will be best served in the Jetson category, I have moved this post for better visibility.

Cheers,
Tom

Hi ignasi.mallen,

What’s the Jetpack version in use?

Sorry that we don’t have your CAN FD transceiver to reproduce it on the devkit.
Do you see any error in dmesg?

You have to confirm these 2 properties are the same for both devices. (i.e. can4 and can5).

If you’ve confirmed this working, why you don’t keep using them?
May I know the block diagram of your connection and also your use case?

Hi Kevin,

My Jetpack is 6.2, Jetson Linux 36.4.3. I have done the test with other transceivers (the recommended WaveShare SN65HVD230 CAN board) and same happens, so it is not a matter of the transceiver.

Only messages in dmesg are

[ +31,188549] mttcan c320000.mttcan can5: entered error warning state
[  +0,000145] mttcan c320000.mttcan can5: entered error passive state
[  +0,000695] mttcan c320000.mttcan can5: entered bus off state

and this is because it expects an ack never received (because the frame is bad), so it keeps retrying (sending bad frames again and again) after entering in error passive state.

The block diagram is simple:
can4 ---- transceiver ---- transceiver ---- can5

I would need this configuration working for my own porpuses:
Clock 80MHz, bitrate 1 Mbps, sample-point 0.6, data bitrate 5 Mbps and dsample-point 0.625.

Worst case I would change the configuration to any that does work, but I would prefer not.

Actually, I’m curious about what do you use for can0, can1, can2, can3?
It seems you have many can devices in your setup.
Please also share the full dmesg for further check.

I have a PEAK pcie_canfd M2 board connected to the jetson, but it is not used, so can be ignored.

I can make an explanation easier for what is going on:

Do this to set up both CANs:

sudo ip link set can4 up type can bitrate 1000000 sample-point 0.6 dbitrate 5000000 dsample-point 0.625 fd on loopback off
sudo ip link set can5 up type can bitrate 1000000 sample-point 0.6 dbitrate 5000000 dsample-point 0.625 fd on loopback on

DMesg are as expected:

[ +19,386157] mttcan c320000.mttcan can5: Bitrate set
[  +0,000181] mttcan_controller_config: ctrlmode 21
[  +0,000029] mttcan c320000.mttcan can5: Bitrate set
[  +0,000065] IPv6: ADDRCONF(NETDEV_CHANGE): can5: link becomes ready
[jun17 10:22] mttcan c310000.mttcan can4: Bitrate set
[  +0,000274] mttcan_controller_config: ctrlmode 20
[  +0,000023] mttcan c310000.mttcan can4: Bitrate set
[  +0,000096] IPv6: ADDRCONF(NETDEV_CHANGE): can4: link becomes ready

Then send a frame from can5 (the one with loopback on) and dump from the other:

$ cansend can5 123##1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
$ candump can4
  can4  123  [20]  AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 00 00 00

This setup works. No more dmesg.

Now, do it with both loopback off:

sudo ip link set can4 down
sudo ip link set can5 down
sudo ip link set can4 up type can bitrate 1000000 sample-point 0.6 dbitrate 5000000 dsample-point 0.625 fd on loopback off
sudo ip link set can5 up type can bitrate 1000000 sample-point 0.6 dbitrate 5000000 dsample-point 0.625 fd on loopback off

And send the same frame:

$ cansend can5 123##1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
$ candump can4

Now, can4 receives nothing, and can5 enters error passive:

[jun17 10:30] mttcan c320000.mttcan can5: Bitrate set
[  +0,000500] mttcan_controller_config: ctrlmode 20
[  +0,000029] mttcan c320000.mttcan can5: Bitrate set
[  +0,000393] IPv6: ADDRCONF(NETDEV_CHANGE): can5: link becomes ready
[  +6,598148] mttcan c310000.mttcan can4: Bitrate set
[  +0,000449] mttcan_controller_config: ctrlmode 20
[  +0,000025] mttcan c310000.mttcan can4: Bitrate set
[  +0,000090] IPv6: ADDRCONF(NETDEV_CHANGE): can4: link becomes ready
[ +16,501512] mttcan c310000.mttcan can4: entered error warning state
[  +0,000296] mttcan c320000.mttcan can5: entered error warning state
[  +0,000123] mttcan c320000.mttcan can5: entered error passive state
[  +0,000729] mttcan c320000.mttcan can5: entered bus off state

You have to check the dmesg to know which can node linked to current CAN FD transceiver.
I would expect they are assigned dynamically according to the order of driver probed.

Okay, these dmesg show can4 and can5 are correct for internal mttcan.

I think you don’t need to add this option.

Please run the candump at receiver side before running cansend from sender.

Have you confirmed that there’s only one 120Ohm resistor as terminator in your CAN setup?

Yes, there is only one 120 Ohm resistor. Are you able to reproduce the error? Because if not, I am starting to think my jetson is somehow broken.

Sorry that I can’t reproduce similar issue on the devkit with CAN-FD data transaction.

Do you have other board hitting the similar issue?
Or the issue is specific to the current board?

We do not have any other board currently, but going to purchase one soon. Can we keep the topic open until I get the new one?

Sure, please also try adding sjw 4 in the command when you are setting up CAN interface to check if it could help.