Jetson Nano with MCP2515 at SPI2

Hello,

how can the CAN-Interface used in Linux?

I have read already CAN on Jetson Nano Devices

Please refer to below threads: CAN with Jetson Nano Production Module - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums

hello kayccc,
I use current JetPack 4.6.2 for Jetson Nano and have followed messages, like you provided from last post:

wlad@ubuntu:~$ sudo modprobe spidev
wlad@ubuntu:~$ sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi2
Bank: 1 Reg: 0x70003064 Val: 0x00006016 -> spi2_mosi_pb4
Bank: 1 Reg: 0x70003068 Val: 0x00006016 -> spi2_miso_pb5
Bank: 1 Reg: 0x7000306c Val: 0x00006016 -> spi2_sck_pb6
Bank: 1 Reg: 0x70003070 Val: 0x00006016 -> spi2_cs0_pb7
Bank: 1 Reg: 0x70003074 Val: 0x00006015 -> spi2_cs1_pdd0
wlad@ubuntu:~$ sudo cat /sys/kernel/debug/gpio | grep SPI
 gpio-12  (SPI1_MOSI           )
 gpio-13  (SPI1_MISO           )
 gpio-14  (SPI1_SCK            )
 gpio-15  (SPI1_CS0            )
 gpio-16  (SPI0_MOSI           )
 gpio-17  (SPI0_MISO           )
 gpio-18  (SPI0_SCK            )
 gpio-19  (SPI0_CS0            )
 gpio-20  (SPI0_CS1            )
 gpio-232 (SPI1_CS1            )
wlad@ubuntu:~$ sudo cat /sys/kernel/debug/tegra_pinctrl_reg | grep -i spi1
Bank: 1 Reg: 0x70003050 Val: 0x0000e015 -> spi1_mosi_pc0
Bank: 1 Reg: 0x70003054 Val: 0x0000e015 -> spi1_miso_pc1
Bank: 1 Reg: 0x70003058 Val: 0x0000e015 -> spi1_sck_pc2
Bank: 1 Reg: 0x7000305c Val: 0x0000e015 -> spi1_cs0_pc3
Bank: 1 Reg: 0x70003060 Val: 0x0000e015 -> spi1_cs1_pc4

in gpio-output is the mentioned SPI1 instead of SPI2 (regarding tegra_pinctrl_reg-output). one output is wrong from this (in gpio or tegra_pinctrl_reg). Maybe there are some other mistakes?

Is there any mechanisms to get working CAN as net-interface, so what the CAN will apear under “ifconfig”?

please see-also Topic 210372 for the code snippets.

the jetson nano module is apply well. Like this:

Bank: 1 Reg: 0x70003064 Val: 0x00006044 -> spi2_mosi_pb4
Bank: 1 Reg: 0x70003068 Val: 0x00006044 -> spi2_miso_pb5
Bank: 1 Reg: 0x7000306c Val: 0x00006044 -> spi2_sck_pb6
Bank: 1 Reg: 0x70003070 Val: 0x00006044 -> spi2_cs0_pb7
Bank: 1 Reg: 0x70003074 Val: 0x00006044 -> spi2_cs1_pdd0

after loading spi driver I have get spi devices under /dev/spidev*

But the command sudo ip link set can0 type can bitrate 500000 throws error: cannot find device can0. I have tried already to load can drivers (can and can-dev) but without success. what should I do first?

I have tried followed snippet:

wlad@ubuntu:/media/wlad/Copy/CAN$ ls /dev/spidev*
/dev/spidev0.0  /dev/spidev0.1  /dev/spidev1.0  /dev/spidev1.1
wlad@ubuntu:/media/wlad/Copy/CAN$ sudo ./spidev_test -p "1233" -v -D /dev/spidev1.1
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
TX | 31 32 33 33 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 1233
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....
wlad@ubuntu:/media/wlad/Copy/CAN$ sudo ./spidev_test -p "1233" -s 16000000 -v -D /dev/spidev1.1
spi mode: 0x0
bits per word: 8
max speed: 16000000 Hz (16000 KHz)
TX | 31 32 33 33 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 1233
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....
wlad@ubuntu:/media/wlad/Copy/CAN$ sudo ./spidev_test -p "1233" -s 16000000 -v -D /dev/spidev1.0
spi mode: 0x0
bits per word: 8
max speed: 16000000 Hz (16000 KHz)
TX | 31 32 33 33 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 1233
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....
wlad@ubuntu:/media/wlad/Copy/CAN$ sudo ./spidev_test -p "1233" -s 16000000 -v -D /dev/spidev0.0
spi mode: 0x0
bits per word: 8
max speed: 16000000 Hz (16000 KHz)
TX | 31 32 33 33 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 1233
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....
wlad@ubuntu:/media/wlad/Copy/CAN$ sudo ./spidev_test -p "1233" -s 16000000 -v -D /dev/spidev0.1
spi mode: 0x0
bits per word: 8
max speed: 16000000 Hz (16000 KHz)
TX | 31 32 33 33 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | 1233
RX | 00 00 00 00 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  | ....

But the PCAN-Explorer shows no traffic, although PCAN show traffic with legacy code. How can I resume with troubleshooting ?

finally I have the followed error:

sudo modprobe spidev
sudo modprobe can
sudo modprobe can-dev
sudo modprobe can-raw
sudo modprobe mcp251x
# ip link set can0 up type can bitrate 125000
sudo ip link set can0 type can bitrate 125000
sudo ifconfig can0 up
SIOCSIFFLAGS: Invalid argument

exists some method to debug such messages?

I have followed outputs:

ls -d /sys/bus/spi/drivers/mcp251x
/sys/bus/spi/drivers/mcp251x
ls /sys/class/net/
can0  docker0  dummy0  eth0  l4tbr0  lo  rndis0  usb0  usb1
dmesg | grep -i mcp
[    5.103570] mcp251x spi1.0 can0: MCP2515 successfully initialized.
dmesg | fgrep -i can
[    0.000000] OF: fdt:memory scan node memory@80000000, reg size 32,
[    1.051702] tegra-pwm 7000a000.pwm: PWM clk cannot sleep in ops
[    1.081724] of_fixed_clk: probe of can_clock failed with error -17
[    5.047406] CAN device driver interface
[    5.103570] mcp251x spi1.0 can0: MCP2515 successfully initialized.
[  295.864235] can: controller area network core (rev 20120528 abi 9)
[  295.901372] can: raw protocol (rev 20120528)

could you please follow this post, Jetson nano and mcp2515 can module - #289 by michael.sanne

Steps 5 and 6 are currently not possible from that post, because in git commits file jetson-mcp251x.dtbo (step 5) will not generated and to step 6 jetson-io is not available in current JetPack 4.6.2

I have the problem with last command:

sudo ifconfig can0 up
SIOCSIFFLAGS: Invalid argument

from where can it be?

and what should I do regarding dmesg:

[    1.081724] of_fixed_clk: probe of can_clock failed with error -17

hello waldemar.friesen,

there’s source file, jetson-mcp251x.dts, you may download that and integrate the device tree overlay to your code-base.
why you said jetson-io is not available? are you using Nano with internal eMMC, which is production module?

yes, I’m using production module. And now?

hello waldemar.friesen,

that’s why Jetson-IO is not available, because it only works with developer kits, i.e. with SDcard version.
so, you’ll need to integrate the device tree sources to your code-base, rebuild the DTB file and apply to your target.

how can I make it?

hello waldemar.friesen,

please access Jetson Linux R32.7.2 Release Page | NVIDIA Developer to download [L4T Driver Package (BSP) Sources].
then, you should integrate the device tree changes and follow the steps for Building the NVIDIA Kernel.
you could use partition update by using the command line option ‑k to Flashing a Specific Partition. it’s DTB partition for Nano’s device tree blob.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.