Something wrong with my can test of NX?

Recently, the following has made me very puzzled about can test of jetson xavier nx developer kit:
1、loopback works well:
(1)reboot nx
(2)sudo modprobe can
sudo modprobe can-raw
sudo modprobe mttcan
(3)dmesg
[ 120.015814] can: raw protocol (rev 20120528)
[ 126.316659] CAN device driver interface
[ 126.326749] Message RAM Configuration
| base addr |0x0c312000|
| sidfc_flssa |0x00000000|
| xidfc_flesa |0x00000040|
| rxf0c_f0sa |0x000000c0|
| rxf1c_f1sa |0x000009c0|
| rxbc_rbsa |0x000009c0|
| txefc_efsa |0x000009c0|
| txbc_tbsa |0x00000a40|
| tmc_tmsa |0x00000ec0|
[ 126.326987] Release 3.2.0 from 19.12.2014
[ 126.327986] net can0: mttcan device registered (regs=ffffff800d1fe000, irq=63)
(4)sudo ip link set can0 up type can bitrate 500000 loopback on
candump can0 &
cansend can0 123#11223344
output:
can0 123 [4] 11 22 33 44
can0 123 [4] 11 22 33 44
(5)ip -details -statistics link show can0
8: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 498701 sample-point 0.870
tq 26 prop-seg 33 phase-seg1 33 phase-seg2 10 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
8 2 0 0 0 0
TX: bytes packets errors dropped carrier collsns
8 2 0 0 0 0

2 Something is wrong with can test when I connect a transceiver to CAN_PIN of J17
(1)sudo busybox devmem 0x0c303000 32 0x0000c400
sudo busybox devmem 0x0c303008 32 0x0000c458
(2)sudo modprobe can
sudo modprobe can-raw
sudo modprobe mttcan
(3)dmesg
[ 242.271887] CAN device driver interface
[ 242.280594] Message RAM Configuration
| base addr |0x0c312000|
| sidfc_flssa |0x00000000|
| xidfc_flesa |0x00000040|
| rxf0c_f0sa |0x000000c0|
| rxf1c_f1sa |0x000009c0|
| rxbc_rbsa |0x000009c0|
| txefc_efsa |0x000009c0|
| txbc_tbsa |0x00000a40|
| tmc_tmsa |0x00000ec0|
[ 242.280749] Release 3.2.0 from 19.12.2014
[ 242.281560] net can0: mttcan device registered (regs=ffffff800d0b8000, irq=63)
(4)sudo ip link set can0 up type can bitrate 500000
(5)candump can0 &
cansend can0 123#11223344
ip -details -statistics link show can0
output:
8: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-PASSIVE (berr-counter tx 128 rx 0) restart-ms 0
bitrate 498701 sample-point 0.870
tq 26 prop-seg 33 phase-seg1 33 phase-seg2 10 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 1 1 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
16 2 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
(6)When execute many “cansend can0 123#11223344”,the following errors come:
write: No buffer space available
(7)dmesg
[ 314.656243] mttcan c310000.mttcan can0: bitrate error 0.2%
[ 314.656389] mttcan c310000.mttcan can0: Bitrate set
[ 314.656465] mttcan_controller_config: ctrlmode 0
[ 314.656483] mttcan c310000.mttcan can0: Bitrate set
[ 314.656625] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 411.724197] mttcan c310000.mttcan can0: entered error warning state
[ 411.724880] mttcan c310000.mttcan can0: entered error passive state

ERROR-PASSIVE? No buffer space available?

Hi,
Can you tell me the value of these registers:
busybox devmem 0x0c303018
busybox devmem 0x0c303010
These registers are for CAN0. I hope these registers are already enabled in SW but let’s confirm.

Thanks,
Shubhi

After NX reboot,I input the followint commands:
sqt@3qt:~$ sudo busybox devmem 0x0c303018
0x0000C450

sqt@3qt:~$ sudo busybox devmem 0x0c303010
0x0000C400

sqt@3qt:~$ sudo busybox devmem 0x0c303000
0x0000C415

sqt@3qt:~$ sudo busybox devmem 0x0c303008
0x0000C415

Thanks.

Ok, register settings are fine.
Problem is with setup.
With the transceiver, you are dumping on can0 and sending from can0 without loopback.
Did you connect CAN bus, if yes where the other CAN node is connected?
Can you please explain your connections?

Do I need to execute the following steps?
sudo busybox devmem 0x0c303000 32 0x0000c400

sudo busybox devmem 0x0c303008 32 0x0000c458

No, these registers are for CAN1. and anyways only CAN0 is enabled on NX, you don’t need to enable CAN.


nx:3.3v—transceiver:3.3v,nx:GND—transceiver:3.3v,
nx:CAN_TX----transceiver:CTX,nx:CAN_RX----transceiver:CRX,
transceiver:CANH----CANalyst:CANH,transceiver:CANL----CANalyst:CANL,
The above is my all connections,

My CANalyst can communicate with STM32F103 by CAN!
Thanks!

Why nx:GND is connected to transceiver:3.3v , is it typo?
You message send by CAN0 is not getting received at other end which is CANalyst right?

Sorry,it is typo! My CANalyst should be right because it can communicate with STM32F103 by CAN。Is my can-transceiver probably bad?

What bitrate is set at CANalyst?
It may be due to bitrate mismatch.


The above picture is seen by me in past post. According to above suggestions,CAN pinmux registers of nx should is :
0x0c303018=0x0000C450,0x0c303000=0x0000C415. I am puzzled about the two different suggestions.
Bitrate of CANalyst is 500k bps which is the same as NX.

CAN0 controller pinmux registers are 0x0c303018 (CAN0_DIN) and 0x0c303010 (CAN0_DOUT)
00 and 08 are for CAN1, I don’t remember why I suggested in above topic, I may have made mistake. But Please follow these details.
And by default, all configurations are set so you don’t need to enable/configure any settings explicitly.

Secondly, bitrate 500Kbps is not exactly set on NX due to CAN parent clock not being PLLAON. That’s why you are seeing ERRORS during transaction.
If you want to set pllaon, please check :
Controller Area Network (CAN) on Xavier NX at 1Mbps - #17 by shgarg


(1)It seemed to be some wishes.When bitrate is set 10k bps,CANalyst can receive can-data,but there are a problem:
when nx send a can-frame,CANalyst receive many can-frames.;
(2)Nx cannot receive can-frame yet.
Thanks!

10kbps must be getting set exactly in NX. You can check that in can-stats:
$ ip -s -d link show can0

You mean sending messages from CANalyst is not getting received at NX while opposite is fine?

1、sqt@3qt:~$ ip -s -d link show can0
5: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 10000 sample-point 0.875
tq 390 prop-seg 111 phase-seg1 112 phase-seg2 32 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
2、You mean sending messages from CANalyst is not getting received at NX while opposite is fine?
(1)sending messages from CANalyst is getting received at NX . but NX receive many repeated frames
(2)sending messages from NX is getting received at CANalyst。ERROR-PASSIVE occura at NX

Hi,
Yes bitrate 10000 got set.
Also, I think because you have sent many frames earlier which were there in the bus so getting received those frames, I may be wrong here. Is it like whenever you send one message from NX, it’s receiving many times?
I would recommend to check connections once. Can you also send error messages/logs and can-stats. Also check if 120ohm termination is there in the bus.