i.MX6ULL CAN的使用问题

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

i.MX6ULL CAN的使用问题

5,625 Views
wuyixuan
Contributor II

硬件:i.MX6ull

软件:yocot_uboot_2016 + yocot_kernel_4.1.15   

NXP的工程师们,我在使用i.MX6ULL的CAN的时候遇到了很奇怪的问题。现在将问题的描述如下:

首先,要使用CAN接口,高版本内核需要先适配其设备树。

<1>imx6ull-14x14-xxx.dts

   &flexcan1 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_flexcan1>;
      xceiver-supply = <&reg_can_3v3>;
      status = "okay";
   };

   &flexcan2 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_flexcan2>;
      xceiver-supply = <&reg_can_3v3>;
      status = "okay";
   };

   

   pinctrl_flexcan1: flexcan1grp{
      fsl,pins = <
         MX6UL_PAD_UART3_RTS_B__FLEXCAN1_RX 0x1b020
         MX6UL_PAD_UART3_CTS_B__FLEXCAN1_TX 0x1b020
      >;
   };

   pinctrl_flexcan2: flexcan2grp{
      fsl,pins = <
         MX6UL_PAD_UART2_RTS_B__FLEXCAN2_RX 0x1b020
         MX6UL_PAD_UART2_CTS_B__FLEXCAN2_TX 0x1b020
      >;
   };

<2>imx6ull.dtsi这个文件不用修改

   flexcan1: can@02090000 {
      compatible = "fsl,imx6ul-flexcan", "fsl,imx6q-flexcan";
      reg = <0x02090000 0x4000>;
      interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
      clocks = <&clks IMX6UL_CLK_CAN1_IPG>,
         <&clks IMX6UL_CLK_CAN1_SERIAL>;
      clock-names = "ipg", "per";
      stop-mode = <&gpr 0x10 1 0x10 17>;
      status = "disabled";
   };

   flexcan2: can@02094000 {
      compatible = "fsl,imx6ul-flexcan", "fsl,imx6q-flexcan";
      reg = <0x02094000 0x4000>;
      interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
      clocks = <&clks IMX6UL_CLK_CAN2_IPG>,
         <&clks IMX6UL_CLK_CAN2_SERIAL>;
      clock-names = "ipg", "per";
      stop-mode = <&gpr 0x10 2 0x10 18>;
      status = "disabled";
   };

<3>驱动程序为flexcan.c,此处无需任何改动

======================================

>>> 编译生成uboot.imx、zImage、dtb

>>> 烧写成功,系统启动 !!!

======================================

系统启动后,通过ifconfig -a查看can0、can1已经存在,只是没有启动

pastedImage_3.png

pastedImage_4.png

按照“i.MX_Linux_Reference_Manual”中的指导,执行以下命令:

ip link set can0 down

ip link set can0 up type can bitrate 500000

pastedImage_5.png

pastedImage_6.png

can1也是一样的操作,至此can0、can1 all becomes ready !!!

下面硬件连接can0与can1,HH相连,LL相连。执行以下命令:

candump can1 &

cansend can0 123#1122334455667788

问题来了,为什么can1口接收不到任何数据?我用示波器测量了cpu直接出来的pins,也没有任何波形。

pastedImage_7.png

尝试了各种角度,依旧没有找到问题的原因。

a.怀疑pin脚功能被定义错误,仔细检查了uboot和kernel中并没有出现复用其他功能的情况,读取寄存器的值也是正常的      0x20

b.尝试替换官方evk的zImage和dtb后,上述问题依然存在

c.can0发送,can1接收的过程中,ifconfig观察RX、TX的数据变化,遇到了不正常的现象

开始发送接收前:

pastedImage_9.png

开始后:

pastedImage_10.png

需要的话,附件为我的内核config文件和dts文件,请查阅。

请NXP的FAE or AE ,帮忙解决下这个问题,谢谢。

Labels (3)
Tags (1)
9 Replies

4,854 Views
almaz1c
Contributor III

Any idea how to make following commands:

ip link set can0 down

ip link set can0 up type can bitrate 500000

ip link set can1 down

ip link set can1 up type can bitrate 500000

to be executed automatically on boot of device?

Tried to place it in 02_network init script but it throws me:

Cannot find device "can0"
Cannot find device "can0"
Cannot find device "can1"
Cannot find device "can1"

0 Kudos

4,892 Views
yecong888
Contributor I

我也遇到一样的问题,请问问题解决了吗?

0 Kudos

4,892 Views
0609ccj
Contributor I

解决了,我的是CAN收发器匹配电阻没有焊接,焊接上就好了

0 Kudos

4,892 Views
0609ccj
Contributor I

你的问题解决了吗?我和你遇到差不多的现象,我用的是imx6q芯片,设置bitrate 500000不能正常收发数据,通过ifconfig查看没有数据发送统计,但是设置成125000可以正常收发数据.一直解决不了

0 Kudos

4,892 Views
wuyixuan
Contributor II

还未解决,你有什么进展吗

0 Kudos

4,892 Views
wuyixuan
Contributor II

Hi jimmychan ,

     我已经试过了将flexcan1和flexcan2的4个pin分别作为GPIO来操控,如下

MX6UL_PAD_UART3_RTS_B__FLEXCAN1_RX   ===》   MX6UL_PAD_UART3_RTS_B__GPIO1_IO27

MX6UL_PAD_UART3_CTS_B__FLEXCAN1_TX   ===》   MX6UL_PAD_UART3_CTS_B__GPIO1_IO26

MX6UL_PAD_UART2_RTS_B__FLEXCAN2_RX   ===》   MX6UL_PAD_UART2_RTS_B__GPIO1_IO23

MX6UL_PAD_UART2_CTS_B__FLEXCAN2_TX   ===》   MX6UL_PAD_UART2_CTS_B__GPIO1_IO22

分别输出高、输出低,来回切换,测得的电压均正常变化,所控制的led亮灭均正常。

L4.1.15是i.mx6ull官方SDK中推荐使用的版本,您的意思是让我再升级一下SDK吗?请问有哪个版本推荐的吗?

0 Kudos

4,892 Views
jimmychan
NXP TechSupport
NXP TechSupport

L4.19.35_1.1.0 support i.MX6ULL. You can download the document from here

Linux 4.19.35_1.1.0 Documentation

0 Kudos

4,892 Views
wuyixuan
Contributor II

Hi jimmychan ,

    因为涉及到了太多改动,暂时不想迁移版本,需要在L4.1.15解决这个问题。目前问题的跟进进度还是之前描述的那些,另外确定了硬件连接,确定没有问题。还有什么手段方法分析定位问题吗?谢谢。

0 Kudos

4,892 Views
jimmychan
NXP TechSupport
NXP TechSupport

I don't see any problem on your setup.

You may double check the hardware pins are good connected.

Have you try to configure the CAN pins to GPIO? and then output 1 or 0 to see the pins are output proper.

L4.1.15 is an old BSP version. Have you try a newer version of BSP?

0 Kudos