Hi,
I am trying to connect an MCP2515 using SPI1 on the 40-pin hdr of dev kit, using L4T 36.4.3.
Here’s my pinmux config:
#include <dt-bindings/pinctrl/pinctrl-tegra.h>
#include "./devsense-gpio-default.dtsi"
/ {
bus@0 {
pinmux@2430000 {
pinctrl-names = "default", "drive", "unused";
pinctrl-0 = <&pinmux_default>;
pinctrl-1 = <&drive_default>;
//pinctrl-2 = <&pinmux_unused_lowpower>;
pinmux_default: common {
soc_gpio33_pq6 {
nvidia,pins = "soc_gpio33_pq6";
nvidia,function = "rsvd0";
nvidia,pull = <TEGRA_PIN_PULL_UP>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_sck_pz3 {
nvidia,pins = "spi1_sck_pz3";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_miso_pz4 {
nvidia,pins = "spi1_miso_pz4";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
nvidia,tristate = <TEGRA_PIN_ENABLE>;
nvidia,enable-input = <TEGRA_PIN_ENABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_mosi_pz5 {
nvidia,pins = "spi1_mosi_pz5";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_cs0_pz6 {
nvidia,pins = "spi1_cs0_pz6";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
spi1_cs1_pz7 {
nvidia,pins = "spi1_cs1_pz7";
nvidia,function = "spi1";
nvidia,pull = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_DISABLE>;
};
};
drive_default: drive {
};
};
};
};
Here’s my SPI config:
/dts-v1/;
#include "tegra234-p3768-0000+p3767-0005-nv.dts"
#include "./devsense-pinmux.dtsi"
#include "../include/kernel/dt-bindings/interrupt-controller/irq.h"
#include <dt-bindings/pinctrl/pinctrl-tegra.h>
#include <dt-bindings/tegra234-p3767-0000-common.h>
/ {
compatible = "nvidia,p3768-0000+p3767-0005-super", "nvidia,p3767-0005", "nvidia,tegra234";
model = "NVIDIA Jetson Orin Nano Developer Kit with MCP2515";
clocks {
can_clock: can_clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <16000000>;
clock-accuracy = <100>;
};
};
bus@0 {
spi@3210000 {
spi@0 {
status = "disabled";
};
can@0 {
status = "okay";
compatible = "microchip,mcp2515";
reg = <0x0>;
spi-max-frequency = <2000000>;
clocks = <&can_clock>;
interrupt-parent = <&gpio>;
interrupts = <TEGRA234_MAIN_GPIO(Q, 6) IRQ_TYPE_LEVEL_LOW>;
//interrupts = <TEGRA234_MAIN_GPIO(Q, 6) IRQ_TYPE_EDGE_FALLING>;
nvidia,enable-hw-based-cs;
gpio-controller;
#gpio-cells = <2>;
controller-data {
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x10>;
nvidia,tx-clk-tap-delay = <0x0>;
nvidia,cs-setup-clk-count = <0x1e>;
nvidia,cs-hold-clk-count = <0x1e>;
};
};
};
};
};
I am facing the following issue: when using IRQ_TYPE_LEVEL_LOW above:
- the command
ip link set can1 up
hangs. Strace - I see no kernel message in console/dmesg
- I can’t kill the ip command with ctrl-C or kill -9
- with the link up command hanging, I can do
grep "gpio 106" /proc/interrupts
:
237: 1 0 0 0 0 0 2200000.gpio 106 Level spi0.0
it shows that the interrupt has been called.
gpioinfo 0 | grep 106
returns:line 106: "PQ.06" "interrupt" input active-high [used]
When I try to strace
the ip link up command above, I get:
...
bind(3, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0
getsockname(3, {sa_family=AF_NETLINK, nl_pid=2319, nl_groups=00000000}, [12]) = 0
setsockopt(3, SOL_NETLINK, NETLINK_GET_STRICT_CHK, [1], 4) = 0
sendto(3, [{nlmsg_len=32, nlmsg_type=0x10 /* NLMSG_??? */, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=0, nlmsg_pid=0}, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"], 32, 0, NULL, 0) = 32
recvmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=52, nlmsg_type=NLMSG_ERROR, nlmsg_flags=0, nlmsg_seq=0, nlmsg_pid=2319}, {error=-ENODEV, msg=[{nlmsg_len=32, nlmsg_type=0x10 /* NLMSG_??? */, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=0, nlmsg_pid=0}, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"]}], iov_len=16384}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 52
socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE) = 4
setsockopt(4, SOL_SOCKET, SO_SNDBUF, [32768], 4) = 0
setsockopt(4, SOL_SOCKET, SO_RCVBUF, [1048576], 4) = 0
setsockopt(4, SOL_NETLINK, NETLINK_EXT_ACK, [1], 4) = 0
bind(4, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0
getsockname(4, {sa_family=AF_NETLINK, nl_pid=-46257228, nl_groups=00000000}, [12]) = 0
sendmsg(4, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=52, nlmsg_type=0x12 /* NLMSG_??? */, nlmsg_flags=NLM_F_REQUEST, nlmsg_seq=1742293406, nlmsg_pid=0}, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x1d\x00\x09\x00\x00\x00\x0c\x00\x03\x00\x63\x61\x6e\x2d"...], iov_len=52}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 52
recvmsg(4, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=NULL, iov_len=0}], msg_iovlen=1, msg_controllen=0, msg_flags=MSG_TRUNC}, MSG_PEEK|MSG_TRUNC) = 880
getrandom("\x2c\xb0\xf7\x87\x5c\xea\xf7\xbe", 8, GRND_NONBLOCK) = 8
brk(NULL) = 0xaaaaf4db3000
brk(0xaaaaf4dd4000) = 0xaaaaf4dd4000
recvmsg(4, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=880, nlmsg_type=0x10 /* NLMSG_??? */, nlmsg_flags=0, nlmsg_seq=1742293406, nlmsg_pid=-46257228}, "\x00\x00\x18\x01\x04\x00\x00\x00\x80\x00\x04\x00\x00\x00\x00\x00\x0c\x00\x03\x00\x63\x61\x6e\x2d\x6d\x63\x70\x00\x08\x00\x0d\x00"...], iov_len=32768}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 880
close(4) = 0
sendmsg(3, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{nlmsg_len=32, nlmsg_type=0x10 /* NLMSG_??? */, nlmsg_flags=NLM_F_REQUEST|NLM_F_ACK, nlmsg_seq=1742293406, nlmsg_pid=0}, "\x00\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00"], iov_len=32}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0
so sendmsg is not returning. Maybe because of an interrupt problem?
When using IRQ_TYPE_EDGE_FALLING:
- the interface comes up with
ip link set can1 up
- but I can’t send or receive packet. Presumably the driver is not receiving interrupts.
gpioinfo 0 | grep 106
returns:line 106: "PQ.06" "interrupt" input active-high [used]
, but maybe it should be active_low?grep "gpio 106" /proc/interrupts
show that interrupt is not happening:
269: 0 0 0 0 0 0 2200000.gpio 106 Edge spi0.0
gpioget 0 106
says0
: the mcp2515 chip did set the interrupt line to 0, which should trigger the interrupt. But it does not.
This problem seems very similar to this post: MCP2515 - Interrupts Disabled
. Also, I did read
MCP2515 verification.
Is there anything wrong in my configuration? What can I do to diagnose the hanging of ip link up
?
Thank you.