# Micro SD card issues on custom TX2i-based board

**URL:** <https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318>\
**Category:** Jetson TX2\
**Tags:** device-tree, board-design\
**Created:** [September 25, 2020, 12:00pm UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318 "2020-09-25T12:00:12Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 25, 2020, 12:00pm UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/1 "2020-09-25T12:00:12Z")

</div>

Hello!  
I have a custom board based on the TX2i module. I have an micro SD card reader connected at the same pins as the dev kit, but I have issues making it work.  
In particular, at U-Boot when no SD card is inserted, I have a message:  
`Card did not respond to voltage select!`  
if it is inserted, I get instead:  
`MMC: no card present`

When Linux boots, I have several messages like:

`[2.498959] mmc1: CMD CRC or end bit error, int mask 0xc0000`

Then, checking the GPIOs in _sysfs_, when I turn on the card with no SD card I get (the Card Detect GPIO value is correct, it is not inverted for the card reader I use):

```
gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-412 ( |vdd-usb0-5v ) out lo    
 gpio-413 ( |vdd-usb1-5v ) out lo    
 gpio-420 ( |eqos_phy_reset ) out hi    
 gpio-445 ( |cd ) in lo    
 gpio-446 ( |en-vdd-sd ) out lo    
 gpio-479 ( |external-connection:) in lo

```

then if I insert the card:

```
gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-412 ( |vdd-usb0-5v ) out lo    
 gpio-413 ( |vdd-usb1-5v ) out lo    
 gpio-420 ( |eqos_phy_reset ) out hi    
 gpio-445 ( |cd ) in hi    
 gpio-446 ( |en-vdd-sd ) out lo    
 gpio-479 ( |external-connection:) in lo

```

and when I remove it again I have in _syslog_  
`Sep 25 13:50:04 drone kernel: [338.164840] mmc2: Enabling vmmc regulator`  
and in _sysfs_:

```
gpiochip0: GPIOs 320-511, parent: platform/2200000.gpio, tegra-gpio:
 gpio-412 ( |vdd-usb0-5v ) out lo    
 gpio-413 ( |vdd-usb1-5v ) out lo    
 gpio-420 ( |eqos_phy_reset ) out hi    
 gpio-445 ( |cd ) in lo    
 gpio-446 ( |en-vdd-sd ) out hi    
 gpio-479 ( |external-connection:) in lo  

```

Checking the voltages on the pins I do have values that match those shown in _sysfs_.

The pins have been configured as in figure:

 ![pinmux](https://global.discourse-cdn.com/nvidia/original/3X/f/1/f19446f689fd3dada784d3baa96554d2d42a8212.png)

Please find in attachment the current DTB decompiled and the dmesg logs.

Could you please help me out? I’ve tried searching quite a while on the Internet, but I was unable to find a relevant result.

Thanks a lot in advance and have a nice week-end!  
Rob

[dmesg\_log.txt](https://forums.developer.nvidia.com/uploads/short-url/qorLdg2G50p80mjjgkEDvgzECmg.txt) (55.8 KB)  
[dtb\_dump.txt](https://forums.developer.nvidia.com/uploads/short-url/yHGZ2uNVD2UHh8QvnvwIXVtBgjS.txt) (338.7 KB)

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [September 28, 2020, 2:57am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/3 "2020-09-28T02:57:02Z")

</div>

Hi,

Could you directly share what you’ve added to device tree?

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 28, 2020, 5:18am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/4 "2020-09-28T05:18:16Z")

</div>

Hello WayneWWW,  
Sure!

I’ve commented out three lines in _tegra186-quill-common.dtsi_:

```
sdhci@3400000 {
		cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
        // wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
		// cd-inverted;
		// wp-inverted;
		uhs-mask = <0x8>;
		status = "okay";
	};

```

(we have no write protect and the Card Detect is not inverted) and that’s basically it, no further changes (I expected it to behave similarly to the SD reader in the devkit…).

Thanks and have a nice day!  
Rob

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [September 28, 2020, 6:54am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/5 "2020-09-28T06:54:40Z")

</div>

Could you also share the board schematic?

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 28, 2020, 8:57am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/6 "2020-09-28T08:57:16Z")

</div>

Hello,  
Here’s the schematic for the SD card part (the negation on the DET pin is a mistake in the schematic given the component we have selected)

 ![pcb_01](https://global.discourse-cdn.com/nvidia/original/3X/b/f/bfef04dfd5cfe7d8b217c48a2cc80c5db4c23eaf.png)  
The pins are connected as follows:

- SDCARD\_PWEN: H16
- SDCARD\_DAT0: H18
- SDCARD\_DAT1: H17
- SDCARD\_DAT2: F19
- SDCARD\_DAT3: F18
- SDCARD\_CMD: G19
- SDCARD\_CLK: G18
- SDCARD\_DET: F17

Please note that I have not changed the _en\_vdd\_sdcard1: regulator@1_ entry in _tegra186-cvb-prod-p2597-b00-p3489-1000-a00-00_, even though the GPIO number is wrong, since this value is overridden by _tegra186-quill-p3489-1000-a00-00-base.dts_.

If you need any additional information, please do not hesitate to ask!  
Thanks again in advance,  
Rob

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [September 28, 2020, 9:10am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/7 "2020-09-28T09:10:11Z")

</div>

Could you compare the device tree under /proc/device-tree between your board and devkit and see what is the diff?

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 28, 2020, 10:05am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/8 "2020-09-28T10:05:44Z")

</div>

I’ve flashed a second module with the same config (except for the CardDetect) and put the module in a dev kit.  
I’ve inserted an SD card an this is what I get in dmesg:

 ![mmc](https://global.discourse-cdn.com/nvidia/original/3X/0/4/04f62f8da3867424e089d3f6fa63af30ed7df540.png)  
Also, in _sysfs_ I have:

```
 gpio-445 ( |cd ) in lo    
 gpio-446 ( |en-vdd-sd ) out hi 

```

I do guess therefore that the issue could be in a configuration required by the new design that is missing, but I cannot see what it could be…

The device tree extracted with the `dtc -I fs /sys/firmware/devicetree/base` command on the two boards are attached.

[custom\_board\_dts.txt](https://forums.developer.nvidia.com/uploads/short-url/xgkhwMl9JteoQZmP5CQC0f8Ue8T.txt) (356.0 KB)  
[devkit\_dts.txt](https://forums.developer.nvidia.com/uploads/short-url/yOjYpOSxme4hcjpUBysHCTynAUg.txt) (356.0 KB)

Do you want me to do a diff wrt the original configuration files?

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [September 29, 2020, 2:23am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/9 "2020-09-29T02:23:05Z")

</div>

Hi,

Only diff the sdhci controller part of your sdcard slot should be fine. Please help check.

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 29, 2020, 5:26am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/10 "2020-09-29T05:26:25Z")

</div>

Actually, there are very few differences, below are the diffs for the related parts (original vs. modified)

file: _sources/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi_

```
622,625c661,664
< cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 6) 0>;
< wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
< cd-inverted;
< wp-inverted;
---
> cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
> // wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
> // cd-inverted;
> // wp-inverted;

```

file: _sources/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-cvb-prod-p2597-b00-p3489-1000-a00-00.dtsi_

```
142c152
< gpio = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
---
> gpio = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 6) 0>;

```

Have a nice day!  
Rob

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [September 29, 2020, 5:27am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/11 "2020-09-29T05:27:41Z")

</div>

Hi,

Do not compare in such way.

Just compare the result from /proc/device-tree for sdhci part.

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 29, 2020, 8:04am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/12 "2020-09-29T08:04:33Z")

</div>

Hello,

Here’s the diff you’ve asked:

```
:~$ diff dev_kit.txt custom.txt 
22c22
< phandle = <0xf8>;
---
> phandle = <0xdc>;
32d31
< cd-inverted;
35c34
< linux,phandle = <0xf8>;
---
> linux,phandle = <0xdc>;
37d35
< wp-inverted;
42d39
< wp-gpios = <0x1b 0x7c 0x0>;

```

– full nodes –

DTB from /proc from the **devkit** , original configuration:

```
sdhci@3400000 {
	nvidia,ddr-tap-delay = <0xb>;
	nvidia,en-periodic-calib;
	cap-mmc-highspeed;
	compatible = "nvidia,tegra186-sdhci";
	clocks = <0x10 0x34 0x10 0x10d 0x10 0x80>;
	cap-sd-highspeed;
	nvidia,cd-wakeup-capable;
	resets = <0x10 0x21>;
	pinctrl-1 = <0x1a>;
	clock-names = "sdmmc", "pll_p", "sdmmc_legacy_tm";
	pll_source = "pll_p";
	cd-gpios = <0x1b 0x7d 0x0>;
	keep-power-in-suspend;
	nvidia,min-tap-delay = <0x54>;
	ddr-clk-limit = <0x2dc6c00>;
	status = "okay";
	nvidia,max-tap-delay = <0x88>;
	interrupts = <0x0 0x3e 0x4>;
	bus-width = <0x4>;
	ddr-trim-delay = <0x5>;
	phandle = <0xf8>;
	tap-delay = <0xb>;
	reg = <0x0 0x3400000 0x0 0x210>;
	iommus = <0x11 0x1a>;
	pinctrl-0 = <0x19>;
	mmc-ocr-mask = <0x3>;
	compad-vref-1v8 = <0x2>;
	trim-delay = <0x5>;
	pwrdet-support;
	reset-names = "sdhci";
	cd-inverted;
	vmmc-supply = <0x1d>;
	uhs-mask = <0x8>;
	linux,phandle = <0xf8>;
	ignore-pm-notify;
	wp-inverted;
	compad-vref-3v3 = <0x1>;
	vqmmc-supply = <0x1c>;
	pinctrl-names = "sdmmc_e_33v_enable", "sdmmc_e_33v_disable";
	max-clk-limit = <0xc28cb00>;
	wp-gpios = <0x1b 0x7c 0x0>;

	prod-settings {
		#prod-cells = <0x3>;

		prod_c_sdr104 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x4000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000503>;
		};

		prod {
			prod = <0x100 0x1fff002e 0x5090028 0x1c0 0xbfc1ff8 0x8000050 0x1c4 0x77 0x0 0x120 0x20001 0x1 0x128 0x43000000 0x0>;
		};

		prod_c_hs {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr50 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x8000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ddr52 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr12 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ds {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr25 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};
	};
};

```

DTB from /proc on the **custom board** , as I have modified it:

```
sdhci@3400000 {
	nvidia,ddr-tap-delay = <0xb>;
	nvidia,en-periodic-calib;
	cap-mmc-highspeed;
	compatible = "nvidia,tegra186-sdhci";
	clocks = <0x10 0x34 0x10 0x10d 0x10 0x80>;
	cap-sd-highspeed;
	nvidia,cd-wakeup-capable;
	resets = <0x10 0x21>;
	pinctrl-1 = <0x1a>;
	clock-names = "sdmmc", "pll_p", "sdmmc_legacy_tm";
	pll_source = "pll_p";
	cd-gpios = <0x1b 0x7d 0x0>;
	keep-power-in-suspend;
	nvidia,min-tap-delay = <0x54>;
	ddr-clk-limit = <0x2dc6c00>;
	status = "okay";
	nvidia,max-tap-delay = <0x88>;
	interrupts = <0x0 0x3e 0x4>;
	bus-width = <0x4>;
	ddr-trim-delay = <0x5>;
	phandle = <0xdc>;
	tap-delay = <0xb>;
	reg = <0x0 0x3400000 0x0 0x210>;
	iommus = <0x11 0x1a>;
	pinctrl-0 = <0x19>;
	mmc-ocr-mask = <0x3>;
	compad-vref-1v8 = <0x2>;
	trim-delay = <0x5>;
	pwrdet-support;
	reset-names = "sdhci";
	vmmc-supply = <0x1d>;
	uhs-mask = <0x8>;
	linux,phandle = <0xdc>;
	ignore-pm-notify;
	compad-vref-3v3 = <0x1>;
	vqmmc-supply = <0x1c>;
	pinctrl-names = "sdmmc_e_33v_enable", "sdmmc_e_33v_disable";
	max-clk-limit = <0xc28cb00>;

	prod-settings {
		#prod-cells = <0x3>;

		prod_c_sdr104 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x4000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000503>;
		};

		prod {
			prod = <0x100 0x1fff002e 0x5090028 0x1c0 0xbfc1ff8 0x8000050 0x1c4 0x77 0x0 0x120 0x20001 0x1 0x128 0x43000000 0x0>;
		};

		prod_c_hs {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr50 {
			prod = <0x100 0xff0000 0xb0000 0x1c0 0xe000 0x8000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ddr52 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr12 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_ds {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x1 0x1e4 0x20007f7f 0x20000000>;
		};

		prod_c_sdr25 {
			prod = <0x100 0xff0000 0xb0000 0x1e0 0xf 0x2 0x1e4 0x20007f7f 0x20000000>;
		};
	};
};

```

---

<div class="post-metadata">

**Author:** ![Trumany](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/trumany/32/14043_2.png) [@Trumany](https://forums.developer.nvidia.com/u/Trumany)\
**Post date:** [September 29, 2020, 11:44pm UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/17 "2020-09-29T23:44:52Z")

</div>

Is the polarity of SDCARD\_DET\_n inverted on your board? It is pulled to low when card inserted on dev kit.

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [September 30, 2020, 5:05am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/18 "2020-09-30T05:05:33Z")

</div>

Dear Trumany,  
No, that’s a mistake in the schematics we are aware of. The part we chose has no inverted polarity (that’s why I’ve removed the _cd-inverted_ from the device tree).

---

<div class="post-metadata">

**Author:** ![rob7989](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@rob7989](https://forums.developer.nvidia.com/u/rob7989)\
**Post date:** [October 1, 2020, 7:59am UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/20 "2020-10-01T07:59:24Z")

</div>

Hello,  
We finally solved the issue, it is a bug in the kernel shipped with the board. We solved it by setting the parameter `override_active_level` to false in the call to `mmc_gpiod_request_cd` in the `mmc_gpiod_request_cd()` call at `drivers/mmc/core/host.c:236`. (there are most likely more elegant ways to patch this, but we had already wasted enough time on this…).  
In the device tree, the values we used are:

```
sdhci@3400000 {
	cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>;
   	// wp-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 4) 0>;
	cd-inverted;
	// wp-inverted;
	uhs-mask = <0x8>;
	status = "okay";
};

```

Best,  
Rob

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 18, 2021, 6:16pm UTC](https://forums.developer.nvidia.com/t/micro-sd-card-issues-on-custom-tx2i-based-board/155318/22 "2021-10-18T18:16:50Z")

</div>


