Can-Bus

Discussion in 'Kernels' started by yesombre, Feb 26, 2014.

  1. yesombre

    yesombre New Member

    Joined:
    Nov 20, 2013
    Messages:
    2
    Likes Received:
    0
    Hello Udoo Community,

    I'm currently trying to get the Can Bus working on the Udoo Quad. Has someone tried the same already?
    I have the current kernel sources from http://github.com/UDOOboard/Kernel_Unico and changed the following parts:

    arch/arm/mach-mx6/board-mx6_seco_UDOO.c:
    Line 140ff:
    Code:
    /******************* CAN *******************/
    #define MX6_SECO_UDOO_CAN1_STBY               IMX_GPIO_NR(1, 2)
    #define MX6_SECO_UDOO_CAN1_EN                 IMX_GPIO_NR(1, 4)
    
    Line 1078ff:
    Code:
    imx6q_add_flexcan0(&mx6q_sabrelite_flexcan0_pdata);
    
    arch/arm/mach-mx6/board-mx6qd_seco_UDOO.h
    Line 369ff:
    Code:
            //MX6Q_PAD_GPIO_7__GPIO_1_7,                                                            // can tx
                    MX6Q_PAD_GPIO_7__CAN1_TXCAN,
            //MX6Q_PAD_GPIO_8__GPIO_1_8,                                                            // can rx
                    MX6Q_PAD_GPIO_8__CAN1_RXCAN,
    
    Line471:
    Code:
            //MX6Q_PAD_GPIO_8__GPIO_MODE,
            //MX6Q_PAD_GPIO_7__GPIO_MODE,
    

    But probably these are not all changes necessary, as its not working.

    Greets and thanks for any help,
    yesombre
     
  2. yesombre

    yesombre New Member

    Joined:
    Nov 20, 2013
    Messages:
    2
    Likes Received:
    0
    Seems like its working now. Haven't tried actual communication, but the device is opening.

    Code:
    root@localhost:/home/udoo# ip link set can0 type can bitrate 125000
    root@localhost:/home/udoo# ipconfig can0 up
    root@localhost:/home/udoo# ifconfig
    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: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:142 
    ...
    
    I will keep you posted if can communication is really working.

    Greets,
    yesombre
     
  3. jbtatou

    jbtatou New Member

    Joined:
    Jun 19, 2014
    Messages:
    1
    Likes Received:
    0
    Hi, have you some result about can communication?

    greets,
    Jb
     
  4. lukas

    lukas New Member

    Joined:
    Aug 1, 2014
    Messages:
    4
    Likes Received:
    0
    Hey, I would also be really interested in information about it! Was there any progress or verification?
     
  5. chrta

    chrta New Member

    Joined:
    Aug 5, 2014
    Messages:
    4
    Likes Received:
    0
    Hello yesombre,

    thanks for your post. CAN is working fine with the your changes. Below is the complete diff i used. I do not use any enable or standby pin, only the RX and TX pins.

    When connecting the CAN-Phy, i discovered a mistake in the schematic pin labels. According to the datasheet (and the kernel sources), GPIO_8 is FLEXCAN1_RX, but in the UDOO schematic the signal is labeled CANTX_IMX. But GPIO_8 must be connected to the R (Receiver output) pin of the Phy. GPIO_7 (FLEXCAN1_TX, and in the schematic CANRX_IMX) must be connected to the D (Driver input) pin of the CAN-Phy.

    Additionally the according pins of the arduino mcu must be configured as input pins, so they do not interfere.

    I use the yocto image from https://github.com/rongals/meta-ronga-udoo and added the following packages:
    Code:
    IMAGE_INSTALL += " \
        canutils \
        iproute2 \
    "
    
    iproute2 is needed to get a ip executable that supports CAN, ip from busybox does not support it.

    Code:
    diff --git a/arch/arm/mach-mx6/board-mx6_seco_UDOO.c b/arch/arm/mach-mx6/board-mx6_seco_UDOO.c
    index 435a50d..942678a 100644
    --- a/arch/arm/mach-mx6/board-mx6_seco_UDOO.c
    +++ b/arch/arm/mach-mx6/board-mx6_seco_UDOO.c
    @@ -1060,7 +1060,7 @@ static void __init mx6_seco_UDOO_board_init(void)
     	imx_asrc_data.asrc_core_clk = clk_get(NULL, "asrc_clk");
     	imx_asrc_data.asrc_audio_clk = clk_get(NULL, "asrc_serial_clk");
     	imx6q_add_asrc(&imx_asrc_data);
    -      //  imx6q_add_flexcan0(&mx6q_sabrelite_flexcan0_pdata);
    +	imx6q_add_flexcan0(&mx6q_sabrelite_flexcan0_pdata);
     
     	/* release USB Hub reset */
     	gpio_set_value(MX6_UDOO_USB_HUB_RESET, 1);
    diff --git a/arch/arm/mach-mx6/board-mx6qd_seco_UDOO.h b/arch/arm/mach-mx6/board-mx6qd_seco_UDOO.h
    index bfd2c4b..9471b03 100644
    --- a/arch/arm/mach-mx6/board-mx6qd_seco_UDOO.h
    +++ b/arch/arm/mach-mx6/board-mx6qd_seco_UDOO.h
    @@ -366,10 +366,10 @@ static iomux_v3_cfg_t mx6qd_seco_UDOO_pads[] = {
     		// MX6Q_PAD_EIM_D24__UART3_TXD,  
     		// MX6Q_PAD_EIM_D24__ECSPI1_SS2,
     
    -	MX6Q_PAD_GPIO_7__GPIO_1_7,								// can tx
    -		// MX6Q_PAD_GPIO_7__CAN1_TXCAN,
    -	MX6Q_PAD_GPIO_8__GPIO_1_8,								// can rx
    -		// MX6Q_PAD_GPIO_8__CAN1_RXCAN,
    +	//MX6Q_PAD_GPIO_7__GPIO_1_7,								// can tx
    +		MX6Q_PAD_GPIO_7__CAN1_TXCAN,
    +	//MX6Q_PAD_GPIO_8__GPIO_1_8,								// can rx
    +		MX6Q_PAD_GPIO_8__CAN1_RXCAN,
     };
     
     static unsigned int mx6q_set_in_outputmode_low[] = {
    
    Regards,
    chrta
     
  6. xuio

    xuio New Member

    Joined:
    Nov 2, 2014
    Messages:
    2
    Likes Received:
    0
  7. modjo

    modjo Active Member

    Joined:
    Sep 29, 2014
    Messages:
    417
    Likes Received:
    127
    Great job ! It's very interesting to can use can on udoo ! But, what kind of PHY do you use ? Is-it possible for somebody to explain me how to modify the kernel to use it ? I never make this ...
     
  8. xuio

    xuio New Member

    Joined:
    Nov 2, 2014
    Messages:
    2
    Likes Received:
    0
    There are instructions on how to modify the kernel in this thread: can-bus-aka-flex-bus-t177.html
    I had no success compiling the kernel on the UDOO itself, so I used the freescale cross compiler toolchain from the downloads page.
    As transciever I am using the TI SN65HVD230D, note that the RX/TX lines are switched for the IMX6

    EDIT: I also have a ubuntu minimal image (14.04LTS) with CAN support available, I can upload it if someone is interested.
     
  9. sirrab

    sirrab UDOOer

    Joined:
    Jul 26, 2014
    Messages:
    264
    Likes Received:
    32
    I'd be interested in the general steps you took, to get a minimal Ubuntu 14.04LTS image up and running.
     
  10. serus

    serus New Member

    Joined:
    Nov 10, 2015
    Messages:
    1
    Likes Received:
    0
    can u post working image please ?

    i compile my own image with can support but nothing going out from board (tested by osciloscope)
     

Share This Page