Setting up CAN bus for networking

Hi, I am pretty new to embedded development. I have been working Nvidia Jetson Tx2 board recently and wanted to setup can communication between the can controller and another external board with can controller on it. I am using the SN65HVD230 external transceiver in between the controllers on the two boards.

Jetson CAN controller [J26 headers] → Transceiver → External Controller

To setup the network I needed to configure the CAN bus interface name & port name on the jetson board. I would really appreciate if someone could help me understand where to find it and/or configure it?

P.S: I was able to use socketCAN between CAN0 and CAN1 of the Jetson board to communicate some test messages.
The board on the receiving end is continuously listening for CAN bus messages.

Hi mohit,
Can you please provide me which external controller are you using?

Hi Shgarg,
I am using a ESCON Positioning Controller for my robot. and I wanted to communicate with it using the CAN bus. I need to understand the interface name and the port name my Jetson CAN controller will be enabled on, to work with the ESCON library for Linux on their website.

Any ideas or references would help.

I appreciate it.

Hi lala,

CAN controller name is mttcan in Jetson. You can find the node in flashing directory:
$TOP/kernel/dtb/tegra186-quill-p3310-1000-c03-00-base.dtb
mttcan@c310000 {
compatible = “bosch,mttcan”;
reg = <0x00000000 0x00000000 0x00000000 0x00000003 0x72656773 0x73672d72 0x00000161 0x00000003 0x6f6e0000 0x0000000d 0x0000000d 0x000003f7>;
reg-names = “can-regs”, “glue-regs”, “msg-ram”;
interrupts = <0x00000000 0x00000007 0x00000003>;
pll_source = “pllaon”;
clocks = <0x0000000d 0x0000000d 0x000003f7 0x00706c6c 0x000003dd 0x00000004>;
clock-names = “can”, “can_host”, “pllaon”;
resets = <0x0000000d 0x000003e4>;
reset-names = “can”;
status = “okay”;
gpio_can_stb = <0x0000001c 0x0000000c 0x00000000>;
gpio_can_en = <0x0000001c 0x00000024 0x00000010>;
mram-params = <0x00000000 0x00000008 0x00000010 0x00000008 0x00000003 0x00000040 0x6d747463 0x00000003 0x682c6d74>;
tx-config = <0x00000008 0x00000003 0x00000040 0x6d747463>;
rx-config = <0x00000040 0x00000001 0x30300000>;
};
mttcan@c320000 {
compatible = “bosch,mttcan”;
reg = <0x00000000 0x00000000 0x00000000 0x00000003 0x72656773 0x73672d72 0x00000161 0x00000003 0x6f6e0000 0x0000000d 0x0000000d 0x000003f7>;
reg-names = “can-regs”, “glue-regs”, “msg-ram”;
interrupts = <0x00000000 0x00000007 0x00000003>;
pll_source = “pllaon”;
clocks = <0x0000000d 0x0000000d 0x000003f7 0x00706c6c 0x000003dd 0x00000004>;
clock-names = “can”, “can_host”, “pllaon”;
resets = <0x0000000d 0x000003e4>;
reset-names = “can”;
status = “okay”;
gpio_can_stb = <0x0000001c 0x0000000c 0x00000000>;
gpio_can_en = <0x0000001c 0x00000024 0x00000010>;
mram-params = <0x00000000 0x00000008 0x00000010 0x00000008 0x00000003 0x00000040 0x73746d40 0x00000020 0x73696768>;
tx-config = <0x00000008 0x00000003 0x00000040 0x73746d40>;
rx-config = <0x00000040 0x00000001 0x00000003>;
There are two CAN controllers in Tegra. So, you will find two nodes with address c310000 & c320000.
Here you can enable your external controller.
Let me know if it helps or anything else you need.

Thanks & Regards,
Shubhi

Hi Lala13,

If you are looking for the setup instructions, below steps can be followed to enable and have CAN working on TX2.
Similar setup instructions can be followed for interfacing both internal as well as external can controllers.

  1. Enable kernel support for mttcan(Other required modules are already supported)
    CONFIG_MTTCAN = m (mttcan is compiled as a module)

  2. Insert CAN BUS subsystem support module.
    modprobe can

  3. Insert Raw CAN protocol module (CAN-ID filtering)
    modprobe can_raw

  4. Real CAN interface support (for our case, it is: mttcan)
    modprobe mttcan (dependent module is can_dev: can driver with netlink support)

  5. CAN interface settings for both the controllers
    ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
    ip link set up can0
    ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
    ip link set up can1

    CAN interfaces are up now. Use ifconfig to list all the interfaces which are up.

  6. Installation of user app to check CAN communication
    sudo apt-get install can-utils

  7. Commands to run to check CAN packet send/receive
    broadcasting a can data packet:
    cansend <can_interface> <can_frame>
    e.g. cansend can0 123#abcdabcd

    Receiving a can data packet:
    candump can_interface
    e.g. candump can1

    Different tools (i.e. cangen, cangw etc) can be used for various filtering options.

  8. To check the interface statistics
    ip -details -statistics link show can0
    ip -details -statistics link show can1

Please specify, if you are looking into anything else.

Thanks & Regards,
Sandipan

Hi shgarg,sparta,

Thank you for your replies.

Sparta, I have already setup and tested the can controllers using the same steps as you provided.
Shgarg, the reply gave me some insight in the controller details.

But, I should have been more clear with my question:

If can0 is my interface name. what port name will it be working with? Or can it somehow be configured or virtually created?

E.G. If I use USB as my interface name, /dev/ttyUSB0 is my port name. Or If I use a serial interface, COM1 is my port name