Specify Linux CAN interface instance number

After enabling two MCP2517FD CAN interfaces on two different SPIs on my Verdin I faced another problem.
ip a lists two CAN interfaces:

4: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10
5: can1: <NOARP,ECHO> mtu 16 qdisc noop state DOWN group default qlen 10

Linux autoenumerates the interfaces, sometimes the can0 interface denotes ecspi2 CAN interface and sometimes ecspi3. Is it possible for user to manually enumerate CAN interfaces ?

@Edward suggested to use aliase in order to avoid Linux autoenumeration. I tried this:

aliases {
       /* ecspi2 CAN interface */
		can1 = &can3;
       /* ecspi3 CAN interface */
		can0 = &can1;

But after rebooting Linux still autoenumerates CAN interfaces. Is there a way for me to manually reference ecspi3 as can0 and ecspi2 as can1 (or can5/6/7…) ?

P.S. It seemed like new problem so I opened new thread.

@gauravks did this for us, I think by setting their names in the devicetree. Then they should be fixed.

It seems I was wrong about it. Looks like CAN interface ordering is not supported in kernel. Somehow it works for i2c or serial…


Greetings @spasoye,

If device tree aliases don’t work, then perhaps we can try to implement a udev rule.

I found this post on the community that may help: How to fix the interface name of CAN on Colibri iMX6ULL - Technical Support - Toradex Community

Perhaps you can create a similar rule as what is show in this post. See if this lets you associate a can interface with a specific ecspi interface.

Best Regards,