How to configure flexCAN2 with alternative pins

Goodmorning,
I have some troubles with the configuration of CAN2 peripheral on imx6ull.
I need to use not standard pins (pin 32 as CAN2_TX and pin 34 as CAN2_RX). To do that I modified my device tree as following:

  1. disabled ‘uart2’ which normally uses pins 32 and 34;
  2. enabled can2 peripheral;
  3. redeclared pinctrl_flexcan2 node to use pin32 and pin34 as new TX and RX pins.

Part of my .dts file:

/* pins 32 and 34 are needed for can1 */
&uart2 {
	status = "disabled";
};

&can2 {
    pinctrl-0 = <&pinctrl_flexcan2>;
    status = "okay";
};

&iomuxc {
      imx6ull-colibri {
       ... (other configurations) ...

	pinctrl_flexcan2: flexcan2-grp {
            fsl,pins = <
		MX6UL_PAD_UART2_CTS_B__FLEXCAN2_TX	0x1b020	/* SODIMM 32 */ 
		MX6UL_PAD_UART2_RTS_B__FLEXCAN2_RX	0x1b020	/* SODIMM 34 */
             >;
        };
}

I see the peripherals into my device if I check it with ‘ifconfig’, but nothing pass on communication line. Only CAN1 works. CAN2 port seems not able to read messages and blocks the line.

Am I missing something in DT configuration?

I work with:

  • imx6ull trdx module;
  • colibri evaluation v3 board;
  • our custom carrier board;
  • Linux BSP 5.6
  • Kernel 5.4-2.3

Thanks.

If you see device with ifconfig -a, then your DT settings should be OK.
Did you configure bit timing with: ?
ip link set can2 type can bitrate XXXXXX

Without connecting any external device, perhaps just CAN transceiver and nothing else; after you up interface, make sure both TX and RX stay high. Then try sending any message like this
cansend can2 123#
TX should start toggling (RX as well, driven by transceiver) with minimum pulse width T matching bitrate (F=1/T), you have set.

ifconfig -a

yes a see both can0 and can1 device.

Then manually I set can1 down, I change bitrate, and then up again. Just to be sure.

ip link set can1 down
ip link set can1 type can bitrate 125000
ip link set can1 up

They I try to send a messagge with PCANview (I have external usb-can device), but messages arrives only on can0. Moreover, RX led of can1 remains off while RX led of can0 blinks. Same thing if I try to send messages from colibri using cansend.

this is our schematic. This is for CAN2 (so can1 device into SoM), and circuit is equal for CAN1 (so can0 device into SoM).

make sure both TX and RX stay high.

Yes, I measure 3.3V on both sides of the leds.

And what happens when you cansend? Error message? Any activity on TXD? CAN analyzer should be listen only or disconnected. What can state reports ip -details link show can2 type can?

Here my quick test mods:

&pinctrl_flexcan2 {
	fsl,pins = <
		MX6UL_PAD_UART2_CTS_B__FLEXCAN2_TX	0x1b020	/* SODIMM 32 */ 
		MX6UL_PAD_UART2_RTS_B__FLEXCAN2_RX	0x1b020	/* SODIMM 34 */	>;
};


&can2 {
	status = "okay";
};

And I see activity on SODIMM 32 (until it goes bus off due to lack of other nodes).

ip link set can1 type can bitrate 1000000 restart-ms 200
ip link set can1 up
cansend can1 123#

When I send a message with

cansend can1 123#

nothing happens. Or better, command seems working, but I do not receive anything on CANanalyzer and nothing on can0 (I shorted can0 and can1 to write and read).

can0 and can1 have these details:

DL-linux:/home/root# ip -details link show can0 type can
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT groupdefault qlen 1000
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 125000 sample-point 0.875
          tq 500 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
          flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
          clock 30000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 5535
DL-linux:/home/root# ip -details link show can1 type can
4: can1: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT groupdefault qlen 1000
    link/can  promiscuity 0 minmtu 0 maxmtu 0
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 125000 sample-point 0.875
          tq 500 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
          flexcan: tseg1 4..16 tseg2 2..8 sjw 1..4 brp 1..256 brp-inc 1
          clock 30000000 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 5535

And I see activity on SODIMM 32 (until it goes bus off due to lack of other nodes).

ip link set can1 type can bitrate 1000000 restart-ms 200
ip link set can1 up
cansend can1 123#

I don’t see any activity. Because we have leds on colibri pin side, I should see them blinking when I send something, but I see everything off.

Another thing is what I see in kernel message. But same error appears on both can0 and can1, but can0 works. So I can’t understand what it is.

DL-linux:/home/root# dmesg | grep flexcan
[    7.107285] flexcan 2090000.flexcan: 2090000.flexcan supply xceiver not found, using dummy regulator
[    7.149638] flexcan 2094000.flexcan: 2094000.flexcan supply xceiver not found, using dummy regulator

LEDs and CAN analyzer are too slow to detect this activity. Use scope instead.
The fact is CAN2 on Colibri IMX6ULL SODIMM pins 32+34 is working well. Are you sure it is not your PCB issue? Did you try with other SOM instance, perhaps this one has damaged pads?

With LEDs and PCANView I can see when can0 sends a message. I read perfectly message 123#.
I tried now with another SoM but nothing. Same result.

Maybe I have problem on the external CAN chip. I want to try using the module on Colibri Evaluation board (if possible) and an external chip which I am already using for CAN communication. I will be back with results.

As shows your circuit, LEDs are on SOM side. Perhaps those wires don’t reach SOM connector or are connected to wrong pins.

ok, problem I think is on CAN chip we received. I tried with Evaluation Board and it works perfectly.
I don’t know why I didn’t test immediately with it sorry.

We will replace the component and check again.
Thank you for the support.