I am trying to enable FlexCAN bus 1 and 2 on iMX6QP based custom hardware.
The two CAN buses are connected from iMX6 as below
GPIO_7 : CAN-TX1
GPIO_8 : CAN-RX1
GPIO-4-5 : CAN-STBY1
KEY_COL4 : CAN-TX2
KEY_ROW4 : CAN-RX2
GPIO-6-10 : CAN-STBY2
The device tree is defined as below:
arch/arm/boot/dts/imx6qdl.dtsi
================================
/ {
aliases {
flexcan0 = &flexcan1;
flexcan1 = &flexcan2;
gpio0 = &gpio1;
...
...
soc {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
interrupt-parent = <&intc>;
ranges;
caam_sm: caam-sm@00100000 {
compatible = "fsl,imx6q-caam-sm";
reg = <0x00100000 0x3fff>;
};
flexcan1: can@02090000 {
compatible = "fsl,imx6q-flexcan";
reg = <0x02090000 0x4000>;
interrupts = <0 110 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_CAN1_IPG>,
<&clks IMX6QDL_CLK_CAN1_SERIAL>;
clock-names = "ipg", "per";
stop-mode = <&gpr 0x34 28 0x10 17>;
status = "enabled";
};
flexcan2: can@02094000 {
compatible = "fsl,imx6q-flexcan";
reg = <0x02094000 0x4000>;
interrupts = <0 111 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_CAN2_IPG>,
<&clks IMX6QDL_CLK_CAN2_SERIAL>;
clock-names = "ipg", "per";
stop-mode = <&gpr 0x34 29 0x10 18>;
status = "enabled";
};
arch/arm/boot/dts/imx6q.dtsi
=====================
&flexcan1 {
pinctrl_flexcan1_1: flexcan1grp {
fsl,pins = <
MX6QDL_PAD_GPIO_7__FLEXCAN1_TX 0x1b0b0
MX6QDL_PAD_GPIO_8__FLEXCAN1_RX 0x1b0b0
>;
};
};
&flexcan2 {
pinctrl_flexcan2_1: flexcan2grp {
fsl,pins = <
MX6QDL_PAD_KEY_COL4__FLEXCAN2_TX 0x1b0b0
MX6QDL_PAD_KEY_ROW4__FLEXCAN2_RX 0x1b0b0
>;
};
};
arch/arm/boot/dts/imx6q-sabresd.dts
===================================
&flexcan1 {
status = "okay";
};
&flexcan2 {
status = "okay";
};
I observe CAN0 and CAN1 interfaces are up.
root@QPU2:~# ifconfig can0
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
root@QPU2:~# ifconfig can1
can1 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:143
I have connected both the CAN ports to KOMODO CAN analyser. When I send packets I do not see any packets sent out from either of the ports. I have run the internal loopback test which is successful.
ip link set can0 up type can bitrate 125000
ifconfig can0 up
ifconfig can0
cansend can0 100#1122334455667788
I suspect some issue with the device tree configuration. Appreciate if anyone could provide some pointers to the problem I am facing.
Thanks
Kishor
Hi Igor,
The issue is resolved, It turns out to be the pinctrls are not placed inside the iomuxc node in dtsi file.
Thanks you.
Kishor
Hi kishor
Can U share your dtsi file ?
my flexcan on MCIMX6Q-SDB RevC4 doesn't work, what should I do now?
---------------------
U-Boot 2014.04-08637-gaffa032 (Dec 01 2016 - 12:25:25)
CPU: Freescale i.MX6Q rev1.2 at 792 MHz
CPU: Temperature 22 C, calibration data: 0x5a04f57d#
Reset cause: POR
Board: MX6-SabreSD
-----------------------------
Linux version 3.10.17 (root@localhost-desktop) (gcc version 4.8.3 20140401 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2014.04 - Linaro GCC 4.8-2014.04) ) #12 SMP PREEMPT Mon Oct 24 11:34:41 CST 2016
---------------------------------------
[/] # dmesg |grep can
pci_bus 0000:00: scanning bus
pci 0000:00:00.0: scanning [bus 01-01] behind bridge, pass 0
pci 0000:00:00.0: scanning [bus 00-00] behind bridge, pass 1
pci_bus 0000:01: scanning bus
pci_bus 0000:01: bus scan returning with max=01
pci_bus 0000:00: bus scan returning with max=01
ahci: SSS flag set, parallel bus scan disabled
flexcan 2090000.can: device registered (reg_base=c0a68000, irq=142)
can: controller area network core (rev 20120528 abi 9)
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
[/] # /bin/ip link set can0 up type can bitrate 5000
flexcan 2090000.can can0: writing ctrl=0xf93e2007
[/] # ifconfig can0
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
[/] #
[/] # /bin/ip -s -d link show can0
2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
link/can
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 5000 sample-point 0.708
tq 8333 prop-seg 8 phase-seg1 8 phase-seg2 7 sjw 1
flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
clock 30000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0
RX: bytes packets errors dropped overrun mcast
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
[/] # /bin/ip -s -d link show can0
2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
link/can
can state ERROR-WARNING (berr-counter tx 0 rx 129) restart-ms 0
bitrate 5000 sample-point 0.708
tq 8333 prop-seg 8 phase-seg1 8 phase-seg2 7 sjw 1
flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
clock 30000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 1 0 0
RX: bytes packets errors dropped overrun mcast
8 1 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
[/] # /opt/imx6/app/can/cansend can0 100#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
[/] #
[/] #
[/] # /bin/ip -s -d link show can0
2: can0: <NO-CARRIER,NOARP,UP,ECHO> mtu 16 qdisc pfifo_fast state DOWN qlen 10
link/can
can state BUS-OFF (berr-counter tx 0 rx 0) restart-ms 0
bitrate 5000 sample-point 0.708
tq 8333 prop-seg 8 phase-seg1 8 phase-seg2 7 sjw 1
flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
clock 30000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 1 1 1
RX: bytes packets errors dropped overrun mcast
24 3 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
[/] #
--------------------debugfs info-----------------------
9 mount -t debugfs none /sys/kernel/debug/
10 cd /sys/kernel/debug/
11 ll
12 cd pinctrl/
13 ll
14 cd 20e0000.iomuxc/
15 ll
16 cat pinconf-pins
17 cat pinmux-pins
18 cat pinmux-functions
19 cat pins
20 cat pingroups
21 cat pinconf-groups
22 cat pinconf-config
23 cat gpio-ranges
pin 149 (MX6Q_PAD_GPIO_19):0x1b0b0
pin 144 (MX6Q_PAD_GPIO_7): 2090000.can (GPIO UNCLAIMED) function flexcan1 group flexcan1grp
pin 145 (MX6Q_PAD_GPIO_8): 2090000.can (GPIO UNCLAIMED) function flexcan1 group flexcan1grp
pin 149 (MX6Q_PAD_GPIO_19): 2090000.can (GPIO UNCLAIMED) function flexcan1 group flexcan1grp
function: flexcan1, groups = [ flexcan1grp ]
pin 144 (MX6Q_PAD_GPIO_7) 20e0000.iomuxc
pin 145 (MX6Q_PAD_GPIO_8) 20e0000.iomuxc
pin 149 (MX6Q_PAD_GPIO_19) 20e0000.iomuxc
group: flexcan1grp
pin 144 (MX6Q_PAD_GPIO_7)
pin 145 (MX6Q_PAD_GPIO_8)
pin 149 (MX6Q_PAD_GPIO_19)
Finally, we found is that the chip TJA1040T is not working properly.
Flexcan works well after we use SN65HVD233
thx, kishorr
I have tested internal loopback and works. Right now I have connected the CAN ports to KOMODO unit.
what is about external loopback, is it working.
Thanks igor.
I have updated the device tree files. But still not able to send any packets on can0 or can1 interfaces.
Just providing the device tree info for reference:
arch/arm/boot/dts/imx6q.dtsi:
&flexcan1 {
pinctrl_flexcan1_1: flexcan1grp-1 {
fsl,pins = <
MX6QDL_PAD_GPIO_7__FLEXCAN1_TX 0x1b0b0
MX6QDL_PAD_GPIO_8__FLEXCAN1_RX 0x1b0b0
MX6QDL_PAD_GPIO_19__GPIO4_IO05 0x1b0b0
>;
};
};
&flexcan2 {
pinctrl_flexcan2_1: flexcan2grp-2 {
fsl,pins = <
MX6QDL_PAD_KEY_COL4__FLEXCAN2_TX 0x1b0b0
MX6QDL_PAD_KEY_ROW4__FLEXCAN2_RX 0x1b0b0
MX6QDL_PAD_NAND_RB0__GPIO6_IO10 0x1b0b0
>;
};
arch/arm/boot/dts/imx6qdl.dtsi:
flexcan1: can@02090000 {
compatible = "fsl,imx6q-flexcan";
reg = <0x02090000 0x4000>;
interrupts = <0 110 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_CAN1_IPG>,
<&clks IMX6QDL_CLK_CAN1_SERIAL>;
clock-names = "ipg", "per";
stop-mode = <&gpr 0x34 28 0x10 17>;
status = "disabled";
};
flexcan2: can@02094000 {
compatible = "fsl,imx6q-flexcan";
reg = <0x02094000 0x4000>;
interrupts = <0 111 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX6QDL_CLK_CAN2_IPG>,
<&clks IMX6QDL_CLK_CAN2_SERIAL>;
clock-names = "ipg", "per";
stop-mode = <&gpr 0x34 29 0x10 18>;
status = "disabled";
};
arch/arm/boot/dts/imx6q-sabresd.dts
&flexcan1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan1_1>;
trx-stby-gpio = <&gpio4 5 GPIO_ACTIVE_LOW>;
status = "okay";
};
&flexcan2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flexcan2_1>;
trx-stby-gpio = <&gpio6 10 GPIO_ACTIVE_LOW>;
status = "okay";
};
&fec {
status = "disabled";
};
When I send a packet using cansend utility I see debug messages from flexcan_start_xmit
but flexcan_irq is not getting triggered.
I see below messages in the kernel initialization:
2090000.can supply xceiver not found, using dummy regulator
2094000.can supply xceiver not found, using dummy regulator
we are using 33901 Can Tranceiver.
root@U2:~# 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
can1 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:143
after sending 10 packets i see the below message
root@U2:~# cansend can0 100#1122334455667788
write: No buffer space available
Any idea whats going on.
Thanks
Kishor
Hi Kishor
is it working with loopback test, as without connection can to
some another can, it will not work (it will consider line as busy).
Best regards
igor
Hi Kishor
can is used on sabre ai board and one can check imx6qp-sabreauto-flexcan1.dts, imx6qdl.dtsi settings:
http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git/tree/arch/arm/boot/dts/imx6qdl.dtsi?id=rel_i...
http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git/tree/arch/arm/boot/dts/imx6qp-sabreauto-flex...
test details are described in imx-test (folder ..test/can)
www.nxp.com/lgfiles/NMG/MAD/YOCTO/imx-test-5.7.tar.gz
Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------