CAN interface in Jetson TX2 NX

Hi,

How can I test can interface on Jetson TX2 NX? If I try to access CAN device it shows error, what is the CAN device name? any changes are required to make CAN working? or CAN is not available in developer preview l4t 32.5.1?

nvidia@nvidia-desktop:~$ modprobe can
nvidia@nvidia-desktop:~$ modprobe can_raw
nvidia@nvidia-desktop:~$ modprobe mttcan
nvidia@nvidia-desktop:~$ ip link set can0 type can bitrate 100000 dbitrate 2000000 berr-reporting on fd on
Cannot find device “can0”
nvidia@nvidia-desktop:~$ ip link set up can0
Cannot find device “can0”
nvidia@nvidia-desktop:~$ ip link set up can1
Cannot find device “can1”
nvidia@nvidia-desktop:~$ lsmod
Module Size Used by
mttcan 72735 0
can_dev 17089 1 mttcan
can_raw 11022 0
can 49729 1 can_raw
bnep 18822 2
fuse 111883 2
zram 29049 4
spidev 14507 0
overlay 51689 0
userspace_alert 6761 0
nvgpu 1731449 18
bluedroid_pm 16059 0
ip_tables 21475 0
x_tables 38016 1 ip_tables

Hello @DSC_Tech

These codes worked in our Jetson TX2 NX:

sudo modprobe can
sudo modprobe can-raw
sudo modprobe mttcan
sudo ip link set can0 up type can bitrate 500000

Hope it works you too
Regards

Hi,

I tried below and same error:
nvidia@nvidia-desktop:~/Desktop$ sudo modprobe can
[sudo] password for nvidia:
nvidia@nvidia-desktop:~/Desktop$ sudo modprobe can-raw
nvidia@nvidia-desktop:~/Desktop$ sudo modprobe mttcan
nvidia@nvidia-desktop:~/Desktop$ sudo ip link set can0 up type can bitrate 500000
Cannot find device “can0”
nvidia@nvidia-desktop:~/Desktop$

Have you made any changes in the BSP with respect to CAN?

I’m not sure but our can configuration it that:

mttcan@c310000 {
	compatible = "nvidia,tegra186-mttcan";
	reg = <0x0 0xc310000 0x0 0x400 0x0 0xc311000 0x0 0x32 0x0 0xc312000 0x0 0x1000>;
	reg-names = "can-regs", "glue-regs", "msg-ram";
	interrupts = <0x0 0x28 0x4>;
	pll_source = "pllaon";
	clocks = <0x10 0xd2 0x10 0xd3 0x10 0x214>;
	clock-names = "can", "can_host", "pllaon";
	resets = <0x10 0x3c>;
	reset-names = "can";
	mram-params = <0x0 0x10 0x10 0x20 0x0 0x0 0x10 0x10 0x10>;
	tx-config = <0x0 0x10 0x0 0x40>;
	rx-config = <0x40 0x40 0x40>;
	status = "okay";
	linux,phandle = <0x153>;
	phandle = <0x153>;
};

The complete dts file is here
tegra186-p3636-0001-p3509-0000-a01.dts (238.6 KB)

Hi venkatraman,
Can you please increase kernel dmesg loglevel? then insert CAN modules.
Share your dmesg logs.

Hi Shgarg,

I did this:
root@nvidia-desktop:/home/nvidia# echo 8 > /proc/sys/kernel/printk
root@nvidia-desktop:/home/nvidia#
root@nvidia-desktop:/home/nvidia# cat /proc/sys/kernel/printk
8 6 1 7 4

then I did this:
root@nvidia-desktop:/home/nvidia# modprobe can
root@nvidia-desktop:/home/nvidia# modprobe can
root@nvidia-desktop:/home/nvidia# modprobe can-raw
root@nvidia-desktop:/home/nvidia# modprobe mttcan
root@nvidia-desktop:/home/nvidia# ip link set can0 up type can bitrate 500000
Cannot find device “can0”
root@nvidia-desktop:/home/nvidia#

After I see below:
root@nvidia-desktop:/home/nvidia# ifconfig -a
dummy0: flags=130<BROADCAST,NOARP> mtu 1500
ether 92:0b:b8:79:cc:43 txqueuelen 1000 (Ethernet)
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

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.11 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::5dcc:2782:6c68:4e50 prefixlen 64 scopeid 0x20
ether 48:b0:2d:3b:43:9a txqueuelen 1000 (Ethernet)
RX packets 1556 bytes 1581941 (1.5 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1470 bytes 222564 (222.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 36

eth1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:06:d5:2f:c0:02 txqueuelen 1000 (Ethernet)
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 memory 0x40100000-4017ffff

l4tbr0: flags=4098<BROADCAST,MULTICAST> mtu 1500
ether 76:30:5b:e0:01:bd txqueuelen 1000 (Ethernet)
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

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 223 bytes 16899 (16.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 223 bytes 16899 (16.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

rndis0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 76:30:5b:e0:01:bd txqueuelen 1000 (Ethernet)
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

usb0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 76:30:5b:e0:01:bf txqueuelen 1000 (Ethernet)
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

root@nvidia-desktop:/home/nvidia#

Attached my dmesg log, this is what you were asking for? let me know if I miss anything.
dmesg_tx2nx_CAN.txt (93.3 KB)

mehmetdeniz,

Thank you I will check this and update you

Thanks.
From the logs, I see CAN and CAN-RAW are inserted properly but I do not see any mttcan logs.
[ 286.300667] can: controller area network core (rev 20120528 abi 9)
[ 286.309538] NET: Registered protocol family 29
[ 298.170662] can: raw protocol (rev 20120528)
[ 303.306624] CAN device driver interface

Can you paste the output of:
$find /lib/ -name “mttcan*”

also the output of cat /proc/device-tree/mttcan@c310000/status

I get nothing if I try this command
$ find /lib/ -name “mttcan*”
$

and cat /proc/device-tree/mttcan@c310000/status also gives nothing

try cat /proc/device-tree/mttcan@c310000/status

this is weird and this is the reason why can0 is not found.
Can you tell me how have you flashed device? any changes in rootfs or in kernel?

one thing I have observed is from the source file while comparing with the one shared from mehmetdeniz is in my kernel_sources/Linux_for_Tegra/source/public/hardware/nvidia/soc/t18x/kernel-dts/tegra186-soc

mttcan0: mttcan@c310000 {
	compatible = "nvidia,tegra186-mttcan";
	reg = <0x00 0x0c310000 0x00 0x400>,
	      <0x00 0x0c311000 0x00 0x32>,
	      <0x00 0x0c312000 0x00 0x1000>;
	reg-names = "can-regs", "glue-regs", "msg-ram";
	interrupts = <0 40 0x04 >;
	pll_source = "pllaon";
	clocks = <&tegra_car TEGRA186_CLK_CAN1>,
		<&tegra_car TEGRA186_CLK_CAN1_HOST>,
		<&tegra_car TEGRA186_CLK_PLLAON>;
	clock-names = "can","can_host","pllaon";
	resets = <&tegra_car TEGRA186_RESET_CAN1>;
	reset-names = "can";
	mram-params = <0 16 16 32 0 0 16 16 16>;
	tx-config = <0 16 0 64>;
	rx-config = <64 64 64>;
	status = "disabled";
};

is this causing anything? I did not change this it is from the stock bsp it is disabled by default, should I try enabling that? and I dont see anything related to mttcan@c310000 in my tegra186-p3636-0001-p3509-0000-a01.dts and i see mttcan stuff in the one shared by mehmetdeniz

in soc file, it is kept disabled, It is already enabled in platforms. You do not need to enable specifically.

can you specify where it is enabled in platforms? I will just check

kernel_sources/Linux_for_Tegra/source/public/hardware/nvidia/platform/

also from target you can check by dump of device-tree.
cat /proc/device-tree/mttcan@c310000/status
before @, add backslash. I am not able to show here.

I have taken the source files from Nvidia download center L4T 32.5.1 and then did enabled this :
ports {
usb2-0 {
status = “okay”;
/mode = “otg”;/
mode = “host”;
};
in tegra186-p3636-0002-lanai.dts

enabled serial@c280000 { as told in TX2 NX RS232 Communication Problem - #10 by JerryChang

and bulit using below commands:
make tegra_defconfig
make -j4 Image
make -j4 modules
make dtbs

deploy the modules I built into our root file system
sudo -E make INSTALL_MOD_PATH=/home/…/…/Linux_for_Tegra/rootfs/ modules_install

copied dtb files to /Linux_for_Tegra/kernel/dtb/
and image file to /Linux_for_Tegra/kernel/

and Flashed using this command:
$ sudo ./flash.sh jetson-xavier-nx-devkit-tx2-nx mmcblk0p1

specifically I made changes to UART, USB from the stock BSP

as I se system booting fine so it should not be a problem but i think you wrote opposite. Image to kernel/ and dtb to kernel/dtb/

that is my bad it is a typo, i have corrected in earlier comment now:
copied dtb files to /Linux_for_Tegra/kernel/dtb/
and image file to /Linux_for_Tegra/kernel/