How to using CAN In nx devkit

Hi everyone:
I want to test CAN in NX devkit.could you give some tip to using CAN.

Hi leetop,
Below the board, you will find J17 where 4 pins are available (CAN RX, TX, VCC, GND), you may need to rework the board to use these pins.
Only one CAN controller is available to use in NX.
Update CAN pinmux registers :
0x0c303000 = 0x0000c400;
0x0c303008 = 0x0000c458;
and you are good to go.

Thanks,
Shubhi

1 Like

Hi shgarg:
ls there any device I need to test CAN? And could you give a example about test CAN step by step?
Thanks a lot .

Hi leetop,
Connect a transceiver something like this: https://www.amazon.in/xcluma-Sn65Hvd230-Transceiver-Communication-Module/dp/B072TCPSB1/ref=sr_1_1?crid=1UF4TU4O2J0M1&dchild=1&keywords=can+transceiver&qid=1590119310&sprefix=CAN+tra%2Caps%2C379&sr=8-1

  1. Connect RX of transceiver to CAN_RX of J17
  2. Same with other 3 pins
  3. Update pinmux registers mentioned above
  4. load kernel modules:
    modprobe can
    modprobe can-raw
    modprobe mttcan
  5. Make can interface up on network with bitrate 500kbps:
    ip link set can0 up type can bitrate 500000
    Your can0 node is ready to transfer packets, you can connect other CAN nodes on bus via CANH and CANL pins of transceiver.
  6. send message from can0
    cansend can0 123#abcdabcd
  7. receive message in can0
    candump can0
    For all these steps, you will need to connect one more CAN node on bus.

If you do not have other CAN device or transceiver:
you can do loopback test:

  1. Connect CAN_RX of J17 to CAN_TX of J17
  2. Update pinmux registers mentioned above
  3. load kernel modules:
    modprobe can
    modprobe can-raw
    modprobe mttcan
  4. Make can interface up on network with bitrate 500kbps:
    ip link set can0 up type can bitrate 500000 loopback on
  5. candump can0 &
  6. cansend can0 123#abcdabcd

Thanks,
Shubhi

2 Likes

Can someone from Nvidia briefly describe the capabilities of the can controller inside NX module? I assume it can do 29-bit id’s (can 2.0b format), but can it go can FD? What max data rate it can support?

-albertr

Hi albertr,
Yes it can go can FD with max data bitrate of 5Mbps currently. You can increase data bitrate further by configuring tdcr register with value depends on transceiver used.
Ex.
echo 0x600 > /sys/devices/c320000.mttcan/net/can0/tdcr

Thanks,
Shubhi

Hi shgarg,
I am now looking at the J17 CAN on the NX devkit.

My question:
Is the setting of 0x0c303000 and 0x0c303008 necessary for J17?

Linux_for_Tegra/bootloader/t186ref/BCT/tegra19x-mb1-pinmux-p3668-a01.cfg in the Jetson_Linux_R32.4.2_aarch64.tbz2, it shows can0 pinmux addresses 0x0c303010 and 0x0c303018, which are already enabled.

#### Pinmux for used pins ####
pinmux.0x0c303010 = 0x0000c400; # can0_dout_paa2: can0, tristate-disable, input-disable
pinmux.0x0c303018 = 0x0000c450; # can0_din_paa3: can0, tristate-enable, input-enable
#### Pinmux for unused pins for low-power configuration ####
pinmux.0x0c303000 = 0x0000c415; # can1_dout_paa0: rsvd1, pull-down, tristate-enable, input-disable
pinmux.0x0c303008 = 0x0000c415; # can1_din_paa1: rsvd1, pull-down, tristate-enable, input-disable

J17 CAN can communicate even if the memory address is rewritten to the default value.

sudo busybox devmem 0x0c303000 32 0x0000c415
sudo busybox devmem 0x0c303008 32 0x0000c415

Hi naisy,
No, it is not required if already enabled.

Hi shgarg,
It’s clear. Thank you very much.

Hello, I just bought an NX and soldered 4 pins on J17. But I don’t read 3.3V on any of the pins, even after running the busybox devmem commands listed in this thread. Is there any reference on the pinmux register manipulation? I assume you are hitting SoC registers, so I’ll try to go read the SoC reference manual for the definition of the bits. But it sure would be nice if there is a more user friendly “getting started with CAN on NX” document.

Hi henry,
Do you read 3.3 V at VCC pin of J17 header?

Hello, I tried stealing the 3V3 from the 40-pin GPIO header and fed it to the SN65HVD230 transceiver (recommended at the top of the thread). Following the modprobe and the ip link set can0 commands recommended earlier in the thread prints the following /var/log/kern.log:

Oct 13 22:53:58 nx kernel: [ 53.602095] can: controller area network core (rev 20120528 abi 9)
Oct 13 22:53:58 nx kernel: [ 53.603179] NET: Registered protocol family 29
Oct 13 22:54:05 nx kernel: [ 59.986265] can: raw protocol (rev 20120528)
Oct 13 22:54:05 nx kernel: [ 60.015373] CAN device driver interface
Oct 13 22:54:05 nx kernel: [ 60.024546] Message RAM Configuration
Oct 13 22:54:05 nx kernel: [ 60.024546] | base addr |0x0c312000|
Oct 13 22:54:05 nx kernel: [ 60.024546] | sidfc_flssa |0x00000000|
Oct 13 22:54:05 nx kernel: [ 60.024546] | xidfc_flesa |0x00000040|
Oct 13 22:54:05 nx kernel: [ 60.024546] | rxf0c_f0sa |0x000000c0|
Oct 13 22:54:05 nx kernel: [ 60.024546] | rxf1c_f1sa |0x000009c0|
Oct 13 22:54:05 nx kernel: [ 60.024546] | rxbc_rbsa |0x000009c0|
Oct 13 22:54:05 nx kernel: [ 60.024546] | txefc_efsa |0x000009c0|
Oct 13 22:54:05 nx kernel: [ 60.024546] | txbc_tbsa |0x00000a40|
Oct 13 22:54:05 nx kernel: [ 60.024546] | tmc_tmsa |0x00000ec0|
Oct 13 22:54:05 nx kernel: [ 60.024828] Release 3.2.0 from 19.12.2014
Oct 13 22:54:05 nx kernel: [ 60.025625] net can0: mttcan device registered (regs=ffffff800beb5000, irq=63)
Oct 13 22:54:32 nx kernel: [ 87.436932] mttcan c310000.mttcan can0: bitrate error 0.2%
Oct 13 22:54:32 nx kernel: [ 87.437089] mttcan c310000.mttcan can0: Bitrate set
Oct 13 22:54:32 nx kernel: [ 87.457858] mttcan_controller_config: ctrlmode 10
Oct 13 22:54:32 nx kernel: [ 87.457886] mttcan c310000.mttcan can0: Bitrate set

But the cansend can0 123#abcdabcd does NOTHING–neither in the kern.log, nor on the CAN bus (I tried connecting the logic analyzer to the CANH/CANL and CTX/CRX). Is there a way to check if my CAN HW on the Jetson NX is damaged? The CANH and CANL are stuck at 2.9V and 0.95V respectively. TI application note said that the quiescent CANH/CANL voltage should be around 2.3V, so I find this strange. The SN65HVD230 data sheet and your instruction above both said I should supply 3.3V to Vcc, so I can’t think of anything I am doing wrong.

Are there anything else I can check? Thanks for reading.

Hi henry,
You can try loopback . Short Tx and Rx pin of CAN port of NX. No need to connect transceiver for loopback check.
$ ip link set can0 up type can bitrate 500000 loopback on
Now try sending msgs:
candump can0 &
cansend can0 123#abcdabcd

check if you are receiving messages.
If you are receiving messages means something is wrong with transceiver or your connections of current setup where cansend is not working.

Thanks,
Shubhi

Hi, shgarg,

Follow the items in the previous questions and leave a question.
Once at J17 VCC, 3.3v wasn’t measured, it didn’t work even though I took it from another 3.3v pin.
Also, it didn’t work in loopback mode either.
Is there any official document on implementing CAN communication in jetson NX?

Thanks!

I also couldn’t use canport loopback
if I command this line
sudo ip link set can0 type can bitrate 500000
I get
RTNETLINK answers: Device or resource busy

Hi hij1995 and treeland88,

Please help to open a new topic for your issue. Thanks

Hello, is there any way to modify pinmux registers without flashing the board?

May I know your exact usecase?
If you want to enable CAN in pinmux, use Jetson-IO tool. Read more on https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/hw_setup_jetson_io.html#