# Jetson Nano with MCP2515 at SPI2

**URL:** <https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080>\
**Category:** Jetson Nano\
**Tags:** can-bus\
**Created:** [September 15, 2022, 2:52pm UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080 "2022-09-15T14:52:58Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 15, 2022, 2:52pm UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/1 "2022-09-15T14:52:58Z")

</div>

Hello,

how can the CAN-Interface used in Linux?

I have read already [CAN on Jetson Nano Devices](https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3261/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/hw_setup_jetson_can.html#wwpID0EOHA)

---

<div class="post-metadata">

**Author:** ![kayccc](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kayccc/32/14043_2.png) [@kayccc](https://forums.developer.nvidia.com/u/kayccc)\
**Post date:** [September 19, 2022, 12:56am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/2 "2022-09-19T00:56:18Z")

</div>

Please refer to below threads: [CAN with Jetson Nano Production Module - Jetson & Embedded Systems / Jetson Nano - NVIDIA Developer Forums](https://forums.developer.nvidia.com/t/can-with-jetson-nano-production-module/213184)

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 26, 2022, 9:50am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/3 "2022-09-26T09:50:48Z")

</div>

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

```auto
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”?

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [September 27, 2022, 6:41am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/5 "2022-09-27T06:41:10Z")

</div>

please see-also [Topic 210372](https://forums.developer.nvidia.com/t/about-using-spi-on-jetson-nano/210372/48) for the code snippets.

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 27, 2022, 9:08am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/6 "2022-09-27T09:08:43Z")

</div>

the jetson nano module is apply well. Like this:

```auto
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?

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 27, 2022, 10:47am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/7 "2022-09-27T10:47:25Z")

</div>

I have tried followed snippet:

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 27, 2022, 3:09pm UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/8 "2022-09-27T15:09:35Z")

</div>

finally I have the followed error:

```auto
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:

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [September 28, 2022, 2:53am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/9 "2022-09-28T02:53:59Z")

</div>

could you please follow this post, [Jetson nano and mcp2515 can module - #289 by michael.sanne](https://forums.developer.nvidia.com/t/jetson-nano-and-mcp2515-can-module/112271/289)

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 28, 2022, 8:54am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/10 "2022-09-28T08:54:02Z")

</div>

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:

```auto
sudo ifconfig can0 up
SIOCSIFFLAGS: Invalid argument

```

from where can it be?

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 28, 2022, 3:03pm UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/11 "2022-09-28T15:03:22Z")

</div>

and what should I do regarding dmesg:

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

```

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [September 29, 2022, 2:41am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/12 "2022-09-29T02:41:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [September 29, 2022, 6:53am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/13 "2022-09-29T06:53:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [September 29, 2022, 7:11am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/14 "2022-09-29T07:11:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![waldemar.friesen](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@waldemar.friesen](https://forums.developer.nvidia.com/u/waldemar.friesen)\
**Post date:** [October 5, 2022, 7:36am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/16 "2022-10-05T07:36:08Z")

</div>

how can I make it?

---

<div class="post-metadata">

**Author:** ![JerryChang](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jerrychang/32/14043_2.png) [@JerryChang](https://forums.developer.nvidia.com/u/JerryChang)\
**Post date:** [October 7, 2022, 8:31am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/17 "2022-10-07T08:31:27Z")

</div>

hello waldemar.friesen,

please access [Jetson Linux R32.7.2 Release Page | NVIDIA Developer](https://developer.nvidia.com/embedded/linux-tegra-r3272) to download [[L4T Driver Package (BSP) Sources](https://developer.nvidia.com/embedded/l4t/r32_release_v7.2/sources/t210/public_sources.tbz2)].  
then, you should integrate the device tree changes and follow the steps for [Building the NVIDIA Kernel](https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3271/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/kernel_custom.html#wwpID0E0XD0HA).  
you could use partition update by using the command line option `‑k` to [Flashing a Specific Partition](https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3271/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html#wwpID0E0VI0HA). it’s DTB partition for Nano’s device tree blob.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [October 21, 2022, 8:32am UTC](https://forums.developer.nvidia.com/t/jetson-nano-with-mcp2515-at-spi2/228080/18 "2022-10-21T08:32:00Z")

</div>

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