Mux flexcan1 to other pins with overlay

I am using the Colibri imx7d with the Iris carrier board rev2. Since the carrier board does not bring out the existing flexcan1 pins which is mapped to SODIMM 63 and 55, I want to remap it to pins available on the Iris board extension header. I identified SODIMM 90 and 92 as suitable pins for this application.

However, when I tried to build the following dts file, I am getting a syntax error and I cannot figure out why this is the case. The code is technically identical to some of the samples posted in the forum here. Tell me I am not blind.


/ {
        compatible = "toradex,colibri-imx7d-emmc-iris-v2",

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

&iomuxc {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_gpio1 &pinctrl_gpio2 &pinctrl_gpio3>;

        pinctrl_flexcan1: flexcan1-grp { /* Mux pin to use I2C1 pads */
                fsl,pins = <
                        MX7D_PAD_I2C1_SCL__FLEXCAN1_RX  0x2 /* SODIMM 90 */
                        MX7D_PAD_I2C1_SDA__FLEXCAN1_TX  0x2 /* SODIMM 92 */

Appreciate any input and insight. Thank you.

Includes are missing. Defines for pads are specified in imx7d-pinfunc.h

Instead of overwriting part of iomuxc with &iomuxc, you should overwrite only pinctrl_flexcan1

&pinctrl_flexcan1 { /* Mux pin to use I2C1 pads /
fsl,pins = <
SODIMM 92 */

With 0x2 here, are you assuming it is PAD MUX setting, which is 2 for CAN? No it is not MUX setting, it is pad control bits like pull up direction, strength, etc. See SW_PAD_CTL_PAD_I2C1_SCL SW PAD Control Register in iMX7 RM.

Thanks for the tip.

That seems to work and I was able to compile it. It seems to load without errors and the can driver is loaded. I can use cansend to send some packets out but I cannot seem to see anything on the scope.

Is there anything else I need to do? Do I need to disable the gpio that was used for the pin before it was reassigned to flexcan1? I am using one of the downstream images provided by the torizon care installer and just reassigning pins I need to the extension connector (X16) on the Iris carrier board.

  • Jerry

You need to verify your overlay really applies. Is it no CAN interface without overlay and CAN with it? That could be a sign overlay is applied. Don’t you see activity on default pins? Once new fsl,pins setting is applied, old pins should left in boot default state, which is usually GPIO. If old pins are toggling on cansend, then your overlay isn’t applied.

No activity? Do Tx/Rx idle high or low? Low (dominant) on Rx would block communications until something recessive’s it. While blocked you may run cansend up to, ehh, perhaps 10+ times until cansend starts complaining.

Hi Edward,

Thanks for that. I am quite sure that the overlay applied successfully because ip link did not show can0 without the overlay.

After trying what you said, I sent a CAN message more than 10+ times, perhaps even more than 20+ times and I finally captured some signal on my scope.

For flexcan2, I tried to do the same as I did for flexcan1.

&pinctrl_flexcan2 { /* Alternatively CAN2 /
fsl,pins = <
SODIMM 194 /
SODIMM 196 */

However, I see this in the boot message;

[ 5.662979] CAN device driver interface
[ 5.675849] flexcan 30a00000.can: 30a00000.can supply xceiver not found, using dummy regulator
[ 5.734348] imx7d-pinctrl 30330000.iomuxc: pin MX7D_PAD_GPIO1_IO14 already requested by 30330000.iomuxc; cannot claim for 30a10000.can
[ 5.750692] imx7d-pinctrl 30330000.iomuxc: pin-11 (30a10000.can) status -22
[ 5.759740] imx7d-pinctrl 30330000.iomuxc: could not request pin 11 (MX7D_PAD_GPIO1_IO14) from group flexcan2-grp on device 30330000.iomuxc
[ 5.776402] flexcan 30a10000.can: Error applying setting, reverse things back
[ 5.793185] sgtl5000 0-000a: sgtl5000 revision 0x11
[ 5.799771] flexcan: probe of 30a10000.can failed with error -22

It seems that the pins were already claimed by the main device tree. How do I fix this?

Thanks for all your guidance. I am still learning :slight_smile:

  • Jerry

Obviously you need to find device which claims that pin and disable that device or overwrite pad settings for that device so it doesn’t claims given pad any more.
Your &pinctrl_flexcan2 seems being not applied since &pinctrl_flexcan2 defaults using MX7D_PAD_GPIO1_IO14. Are you sure you don’t have more overlays which are applied for the same things?

linux-toradex/arch/arm/boot/dts$ grep MX7D_PAD_GPIO1_IO14  imx7-colibri*
imx7-colibri.dtsi:			MX7D_PAD_GPIO1_IO14__GPIO1_IO14		0x14 /* SODIMM 188 */
imx7-colibri.dtsi:			MX7D_PAD_GPIO1_IO14__FLEXCAN2_RX	0x79 /* SODIMM 188 */