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.

AM62A7: How to enable mcan module on AM62Ax

Part Number: AM62A7

Tool/software:

Hi,

We have started working on the MCAN module configuration for the AM62A7 Development Board。SDK version is 09_01_00.

We have done the following:

1. enable can driver in kernel.

2. config main_can0 and gpio in DTS.

After build SDK and flash to our board, we check it with some error: 

1> "ifconfig" -----> not find can0 device

2> "ifocnfig -a" ---->find can0 device

3> "ip link set can0 type can bitrate 12500"

error info: "ip: either "dev" is duplicate, or "type" is garbage"

4. "ip link set can0 up" 

error info : "ip: SIOCSIFFLAGS: Invalid argument"

so how to config mcan module correctlly?

I would appreciate your advice on this particular matter.

thanks.

  • Hi,

    AM62 SKs do not have on-board CAN transceivers, hence there are no transceiver nodes in their respective DTS files.
    You will have to use an overlay file, and apply it at the U-boot prompt to enable CAN communication.

    https://software-dl.ti.com/processor-sdk-linux/esd/AM62AX/09_02_00/exports/docs/linux/How_to_Guides/Target/How_to_test_MCAN_on_AM62x.html#enable-device-tree-overlay

    Regards,
    Aparna

  • Hi,

    1. according to the guide document,we modify "k3-am62x-sk-mcan.dtso", and add "dtb-$(CONFIG_ARCH_K3) += k3-am62x-sk-mcan.dtbo" in arch/arm64/boot/dts/ti/Makefile, but connot get "k3-am62x-sk-mcan.dtbo"  after rebuild. Is there something wrong with my operation?

    2. We use our custom board and have on_board CAN transceivers, so how do we continue with what we did earlier?

  • add "dtb-$(CONFIG_ARCH_K3) += k3-am62x-sk-mcan.dtbo" in arch/arm64/boot/dts/ti/Makefile

    This change is already present in the common overlays section in the Makefile. If you make any change in the dtso file, the corresponding dtbo should be built.

    Anyways, if you have on-board CAN transceiver, you can add the overlay file changes to your dts file and compile.

    I have not tried this myself yet, let me know if you see any issues.

    Regards,
    Aparna

  • Based on our custom board, we modified "k3-am62a-sk.dts" dts file. 

    The modification is as follows:

    diff --git a/arch/arm64/boot/dts/ti/k3-am62a7-sk.dts b/arch/arm64/boot/dts/ti/k3-am62a7-sk.dts
    index d21a31983..41c693ab3 100644
    --- a/arch/arm64/boot/dts/ti/k3-am62a7-sk.dts
    +++ b/arch/arm64/boot/dts/ti/k3-am62a7-sk.dts
    @@ -27,6 +27,7 @@
                    mmc1 = &sdhci1;
                    ethernet0 = &cpsw_port1;
                    spi0 = &ospi0;
    +               can0 = &main_mcan0;
            };
     
            chosen {
    @@ -262,6 +263,13 @@
                    #clock-cells = <0>;
                    clock-frequency = <12000000>;
            };
    +
    +       transceiver0: can-phy0 {
    +               compatible = "ti,tcan1042";
    +               #phy-cells = <0>;
    +               max-bitrate = <5000000>;
    +               /*standby-gpios = <&exp1 8 GPIO_ACTIVE_HIGH>;*/
    +       };
     };
     
     &main_pmx0 {
    @@ -403,6 +411,13 @@
                            AM62AX_IOPAD(0x008, PIN_INPUT, 0) /* (J24) OSPI0_DQS */
                    >;
            };
    +
    +       main_mcan0_pins_default: main-mcan0-pins-default {
    +               pinctrl-single,pins = <
    +                       AM64X_IOPAD(0x01dc, PIN_INPUT, 0) /* (C18) MCAN0_RX */
    +                       AM64X_IOPAD(0x01d8, PIN_OUTPUT, 0) /* (B17) MCAN0_TX */
    +               >;
    +       };
     };
     
     &mcu_pmx0 {
    @@ -941,3 +956,10 @@
            ti,driver-strength-ohm = <50>;
            disable-wp;
     };
    +
    +&main_mcan0 {
    +       status = "okay";
    +       pinctrl-names = "default";
    +       pinctrl-0 = <&main_mcan0_pins_default>;
    +       phys = <&transceiver0>;
    +};

    And we meet a problem: if we turn on the "#phy-cells = <0>;" configuration, it failed in registering the CAN0 device.

    // m_can_platform.c
    ......
    	transceiver = devm_phy_optional_get(&pdev->dev, NULL);
    	if (IS_ERR(transceiver)) {
    		ret = PTR_ERR(transceiver);
    		dev_err_probe(&pdev->dev, ret, "failed to get phy\n");
    		goto probe_fail;
    	}
    	
    ......

    dmesg infoormation

    [   65.107589] ----------------------> m_can_plat_probe
    [   65.113069] ----------------------> devm_platform_ioremap_resource_byname()
    [   65.120228] ----------------------> platform_get_irq_byname(): irp = 439
    [   65.126949] ----------------------> platform_get_resource_byname()
    [   65.133160] ----------------------> devm_ioremap()
    [   65.137964] ----------------------> failed to get phy: ret = -517
    

  • Thanks for sharing. I will look at it and get back to you. 

    Regards, 

    Aparna

  • Hi, 

    May I have another question: "Is there a driver in the SDK that supports TJA1042 CAN transceiver?"

    Now there are two scenarios:

    1. under the following configuration, Insmod phy-can-transceiver.ko can solve the above problem

    	transceiver0: can-phy0 {
    		compatible = "ti,tcan1042";
    		#phy-cells = <0>;
    		max-bitrate = <5000000>;
    	};

    2. The CAN transceiver for our custom board is TJA 1042. We modify the compatible configuration and have the same error infomation.

    transceiver0: can-phy0 {
    		compatible = "tja1042";
    		#phy-cells = <0>;
    		max-bitrate = <5000000>;
    	};

    so How should we configure the driver information for the TJA 1042?

  • Is there a driver in the SDK that supports TJA1042 CAN transceiver?

    No, there is no driver support for tja1042

    Regards,
    Aparna

  • Hi, 

    We have verified the mcan in the main domain by ip commands. Is there any C/C++ demo code to implement the sending and receiving of can data in main domain?

  • Hi Charles,

    Aparna is out of office today. Please expect some delay in response time.

    Regards,

    Nitika

  • Hi Charles,

    We have RTOS examples to verify CAN communication, you can go through the following document:
    https://software-dl.ti.com/mcu-plus-sdk/esd/AM62AX/09_02_00_38/exports/docs/api_guide_am62ax/EXAMPLES_DRIVERS_MCAN_LOOPBACK_INTERRUPT.html

    Regards,
    Aparna