Flexcan Communication issue with IMX-53 SABRE AI Rev B Board

Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flexcan Communication issue with IMX-53 SABRE AI Rev B Board

Contributor I


While transmitting CAN message using FLEXCANdriver the CAN ACK error is
occurring frequently. The error (as obtained from the print in the error handler) is given below

_______________ ENTEREDflexcan_err_handler__________________

____flexcan_err_handler_after____raw_readl__esr  =2152__

____flexcan_err_handler_after__raw_writel__esr  =2152__

____flexcan_err_handler___skb =df4e0f00__

_flexcan_err_handle >>>>> if(esr & __ESR_ACK_ERR)__

_flexcan_err_handle >>>>>if(__ECR_RX_ERR_COUNTER(ecr) >=

_______________ EXITflexcan_err_handler__________________

1.      The details of test  set up
a.      BoardName – IMX-53 SABRE AI Rev B
b.    Linuxkernel version of the BSP  -
c.      BSPversion - L2.6.35_11.03_ER_source_bundle
d.      CAN Test utility – IXXAT usb to can compact
e.    Installledcanutils and libsocketcan. The driver attributes are seen in/sys/devices/platform/FlexCAN.1/ and Flexcan0 (Ref: https://community.freescale.com/docs/DOC-1437)

2.      Steps followed after the system is booted (The CAN2 header in the Evaluation board is connected with CAN analyzer IXXAT USB to CAN compact)
a.      Tried with baud rate of 1Mbps with the setting done under /sys/devices/platform/FlexCAN.1
b.      (
br_Propseg =4; br_Pseg2=2; br_Pseg1=1;br_rjw =1 ; br_presdiv =3, br_clksrc = osc(CAN1 clk 24Mhz) (Set by "ech0 val >br_xyz")
c.      Ifconfig CAN1 up
d.      cansend can1 -i0x100 11 22 33 44

3.      Using the oscilloscope verified the following

a.      CAN_STDBY and CAN_EN of MC33902 CAN transceiver both high
b.      While transmitting there is activity in the CAN H and CAN L pin of MC33902transceiver.
c.      Bus activity in the CAN2_TXD and CAN2_RXD of the controller lines

Request to help in this to resolve  the issue. Thanks

Tony Thomas

Tags (3)
0 Kudos
4 Replies

Specialist II

> br_clksrc=osc

That only works on an i.MX35 board, and not on an i.MX53.

The driver happily assumes it is running on an i.MX35, and selects either the 66.5MHz bus clock or the 24.576MHz oscillator. Good luck trying to divide 24.576 down to any normal CAN baud rate with the required fractional-percent baud rate accuracy though.

On an i.MX53, the clock is - tricky. In the Reference Manual, bit FLEXCANx_CTRL[13] is called "-", marked "Reserved", but confusingly says it selects the 66.5 or 24.576 MHz clocks. It doesn't. That section was pasted in out of the i.MX35 manual and not properly edited. The Flexcan baud rate clock selection is handled in the i.MX53 by CCM_CSCMR2[CAN_CLK_SEL].

That, as you found, is set up by getting the platform to select the 24MHz "lp_apm" clock.

There are plenty of other problems with the documentation and the driver.

The "mx53_linux.pdf" document states:

bitrate configures the bitrate. Currenlty, [sic] this parameter only shows the bitrate that is supported. To ensure bitrate exactly, set the individual parameters:

The driver in drivers/net/can/flexcan/dev.c has the comment:

static void flexcan_set_bitrate(struct flexcan_device *flexcan, int bitrate) {      /* TODO:: implement in future       * based on the bitrate to get the timing of       * presdiv, pseg1, pseg2, propseg       */

The following commit added all the code to set the bit rate, but then left the above comment in the code!

Author: William Lai <b04597@freescale.com>  2010-04-21 12:20:44 Committer: William Lai <b04597@freescale.com>  2010-04-22 17:10:20 Parent: e783aee7a0b858727595a1416e901dee08e96bc2 (ENGR00122399-2 MX53 CAN: MBM word access only) Branches: remotes/origin/remote/freescale/imx_2.6.31, remotes/origin/remote/freescale/imx_2.6.31_10.05.02,

remotes/origin/remote/freescale/imx_2.6.31_10.07.11, remotes/origin/remote/freescale/imx_2.6.31_10.08.01 Follows: rel_imx_2.6.31_10.03.00 Precedes: rel-imx-2.6.31-10.08.00, rel_imx_2.6.31_10.05.02, rel_imx_2.6.31_10.07.11

    ENGR00122723 CAN: Enable the adaptive bitrate setting     Enable the adaptive bitrate setting, according to the clock rate.     And the bitrate can be changed by the proc file.

The above change was made in 2.6.31, earlier and 5 months before "mx53_linux.pdf" stated that didn't support setting the bitrate when it does.

There's a bug in the driver in its reporting of the RJW as well. Here's the setting and reporting code. Spot the difference:

static ssize_t flexcan_set_attr(struct device *dev,                 struct device_attribute *attr, const char *buf,                 size_t count) {     ...     case FLEXCAN_ATTR_BR_RJW:             flexcan->br_rjw = tmp - 1;     case FLEXCAN_ATTR_BR_PROPSEG:             flexcan->br_propseg = tmp - 1;     case FLEXCAN_ATTR_BR_PSEG1:             flexcan->br_pseg1 = tmp - 1;     case FLEXCAN_ATTR_BR_PSEG2:             flexcan->br_pseg2 = tmp - 1; static ssize_t flexcan_show_attr(struct device *dev,                  struct device_attribute *attr, char *buf) {     ...     case FLEXCAN_ATTR_BR_PRESDIV:         return sprintf(buf, "%d\n", flexcan->br_presdiv + 1);     case FLEXCAN_ATTR_BR_RJW:         return sprintf(buf, "%d\n", flexcan->br_rjw);     case FLEXCAN_ATTR_BR_PROPSEG:         return sprintf(buf, "%d\n", flexcan->br_propseg + 1);     case FLEXCAN_ATTR_BR_PSEG1:         return sprintf(buf, "%d\n", flexcan->br_pseg1 + 1);     case FLEXCAN_ATTR_BR_PSEG2:         return sprintf(buf, "%d\n", flexcan->br_pseg2 + 1);

It sets the RJW properly, but forgets to add one to the field when printing it.


0 Kudos

Contributor I

Dear All,

Checked the IO Mux control and Pad control register settings in mx53_ard.c (\arch\arm\mach-mx5) and iomux-mx53.c (\arch\arm\plat-mxc\include\mach). The settings are performed correctly for CAN TX, CAN RX pins.

Currently I am checking the CAN bus with vector CANalyzer

There is a bus activity in the can TX pins while initiating the transmission using

ifconfig can1 up

cansend can1 -i0x100 11 22 33 44

However no activity is availble at the CANH and CANL lines of the MC33902 transceiver.

The STBY and EN pin of the MC33902 trasceiver is probed and is indicating high.

In my BSP source, I could not find the Flexcan.c source file. The drv.c file in the "\drivers\net\can\flexcan" does the driver initialisation.

1. Is there a patch availabe for Flexcan for the BSP I am using?

Any input to resolve this issue is highly helpful



Tony Thomas

0 Kudos

Contributor I

Dear All,

After few days the issue was resolved. The following steps are followed to solve the issue


  1. 1.Go to location
  1. Edit file
  2. Update

struct flexcan_platform_data flexcan0_data = {
.core_reg = NULL, .io_reg = NULL,  + .root_clk_id = "lp_apm",       
.xcvr_enable = flexcan_xcvr_enable,
.br_clksrc = 1,
.br_rjw = 2,

  1. Update

struct flexcan_platform_data flexcan1_data = {
.core_reg = NULL,
.io_reg = NULL,

+ .root_clk_id = "lp_apm",       
.xcvr_enable = flexcan_xcvr_enable,
.br_clksrc = 1,
.br_rjw = 2,




0 Kudos

Contributor II

Hi Tony,

I’m the administrator of the i.MX community. I moved your question out to the message boards so the experts can read and answer your question.

I hope this helps!

Jodi Paul

0 Kudos