Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

[FAQ] TDA4VM: How can I use CAN on Linux

Part Number: TDA4VM

I see that on TDA4 there is no support for a CAN driver on Linux, is there a patch which I use to achieve basic functionallity?

  • Till SDK7.0 we do not support CAN on Linux on TDA4, we recommend that CAN be controlled by R5F cores in respective domains i.e. MCU CANs being controlled by MCU R5 Fand MAIN CANs controlled by MAIN R5F.

    That being said, there is a patch you can apply in the device tree and do some basic level of tests on Linux with CAN. The attached patch is validated on SDK 6.02 and after applying the patch you can refer the instructions at https://software-dl.ti.com/processor-sdk-linux/esd/docs/06_03_00_106/linux/Foundational_Components/Kernel/Kernel_Drivers/MCAN.html to test the interface.

    To summarize the steps:

    #can0 corresponds to MAIN CAN0 (J27) and can1 corresponds to MAIN CAN2 (J28) on the TDA4 EVM
    #replace can0 with can1 in case you are using MAIN MCAN2
    #setup can0 in CAN FD mode with BRS enabled, 1Mbps of nominal bit rate and 5Mbps of data bit rate
    ip link set can0 type can bitrate 1000000 dbitrate 5000000 fd on
    ip link set can0 up
    
    #this should send a message on to your CAN emulator and you should be able to see this
    #send CAN FD frame
    cansend can0 113##2AAAAAAAA
    
    #send CAN FD frame with BRS
    cansend can0 143##1AAAAAAAA
    
    #after running the below command, send messages from the CAN emulator to the MCAN0 interface. You will see the messages on the EVM’s console. 
    candump can0

    Patch on top of SDK 6.02

    patch: /cfs-file/__key/communityserver-discussions-components-files/791/0001_2D00_dts_2D00_Add_2D00_MCAN0_2D00_and_2D00_MCAN2_2D00_support_2D00_in_2D00_linux.patch

    Debug tips

    If something doesn't work, it is always good to check if the internal loopback is working or not. Please use the below commands to test it:

    # Check if the device is registered on not
    root@j7-evm:~# dmesg | grep can
    [   10.390506] m_can_platform 2701000.mcan: m_can device registered (irq=21, version=32)
    [   10.810563] m_can_platform 2721000.mcan: m_can device registered (irq=23, version=32)
    
    # Put the controller in internal loopback mode
    root@j7-evm:~# ip link set can0 type can bitrate 1000000 dbitrate 5000000 fd on loopback on
    root@j7-evm:~# ip link set can0 up
    
    # Check the details for can0 node, this should show LOOPBACK
    root@j7-evm:~# ip -details link show can0
    3: 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 <LOOPBACK,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 1..128 sjw 1..128 brp 1..512 brp-inc 1
              dbitrate 5000000 dsample-point 0.750
              dtq 12 dprop-seg 5 dphase-seg1 6 dphase-seg2 4 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
    
    # Run candump in background
    root@j7-evm:~# candump can0 &
    
    # Send message on can0, this should be echoed back on the console as candump is running in background
    root@j7-evm:~# cansend can0 113##2AAAAAAAA
      can0  113  [04]  AA AA AA AA
      can0  113  [04]  AA AA AA AA



    Follow below FAQ for adding CAN on GESI Board
    e2e.ti.com/.../faq-tda4vm-how-do-i-enable-can-channels-on-gateway-ethernet-switch-industrial-gesi-expansion-card-when-using-j721e-evm-from-linux-a72

    Regards,

    Karan

  • Hi all,

    More recent SDKs have some extra things to define in DTS. Updated patch that works on top of 8.5 SDK can be found here: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1216687/faq-j7200xsomxevm-how-do-i-enable-can-with-linux-driver-on-j7200

    Regards,

    Takuma