This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x CAN0 CAN1 同时使用时, 冲突问题

Other Parts Discussed in Thread: AM3352

Hello 大家好:

我在使用AM3352时, 单独测试 can0 / can1 收发都是正常, 同时使用can0 & can1 时, can1 被 block 住, 一直在等 can0 释放 can1 才可以接收资料.

Linux Kernel : linux-rt-4.19.38+gitAUTOINC+1224cd679e-g1224cd679e

两片板子can1 接在一起, 测试步骤如下:

第一片板子

$ /bin/ip link set can0 type can bitrate 1000000;/bin/ip link set can0 up

$ /bin/ip link set can1 type can bitrate 1000000;/bin/ip link set can1 up

$ candump can0 &

$ candump can1 &

第二片板子

$ /bin/ip link set can0 type can bitrate 1000000;/bin/ip link set can0 up

$ /bin/ip link set can1 type can bitrate 1000000;/bin/ip link set can1 up

$cansend can1 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88

当第二片 "cansend" 后, 在第一片板子上并没看到接收到资料,之后在第一片板子停掉 can0 后

$ /bin/ip link set can0 down

马上收到  "<0x010> [8] 11 22 33 44 55 66 77 88"

该如何解决排除这个问题呢?

麻烦知道的人可以帮忙回答 谢谢

附上kernel config file

4201.tisdk_am335x-evm-rt_defconfig.txt



  • 请看看下面的帖子是否有帮助。
    e2e.ti.com/.../494905
  • 謝謝幫忙解答, 不過這個版本在"c_can.c"已經打過補丁, "c_can_platform.c" 改動不少和補丁不合
  • 看看是否中断的问题
  • 你好, 中断的问题要从哪边查看呢?

  • 我在e2e上发了帖,请关注下面的帖子。
    e2e.ti.com/.../3327719
  • 你can设置为什么模式
  • Master:


    /bin # /bin/ip link set can0 type can bitrate 1000000;/bin/ip link set can0 up
    /bin # /bin/ip link set can1 type can bitrate 1000000;/bin/ip link set can1 up
    /bin # ip -d -s link show can0;ip -d -s link show can1
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    /bin # candump can0 &
    /bin # interface = can0, family = 29, type = 3, proto = 1

    /bin # candump can1 &
    /bin # interface = can1, family = 29, type = 3, proto = 1

    /bin # ip -d -s link show can0;ip -d -s link show can1
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    /bin #

    Salve:


    /bin # /bin/ip link set can0 type can bitrate 1000000;/bin/ip link set can0 up
    /bin # /bin/ip link set can1 type can bitrate 1000000;/bin/ip link set can1 up
    /bin # ip -d -s link show can0;ip -d -s link show can1
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    /bin # cansend can1 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
    interface = can1, family = 29, type = 3, proto = 1
    /bin # ip -d -s link show can0;ip -d -s link show can1
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    3: can1: <NO-CARRIER,NOARP,UP,ECHO> mtu 16 qdisc pfifo_fast state DOWN qlen 10
        link/can
        can state BUS-OFF (berr-counter tx 248 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          1          1          1         
        RX: bytes  packets  errors  dropped overrun mcast   
        24         3        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      
    /bin #

    Result:

    板子不是TI开发板, 两块板子分别是Master 和Salve, Master CAN0 和 Salve CAN0 连接, Master CAN1 和 Salve CAN1 连接.

    从上面发现 Master端没看到异常地方, Salve端 输入"cansend" 后, can1 state 从"ERROR-ACTIVE" 变成 "BUS-OFF".

    如果只使用can1, 并没有这个情况, 这种情况是kernel 配置出问题? 还是Driver的bug? 还是其他原因呢? 附件是Dual CAN 和 Single CAN 的测试结果

    7345.Single_Master.txt8168.Single_Salve.txt0871.Dual_Master.txt2604.Dual_Salve.txt

  • 你好, 你指的can模式是指什么?
  • 你可以试试改大fifo看看
  • 我调整 c_can.h 

    #define C_CAN_NO_OF_OBJECTS    64     // old:32
    #define C_CAN_MSG_OBJ_RX_NUM    32  // old:16
    #define C_CAN_MSG_OBJ_TX_NUM    32   // old:16

    还是同样的情况, 这样改 fifo 正确?

  • 建议检查一下板子的cable线。
    The only thing I can suggest from what I can see at the moment is to check the cabling and line terminations on the both boards for both can interfaces. The bus-off condition I believe typically means something is wrong with the electrical signaling. Since can1 is showing bus-off indication it was not able to send the can frame. So if this condition only appears when both can0 and can1 perhaps can0 and can1 are not electrically isolated.
  • 你好 我检查过板子 cable 都正常, 因此我调整接线, 有两块板子分别是Master, Salve, Master CAN0 CAN1 和 Salve CAN0 都接在一起, 以下是测试步骤:

    Color Define: The color is a command , The color is a respond, The color is a comment

     

    Master$ /bin/ip link set can0 type can bitrate 1000000;/bin/ip link set can0 up
    Master$ /bin/ip -d -s link show can0
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0   

    Salve$ /bin/ip link set can0 type can bitrate 1000000;/bin/ip link set can0 up
    Salve$ candump can0 &
    interface = can0, family = 29, type = 3, proto = 1

    Salve$ /bin/ip -d -s link show can0
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0     

    Master$ cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
    interface = can0, family = 29, type = 3, proto = 1

    Salve$ <0x010> [8] 11 22 33 44 55 66 77 88

    # Master can0 cable is normal.

    Master$ /bin/ip link set can0 down
    Master$ /bin/ip link set can1 type can bitrate 1000000;/bin/ip link set can1 up
    Master$ /bin/ip -d -s link show can1
    3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        0          0        0       0       0       0      

    Master$ cansend can1 -i 0x20 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
    interface = can1, family = 29, type = 3, proto = 1

    Salve$ <0x020> [8] 11 22 33 44 55 66 77 88

    # Master can1 cable is normal.

    Master$ /bin/ip link set can0 up
    Master$ ip -d -s link show can0; ip -d -s link show can1
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        8          1        0       0       0       0      
    3: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        8          1        0       0       0       0      

    Master$ cansend can1 -i 0x20 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
    interface = can1, family = 29, type = 3, proto = 1

    # Wait for some time, Salve did not receive any response.


    Master$ ip -d -s link show can0; ip -d -s link show can1
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
        link/can
        can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          0          0          0         
        RX: bytes  packets  errors  dropped overrun mcast   
        0          0        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        8          1        0       0       0       0      
    3: can1: <NO-CARRIER,NOARP,UP,ECHO> mtu 16 qdisc pfifo_fast state DOWN qlen 10
        link/can
        can state BUS-OFF (berr-counter tx 248 rx 0) restart-ms 0
        bitrate 1000000 sample-point 0.750
        tq 83 prop-seg 4 phase-seg1 4 phase-seg2 3 sjw 1
        c_can: tseg1 2..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
        clock 24000000
        re-started bus-errors arbit-lost error-warn error-pass bus-off
        0          0          0          1          1          1         
        RX: bytes  packets  errors  dropped overrun mcast   
        24         3        0       0       0       0      
        TX: bytes  packets  errors  dropped carrier collsns
        8          1        0       0       0       0      

    单独测试 can0 can1 都是正常, 但是两个都打开时, 就有问题, 只要传送 cansend can state 就会跳成 BUS-OFF, 但是接线并没有改动. 该怎么解决这问题呢?




  • 我已经跟进下面的e2e帖子了。请关注下面帖子的回复,您也可以直接回复帖子。
    e2e.ti.com/.../3332468
  • Hi: 

    谢谢了, 问题排除, 刚好测试的板子GPIO有问题, 更换一片板子就排除该问题

  • 非常感谢告知原因!