SD/mmc0 not accessible if booting from emmc

I’m observing a very strange behaviour:

  • when booting from the SD card (mmc0), u-boot is able to scan/list both the SD-card (mmc0) and the emmc (mmc1):
=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 41
OEM: 3432
Name: ASTCBus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
=> mmc dev 1
switch to partitions #0, OK
mmc1(part 0) is current device
=> mmc info
Device: FSL_SDHC
Manufacturer ID: 45
OEM: 100
Name: DG406 
Bus Speed: 50000000
Mode: MMC High Speed (52MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 59.2 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 59.2 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected

However, when changing the DIP switch to boot from emmc, suddenly u-boot can no longer access the SD card in mmc0:

=> mmc info
Device: FSL_SDHC
Manufacturer ID: 45
OEM: 100
Name: DG406 
Bus Speed: 50000000
Mode: MMC High Speed (52MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 59.2 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 59.2 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected
=> mmc dev 0
MMC: no card present

I am using the same u-boot version on both the SD card and eMMC (from lx2160acex7_2000_700_3200_8_5_2-f57e117.img.xz). Also, the same SD card is used (and remains inserted) between both of the boots. The card was not even removed, just the jumper changed.

This makes it impossible to boot u-boot from eMMC and then start a debian installer image as explained in Documentation/debian-11.md at bsp · SolidRun/Documentation · GitHub

1 Like

I think you’d be able to boot from USB if you have a USB card-reader.
My wild guess is that the SD card slot is shared with eMMC and that normally the CPU can switch between the two using a GPIO-pin.
However, if the DIP-switch is hardware-forcing the chip-select to eMMC, then it would likely be impossible to read from the SD-card.
-Still, this is a wild guess and I might be wrong.
If you have a card-reader, try the USB-boot option (U-Boot’s default scripts only allow for USB0, but I think you can easily extend that to USB1, USB2, …)

Same applies if booting from SPI flash. (eMMC is still accessible though)

I think somehow the SD card interface is powered down. It is also not accessible under Linux/OS.

Is there a hidden configuration or GPIO PIN to enable SD card access when not using it as boot device?

With the CN913x CX7 board this limitation does not exist.

I’m gonna refresh this topic since i’ve encountered the same issue - SD card is not accessible when booting from internal eMMC flash.

I’ve done some investigations and the results look weird for me.
I guess that the problem resides in RCW or internal boot logic (or something else which i don’t know).
IIC2_PMUX[354-352] RCW configuration’s bits are responsible for multiplexing SDHC1 CD (card detect) pin with other controllers (I2C, GPIO, flextimer).
RCW source code (lx2160acex7/configs/lx2160a_defaults.rcwi) sets IIC2_PMUX=6 which means that SDHC1 CD pin is enabled.

I checked that these bits are really set inside FLASH memory, then i booted to u-boot and checked the content of “Reset Configuration Word Status Register 12 (RCWSR12)” which stores the content of RCW IIC2_PMUX[354-352] after reset (see 9.3.29 of User’s Manual) and this register contained all zeros which means that CPU uses II2C instead of SDHC1:

=> md.l 1E0012c 1
01e0012c: 00000000

So my guess that when you select “boot from SD card” LX2160A forces SD controller initialization (including configuration Card Detect pin) and everything goes OK. But when you boot from another source (eMMC, SPI Flash) RCW configuration comes into play and SD card does not work.

@jnettlet - have you encountered something like that or this is more NXP specific question?

I have not specifically checked this, but most likely this is the case. For instance we have special pbl code that initializes the SPI-NOR pins when booting from SDHC. We probably need similar code for SDHC when booting from eMMC.

Could you please point where this pbl code is located? Do you mean pbi commands located within RCW block?

To workaround the problem with CD (card detect) pin I added CONFIG_MMC_BROKEN_CD to u-boot config and added broken-cd parameter to esdhc@2140000 node in my DTB file:

                esdhc@2140000 {
                        compatible = "fsl,esdhc";
                        reg = <0x00 0x2140000 0x00 0x10000>;
                        interrupts = <0x00 0x1c 0x04>;
                        clocks = <0x02 0x04 0x01>;
                        dma-coherent;
                        voltage-ranges = <0x708 0x708 0xce4 0xce4>;
                        sdhci,auto-cmd12;
                        broken-cd;
                        little-endian;
                        bus-width = <0x04>;
                        status = "okay";
                        sd-uhs-sdr104;
                        sd-uhs-sdr50;
                        sd-uhs-sdr25;
                        sd-uhs-sdr12;
                        phandle = <0x66>;
                };

After that everything became ok - SD card is visible when booting from internal eMMC card in u-boot and in Linux.
These configuration options force to ignore card detect pin and initialize SD card