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.

AM6442: How to test MCAN driver on AM64x-EVM board

Part Number: AM6442
Other Parts Discussed in Thread: TCAN4550

Dear TI supporters,

I have just got a Linux SDK8.0 for AM64x-EVM and now I would like to test MCAN driver.

Default, in the tisdk_am64xx-vm_defconfig shows

CONFIG_CAN_M_CAN=m
CONFIG_CAN_M_CAN_PLATFORM=m

Insmod these modules and on Linux type:

ifconfig -a

It will be show can0 and can1. Is it right?

And then I can bringing interface up with any bitrate. Is it right?

For example, 

ip link set can0 type can bitrate 12500

ip link set up can0

Finall?

I can use the libsocketCAN to connect the CAN device file. Right?

Does TI have any application for testing MCAN driver?

Thanks,

  • Hi,

    Are you using a TI EVM? Which mode do you plan to use CAN or CAN FD?

    The answers to your questions are correct except for the bitrate is probably too low. Yes libsocketCAN is with the MCAN interfaces. For evaluation purpose canutils has been integrated into the SDK. As the current AM64 documentation is still a work in progress it does not any info on the MCAN interface. This page will work for the time being until the documentation is ready. 

    Best Regards,

    Schuyler

  • Hello Schuyler,

    My prototype board plans to CANFD, but I want to test this driver on TI AM64xx-EVM first.

    So I need to check CAN and CANFD function, you can give me some information?

    By the way, I would like to give some suggestion from you for

    - Another one, that is a CANFD interface connected to UART2.

      If communication in CAN FD fast data rate upto 5Mbit/s, which UART boudrate? Now I don't know the relationship between them.

    - And another one, that is a CANFD 8Mbps using TCAN4550 of TI connected to SPI.

      In the kernel has drivers/net/can/m_can/tcan4x5c.c

      I don't know if that the data rate in 5 Mbps or 8Mbps I need to configure which parameters? Need configure SPI boudrate and transceiver?

    Thank you so much

  • Hi,

    Were you able to look at the link in the previous reply? Link to documentation This documentation has some examples on setting up the CAN from an application perspective? 

    The TCAN4550 is a product from a different BU within TI that I will not be to support. Is this a device you need information on?

    Best Regards,

    Schuyler

  • Hello Schuyler,

    Sorry, I miss this link. It's good doc for me.

    About TCAN4550, Yes, I am adding a node inside dts of am64xx-evm to control iit via SPI0 bus.

    Thank you so much,

  • Hi,

    I am happy to hear that you found the doc useful. 

    As I mentioned I will not be able to assist with the TCAN device, is the SPI interface working as you need?

    Best Regards,

    Schuyler

  • Hello Schuyler,

    in insmod module successfully as:

    root@am64xx-evm:/# lsmod
    Module                  Size  Used by
    m_can_platform        262144  0
    m_can                 327680  1 m_can_platform
    can_dev               327680  1 m_can
    phy_can_transceiver   262144  2
    

    Check CAN device interface

    root@am64xx-evm:/# ifconfig -a
    can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
              UP RUNNING NOARP  MTU:72  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:10 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
              Interrupt:36 
    
    can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
              NOARP  MTU:16  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:10 
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
              Interrupt:38 
    
    

    Set bitrate:

    CAN-FD mode:

    CAN-FD mode with bitrate switching:

    root@am64xx-evm:/# ip link set can0 type can bitrate 1000000
    root@am64xx-evm:/# ip link set can0 type can bitrate 1000000 fd on
    RTNETLINK answers: Operation not supported
    root@am64xx-evm:/# ip link set can0 type can bitrate 1000000 dbitrate 4000000 fd on

    =>>> When "fd on" logout RTNETLINK answers: Operation not supported

    That means CAN FD does not operate. Please check it again help me.

    Thank

  • Hi,

    Your second command worked for me. This is from my board with the 8.0 SDK :

    root@am64xx-evm:~# ip link set can0 type can bitrate 1000000 dbitrate 4000000 fd on

    root@am64xx-evm:~# ip link set can0 up

    [ 479.322141] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready

    There is an error in the documentation that will be corrected. In the meantime this work

    Best Regards,

    Schuyler

  • Hello Schuyler,

    On am64xx-evm, CAN0 connected to CAN1 via Jumper Wires

    I flashed tisdk-default-image-am64xx-evm.wic of ti-processor-sdk-linux-am64xx-evm-08.00.00.21 inside SD card.

    It is done to test CAN as below

    root@am64xx-evm:~# uname -r
    5.10.41-g4c2eade9f7
    root@am64xx-evm:~# ip link set can0 type can bitrate 1000000
    root@am64xx-evm:~# ip link set can0 type can bitrate 1000000 fd on
    RTNETLINK answers: Operation not supported
    root@am64xx-evm:~# 
    root@am64xx-evm:~# ip link set can0 type can bitrate 1000000 dbitrate 4000000 fd on
    root@am64xx-evm:~# ip link set can0 up
    [ 7784.410651] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
    root@am64xx-evm:~# ip link set can1 type can bitrate 1000000
    root@am64xx-evm:~# ip link set can1 type can bitrate 1000000 fd on
    RTNETLINK answers: Operation not supported
    root@am64xx-evm:~# ip link set can1 type can bitrate 1000000 dbitrate 4000000 fd on
    root@am64xx-evm:~# ip link set can1 up
    [ 7942.830058] IPv6: ADDRCONF(NETDEV_CHANGE): can1: link becomes ready
    ^Croot@am64xx-evm:~# candump can1&
    [1] 4981
    root@am64xx-evm:~# cansend can0 213##311223344
      can1  213  [04]  11 22 33 44
    root@am64xx-evm:~# cansend can0 213##311223355
      can1  213  [04]  11 22 33 55
    root@am64xx-evm:~# cansend can0 113##2AAAAAAAA
      can1  113  [04]  AA AA AA AA
    root@am64xx-evm:~# ip -det link show can0 | awk '/bitrate/ {print $1 "=" $2}'
    bitrate=1000000
    dbitrate=4000000
    root@am64xx-evm:~# ip -det link show can0                                    
    4: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
        link/can  promiscuity 0 minmtu 0 maxmtu 0 
        can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
              bitrate 1000000 sample-point 0.750 
              tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1
              m_can: tseg1 2..256 tseg2 2..128 sjw 1..128 brp 1..512 brp-inc 1
              dbitrate 4000000 dsample-point 0.750 
              dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1
              m_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..32 dbrp-inc 1
              clock 80000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    root@am64xx-evm:~# ip -det link show can1
    5: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
        link/can  promiscuity 0 minmtu 0 maxmtu 0 
        can <FD> state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
              bitrate 1000000 sample-point 0.750 
              tq 12 prop-seg 29 phase-seg1 30 phase-seg2 20 sjw 1
              m_can: tseg1 2..256 tseg2 2..128 sjw 1..128 brp 1..512 brp-inc 1
              dbitrate 4000000 dsample-point 0.750 
              dtq 12 dprop-seg 7 dphase-seg1 7 dphase-seg2 5 dsjw 1
              m_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..32 dbrp-inc 1
              clock 80000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    root@am64xx-evm:~# cansend can0 123#DEADBEEF
      can1  123   [4]  DE AD BE EF
    root@am64xx-evm:~# cansend can0 213##311223355
      can1  213  [04]  11 22 33 55
    root@am64xx-evm:~# cansend can0 143##1AAAAAAAAA
    
    Wrong CAN-frame format! Try:
    
        <can_id>#{data}            for 'classic' CAN 2.0 data frames
        <can_id>#R{len}            for 'classic' CAN 2.0 RTR frames
        <can_id>##<flags>{data}    for CAN FD frames
    
    <can_id> can have 3 (SFF) or 8 (EFF) hex chars
    {data} has 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')
    {len} is an optional 0..8 value as RTR frames can contain a valid dlc field
    <flags> a single ASCII Hex value (0 .. F) which defines canfd_frame.flags
    
    e.g. 5A1#11.2233.44556677.88 / 123#DEADBEEF / 5AA# / 123##1 / 213##311223344
         1F334455#1122334455667788 / 123#R / 00000123#R3
    
    root@am64xx-evm:~# 

    According to https://software-dl.ti.com/processor-sdk-linux/esd/docs/06_03_00_106/linux/Foundational_Components/Kernel/Kernel_Drivers/MCAN.html

    part c.Send CAN FD frame with BRS

    $ cansend can0 143##1AAAAAAAAA
    will be failed as above log. It seems to be failed command

    Please explain me. Thanks
  • Hi,

    I will try the commands that you are doing early next week as I am not able to try them today.  I apologize for the delay. 

    Best Regards,

    Schuyler

  • Hello Schuyler,

     Do you have any update?

    Slight smile

    Thanks

  • Hi,

    No update yet but I expect to have one tomorrow as I now have an environment to try with.

    Best Regards,

    Schuyler

  • Hi,

    I setup my system like you have I believe. I am using the gp evm and have connected CAN0 to CAN1. I think I understand the issue that you are having with the cansend utility when sending CAN-FD frames. When I copy your cansend line I get the same error that you are getting. If you add an extra A to your example it works:

    root@am64xx-evm:~# cansend can0 143##1AAAAAAAAAA
    can1 143 [05] AA AA AA AA AA

    The issue appears to (I didn't look through the community source code) that after the flags field there has to be an even number of characters. After adding an A for example to your command line there are even number of characters after the flags field.

    Best Regards,

    Schuyler