1 1
shigeki

BananaPi CanBus not working

Recommended Posts

Armbianmonitor:

Hi again.

 

After 2 years i want to try configure CanBus on BananaPi and still nothing.  I'm continuing my previous post

 

What i do:

1) Paths dtb with this instruction :

2) Load kernel modules:

# lsmod | grep can
can_raw                20480  1
can_bcm                24576  0
can                    20480  2 can_raw,can_bcm
sun4i_can              16384  0
can_dev                20480  1 sun4i_can

3) Spawn can0 interface

# ip link set can0 type can bitrate 500000 restart-ms 100 triple-sampling on loopback on
# ip link set up can0 

4) Play with candump / cansend

 

On loopback my messages show in candump, but on arduino receiver still nothing

 

My test env:

Two arduino uno with mcp2515 + tja1050 - one as sender other as receiver

BananaPi 4.19.62-sunxi and tja1051 transceiver

 

Bitrate on all boards set to 500k

 

Maybe this may be helpful:

# ip -det link show can0
4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can <LOOPBACK,TRIPLE-SAMPLING> state ERROR-WARNING (berr-counter tx 0 rx 129) restart-ms 100
	  bitrate 500000 sample-point 0.875
	  tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
	  sun4i_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
	  clock 24000000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
# dmesg | grep can
[    8.090861] sun4i_can 1c2bc00.can: device registered (base=(ptrval), irq=53)
[    8.120057] can: controller area network core (rev 20170425 abi 9)
[    8.128499] can: broadcast manager protocol (rev 20170425 t)
[    8.132629] can: raw protocol (rev 20170425)
[ 3502.151374] sun4i_can 1c2bc00.can can0: bus-off
[ 3502.255288] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3507.633774] sun4i_can 1c2bc00.can can0: bus-off
[ 3507.735553] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3509.316187] sun4i_can 1c2bc00.can can0: bus-off
[ 3509.419665] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3510.275698] sun4i_can 1c2bc00.can can0: bus-off
[ 3510.388158] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3518.457783] sun4i_can 1c2bc00.can can0: bus-off
[ 3518.560252] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3520.323530] sun4i_can 1c2bc00.can can0: bus-off
[ 3520.710972] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3522.219241] sun4i_can 1c2bc00.can can0: bus-off
[ 3522.320498] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[ 3523.602391] sun4i_can 1c2bc00.can can0: bus-off
[ 3523.704584] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready

 

Share this post


Link to post
Share on other sites

So, i finally manege this to work.

 

Tested on newest kernel :

Linux bananapi 5.4.26-sunxi #20.02.5 SMP Thu Mar 19 22:23:40 CET 2020 armv7l GNU/Linux

First, you need to patch dtb :

# cd /boot/dtb-5.4.26-sunxi

# diff sun7i-a20-bananapi.dts sun7i-a20-bananapi.dts.bak
710c710,716
< 			can0_pins_a: can0@0 {
---
> 			can-pa-pins {
> 				pins = "PA16\0PA17";
> 				function = "can";
> 				phandle = < 0x63 >;
> 			};
>
> 			can-ph-pins {
713d718
< 				linux,phandle = < 0x64 >;
1446,1447c1451
< 			status = "okay";
< 			linux,phandle = < 0xb0 >;
---
> 			status = "disabled";
1449,1450d1452
< 			pinctrl-names = "default";
< 			pinctrl-0 = <&can0_pins_a>;
1862c1864,1865
< 		can0_pins_a = "/soc/pinctrl@1c20800/can0@0";
---
> 		can_pa_pins = "/soc/pinctrl@1c20800/can-pa-pins";
> 		can_ph_pins = "/soc/pinctrl@1c20800/can-ph-pins";

 

And in my test environment (two Arduino with mcp2515 CAN Module  receiver and sender ) and bananapi i had to set baud rate 125K on banana pi and 250K on Arduino sender/receiver.

Share this post


Link to post
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
Reply to this topic...

×   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...
1 1