# SD/mmc0 not accessible if booting from emmc

**URL:** <https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361>\
**Category:** NXP LX2160\
**Created:** [June 21, 2022, 2:38pm UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361 "2022-06-21T14:38:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![laforge](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@laforge](https://community.solid-run.com/u/laforge)\
**Post date:** [June 21, 2022, 2:38pm UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/1 "2022-06-21T14:38:00Z")

</div>

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):

```auto
=> 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:

```auto
=> 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](https://github.com/SolidRun/Documentation/blob/bsp/lx2k/debian-11.md)

---

<div class="post-metadata">

**Author:** ![PacMan](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@PacMan](https://community.solid-run.com/u/PacMan)\
**Post date:** [June 23, 2022, 10:25am UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/2 "2022-06-23T10:25:14Z")

</div>

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, …)

---

<div class="post-metadata">

**Author:** ![Takarth](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Takarth](https://community.solid-run.com/u/Takarth)\
**Post date:** [September 14, 2022, 3:21pm UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/3 "2022-09-14T15:21:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dstepanov](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/dstepanov/32/144_2.png) [@dstepanov](https://community.solid-run.com/u/dstepanov)\
**Post date:** [November 3, 2022, 9:24pm UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/4 "2022-11-03T21:24:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jnettlet](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/jnettlet/32/62_2.png) [@jnettlet](https://community.solid-run.com/u/jnettlet)\
**Post date:** [November 4, 2022, 6:58am UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/5 "2022-11-04T06:58:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dstepanov](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/dstepanov/32/144_2.png) [@dstepanov](https://community.solid-run.com/u/dstepanov)\
**Post date:** [November 7, 2022, 11:41am UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/6 "2022-11-07T11:41:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dstepanov](https://dub1.discourse-cdn.com/flex005/user_avatar/community.solid-run.com/dstepanov/32/144_2.png) [@dstepanov](https://community.solid-run.com/u/dstepanov)\
**Post date:** [November 28, 2022, 8:00am UTC](https://community.solid-run.com/t/sd-mmc0-not-accessible-if-booting-from-emmc/361/7 "2022-11-28T08:00:44Z")

</div>

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:

```auto
                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
