How enabling MCP251x (MCP2515) on the Jetson Nano (SPI CAN)?

Hi,

how can I enable MCP2515 on the Jetson Nano for SPI CAN?

I connect a MCP2515 CAN-Module:

  • CS --> Pin24(CEO) / GPIO19
  • SO --> Pin21(MISO) / GPIO17
  • SI --> Pin19(MOSI) / GPIO16
  • SCK --> Pin23(CLK) / GPIO18
  • NT --> Pin22(GPIO for interrupt) / GPIO13

I read a guide for the Jetson TX1:
https://www.jetsonhacks.com/2017/04/04/gpio-and-spi-nvidia-jetson-tx1/

and a guide for the Jetson TX2:
https://devtalk.nvidia.com/default/topic/1057158/jetson-tx2/guide-to-enabling-mcp251x-mcp2515-on-the-tx2-spi-can

Have somone a guide for the Jetson Nano or some hints for me, how I can enable the MCP2515 with SPI?
Or how do I have to edit these guides for the Jetson Nano?

Thanks.

Hi,

Here are the steps you can follow:

  1. Choose a GPIO pin on J41 (40 pin header) and enable interrupts on that pin.
  2. Make proper connections from MCP2515 to SPI controller on J41. There are 2 SPI controller present on J41. I have connected two MCP chips on respective SPI controller with INT pin connected to chosen GPIO.
  3. Make changes in Nano DTB:
    can_clock: can_clock {
    compatible = “fixed-clock”;
    #clock-cells = <0>;
    clock-frequency = <20000000>;
    clock-accuracy = <100>;
    };
    spi@7000d400 { /* SPI 1 to 40 pin header */
    status = “okay”;
    spi@0 {
    compatible = “microchip,mcp2515”;
    reg = <0x0>;
    spi-max-frequency = <10000000>;
    nvidia,enable-hw-based-cs;
    nvidia,rx-clk-tap-delay = <0x7>;
    clocks = <&can_clock>;
    interrupts = <&gpio TEGRA_GPIO(Z, 0) 0x1>; // GPIO pin chosen from 40 pin header
    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@7000d600 { /* SPI 2 to 40 pin header */
status = “okay”;
spi@0 {
compatible = “microchip,mcp2515”;
reg = <0x0>;
spi-max-frequency = <10000000>;
nvidia,enable-hw-based-cs;
nvidia,rx-clk-tap-delay = <0x6>;
clocks = <&can_clock>;
interrupts = <&gpio 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>;
};
};
4) Make changes in Nano pinmux and GPIO dtb:
Enable SPI0 and SPI1 with SPI functionality by configuring pins(tristate disable, input enable, change function property…)
Add GPIO entry in gpio-input section.

Flash with the change in DTB.

Now on device after boot, run following commands:
ip link set can0 type can bitrate 500000
ip link set can0 up
ip link set can1 type can bitrate 500000
ip link set can1 up
candump -x any
cansend can0 123#abcdabcd

Thanks,
Shubhi

The above guide is a bit unclear.
We have followed this guide to enable SPI1 and SPI2:
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3231/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide%2Fhw_setup_jetson_io.html%23

It is a bit unclear where to add the above information to the nano DTB file.
SPI has been enabled, but how to we to add the above information to get it working with the MCP2515.
Do we need to add into another dts or dtsi file, we compile into the some *.dtb ?
Also the lines <&gpio TEGRA_GPIO(Z, 0) 0x1> and interrupts = <&gpio TEGRA_GPIO(V, 0) 0x1 makes it a bit unclear what GPIO pins we are talking back on the development board.

We have also looked at the following link
https://github.com/krzk/tizen-tv-rpi-linux/blob/master/arch/arm/boot/dts/overlays/mcp2515-can0-overlay.dts

Hi,
Please check this thread: Jetson nano and mcp2515 can module