Mmc0, mmc3 system confusion

Hello all,
basically, my system confuses mmc0 and mmc3, details are below.

I’m testing secondary sd card slot on a custom carrier board for Xavier NX. I use Xavier NX devkit (that is, the one with builtin sd card) for this purpose. I enabled sdhci@3440000 sd slot in the device tree using the information I found on this forum, and when booting, the system for some reason expects the OS to be on it rather than mmcblk0. If there is no card in sdhci@3440000, the boot process will stop, as shown below:

[    7.217473] mmcblk mmc1:aaaa: Card claimed for testing.
[    7.253455] bpmp: mounted debugfs mirror
[    7.260175] ALSA device list:
[    7.260276]   #0: tegra-hda-xnx at 0x3518000 irq 65
[    7.260385]   #1: jetson-xaviernx-ape
[    7.262451] Freeing unused kernel memory: 8640K
[    7.302782] Root device found: mmcblk0p1
[   17.527134] ERROR: mmcblk0p1 not found

If I insert an sd card into sdhci@3440000 at this time, I will get:

[   17.409661] ERROR: mmcblk0p1 not found
[   17.560765] extcon-gpio-states external-connection:extcon@1: Cable state:0, cable id:0
[   17.560952] tegra-xudc-new 3550000.xudc: vbus state: 0
[   17.561042] tegra-xudc-new 3550000.xudc: device mode off: 0
[   17.561168] tegra-xudc-new 3550000.xudc: active: 1 => 0
[   17.561260] tegra-xudc-new 3550000.xudc: entering ELPG
[   17.561644] tegra-xudc-new 3550000.xudc: entering ELPG done
[   20.808720] extcon-gpio-states external-connection:extcon@1: Cable state:1, cable id:1
[   20.808909] tegra-xudc-new 3550000.xudc: vbus state: 1
[   20.809009] tegra-xudc-new 3550000.xudc: exiting ELPG
[   20.809754] tegra-xudc-new 3550000.xudc: exiting ELPG done
[   20.809853] tegra-xudc-new 3550000.xudc: device mode on: 0
[   20.809951] tegra-xudc-new 3550000.xudc: active: 0 => 1
[   38.244853] vdd-sdmmc3-sw: disabling
[   38.244956] vdd-1v8-sd: disabling
[   38.245018] vdd-1v8-cvb: disabling
[   38.245094] vdd-epb-1v0: disabling
[   38.245152] avdd-cam-2v8: disabling
[   38.245217] vdd-fan: disabling
[   38.245273] vdd_sys_en: disabling
[   47.670753] mmc0: Enabling vmmc regulator
[   47.993771] mmc0: host does not support reading read-only switch, assuming write-enable
[   48.137125] mmc0: hw tuning done ...
[   48.137260] mmc0: new ultra high speed SDR104 SDXC card at address aaaa
[   48.137811] mmcblk0: mmc0:aaaa SR128 119 GiB 
[   48.146213]  mmcblk0: p1
[   67.676724] extcon-gpio-states external-connection:extcon@1: Cable state:1, cable id:1
[   70.387504] mmc0: Disabling vmmc regulator
[   70.387708] mmc0: card aaaa removed
[   72.912076] mmc0: Enabling vmmc regulator
[   73.213708] mmc0: host does not support reading read-only switch, assuming write-enable
[   73.355924] mmc0: hw tuning done ...
[   73.356037] mmc0: new ultra high speed SDR104 SDXC card at address aaaa
[   73.356549] mmcblk0: mmc0:aaaa SR128 119 GiB 
[   73.365241]  mmcblk0: p1
[   78.870067] mmc0: Disabling vmmc regulator
[   78.870267] mmc0: card aaaa removed
[   79.376752] extcon-gpio-states external-connection:extcon@1: Cable state:1, cable id:1
[   80.148761] extcon-gpio-states external-connection:extcon@1: Cable state:0, cable id:0
[   80.148922] tegra-xudc-new 3550000.xudc: vbus state: 0
[   80.149016] tegra-xudc-new 3550000.xudc: device mode off: 0
[   80.149141] tegra-xudc-new 3550000.xudc: active: 1 => 0
[   80.149232] tegra-xudc-new 3550000.xudc: entering ELPG
[   80.149591] tegra-xudc-new 3550000.xudc: entering ELPG done
[   81.080722] extcon-gpio-states external-connection:extcon@1: Cable state:1, cable id:1
[   81.080916] tegra-xudc-new 3550000.xudc: vbus state: 1
[   81.081012] tegra-xudc-new 3550000.xudc: exiting ELPG
[   81.081740] tegra-xudc-new 3550000.xudc: exiting ELPG done
[   81.081842] tegra-xudc-new 3550000.xudc: device mode on: 0
[   81.081942] tegra-xudc-new 3550000.xudc: active: 0 => 1
[  173.284933] random: crng init done

For reference below, a bootlog fragment when two cards, each with OS (with different host names and logins for differentiation). Note that expected host name is “nx” instead of “ubuntu”.

[    7.265596] tegra_rtc c2a0000.rtc: setting system clock to 2000-01-01 01:00:19 UTC (946688419)
[    7.266354] mmcblk mmc0:0001: Card claimed for testing.
[    7.266486] mmcblk mmc1:aaaa: Card claimed for testing.
[    7.305340] bpmp: mounted debugfs mirror
[    7.312112] ALSA device list:
[    7.312211]   #0: tegra-hda-xnx at 0x3518000 irq 65
[    7.312313]   #1: jetson-xaviernx-ape
[    7.314557] Freeing unused kernel memory: 8640K
[    7.356579] Root device found: mmcblk0p1
[    7.358549] Found dev node: /dev/mmcblk0p1
[    7.400412] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Opts: (null)
[    7.403212] Rootfs mounted over mmcblk0p1
[    7.432425] Switching from initrd to actual rootfs
[    7.669694] systemd[1]: System time before build time, advancing clock.
[    7.704913] ip_tables: (C) 2000-2006 Netfilter Core Team
[    7.710997] cgroup: cgroup2: unknown option "nsdelegate"
[    7.729115] systemd[1]: systemd 237 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid)
[    7.730188] systemd[1]: Detected architecture arm64.
[    7.741039] systemd[1]: Set hostname to <ubuntu>.
[    7.881254] systemd[1]: File /lib/systemd/system/systemd-journald.service:36 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
[    7.881586] systemd[1]: Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
[    8.098375] random: systemd: uninitialized urandom read (16 bytes read)
[    8.101607] systemd[1]: Created slice User and Session Slice.
[    8.102164] random: systemd: uninitialized urandom read (16 bytes read)
[    8.103473] systemd[1]: Created slice System Slice.
[    8.103882] random: systemd: uninitialized urandom read (16 bytes read)
[    8.104285] systemd[1]: Listening on /dev/initctl Compatibility Named Pipe.
[    8.104910] systemd[1]: Listening on Journal Socket.
[    8.110280] systemd[1]: Starting Load Kernel Modules...
[    8.202086] EXT4-fs (mmcblk0p1): re-mounted. Opts: (null)
[    8.240804] nvgpu: 17000000.gv11b          nvgpu_nvhost_syncpt_init:291  [INFO]  syncpt_unit_base 60000000 syncpt_unit_size 400000 size 1000
[    8.240804] 
��WARNING: at platform/drivers/pg/pg-gpu-t194.c:185
WARNING: at platform/drivers/pg/pg-gpu-t194.c:185
��[    9.360721] random: crng init done
[    9.360851] random: 7 urandom warning(s) missed due to ratelimiting
[    9.416825] using random self ethernet address
[    9.416963] using random host ethernet address
[   10.608119] using random self ethernet address
[   10.608263] using random host ethernet address
[   13.177053] CPU4: shutdown
[   13.242287] CPU5: shutdown
[   17.795974] Bridge firewalling registered

Ubuntu 18.04.6 LTS ubuntu ttyTCU0

ubuntu login: 

I tried adding id = <devnode_number> field to the sdmmc nodes but it did not help.
How can I hard code device number into devnode name?
Full boot log in the attachment.

boot.log (82.4 KB)

My mmc3 dts settings for reference:

	sdhci@3440000 {
		mmc-ocr-mask = <0x0>;
		cd-gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 1) 0>;
		nvidia,cd-wakeup-capable;
		mmc-ocr-mask = <0>;
		cd-inverted;
		vmmc-supply = <&p3668_vdd_sdmmc3_sw>;
		status = "okay";
	};

Power supply:

		p3668_vdd_sdmmc3_sw: regulator@103 {
		compatible = "regulator-fixed";
		reg = <103>;
		regulator-name = "vdd-sdmmc3-sw";
		gpio = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 2) 0>;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		enable-active-high;
		};

Fragment from https://www.kernel.org/doc/Documentation/devicetree/bindings/mmc/mmc-controller.yaml

  It is possible to assign a fixed index mmcN to an MMC host controller
  (and the corresponding mmcblkN devices) by defining an alias in the
  /aliases device tree node.

How can it be done in Jetson source code context? Manipulating the part:

	aliases {
		sdhci3 = &sdmmc4;
		sdhci2 = &sdmmc3;
		sdhci0 = &sdmmc1;
	};

doesnt seem to affect anything.

The order of the device tree decides which node to be mmcblk0… in your case, I guess you didn’t follow our official way to build device tree. So your mmcblk0 becomes your mmc3.