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.

Linux/AM5728: DCAN communication

Part Number: AM5728

Tool/software: Linux

I am using ubuntu-16.04.3-minimal-armhf-2017-10-10 on my bb-x15.And some questions occured when developing CAN .

1.According to the user guide:

every thing is good , but I can't set ctrlmode tripple-sampling on using cammand :canconfig can0  ctrlmode tripple-sampling on

can0 ctrlmode: loopback[OFF], listen-only[OFF], tripple-sampling[OFF],one-shot[OFF], berr-reporting[OFF]

2.I have check the pinmux register value and connect the dcan1_txd to dcan1_rxd for quick test.  But It's not working,(I use command cansend &candump ),it looked like candump is blocked and I supposed dcan1_rxd receive nothing .

#devmem2 0x4A0037D4  h
/dev/mem opened.
Memory mapped at address 0xb6fb3000.
Value at address 0x4A0037D4 (0xb6fb37d4): 0x0

# devmem2 0x4A0037D0  h
/dev/mem opened.
Memory mapped at address 0xb6fa5000.
Value at address 0x4A0037D0 (0xb6fa57d0): 0x0

Thinks in advance.

  • Hi,

    Ubuntu is not supported by TI. This forum supports only the TI released Processor SDK: www.ti.com/.../PROCESSOR-SDK-AM57X
  • OK,thanks for the suggestion ,I have changed the sdk to ti-processor-sdk-linux-rt-am57xx-evm-04.01.00.06.

    And good news is that problem 1 is solved.

    # canconfig can0 bitrate 50000 ctrlmode triple-sampling on
    can0 bitrate: 50000, sample-point: 0.875
    can0 ctrlmode: loopback[OFF], listen-only[OFF], tripple-sampling[ON],one-shot[OFF], berr-reporting[OFF]
    

    But there is a error print by kernel says :

    omap_hwmod: dcan1: _wait_target_disable failed

    And problem 2 remains.

  • Hi,

    Are you using the pre-built images from the ti processors SDK? Did you modify the dts file to enable the DCAN interface for the board?

    Best Regards,
    Schuyler
  • The am57xx-beagle-x15-revb1.dtb TI provide don't  have dcan when boot up.

    I have modified  the dtsi like:

    	dcan1_pins_ds: pinmux_dcan1_pins_ds {
    		pinctrl-single,pins = <
    			DRA7XX_CORE_IOPAD(0x37d4, PIN_INPUT | MUX_MODE0) 	/* (Errata i893) dcan1_rx.dcan1_rx */
    			DRA7XX_CORE_IOPAD(0x37d0, PIN_OUTPUT | MUX_MODE0) 	/* dcan1_tx.dcan1_tx */
    		>;
    	}; 
    
    &dcan1 {
    	status = "okay";    /* Enable only if Profile 1 is selected */
        pinctrl-names = "default";
        pinctrl-0 = <&dcan1_pins_ds>;
    };
    

    And as what I sayed before ,I followed the DCAN_GUIDE ,and chose dcan_driver to "y" in the  zImage I am using right now.

  • Hi,

    I want to make sure you modified the correct file, which dtsi did you modify? This comment is in the am335x-evm.dts /* Enable only if Profile 1 is selected */, did copy this to the X15 dts file?

    Could you also put a logic analyzer or oscilloscope to see if the tx line is toggling?

    Best Regards,
    Schuyler
  • Hi ,thanks for reply.
    I was wrong about my last comment "The am57xx-beagle-x15-revb1.dtb TI provide don't have dcan when boot up."
    Today I notice that there is a can interface for debug on AM57xx_idk_board .I download the lastest SDK ti-processor-sdk-linux-rt-am57xx-evm-05.00.00.15, and try can communication between 2 idk_board.

    It works perfetly .

    Question is still how should I modify the dts for bb_x15 .I have no idea.(the dtb for idk_board don't work for bb_x15)

    1."I want to make sure you modified the correct file, which dtsi did you modify? "

    I modify "bb-x15/ti-linux-kernel-dev/KERNEL/arch/arm/boot/dts/am57xx-beagle-x15-revc.dts",

    /*
     * Copyright (C) 2014-2017 Texas Instruments Incorporated - http://www.ti.com/
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    
    #include "am57xx-beagle-x15-common.dtsi"
    #include "am57xx-cmem.dtsi"
    
    / {
    	model = "TI AM5728 BeagleBoard-X15 rev C";
    };
    
    &tpd12s015 {
    	gpios = <&gpio7 10 GPIO_ACTIVE_HIGH>,	/* gpio7_10, CT CP HPD */
    		<&gpio2 30 GPIO_ACTIVE_HIGH>,	/* gpio2_30, LS OE */
    		<&gpio7 12 GPIO_ACTIVE_HIGH>;	/* gpio7_12/sp1_cs2, HPD */
    };
    
    &dra7_pmx_core {
    	dcan1_pins_ds: pinmux_dcan1_pins_ds {
    		pinctrl-single,pins = <
    			DRA7XX_CORE_IOPAD(0x37d4, PIN_INPUT | MUX_MODE0) 	/* (Errata i893) dcan1_rx.dcan1_rx */
    			DRA7XX_CORE_IOPAD(0x37d0, PIN_OUTPUT | MUX_MODE0) 	/* dcan1_tx.dcan1_tx */
    		>;
    	};
    
    };
    
    
    
    
    &mmc1 {
    	pinctrl-names = "default", "hs", "sdr12", "sdr25", "sdr50", "ddr50", "sdr104";
    	pinctrl-0 = <&mmc1_pins_default>;
    	pinctrl-1 = <&mmc1_pins_hs>;
    	pinctrl-2 = <&mmc1_pins_sdr12>;
    	pinctrl-3 = <&mmc1_pins_sdr25>;
    	pinctrl-4 = <&mmc1_pins_sdr50>;
    	pinctrl-5 = <&mmc1_pins_ddr50 &mmc1_iodelay_ddr_rev20_conf>;
    	pinctrl-6 = <&mmc1_pins_sdr104 &mmc1_iodelay_sdr104_rev20_conf>;
    	vmmc-supply = <&vdd_3v3>;
    	vmmc_aux-supply = <&ldo1_reg>;
    };
    
    &mmc2 {
    	pinctrl-names = "default", "hs", "ddr_1_8v";
    	pinctrl-0 = <&mmc2_pins_default>;
    	pinctrl-1 = <&mmc2_pins_hs>;
    	pinctrl-2 = <&mmc2_pins_ddr_rev20>;
    };
    
    
    
    &dcan1 {
    	status = "okay";    /* Enable only if Profile 1 is selected */
        pinctrl-names = "default";
        pinctrl-0 = <&dcan1_pins_ds>;
    };
    
    

    2. "/* Enable only if Profile 1 is selected */, did copy this to the X15 dts file?"

    Maybe you hit the point ,I haven't notice this . Do you have ideas about what this Profile 1 mean or where it exits?

  • I found that profile 1 ,is a hardware switch for AM335x GP EVM.So this is not the reason

    processors.wiki.ti.com/.../Linux_Core_DCAN_User's_Guide

  • root@am57xx-evm:~# devmem2 0x4AE07888 h
    /dev/mem opened.
    Memory mapped at address 0xb6fe9000.
    Read at address  0x4AE07888 (0xb6fe9888): 0x0000
    root@am57xx-evm:~# canconfig can0 bitrate 50000 ctrlmode triple-samplin
    [  757.361582] omap_hwmod: dcan1: _wait_target_disable failed
    can0 bitrate: 50000, sample-point: 0.875                               
    [  757.376837] omap_hwmod: dcan1: _wait_target_disable failed          
    can0 ctrlmode: loopback[OFF], listen-only[OFF], tripple-sampling[ON],o]
    root@am57xx-evm:~# ifconfig can0 up                                    
    [  763.253046] c_can_platform 4ae3c000.can can0: setting BTR=1c18 BRPE0
    root@am57xx-evm:~# devmem2 0x4AE07888 h                                
    /dev/mem opened.                                                       
    Memory mapped at address 0xb6f43000.                                   
    Read at address  0x4AE07888 (0xb6f43888): 0x0002                       
    root@am57xx-evm:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 8
    interface = can0, family = 29, type = 3, proto = 1                     
    root@am57xx-evm:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 8
    interface = can0, family = 29, type = 3, proto = 1                     
    root@am57xx-evm:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 8
    interface = can0, family = 29, type = 3, proto = 1                     
    root@am57xx-evm:~#

    0x4AE07888 is the dcan1_clkctrl address. And dcan1_tx ouput shows  nothing(using a scope) 

  • Hi,

    Could you please list the commands you are using to configure the DCAN interface? And please post the results of this command:
    lsmod | grep can

    Best Regards,
    Schuyler

  • root@am57xx-evm:~# canconfig can0 bitrate 50000 ctrlmode triple-sampling on [ 757.361582] omap_hwmod: dcan1: _wait_target_disable failed can0 bitrate: 50000, sample-point: 0.875 [ 757.376837] omap_hwmod: dcan1: _wait_target_disable failed can0 ctrlmode: loopback[OFF], listen-only[OFF], tripple-sampling[ON],... root@am57xx-evm:~# ifconfig can0 up [ 763.253046] c_can_platform 4ae3c000.can can0: setting BTR=1c18 BRPE0 root@am57xx-evm:~# cansend can0 -i 0x10 0x11 0x22 0x33 0x44 0x55 0x66 8 interface = can0, family = 29, type = 3, proto = 1 root@am57xx-evm:~#

    1.This is the command I used to configure CAN on bb_x15 , actually I have mentioned this in my last post.

    2.This is the output of " lsmod | grep can "

    root@am57xx-evm:~# lsmod | grep can                                
    can_raw                 6589  2                                              
    can                    29904  1 can_raw                                      
    c_can_platform          6638  0         
    c_can                   9718  1 c_can_platform
    can_dev                12397  1 c_can   

    3.One last question :Have you(or your staff) ever test can on bb_x15? ( No offense)

    And  now I am using the  same sd_card(same zImage,same dtb,same u-boot),and both am5728_idk and bb_x15 can successfully boot-up,but bb_x15 still has problem with can communication while am5728_idk works perfectly .Will this  omap_hwmod: dcan1: _wait_target_disable failed be a hardware problem ?

  • Hi,

    No offense taken concerning the testing, TI does not test the bb_x15 since it is a Beagle community board and technically not supported by TI. But the TI gpevm though is very close to the X15, except one key difference is that an LCD is attached to the connectors that you are trying to use.

    I will check with the driver team on the error message that you are seeing. Is there a reason you would want to use the X15 instead of the IDK board?

    In the meantime what does this command return? Your board should "okay" for status.
    cat /proc/device-tree/ocp/can\@481cc000/status

    Best Regards,
    Schuyler
  • Thanks a lot for the reply.

    1.The reason why we are using bb_x15 instead of idk_board : bb_x15 is smaller (and besides ,cheaper .Actually it's the boss 's choice -_- )

    2.The result of "cat /proc/device-tree/ocp/can\@481cc000/status" is :

    root@am57xx-evm:~# cat /proc/device-tree/ocp/can\@481cc000/status      
    okay

  • on arch/arm/mach-omap2/omap_hwmod.c 

    line:1845

    /**
     * _omap4_disable_module - enable CLKCTRL modulemode on OMAP4
     * @oh: struct omap_hwmod *
     *
     * Disable the PRCM module mode related to the hwmod @oh.
     * Return EINVAL if the modulemode is not supported and 0 in case of success.
     */
    static int _omap4_disable_module(struct omap_hwmod *oh)
    {
    	int v;
    
    	if (!oh->clkdm || !oh->prcm.omap4.modulemode)
    		return -EINVAL;
    
    	/*
    	 * Since integration code might still be doing something, only
    	 * disable if all lines are under hardreset.
    	 */
    	if (_are_any_hardreset_lines_asserted(oh))
    		return 0;
    
    	pr_debug("omap_hwmod: %s: %s\n", oh->name, __func__);
    
    	omap_cm_module_disable(oh->clkdm->prcm_partition, oh->clkdm->cm_inst,
    			       oh->prcm.omap4.clkctrl_offs);
    
    	v = _omap4_wait_target_disable(oh);
    	if (v)
    		pr_warn("omap_hwmod: %s: _wait_target_disable failed\n",
    			oh->name);
    
    	return 0;
    }

  • Hi,

    Can I ask a favor and please check if you are seeing the wait_target_disable failed message on the IDK board? Does dmesg | grep dcan show the message?

    I am still discussing with the driver team, they mentioned an issue that was resolved over a year ago but checking your the source you are using has the fix in it.

    Best Regards,
    Schuyler
  • No dcan error message on idk_board

  • Hi ,  Schuyler

    1.

    Bruno Lui  ,he add a 5V power supply to beagle-bone-black's   "CBB-Serial cape ".But I have no idea where this so call 5V is add to .


    2.Do you think disabling HDMI will help ? I search and found people disable HDMI while developing CAN on BBB.

    And how should I check the status of HDMI on bb_x15?

  • Hi,
    Discussing with the driver team here is the solution. The issue has to do with the DCAN interface pins being in a default state which means the pins are enabled. When the DCAN IP coming out of reset any possible data on the line might cause an undefined condition in the DCAN IP module which is the condition you are experiencing. If you look at the DTS file for the IDK board you will need to define the interface pins like this:

    &dra7_pmx_core {
    dcan1_pins_default: dcan1_pins_default {
    pinctrl-single,pins = <
    DRA7XX_CORE_IOPAD(0x37d0, PIN_OUTPUT_PULLUP | MUX_MODE0) /* dcan1_tx */
    DRA7XX_CORE_IOPAD(0x37d4, PIN_INPUT_PULLUP | MUX_MODE0) /* dcan1_rx */
    >;
    };

    dcan1_pins_sleep: dcan1_pins_sleep {
    pinctrl-single,pins = <
    DRA7XX_CORE_IOPAD(0x37d0, MUX_MODE15 | PULL_UP) /* dcan1_tx.off */
    DRA7XX_CORE_IOPAD(0x37d4, MUX_MODE15 | PULL_UP) /* dcan1_rx.off */
    >;
    };
    };

    &dcan1 {
    status = "okay";
    pinctrl-names = "default", "sleep", "active";
    pinctrl-0 = <&dcan1_pins_sleep>;
    pinctrl-1 = <&dcan1_pins_sleep>;
    pinctrl-2 = <&dcan1_pins_default>;
    };

    The solution above defines the default state and the sleep mode together which is the interface pins in the off state. The active state is an added state and this state is what enables the pins for traffic. Please give this a try and let us know.

    Best Regards,
    Schuyler
  • Hi ,Schuyler

    1.Now I use am572x-idk.dtb, its dts is like

    /*
     * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    
    /dts-v1/;
    
    #include "dra74x.dtsi"
    #include "am572x-idk-common.dtsi"
    #include "dra74x-mmc-iodelay.dtsi"
    
    / {
    	model = "TI AM5728 IDK";
    	compatible = "ti,am5728-idk", "ti,am5728", "ti,dra742", "ti,dra74",
    		     "ti,dra7";
    };
    
    &cpu0 {
    	vdd-supply = <&smps12_reg>;
    };
    
    &mmc1 {
    	pinctrl-names = "default", "hs", "sdr12", "sdr25", "sdr50", "ddr50", "sdr104";
    	pinctrl-0 = <&mmc1_pins_default>;
    	pinctrl-1 = <&mmc1_pins_hs>;
    	pinctrl-2 = <&mmc1_pins_sdr12>;
    	pinctrl-3 = <&mmc1_pins_sdr25>;
    	pinctrl-4 = <&mmc1_pins_sdr50>;
    	pinctrl-5 = <&mmc1_pins_ddr50 &mmc1_iodelay_ddr_rev20_conf>;
    	pinctrl-6 = <&mmc1_pins_sdr104 &mmc1_iodelay_sdr104_rev20_conf>;
    };
    
    &mmc2 {
    	pinctrl-names = "default", "hs", "ddr_1_8v";
    	pinctrl-0 = <&mmc2_pins_default>;
    	pinctrl-1 = <&mmc2_pins_hs>;
    	pinctrl-2 = <&mmc2_pins_ddr_rev20>;
    };
    
    &pruss2_mdio {
    	reset-gpios = <&gpio5 8 GPIO_ACTIVE_LOW>,
    		      <&gpio5 9 GPIO_ACTIVE_LOW>;
    	reset-delay-us = <2>;	/* PHY datasheet states 1uS min */
    };
    
    #include "am57xx-evm-cmem.dtsi"
    

    And am572x-idk.dts  includes am572x-idk-common.dtsi which already defined the pins you mentioned 

    &dra7_pmx_core {
    	dcan1_pins_default: dcan1_pins_default {
    		pinctrl-single,pins = <
    			DRA7XX_CORE_IOPAD(0x37d0, PIN_OUTPUT_PULLUP | MUX_MODE0)	/* dcan1_tx */
    			DRA7XX_CORE_IOPAD(0x37d4, PIN_INPUT_PULLUP | MUX_MODE0)		/* dcan1_rx */
    		>;
    	};
    
    	dcan1_pins_sleep: dcan1_pins_sleep {
    		pinctrl-single,pins = <
    			DRA7XX_CORE_IOPAD(0x37d0, MUX_MODE15 | PULL_UP)	/* dcan1_tx.off */
    			DRA7XX_CORE_IOPAD(0x37d4, MUX_MODE15 | PULL_UP)	/* dcan1_rx.off */
    		>;
    	};
    };
    
    
    &dcan1 {
    	status = "okay";
    	pinctrl-names = "default", "sleep", "active";
    	pinctrl-0 = <&dcan1_pins_sleep>;
    	pinctrl-1 = <&dcan1_pins_sleep>;
    	pinctrl-2 = <&dcan1_pins_default>;
    };
    

    2. Dcan is not working still.

  • Hi,

    Are you using the idk dts completely for the x15? I am concerned that there are differences that might compound the problem.

    I don't have an X-15 here but I will try to find one and see what the changes I have recommended do on the board.

    Regards,
    Schuyler
  • Hi,
    Could you post a picture of how you looped the cable back on the X-15?
    Best Regards,
    Schuyler