shigeki

  • Posts

    3
  • Joined

  • Last visited

Posts posted by shigeki

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

  2. 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

     

  3. Hi all, I'm interested in running canbus on Banana Pi (A20).

    I have problem with setup canbus.

    Some info about system:

    ARMBIAN 5.38 stable Debian GNU/Linux 9 (stretch) 4.14.18-sunxi

    in armbian-config -> System -> Hardware only "can" is enable and MCP2551 transreciver is connected to can rx/tx banana pinout.

     

    lsmod | grep can:

    root@bananapi:~# lsmod | grep can
    can_bcm                24576  0
    can_raw                20480  1
    can                    20480  2 can_raw,can_bcm
    sun4i_can              16384  0
    can_dev                20480  1 sun4i_can

     

    Next setup interface:

    ip link set can0 type can bitrate 125000 restart-ms 100 triple-sampling on loopback on

    ip link set up can0

     

    cangen seems to working well, but there is no info from candump:

    root@bananapi:~# ip -details -statistics link show can0
    4: can0: <NOARP,UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
        link/can  promiscuity 0
        can <LOOPBACK,TRIPLE-SAMPLING> state BUS-OFF (berr-counter tx 207 rx 0) restart-ms 100
              bitrate 125000 sample-point 0.875
              tq 500 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 24000000
              re-started bus-errors arbit-lost error-warn error-pass bus-off
              1398       1796       0          1399       1          1399      numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
        RX: bytes  packets  errors  dropped overrun mcast
        47248      5906     1796    0       0       0
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       6       0       0

    dmesg:

    [   11.943534] sun4i_can 1c2bc00.can: device registered (base=f14bac00, irq=50)
    [  918.999564] can: controller area network core (rev 20170425 abi 9)
    [  919.016080] can: raw protocol (rev 20170425)
    [ 1257.584974] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready

     

    ifconfig:

    root@bananapi:~# 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 8936  bytes 71488 (69.8 KiB)
            RX errors 2669  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 6 overruns 0  carrier 6  collisions 0
            device interrupt 50

     

    I have play with arduino sender and reciver, both working ok, reciver recive msg candum nothing recive.

     

    Wiring:

    Wiring.png