Jetson Nano and SPI CAN Bus

@oxoocoffee
I said “it works for me” means I can run jetson-io.py and save reboot without problem with mcp-latest.zip I don’t have CAN bus to verify the CAN function.

Yes, you need to connect the USB and enter force recovery mode for sdk manager install the image.

@ShaneCCC
Please clergy this to me. Since I very recently downloaded latest SD image (last week), and also updated to latest “apt full-upgrade”. Should’t I be on latest already? What will SDK manager do for me? Will it update entire SD card? just boot/? Is SDK manager installed image in recovery mode different then downloaded image? Am I expected to loos data on SD card?

On different topic.
Also would it be possible to add MCP25xx to jetson-io.py by default like other two devices?

When you update the image by sdkmanager it will format the SD card first, So yes the data will be lost.

Hi,
Am I missing something or is there something wrong with my board?
I download the newest Jetson Nano image then flash that to the SD card.
Once flashed I finished the ToS screen and Launch SDK Manager to flash the Nano with newest Image. While In SDK Manager it detect my board as Jetson Nano (Development Kit), does this matter? I have the Standard Jetson Nano with SD card slot.

Once finished, I copied the mcp-lastest.zip file over to my Nano
1)I copied
…-a02.dtb to /boot
…-a02-mcp251…dtbo to /boot
…-b01.dtb to /boot/dtb
2)reboot the machine
3)sudo /opt/nvidia/jetsonio/jetsonio.py - > configured by hardware -> select the new CAN module and restart

After Restart. My Nano is now stuck in the Boot LOGO. Did i missed a step or messed up somewhere?

Your board isn’t devkit?

I’m not sure; I am confused on where to find the information for it
My module is P3448 180-13448-DAAA-B01, Is this the same as P3448-0000?
and my carrier board is P3450 180-13449-DAAF-B01

Where did you get it. Could you take a picture for checking.

Here are the pictures of the carrier board and module. My purchasing department got it from Arrow.com.

Beside that, did I missed a step somewhere that caused my board not to boot after setting the overlay?
Or do you think it is a board compatibility issue ?

Looks like it’s devkit.
Can you try if can connect it by ssh then modify the /boot/extlinux/extlinux.conf to apply original dtb to check if can boot.

It boot fine with the original dtb. It stop booting correctly when the files from your link is applied
https://forums.developer.nvidia.com/uploads/short-url/yQPyx7C4JJXnQxWmKbRJA5jNm7e.zip (Pulled from comment above)
Here is the two states that I can achieve with the mcp-latest.zip from link above
1)
If I copy JUST the a02.dtb and a02-mcp2515.dtbo from that link, then Jetson-io.py will say that MCP2515 is not compatible and wouldnt let me enable it.

  1. If I copy a02.dtb and a02-mcp2515.dtbo to /boot/ AS WELL AS b00.dtb into /boot/dtb and enable the MCP2515 through Jetson-io hardware function mode, then the system will stuck at Nvidia Logo on boot.

Do you know why mcp2515.dtbo from the link above is incompatible? I tried to de-compile the dtbo but I get (DUMP ABORTED) message. Could you generate a new Mcp2515 overlay that is compatible with B0x version of the Nano?

Hi will1,

Try this : https://forums.developer.nvidia.com/t/jetson-nano-and-mcp2515-can-module/112271/249?u=tnakyol

Regards,

Thanks @tnakyol , I was following that forums post before coming to this one.
With Andrew’s method, my jetson-io.py would crash as soon as I try to run it.
All I can see is the border of the program then it closes.

Hi will1,

The same happened to me, jetson-io.py would crash, however I had began all the step in the beginning and never crashed again. Careful with the steps.

I created MCP251x.dtbo file without any change in MCP251x.dts.txt .
What I have done step by step:

  1. Delete txt extension in MCP251x.dts.txt.
  2. “make all_jetsonnano” and “sudo make install_jetsonnano”
  3. MCP251x.dtbo generated and I copied the file into /boot/
  4. “sudo /opt/nvidia/jetson-io/jetson-io.py” . I choose MCP251x can controller. Jetson nano reboot itself
  5. Now I can see can0 interface when I type ifconfig.
  6. sudo ip link set can0 up type can bitrate 500000
  7. cansend can0 456#43414e2054657374
  8. "7.th step didn’t give any error but Nothing have seen by PCAN-USB(pcanview).

@tuna.akyol I will try that method one more time. I was able to get the can module (MCP2515) to send data with Raspberry PI and Jetson NX; so atleast I know there is no hardware issue.

for your 7-8 can you verify your can signal with an oscilloscope ?
make sure there is SPI coming out from Nano and Can coming out from MCP2515; Do not connect the PCAN-USB while testing for the can signal because it might generate it own CAN signal which wouldn’t help you verify if the MCP module itself is working or not.

Update: I followed the step and was able to enable can0
dmesg | grep can0 show that MCP2515 successfully initialized.
step 5 and 6 need to be switch. If config can’t see that interface until it is on “up”

Now the problem:
I scoped the signal coming from the Nano and I was only able to get SCK to show data when turn on and off the interface via “ip link”
No data are coming out or in the nano via MISO, MOSI or CS
based on the configuration from that dts file.
This is my pin connections

MOSI 19
MISO 21
SCLK 23
Int 22
CS 24
VCC - 3.3V (pin 17 on header)
GND - GND ( pin 25 on header)
5V for TA chip ( pin 2 on header) The TA chip works only when the 5V modification is there. I tried without the 5V source for Raspberry Pi test bench and it didn’t work either.

Is the DTS still wrong ? and not configuration the right pins on the Nano B0x?

@tuna.akyol
Hi do you have any update on if your can/spi bus actually producing any signal with a scope ?
I think we are at the same point.

Hi @will1
Sorry for the late answer I was working on my other projects.
@shgarg said with Jetpack 4.5, you will find these dtbs already present on the device and with the steps to use MCP in CAN documentation.
shgarg’s answer
Jetpack 4.5 will release in January 2021. So I am still getting same errors in this post
I will wait for this update and If Jetpack 4.5 release doesn’t work for MCP2515, We can work on it together.

Regards,

hi @tuna.akyol
Do you have any luck on the jetpack 4.5 ? I encountering the same problem as above with the new version of Jetpack. I’m wondering if it is the crystal setting ?
Is the wiring setup still the same ? I tried to dump the dtb to change clock and figure out the pin layout but no luck.
I also tried all the possible location for the Interrupt pin.

Is there any document on how to use the new jetpack with mcp25xx anywhere @ShaneCCC

Hi @will1,

I wrote all thing that I did last week here
Here what I try in this month.
1-) So I’ll change 8 Mhz crystal to 10 Mhz crystal on the MCP2515 board. I guess it will be available for the driver which already written by @shgarg.
2-) 2 Channel CAN BUS FD Shield for Raspberry Pi - Seeed Wiki I will try this product.
3-) I will try @jetson_spi’s steps Jetson nano and mcp2515 can module - #264 by jetson_spi

@ShaneCCC Can you prepare a documentation explaining how to integrate the MCP2515 into the Jetson Nano, regardless of the crystal frequency on it? In particular, answering the following question:
1-) What changes need to be made to Jetson nano for the 8 mhz crystal MCP2515? What are these changes in order?

@tuna.akyol
Below is what I found.

MCP251X(SPI-CAN) Testing
On Jetson-Nano:

Connections
Connect two MCP chips to each SPI controller (MOSI, MISO, SCK, CS)
Connect INT (interrupt pin) on MCP2515 to any GPIO pin present on 40 pin Header
Enable interrupts on the GPIO pin chosen
Device Tree changes (Ex Jetson-Nano)
  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>;
              };
        };
  };
Similarly, add entry in other SPI controller (use other GPIO pin for interrupts)

Make software change to enable interupts on GPIO
 gpio = of_get_named_gpio(dev->of_node, "interrupts", 0);
 err = gpio_request(gpio, "true");
 err = gpio_export(gpio, "true");
 gpio_direction_input(gpio);
 if (err < 0)
   printk("Error in requesting GPIO\n");
 spi->irq = gpio_to_irq(gpio);
Flash device with these changes
modprobe can
modprobe can-raw
modprobe mttcan
apt-get install can-utils
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 # Transfer 4 bytes of data from can0
1 Like