livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)’ failed.
Aborted (core dumped)
Can you provide an original document of dtsi,i make cs1 for 2 mcp2515， idon‘n how to make cs?
@juha.kauppi I haven’t worked with that specific hat, but waveshare used to sell one based on the mcp2517fd. Seeedstudio sells a 2 channel mcp2518fd based can hat and they also have an excellent driver for the nano, which also happens to work with the waveshare mcp2517fd hat. I suggest switching to the seeedstudio canfd hat if you can. The driver builds and installs and just works. I have two of them and they work perfectly with both the nano and raspi. Or use the waveshare canfd hat if you can find one, with the seedstudio driver.
CANFD is the latest version of the CAN spec. It is much faster and supports larger packets. However the mcp251xfd chips from microchip are fully backward compatible, so if you actually need classic can, these will work nicely there too.
I have a Jetson Nano version b01. Do I need to rename the dtbo name
tegra210-p3448-0000-p3449-0000-a02-mcp251x.dtbo under /boot/
tegra210-p3448-0000-p3449-0000-b00-mcp251x.dtbo under /boot/ in 3rd step?
In 4th step, Should I copy b00 version instead of a02 ?
After I have done all steps , jetson won’t boot again. Nvidia Logo doesn’t even show up.
Is there a date to jetpack 4.5 comes up ?
I am also having same issue. I created new thread so I will link it here for others Jetson Nano and SPI CAN Bus - #7 by oxoocoffee
Is there anyone in recent times who was able to get one CAN bus working?
I was able to get the canbus working. I deviated from the guide here as I was having issues with the tegra210-p3448-0000-p3449-0000-b00-mcp251x.dtbo that @shgarg posted. I had similar issues to the guys above with the unit not booting up on the B00 variant.
I found that seeed studio posted on git its overlay for their CAN hats for the jetson-nano. I modified it to work with a CAN hat that uses the mcp251x chip discussed in this thread, but you could use their can hat and drivers as is.
Modifications I made are to this file: seeed-linux-dtoverlays/2xMCP2518FD-spi0.dts at master · Seeed-Studio/seeed-linux-dtoverlays · GitHub
I changed all instances of mcp2518fd to mcp2515.
I also removed all the can1 info/setup since the CAN hat I am using only has one CAN chip on it.
I’ve included my dts file for reference. If you use this file copy it to the overlays/overlays/jetsonnano folder.
Run make all_jetsonnano.
Copy the generated MCP251x.dtbo to /boot.
Once copied over run “sudo /opt/nvidia/jetson-io/jetson-io.py” and configure the Jetson for compatible hardware and select the CAN module you just added.
Doing it this way you don’t need to modify the tegra210-p3448-0000-p3449-0000-b00-mcp251x.dtbo file.
MCP251x.dts.txt (3.0 KB)
Did you succeed with the B01 version? I’m also using the B01 EMMC version
No, I couldn’t. Jetson nano crashed every time.
Thank you for your information.
Following your advice, I successed “jetson-io.py” process and I was able to confirm can0 had enabled on my JetsonNano.
After that I connected an another can device to Can Bus for trial
and to try to send data from the another device to my JetsonNANO.
Unfortunately, I could not receive data by “candump can0”.
The mcp2515 chip that I use may be out of order.
Or I probably mistook or lacked proseadure.
I will check them.
Thank you for sharing the information.
I downloaded your MCP251x.dts.txt file and After I applied your step, I couldn’t run jetson-io.py. After running the command. I see a flash of grey. It is probably launched and closed immediately. So I used 2xMCP2518FD-spi0.dtbo and I could execute jetson-io.py. It works until this step.
Can you guide me on how to confirm that mcp2515 is working? I don’t have much information coding CanBus
I then found the cause of the CAN communication failure.
I connected the wrong pin on my JetsonNANO.
The “INT” pin on MPC2515 have to connect to pin No.22 on NANO.
This was noted on line no.63 and 82-88 of MCP251x.dts.txt that andrew_h shared.
MCP2515 have been working on NANO. The CAN data sending and recieving became enable.
I have a peak-usb that I connected to the MCP2515 Low and High pin, USB side connected to my laptop(I will see receive message with pcanview). But I don’t have knowledge about how to send messages with MCP2515.
Could you guide me about how to send messages using python or through the terminal? How to test MCP2515 is working for me?
I did what @andrew_h said and when I type ifconfig in the terminal I can see the can0 interface.
But I can’t send messages through the PCAN-USB to my laptop. My connections are between MCP2515 and PCAN-USB are: LOW-Pin2 , HIGH-Pin7. I am trying to see the received message using the pcanview. I don’t get an error while sending a message from jetson but I can’t view it on pcanview. Is there a problem until here?
Also I found this blog and It says you need to modify MCP2515
Because MCP2515 must be powered from 3,3V, because MCP2515 is directly connected to Pi GPIO and GPIO only accept 3,3V , higher voltage will break pin (so powering MCP2515 and TJA1050 from 5V will break Pi IOs). The TJA1050/MCP2551/etc. CAN bus transceiver must be powered from 5V, because CAN bus operates on 0V and 5V levels, lower high level is considered as noise/distortion (this is defined by CAN Bus specification).
Did you modify your MCP2515 like this?
My connections are:
INT pin 22
SCK pin 23
SI pin 19
SO pin 21
CS pin 24
I modified my mcp2515 board because TJA1050 need 5V for power.
I assigned 3.3V to the power for MCP2515 and 5V to TJA1050.
I used No.2 pin of JetsonNANO’s GPIO to input 5V to TJA1050.
I saw your response view of “ifconfig”.
It seems MCP2515 is working well.
Did you try the “cansend” command?
$ ip link set can0 up type can bitrate 500000
$ cansend can0 123#abcdabcd
I refered below site to modify power source for TJA1050.
Hi ume_nano_tr and everybody,
I modified my MCP2515 as you can see in the picture and TJA1050 powered it up with 5V.
I have a 16Mhz crystal. Do I need to change clock-frequency = <8000000>; parameter to 16mhz in MCP251x.dts.txt file?
I created MCP251x.dtbo file without any change in MCP251x.dts.txt .
What I have done step by step:
- Delete txt extension in MCP251x.dts.txt.
- “make all_jetsonnano” and “sudo make install_jetsonnano”
- MCP251x.dtbo generated and I copied the file into /boot/
- “sudo /opt/nvidia/jetson-io/jetson-io.py” . I choose MCP251x can controller. Jetson nano reboot itself
- Now I can see can0 interface when I type ifconfig.
- sudo ip link set can0 up type can bitrate 500000
- cansend can0 456#43414e2054657374
- "7.th step didn’t give any error but Nothing have seen by PCAN-USB(pcanview).
What do I need to do? Any suggestion? What parameter I should change?
ip -d -s link show dev can0
dmesg | grep -i can
[ 0.000000] OF: fdt:memory scan node memory@80000000, reg size 32, [ 0.961240] tegra-pwm 7000a000.pwm: PWM clk cannot sleep in ops [ 2.002486] tegra_cec 70015000.tegra_cec: Can't find physical addresse. [ 4.788819] CAN device driver interface [ 4.816336] mcp251x spi0.0 can0: MCP2515 successfully initialized. [ 53.446601] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready [ 115.215408] can: controller area network core (rev 20120528 abi 9) [ 115.220388] can: raw protocol (rev 20120528)
dmesg | grep -i spi
[ 0.432753] iommu: Adding device 7000d400.spi to group 7 [ 0.433037] iommu: Adding device 7000d600.spi to group 8 [ 0.433315] iommu: Adding device 70410000.spi to group 9 [ 1.611205] spi-tegra114 7000d400.spi: chipselect 0 already in use [ 1.617437] spi_master spi0: spi_device register error /spi@7000d400/spi@0 [ 1.624332] spi_master spi0: Failed to create SPI device for /spi@7000d400/spi@0 [ 1.626418] tegra-qspi 70410000.spi: Prod settings list not found [ 1.627552] qspi_mtd spi32766.0: MX25U3235F (4096 Kbytes) [ 1.627563] qspi_mtd spi32766.0: mtd .name = spi32766.0, .size = 0x400000 (4MiB) .erasesize = 0x00001000 (4KiB) .numeraseregions = 0 [ 4.816336] mcp251x spi0.0 can0: MCP2515 successfully initialized.
Failed to create SPI device for /spi@7000d400/spi@0
what does it mean?
@ume_nano_tr It looks like I missed something in my changes. On line 64 in the file I uploaded it is missing a parameter. It should look like this.
/* GPIO13, HDR PIN22, TEGRA spi2_miso_pb5 */
interrupts = <&gpio TEGRA_GPIO(B, 5) IRQ_TYPE_LEVEL_LOW>;
A few notes:
The interrupt pin above may be different if you are using a CAN_HAT I am testing this one 2-Channel Isolated CAN Bus Expansion HAT for Raspberry Pi, MCP2515 + SN65HVD230 Dual Chips Solution, Multi Onboard Protection Circuits it uses pin 22 for CAN1 hence why I chose that pin. It also has built in level shifters for the pins as a few have pointed out below should be done.
(I also am testing this one https://www.waveshare.com/rs485-can-hat.htm which also uses pin22.)
You may also need to replace the MCP251x.ko driver as one of the members has said above to enable gpio interrupts. I rebuilt the driver myself adding in his patch. His may work just as well. I have also seen responses where this is not needed but modifying it did get it working for me. Building the driver for myself I was able to find that I was missing the &gpio in my overlay as the of_get_named_gpio() function was not finding the pin specified until I added that in.
I have attached the modified driver as well.
mcp251x.ko.txt (500.9 KB)
A couple extra notes:
If the interrupt pin is configured correctly you can bring up the CAN network.
$ sudo ip link set can0 up type can bitrate 250000
You should see the MCP GPIO configured as an IRQ.
$ sudo cat /sys/kernel/debug/gpio |grep mcp
gpio-13 (SPI1_MISO |mcp251x-gpio-irq ) in hi IRQ
$ cat /proc/interrupts | grep mcp
112: 461 0 0 0 GPIO 13 Edge mcp251x
If the interrupt pin is configured correctly you should be able to receive data. At this point I still had issues with one of my MCP251x and would get two errors for every packet received, and if I tried to transmit the canbus would go to the BUS-OFF state.
A sidenote here is even if you have the IRQ pinned out wrong, wrong pin selected on the Jetson nano or connected incorrectly from the MCP251x device to the Jetson nano, the MCP251x driver can still initialize and not work.
When I switched to the 2-Channel Isolated CAN Bus Expansion HAT for Raspberry Pi, MCP2515 + SN65HVD230 Dual Chips Solution, Multi Onboard Protection Circuits CAN_HAT this issue went away. I did have to change my overlay though and update the clock frequency to match the oscillator or crystal on the board. (clock-frequency = <16000000>;)
I believe the difference here was that the 2 CH CAN HAT has a 3.3v/5v logic select jumper set to 3.3v. I do have the MCP2515 that @tuna.akyol has and will try that mod and see if it works.
Yes you need to change the clock-frequency = <8000000> to clock-frequency = <16000000>. It should match the crystal on the board and from your picture it shows a 16MHz crystal.
You can skip step 2 here and just copy the MCP251x.dtbo.
I modified my board as well and everything is working as it should. On your mod make sure you cut the trace connecting C5 to the 3V rail. If you don’t you are bridging the 3v and 5v rails.
I cut mine right between the via and the capacitor
Other than that the only other difference is that my board has a 8MHz crystal and switched to spi0.cs1 (pin26).
For some reason spi0.cs0 causes RX errors and when I try to transmit the bus turns off.
$ ip -details -statistics link show can0
7: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
link/can promiscuity 0
can state ERROR-ACTIVE restart-ms 0
bitrate 250000 sample-point 0.875
tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
mcp251x: tseg1 3…16 tseg2 2…8 sjw 1…4 brp 1…64 brp-inc 1
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 4 4 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
RX: bytes packets errors dropped overrun mcast
39 5 4 0 4 0
TX: bytes packets errors dropped carrier collsns
18446744073709551615 1 0 0 0 0
I changed 16mhz crystal to 8mhz. And outputs are like these:
sudo cat /sys/kernel/debug/gpio |grep mcp gpio-13 (SPI1_MISO |mcp251x-gpio-irq ) in lo IRQ cat /proc/interrupts | grep mcp 112: 1 0 0 0 GPIO 13 Edge mcp251x
When I try to send/receive a message nothing seen by mcp2515 or PCANUSB
ip -details -statistics link show can0 4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10 link/can promiscuity 0 can state ERROR-ACTIVE restart-ms 0 bitrate 500000 sample-point 0.750 tq 250 prop-seg 2 phase-seg1 3 phase-seg2 2 sjw 1 mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1 clock 4000000 re-started bus-errors arbit-lost error-warn error-pass bus-off 0 0 0 0 0 0 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 RX: bytes packets errors dropped overrun mcast 2 3 0 3 0 0 TX: bytes packets errors dropped carrier collsns 18446744073709551615 1 0 0 0 0
Can you share me updated mcp251x.dts file?
Can you not see receive/sent message?