how to enable and test CAN on Xavier

hi,
When we test the can of xavier ,we find we can not detect the signal from xavier directly with oscilloscope.
We can see the information of can by ifconfig .And we have configured the pinmux.

nvidia@nvidia-desktop:~/system$ ifconfig
can0: flags=193<UP,RUNNING,NOARP>  mtu 72
        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 65

can1: flags=193<UP,RUNNING,NOARP>  mtu 72
        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 66

pinmux config

devmem2 0x0243d040 word 0x00000400
devmem2 0x0243d020 word 0x00000458
devmem2 0x0243d058 word 0x00000400
devmem2 0x0243d010 word 0x00000400
devmem2 0x0243d050 word 0x00000400
devmem2 0x0c302048 word 0x00000400
devmem2 0x0c302050 word 0x00000450
devmem2 0x0c302028 word 0x00000400
devmem2 0x0c302038 word 0x00000400


#can
devmem2 0x0c303000 word 0x0000c400
devmem2 0x0c303008 word 0x0000c458
devmem2 0x0c303010 word 0x0000c400
devmem2 0x0c303018 word 0x0000c458

but we still can not see the signal of can0dout or can1dout with oscilloscope.

Hi,
Your register settings are correct. Without oscilloscope, are you getting dump of messages using can-utils?
Please let me know.

Thanks,
Shubhi

hi shgarg,
When we send the message to xavier,use the command “candump can0”,we can see the message,the receive function is ok for xavier.
But when we use the xavier to send the message use the command “cansend can1 5A1#1122334455667788” ,we can not receive the message,and we can not see the signal with the oscilloscope.

Hi,

Are you getting any errors/logs while sending?
Can you share output of following after you send the message:
ip -d -s link show can1
ip -d -s link show can0
It will provide more details.

Hi shgarg,
We did not get errors.Below is the message .

can1

nvidia@nvidia-desktop:~$ cansend can1 5A1#1122334455667788
nvidia@nvidia-desktop:~$ cansend can1 5A1#1122334455667788
nvidia@nvidia-desktop:~$ ip -s -d link show can1
8: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can <BERR-REPORTING,FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 500000 sample-point 0.870
          tq 20 prop-seg 43 phase-seg1 43 phase-seg2 13 sjw 1
          mttcan: tseg1 2..255 tseg2 0..127 sjw 1..127 brp 1..511 brp-inc 1
          dbitrate 2000000 dsample-point 0.720
          dtq 20 dprop-seg 8 dphase-seg1 9 dphase-seg2 7 dsjw 1
          mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
          clock 50000000
          re-started bus-errors arbit-lost error-warn error-pass bus-off
          0          4          0          1          1          1         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    RX: bytes  packets  errors  dropped overrun mcast
    200        25       4       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       1       0       0
nvidia@nvidia-desktop:~$ cansend can1 5A1#1122334455667788
nvidia@nvidia-desktop:~$ ip -s -d link show can1
8: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can <BERR-REPORTING,FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 500000 sample-point 0.870
          tq 20 prop-seg 43 phase-seg1 43 phase-seg2 13 sjw 1
          mttcan: tseg1 2..255 tseg2 0..127 sjw 1..127 brp 1..511 brp-inc 1
          dbitrate 2000000 dsample-point 0.720
          dtq 20 dprop-seg 8 dphase-seg1 9 dphase-seg2 7 dsjw 1
          mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
          clock 50000000
          re-started bus-errors arbit-lost error-warn error-pass bus-off
          0          4          0          1          1          1         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    RX: bytes  packets  errors  dropped overrun mcast
    200        25       4       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       1       0       0

can0

nvidia@nvidia-desktop:~$ cansend can0 5A1#1122334455667788
write: No buffer space available
nvidia@nvidia-desktop:~$ dmesg
[13425.596402] NOHZ: local_softirq_pending 80
[13431.264153] NOHZ: local_softirq_pending 80
[13438.695683] NOHZ: local_softirq_pending 80
[13444.527381] NOHZ: local_softirq_pending 80
[13444.859365] NOHZ: local_softirq_pending 80
nvidia@nvidia-desktop:~$ ip -s -d link show can0
7: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can <BERR-REPORTING,FD> state ERROR-WARNING (berr-counter tx 0 rx 112) restart-ms 0
          bitrate 500000 sample-point 0.870
          tq 20 prop-seg 43 phase-seg1 43 phase-seg2 13 sjw 1
          mttcan: tseg1 2..255 tseg2 0..127 sjw 1..127 brp 1..511 brp-inc 1
          dbitrate 2000000 dsample-point 0.720
          dtq 20 dprop-seg 8 dphase-seg1 9 dphase-seg2 7 dsjw 1
          mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
          clock 50000000
          re-started bus-errors arbit-lost error-warn error-pass bus-off
          0          12208      0          1          1          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    RX: bytes  packets  errors  dropped overrun mcast
    97800      12225    12208   0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       1       0       0

nvidia@nvidia-desktop:~$ sudo ip link set down can0
[sudo] password for nvidia:
nvidia@nvidia-desktop:~$ sudo ip link set up can0
nvidia@nvidia-desktop:~$ cansend can0 5A1#1122334455667788
nvidia@nvidia-desktop:~$ ip -s -d link show can0
7: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can <BERR-REPORTING,FD> state ERROR-WARNING (berr-counter tx 0 rx 112) restart-ms 0
          bitrate 500000 sample-point 0.870
          tq 20 prop-seg 43 phase-seg1 43 phase-seg2 13 sjw 1
          mttcan: tseg1 2..255 tseg2 0..127 sjw 1..127 brp 1..511 brp-inc 1
          dbitrate 2000000 dsample-point 0.720
          dtq 20 dprop-seg 8 dphase-seg1 9 dphase-seg2 7 dsjw 1
          mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
          clock 50000000
          re-started bus-errors arbit-lost error-warn error-pass bus-off
          0          12208      0          1          1          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
    RX: bytes  packets  errors  dropped overrun mcast
    97800      12225    12208   0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       1       0       0

CAN state went to ERROR-WARNING and thus BUS-OFF. Therefore, it dropped message in xavier instead of sending.
I can see RX packets in CAN0 but there are errors too in RX side.
There are two CAN controllers on Xavier, I have tried communicating between these two using external transceivers, communication was successful (both TX and RX).
Which device have you connected on the other end? Can you share your setup, I will debug it at my place.

We use Usbcan transceiver to communication with xavier .We can receive message but can not send message .
Do you know what lead to ERROR-WARNING and BUS-OFF? Maybe it is hardware problem? We use latest 32.2 with rt patch.

Hi,

Well, I have not tried Usbcan. I will give it a try.
I observed BUS-OFF when there is a transceiver issue(hardware problem) or when CAN bus is not properly in sync.It is not the problem with xavier, maybe some SW configurations are mismatched to keep BUS in sync with xavier. I will look into it soon, please let me know if you find any other results.

Thanks,
Shubhi

Hi shgarg,
Thank you !
We do not find other results now ,if we find other issues I will inform you.
And what SW configurations should we check first? We will test another external transceivers tomorrow.

Hi shgarg,
We find the problem why xavier can not send message.It seems because we use thr RT patch for kernel.
If we do not use RT patch for kernel ,CAN module can work normally.But when we use the RT patch for the kernel CAN module can not send message.
Can you test the can module with kernel using RT patch?

I have the same problem,xavier can receive the message,but can’t send, could you explain how you disable RT patch for kernel
thanks