Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - CAN on i.MX6Q SABRE Lite: (5 Items)
   
CAN on i.MX6Q SABRE Lite  
Hi,

I'm trying to get the CAN interface to work on the i.MX6Q SABRE Lite from Boundary Devices.

Should I be able to do it using the Freescale i.MX6Q Sabre Lite Board BSP?

First of all, according to the user guide of this BSP, the CAN driver is named dev-can-mx6x, but the BSP only has 
something called dev-can-mx35 (are these compatible?).

In addition, this driver does not have execution permissions on the resulting default image. After I fixed that, the 
driver crashes:

Process 790564 (dev-can-mx35) terminated SIGBUS code=3 fltno=5 ip=0106d0f8(/usr/lib/ldqnx.so.2@__generic_memset+0x58) 
mapaddr=0006d0f8. ref=28001080
Bus error (core dumped)

Which seems to be from here:

// Clear the mailbox memory if there is no mini-driver
	if(!(devinit->flags & INIT_FLAGS_MDRIVER_INIT) || mdriver_intr == -1)
		memset(devinfo->canmsg, 0, RINGO_CAN_MEM_SIZE_FLEXCAN);

(from driver.c)

Can anyone please help?

Thanks!


Re: CAN on i.MX6Q SABRE Lite  
Hi Yaron,

I assume that you are using the 6.6 BSP - yes, that is an issue that has been remedied but hasn't been formally released
 yet.

To get you unblocked, you can change driver.c  line 125 from:

// Get I/O privity	     
ThreadCtl( _NTO_TCTL_IO, 0 );

To:
// Get I/O privity - new flags introduced in 6.6 must be set up to access the CAN register space
ThreadCtl( PRIVITY_FLAGS, 0 );

And add to can-mx header file the following macro:

/*
 * Note: ARM platforms running >= 6.6.0 need to execute at a lower privilege level
 *       CAN registers are otherwise inaccessible (bus error).
 */
#if defined(__ARM__) && defined(_NTO_TCTL_IO_PRIV)
#define PRIVITY_FLAGS    _NTO_TCTL_IO_PRIV
#else
#define PRIVITY_FLAGS    _NTO_TCTL_IO
#endif

Regards,
Andre 
Re: CAN on i.MX6Q SABRE Lite  
Thanks this fixed the crash and the driver works in the loop back mode.

However I"m unable to make it work on a real CAN bus (shared between the board and a Kvaser device).

I suspect there is something wrong in the bit timing calculation (I'm getting bus errors when I try to send out packets 
on the bus using the Kvaser). Is it possible something needs to be changed there as well?

Thanks
Re: CAN on i.MX6Q SABRE Lite  
Hi Yaron,

Try changing the following bit rate settings in hardware/can/mx35/driver.c and adding the CSCMR2 register initialization
:

/* Bitrate table for PLL3 30 MHz, desired Sample Point at 87.5% */
#define CAN_PRESDIV_50K_PLL         0x55
#define CAN_PRESDIV_125K_PLL        0x21
#define CAN_PRESDIV_250K_PLL        0x10
#define CAN_PRESDIV_500K_PLL        0x08

...

void device_init(int argc, char *argv[])
{
    int                      opt, hwi_can0, hwi_can1;
    int                      numcan = 0;
    char                    *cp;
    CANDEV_HWINFO            can0, can1;
+    unsigned long           *ccm_cscmr2_reg_ptr;
...
    hwi_can0 = hwi_can1 = -1;
    hwi_can0 = get_can_hwinfo(&can0, 0);
    hwi_can1 = get_can_hwinfo(&can1, 1);

+    // Set up can_clk divider to 1 for better bit rate resolution
+   ccm_cscmr2_reg_ptr = mmap_device_io(4, 0x020C4020);
+   if(ccm_cscmr2_reg_ptr == MAP_DEVICE_FAILED)
+    {
+        perror("CAN REG: Can't map CCM_CSCMR2 register");
+        exit(EXIT_FAILURE);
+    } else {
+        *ccm_cscmr2_reg_ptr = 0x02B92F02;
+    }
...

Regards,

Andre 
Re: CAN on i.MX6Q SABRE Lite  
Hi Yaron,
 I am running into the same problem. Could you please share your fixes?
Thanks
Kelvin