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.

D_CAN interrupts problem

Other Parts Discussed in Thread: DM385

We have a project is going to use CAN bus to communicate with some handheld device. We currently working on DM814x-EVM with ezsdk 5.04.00.11 in Linux environment. I have libsocketcan and canutils as test program. I have seen the d-can drive and can protocol were up during boot time.

CAN device driver interface

CAN bus driver for Bosch D_CAN controller 1.0

d_can d_can.0: pdev c052bec0 pdev->dev c052bec8 offset 0 clk dcan0_fck

d_can d_can.0: mem 0x481cc000

d_can d_can.0: d_can device registered (ndev= cc98b000, irq=52, irq_obj=53) base=0xfa1cc000

 The steps that I run my test on the target were:

  1. ip link set can0 type can bitrate 50000
  2. ip link set can0 up
  3. candump can0 &
  4. cansend can0 -i 0x01 0xaa 0xbb
My expectation is I send a data frame on can0 that I will receive it on can0 with candump. I used the d_can driver from the DevKit, I get status interrupts, but no message object interrupts. Then I set the D_CAN_IF_MCTL_INTPND bit in D_CAN_IFMCTL register, this way I get tx interrupts. When I probe the CAN_H and CAN_L, I did see the data. However, I never get any rx interrupts. 
My question are:
  • Is this the right way to test can bus? 
  • Base on the DM814x TRM I've read ID_CAN_IF_MCTL_INTPND bit will be set when data frame is transferred, why do I need to set it in order to get tx interrupts? 
  • How do I get rx interrupts to work? 
If anybody could provide any comments or suggestions, I would appreciate very much.
Jiewen
  • I am also trying to get CAN to work on a DM814x.  I also can transmit data but not receive anything.  I put my oscilloscope on the DCAN0_RX pin (AG6) and it appears to be stuck high, like it's driving the line instead of receiving.  Have you looked at this? 

  • Hi Mark, 

    I probed the DCAN0_RX pin, it looks matching the CAN_H and CAN_L signals. it is not always high. Have you made any changes in the driver?

    Jiewen

     

  • Thank you for that information.  I think I may have a hardware problem.  My CAN PHY chip, SN64HVD251 is a 5V part, I wonder if the Rx damaged the 8148 pin?

    I did move the pinmuxing to a later point because my hardware was driving the CAN bus on boot, but other than that I did not change anything in software. 

  • I did commented out the following pinmux setting in mux814x.c

    _TI814X_MUXENTRY(UART0_RTSN, 0, "uart0_rtsn", "sata_act1_led_mux", NULL, "dcan1_rx", "spi1_cs2", NULL, "mmc2_sdcd", NULL),  /* DM385 only */

  • It turned out I had a bad solder connection!  So I am now able to use candump to see data on my car's OBD connector.  No changes to the driver, but this is custom hardware, not the EVM.

  • Hi Jiewen,

    Don't change any part of the code from release w.r.t to D_CAN and follow these steps?

    1. Board-Board connection details

    http://processors.wiki.ti.com/index.php/TI81XX_DCAN_Driver_Guide#dm814x

    2. Can you use exact steps mentioned at

    http://processors.wiki.ti.com/index.php/TI81XX_DCAN_Driver_Guide#Quick_Steps

    3. D_CAN0 don't have relation with these changes

    Jiewen Wang said:

    I did commented out the following pinmux setting in mux814x.c

    _TI814X_MUXENTRY(UART0_RTSN, 0, "uart0_rtsn", "sata_act1_led_mux", NULL, "dcan1_rx", "spi1_cs2", NULL, "mmc2_sdcd", NULL),  /* DM385 only */

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • AnilKumar,

    I did a test as in the TI81XX_DCAN_Driver_Guide except I connected a known CAN device to the dcan0. The kernel is the original one. Test failed, still no tx or rx  interrupt occurred. I did see data on CANH and CANL though. Here is the log:

    root@dm814x-evm:~# ip link set can0 type can bitrate 50000 triple-sampling on loopback on
    root@dm814x-evm:~# ip link set can0 up
    d_can d_can: can0: setting CAN BT = 0x1c18
    root@dm814x-evm:~# candump can0 &
    root@dm814x-evm:~# open 0 'can0'.
    using interface name 'can0'.

    root@dm814x-evm:~# cansend can0 -i 0x4e1 1 1
    interface = can0, family = 29, type = 3, proto = 1, idx = 2

    root@dm814x-evm:~# cat /proc/interrupts
    CPU0
    4: 0 INTC omap2_elm
    12: 236 INTC edma
    14: 0 INTC edma_error
    16: 0 INTC ahci
    17: 0 INTC cppi41_dma
    18: 1 INTC musb-hdrc.0
    19: 1 INTC musb-hdrc.1
    20: 0 INTC gpmc
    28: 729 INTC mmc1
    30: 1 INTC omap_i2c
    37: 0 INTC SGX ISR
    38: 0 INTC HDMI
    40: 0 INTC cpsw.0
    41: 67104 INTC cpsw.0
    42: 69946 INTC cpsw.0
    43: 0 INTC cpsw.0
    44: 0 INTC serial idle
    45: 0 INTC serial idle
    46: 0 INTC serial idle
    52: 2 INTC can0
    53: 0 INTC can0
    64: 13 INTC mmc0
    67: 6953 INTC gp timer
    70: 774 INTC omap_i2c
    72: 604 INTC serial idle, OMAP UART0
    73: 0 INTC serial idle
    74: 0 INTC serial idle
    75: 0 INTC rtc0
    76: 0 INTC rtc0
    77: 9789 INTC mailbox-dsp, mailbox-video, mailbox-vpss
    122: 0 INTC omap-iommu.1
    123: 0 INTC omap-iommu.0
    191: 2 GPIO qt602240_ts
    Err: 0
    root@dm814x-evm:~# cat /proc/net/can/stats

    1 transmitted frames (TXF)
    0 received frames (RXF)
    0 matched frames (RXMF)

    0 % total match ratio (RXMR)
    0 frames/s total tx rate (TXR)
    0 frames/s total rx rate (RXR)

    0 % current match ratio (CRXMR)
    0 frames/s current tx rate (CTXR)
    0 frames/s current rx rate (CRXR)

    0 % max match ratio (MRXMR)
    1 frames/s max tx rate (MTXR)
    0 frames/s max rx rate (MRXR)

    1 current receive list entries (CRCV)
    2 maximum receive list entries (MRCV)

    root@dm814x-evm:~# ip -s -d link show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX: bytes packets errors dropped overrun mcast
    340 6 0 0 0 0
    TX: bytes packets errors dropped carrier collsns
    340 6 0 0 0 0
    2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
    link/can
    can <LOOPBACK,TRIPLE-SAMPLING> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
    bitrate 50000 sample-point 0.875
    tq 1250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
    d_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1
    clock 20000000
    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: eth0: <BROADCAST,MULTICAST,ALLMULTI,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 40:5f:c2:08:94:18 brd ff:ff:ff:ff:ff:ff
    RX: bytes packets errors dropped overrun mcast
    92006778 68061 0 93 0 0
    TX: bytes packets errors dropped carrier collsns
    3657904 39452 0 0 0 0
    root@dm814x-evm:~#


     Regards.

    Jiewen


  • Hi Jiewen,

    Is this issue resolved?

    Thanks

    AnilKumar

  • Hi Anil,

    I do see the same problem as Jiewen.  Is it a connector solder issue?  Or a current loop problem requiring modifying the diff term resistor?  Or a S/W issue?

    Best regards,

    Ershad

  • Hi Ershad,

    Can you get these details to get more idea on what is happening really?

    1. cat /proc/interrupts | grep -i can

    2. ip -d -s link show can0

    3. cat /proc/net/can/stats

    4. Checking the error details in dcan registers

        a. devmem2 0x481CC000

        b. devmem2 0x481CC004

    Note: devmem2 is a utility used to read data

    Regards

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Hi Anil, here is what you asked for

    root@dm814x-evm:~# ./CANBringup.sh

    can0 state: STOPPED

    can0 bitrate: 1000000, sample-point: 0.750

    d_can d_can: can0: setting CAN BT = 0x4d00

    root@dm814x-evm:~# cat /proc/interrupts | grep -i can

     52:          2        INTC  can0

     53:          0        INTC  can0

    root@dm814x-evm:~# 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 50 prop-seg 7 phase-seg1 7 phase-seg2 5 sjw 1

        d_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..1024 brp-inc 1

        clock 20000000

        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

    root@dm814x-evm:~# cat /proc/net/can/stats

     

            0 transmitted frames (TXF)

            0 received frames (RXF)

            0 matched frames (RXMF)

     

            0 % total match ratio (RXMR)

            0 frames/s total tx rate (TXR)

            0 frames/s total rx rate (RXR)

     

            0 % current match ratio (CRXMR)

            0 frames/s current tx rate (CTXR)

            0 frames/s current rx rate (CRXR)

     

            0 % max match ratio (MRXMR)

            0 frames/s max tx rate (MTXR)

            0 frames/s max rx rate (MRXR)

     

            0 current receive list entries (CRCV)

            0 maximum receive list entries (MRCV)

     

    root@dm814x-evm:~# devmem2 0x481CC000

    /dev/mem opened.

    Memory mapped at address 0x40209000.

    Read at address  0x481CC000 (0x40209000): 0x00000000

    root@dm814x-evm:~# devmem2 0x481CC004

    /dev/mem opened.

    Memory mapped at address 0x4015d000.

    Read at address  0x481CC004 (0x4015d004): 0x00000107

    root@dm814x-evm:~#

     

    Best regards,

    Ershad

     

  • Hi Anil,

    I got the candump to working.  However, there is still an intermittent issue, suggesting perhaps a hardware (pin contact or impedance) problem.

    Best regards,

    Ershad

  • Hi again Anil,

    I can not rule out a S/W problem, because if I execute the following steps, I can get the candump working reliably:

    canconfig can0 stop
    canconfig can0 bitrate 1000000
    ip link set can0 up
    cansend can0 -i 0x001 0x12 0x23 0x34 0x56 0x45 0x78 0xAB 0xFF
    canconfig can0 stop
    canconfig can0 bitrate 125000
    ip link set can0 up

  • Hi Ershad Hussein,

    root@dm814x-evm:~# devmem2 0x481CC000

    /dev/mem opened.

    Memory mapped at address 0x40209000.

    Read at address  0x481CC000 (0x40209000): 0x00000000 (This is wrong this should be 0x0000000e)

    Can you change the D_CAN driver similar to this patch and see whether the issue got fixed or not (I hope this is the fix)? Commit message has the details of the issue.

    http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=commitdiff;h=f461f27a4436dbe691908fe08b867ef888848cc3;hp=148c87c89e1a8863d3d965179f3ab1a06490569e

    Thanks

    AnilKumar

    Please mark this Forum post as answered via the Verify Answer button below if it helps answer your question.  Thanks!

  • Thanks Anil, it fixes the problem.

  • Antil,

    I have a new problem now. Sometimes I see DCAN bus stuck in warning/error passive state, 0x481cc004 = 0x00000063, so once it gets in this state, it is unable to recover. I have to restart the system. I'd like to know if there is a way it can be recovered by software. (I have incorporated the change you mentioned above)

    root@dm814x-evm:~/dm814x# devmem2 0x481cc000
    /dev/mem opened.
    Memory mapped at address 0x40297000.
    Read at address 0x481CC000 (0x40297000): 0x0002000E


    root@dm814x-evm:~/dm814x# devmem2 0x481cc004
    /dev/mem opened.
    Memory mapped at address 0x4003b000.
    Read at address 0x481CC004 (0x4003b004): 0x00000067

    root@dm814x-evm:~/dm814x# devmem2 0x481cc008
    /dev/mem opened.
    Memory mapped at address 0x4033a000.
    Read at address 0x481CC008 (0x4033a008): 0x00000080

    Thanks.

    Jiewen