Switching mmclbk0 and mmcblk1 in when using mainline linux

I’m trying to get my Colibri imx6 system running on the mainline kernel (as suggested here: Linux 4.1 Support for Colibri iMX6 - Toradex Community ). One problem I’m running into is that the enumeration of the block devices change from what they are on the Toradex branch, the mainline kernel enumerates the eMMC->mmcblk1 and sdcard->mmcblk0 (Toradex linux V2.6.1B1 has eMMC->mmcblk0 and sdcard->mmcblk1).

My world would be somewhat simpler if I could apply the Toradex block device enumeration on a mainline kernel. Is there a simple way to do this?

The general consensus on the kernel mailing list is that one should not rely on a specific MMC block device numbering. There has been discussion on this quite a few times, but, the proposal for a consistent block device numbering has been rejected. See one of the recent discussions here. Patches for the same can be found here and here. You might also want to take a look here. So currently it’s not possible without out of tree patches.

Thanks @sanchayan.tx, I applied the patch from Stefan Agner and it fixed up my device naming. However, I feel like I should be able to modify the applicable u-boot configuration as follows:

root=/dev/disk/by-path/platform-2198000.usdhc-part1

I tried doing that (using part2 instead of part1 to reflect my configuration) and the kernel boot hangs on:

[    3.975707] Waiting for root device /dev/disk/by-path/platform-2198000.usdhc-part2...

Using /dev/mmcblk0p2 works however.

I’m using /dev/disk/by-path/platform-2198000.usdhc-part* in fstab and that works fine. Do you know why using the “by-path” symlink does not work where using /dev/mmcblk0p2 works in the bootargs?

Edit: Clarified issue, added question at end

Those symlinks are created by user space utilities such as systemd/udev (see udev-builtin-path_id.c). Distributions typically compile a kernel with an initramfs which creates those symlinks for you, so that you can use them for root=.... However, our BSP, as most embedded BSP, do not go through that extra step to loading a initramfs and search the root file system from there. That said, it can be done if you wish so, Yocto/OpenEmbedded has a special config variable for it called INITRAMFS_IMAGE.

If you don’t want to use a initramfs (which I also would not recommend just for that purpose) you need to rely on mechanism provided by the kernel. Luckily the kernel also knows a path independent mechanism: PARTUUID. The U-Boot boot loader has support to determine the partition UUID using the part uuid command:

Apalis iMX6 # part uuid mmc 0:1
d4cf7120-01

You can use part uuid <interface> <dev>:<part> <varname> to set a variable with the partition UUID and pass that to the kernel.