Jump to content
  • 0

OPiPC+ mcp2515 CAN bus mute


Jodaille
 Share

Question

Armbianmonitor:

Hello,

 

I am trying to communicate with a mcp2515 breakout (8Mhz oscillator) on an Orange Pi Pc+

I have modified the breakout following info on Raspberry Pi: HowTo/Quickstart MCP2515 to keep logic level @3v

I have two other nodes composed by two Arduinos, with same (not modified) breakout, one that transmits the other receives.

I have successfully tested the first breakout (used on OPi) with an Arduino (powered by 3.3v and 5v on TJA1050).

It lets me think that hardware is OK.

 

Below photos of wiring (nb: orange wire becomes red, is wired near TJA1050 = 5v):

Wiring Opi <-> mcp2515

 

It seems I have the same results with (edited) user_overlay and the compiled one provided in zador.blood.stained's post

 

dmesg| grep 'can\|mcp\|spi'
[    6.701431] mcp251x spi0.0 can0: MCP2515 successfully initialized.
[   28.455699] can: controller area network core (rev 20170425 abi 9)
[   28.471752] can: raw protocol (rev 20170425)

The controller seems well seen, I can bring up the can0 interface:

sudo ip link set can0 type can bitrate 125000 triple-sampling on
sudo ifconfig can0 up
ifconfig can0   
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

but candump is mute although the Arduino receiver displays messages from Arduino transmitter.

And cansend do not give error but I could not see this messages on Arduino receiver.

 

Does someone would have an idea of what I am missing ?

Edited by Jodaille
add link user overlay spi-mcp251x.dts
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Do you have terminator register??

 

It's mine.

$ cat /boot/armbianEnv.txt
verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=4c260e6c-6b83-490b-9c33-a1c61c5840a5
rootfstype=ext4
overlays=i2c0 i2c1 i2c2 spi-spidev
extraargs=net.ifnames=0
##param_spidev_spi_bus=0
user_overlays=spi-mcp251x
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

$ dmesg| grep 'can\|mcp\|spi'
[    5.578413] mcp251x spi0.0 can0: MCP2515 successfully initialized.
[  137.204768] can: controller area network core (rev 20170425 abi 9)
[  137.219630] can: raw protocol (rev 20170425)

$ lsmod | grep can
can_dev                20480  1 mcp251x

$ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  power  statistics  subsystem  uevent

$ ls /sys/bus/spi/devices/spi0.0/net
can0

$ ls /sys/bus/spi/devices/spi0.0/net/can0
addr_assign_type    dev_id             link_mode         proto_down
address             dev_port           mtu               queues
addr_len            dormant            name_assign_type  speed
broadcast           duplex             netdev_group      statistics
carrier             flags              operstate         subsystem
carrier_changes     gro_flush_timeout  phys_port_id      tx_queue_len
carrier_down_count  ifalias            phys_port_name    type
carrier_up_count    ifindex            phys_switch_id    uevent 

$ sudo ip link set can0 type can bitrate 125000 triple-sampling on

$ sudo ifconfig can0
can0: flags=128<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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ sudo ifconfig can0 up

$ sudo ifconfig can0
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

Link to comment
Share on other sites

When discussing a problem make sure to provide full logs!

  • 0
On 3/31/2019 at 9:41 AM, nopnop2002 said:

Do you have terminator register??

 

It's mine.


$ cat /boot/armbianEnv.txt
verbosity=1
logo=disabled
console=both
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
rootdev=UUID=4c260e6c-6b83-490b-9c33-a1c61c5840a5
rootfstype=ext4
overlays=i2c0 i2c1 i2c2 spi-spidev
extraargs=net.ifnames=0
##param_spidev_spi_bus=0
user_overlays=spi-mcp251x
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

$ dmesg| grep 'can\|mcp\|spi'
[    5.578413] mcp251x spi0.0 can0: MCP2515 successfully initialized.
[  137.204768] can: controller area network core (rev 20170425 abi 9)
[  137.219630] can: raw protocol (rev 20170425)

$ lsmod | grep can
can_dev                20480  1 mcp251x

$ ls /sys/bus/spi/devices/spi0.0
driver  modalias  net  of_node  power  statistics  subsystem  uevent

$ ls /sys/bus/spi/devices/spi0.0/net
can0

$ ls /sys/bus/spi/devices/spi0.0/net/can0
addr_assign_type    dev_id             link_mode         proto_down
address             dev_port           mtu               queues
addr_len            dormant            name_assign_type  speed
broadcast           duplex             netdev_group      statistics
carrier             flags              operstate         subsystem
carrier_changes     gro_flush_timeout  phys_port_id      tx_queue_len
carrier_down_count  ifalias            phys_port_name    type
carrier_up_count    ifindex            phys_switch_id    uevent 

$ sudo ip link set can0 type can bitrate 125000 triple-sampling on

$ sudo ifconfig can0
can0: flags=128<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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

$ sudo ifconfig can0 up

$ sudo ifconfig can0
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

Well, I have same problem. Seems that everything is correct but I don't have any candump output

 

 

pasha@orangepipcplus:~$ sudo ifconfig can0
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pasha@orangepipcplus:~$ sudo ifconfig can0
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


pasha@orangepipcplus:~$ lsmod | grep can
can_raw                20480  0
can_dev                20480  1 mcp251x
can                    20480  1 can_raw

pasha@orangepipcplus:~$ dmesg | grep "can\|mcp\|spi"
[    6.236392] can: controller area network core (rev 20170425 abi 9)
[    6.246062] can: raw protocol (rev 20170425)
[    7.585019] mcp251x spi0.0 can0: MCP2515 successfully initialized.
pasha@orangepipcplus:~$ 

 

but:

pasha@orangepipcplus:~$ candump can0  - no output

 

resistor is OK, I connect Opi to existing can bus where one device sends data and second receive successfully

 

Also I wonder why I can't compile overlay from example

https://github.com/armbian/sunxi-DT-overlays/blob/master/examples/spi-mcp251x.dts

 

sudo armbian-add-overlay spi-mcp251x.dts
Compiling the overlay
dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)' failed.
/usr/sbin/armbian-add-overlay: line 81:  2323 Aborted                 dtc -@ -q -I dts -O dtb -o ${temp_dir}/${fname}.dtbo $1
Error compiling the overlay

 

Device tree compiler is newest version (1.4.5-3)

thanks for help...

 

 

 

 

 

Link to comment
Share on other sites

  • 0
On 4/25/2020 at 7:00 PM, svd93 said:

Well, I have same problem. Seems that everything is correct but I don't have any candump output

 

 

pasha@orangepipcplus:~$ sudo ifconfig can0
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pasha@orangepipcplus:~$ sudo ifconfig can0
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.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


pasha@orangepipcplus:~$ lsmod | grep can
can_raw                20480  0
can_dev                20480  1 mcp251x
can                    20480  1 can_raw

pasha@orangepipcplus:~$ dmesg | grep "can\|mcp\|spi"
[    6.236392] can: controller area network core (rev 20170425 abi 9)
[    6.246062] can: raw protocol (rev 20170425)
[    7.585019] mcp251x spi0.0 can0: MCP2515 successfully initialized.
pasha@orangepipcplus:~$ 

 

but:

pasha@orangepipcplus:~$ candump can0  - no output

 

resistor is OK, I connect Opi to existing can bus where one device sends data and second receive successfully

 

Also I wonder why I can't compile overlay from example

https://github.com/armbian/sunxi-DT-overlays/blob/master/examples/spi-mcp251x.dts

 

sudo armbian-add-overlay spi-mcp251x.dts
Compiling the overlay
dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)' failed.
/usr/sbin/armbian-add-overlay: line 81:  2323 Aborted                 dtc -@ -q -I dts -O dtb -o ${temp_dir}/${fname}.dtbo $1
Error compiling the overlay

 

Device tree compiler is newest version (1.4.5-3)

thanks for help...

 

For those who bump into the same problem. Change in the spi-mcp251x.dts file: from "clock-frequency = <8000000>;" to "clock-frequency = <16000000>;". (although the quartz on the can modul board is definitely 8Mhz)

 

 

 

 

Link to comment
Share on other sites

  • 0

My problem was on the latest system. According to dmesg, ifconfig everything OK but did not work at all until I changed the frequency.

 uname -a
Linux orangepione 5.4.45-sunxi #20.05.4 SMP Sun Jun 14 21:46:20 CEST 2020 armv7l armv7l armv7l GNU/Linux

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...