Help configuring Nano for Waveshare Nano Hat with RS485 and CAN

Hi guys, can anyone help me build my device tree overlay for the following product :

Currently i use this device tree overlay

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Jetson Device-tree overlay for
 *   MCP2515
 *
 * Copyright (c) 2020 Seeed Technology Co,Ltd - https://www.seeed.cc.
 * All rights reserved.
 *
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/pinctrl-tegra.h>
#include <dt-bindings/gpio/tegra-gpio.h>

/ {
	overlay-name = "MCP251x CAN Controller";
	jetson-header-name = "Jetson 40pin Header";	
	compatible = "nvidia,p3449-0000-b00+p3448-0000-b00\0nvidia,p3449-0000-a02+p3448-0000-a02";

    

   	fragment@0 {
		target-path = "/";
		__overlay__ {
			clocks {
				can_clock: can_clock {
					compatible = "fixed-clock";
					#clock-cells = <0>;
					clock-frequency = <8000000>;
					clock-accuracy = <100>;
				};
			};
		};
	};

	fragment@1 {
		target = <&spi0>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			spi@0 {
				status = "okay";
				compatible = "microchip,mcp2515";
				reg = <0x0>;
				spi-max-frequency = <10000000>;
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x7>;
				clocks = <&can_clock>;
				interrupt-parent = <&gpio>;
				interrupts = <TEGRA_GPIO(DD, 0) 0x1>;
				controller-data {
					nvidia,cs-setup-clk-count = <0x1e>;
					nvidia,cs-hold-clk-count = <0x1e>;
					nvidia,rx-clk-tap-delay = <0x1f>;
					nvidia,tx-clk-tap-delay = <0x0>;
				};
			};
			spi@1 {
				status = "disabled";
			};
		};
	};

	fragment@2 {
		target = <&spi1>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			spi@0 {
				status = "disabled";
			};			
			spi@1 {
				status = "okay";
				compatible = "microchip,mcp2515";
				reg = <0x0>;
				spi-max-frequency = <10000000>;
				nvidia,enable-hw-based-cs;
				nvidia,rx-clk-tap-delay = <0x7>;
				clocks = <&can_clock>;
				interrupt-parent = <&gpio>;
				interrupts = <TEGRA_GPIO(V, 0) 0x1>;
				controller-data {
					nvidia,cs-setup-clk-count = <0x1e>;
					nvidia,cs-hold-clk-count = <0x1e>;
					nvidia,rx-clk-tap-delay = <0x1f>;
					nvidia,tx-clk-tap-delay = <0x0>;
				};
			};
		};
	};

	fragment@3 {
		target = <&pinmux>;
		__overlay__ {
			pinctrl-names = "default";
			pinctrl-0 = <&jetson_io_pinmux>;

			jetson_io_pinmux: exp-header-pinmux {
				hdr40-pin19 {
					nvidia,pins = "spi1_mosi_pc0";
					nvidia,function = "spi1";
					nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				};
				hdr40-pin21 {
					nvidia,pins = "spi1_miso_pc1";
					nvidia,function = "spi1";
					nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				};
				hdr40-pin23 {
					nvidia,pins = "spi1_sck_pc2";
					nvidia,function = "spi1";
					nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				};
				hdr40-pin24 {
					nvidia,pins = "spi1_cs0_pc3";
					nvidia,function = "spi1";
					nvidia,pull = <TEGRA_PIN_PULL_UP>;
					nvidia,tristate = <TEGRA_PIN_DISABLE>;
					nvidia,enable-input = <TEGRA_PIN_ENABLE>;
				};

			};
		};
	};
};

and I can get the can0 up with:

sudo ip link set can0 up type can bitrate 500000 

but i cannot send or receive any messages at all. Please help. I have the B01 version with 4 Gb

I have followed the steps from here

bf9582673307e8b25db7d2c7bfa718aecd0603c5_2_690x431

don’t it shows the RS485 CAN for Jetson Nano - Waveshare Wiki for using this board?

Hey @JerryChang . Thanks for response. Yes, i made it working with the wiki guide and I can receive and send messages, but the library is a bit poor , so i cannot read the node ID-s or send with ID. I can just read or send message. I wanted to use the python-can library, that is why i used this type of tree overlay.

hello rosen1,

had you also reboot the target and check you’ve apply the device tree overlay with boot options?
please examine your device trees, please check all settings has applied correctly.

Yes i can confirm that. As i have written:

sudo ip link set can0 up type can bitrate 500000 

is working and if i write then ifconfig, I get:

can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0   (0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

but nothing recieved and nothing sent …

please try the commands for checking CAN packet send/receive, you may broadcasting a can data packet.
for example, cansend <can_interface> <can_frame> or, cansend can0 123#abcdabcd.
then, please have dump the data packet at receiver side… candump can1

I get nothing both ways. I think somehow the problem is in the Interrupt as what i have read here:

My interrupt pin is 29, so that is why i have :

interrupts = <TEGRA_GPIO(DD, 0) 0x1>;

As i write:

cat /proc/interrupts | grep "mcp"

i get :
331 0 0 0 0 GPIO 232 EDGE mcp251x

After I spent two days trying different solutions from the forum, i finally found the right one for me.
I have Jetson Nano Devkit 4GB B01 with Jetpack 4.6.
I followed this Guide :