Enabling microSD card for Jetson TX2
|
|
Introduction
It may be that a custom carrier board with a microSD card uses a TX2 module and needs this slot enabled. Since the TX2 developer kit comes with a normal size SD card slot, microSD cards are not supported by default. This wiki describes how can this support be easily added by taking the default device tree files and making slight modifications.
Schematics review
- In the TX2 developer kit, the SD card schematic looks like the following:
These schematics show that SDcard power is controlled by a switch. This switch is controlled by the SD_CARD_PWR_EN
signal. This SD_CARD_PWR_EN
signal depends on the SDCARD_CD#
(card detect) signal that comes from the SD card, which is used for plug-in detection.
- The below schematic is an example of a microSD card wired to the TX2 module:
As seen, this hardware connects the microSD card to VDD directly without a switch. Since SDCARD_CD#
(card detect signal) is what triggers SD_CARD_PWR_EN
that in turn allows power to flow to the SD card, these pins are not necessary if VDD is directly provided to the SD card.
Another thing to be noticed is that there is no write protect signal coming from the SD card.
- The SD card mapping interface for the TX2 is the following:
- From the device tree it can be seen that sdmmc1 (interface used in our example schematic) is mapped to the sdhci@3400000 node, this will be the node of interest.
sdmmc1 = "/sdhci@3400000";
Device tree changes
To enable a microSD card with the above characteristics, a few changes in the device tree are necessary.
Important: Te device tree files listed are assuming a standard 8GB TX2 is used, these files will vary for TX2-4GB and TX2i modules, but the changes are still the same. |
Changes in tegra186-quill-p3310-1000-a00-00-base.dts
1. The following node needs to be added:
sdhci@3400000 { nvidia,vmmc-always-on; disable-wp; /delete-property/cd-gpios; };
The above properties serve the following purpose:
- nvidia,vmmc-always-on: This property enables the SD card to be detected as an ultra high speed device.
- disable-wp: This property disables write protection so the SD card can be written to when mounted.
- /delete-property/cd-gpios: Since there is no card to detect a signal being used, the gpios need to be deleted in order for the kernel to detect it.
Note:By removing the cd-gpios, the card is going to appear as permanently detected, even when it is not inserted. |
2. The sd card note in the plugin manager needs to be deleted, this prevents the above setting from being overridden by the plugin manager. For this, the following node must be added:
plugin-manager { /delete-node/fragment-sdwake-p3310-1000-300; };
Changes in tegra186-quill-p3310-1000-c03-00-base.dts
The cd-gpios property must be deleted from the top level device tree as well:
diff --git a/Linux_for_Tegra/sources/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-ch1-00-base.dts b/Linux_for_Tegra/sources/hardware/nvidia/platform/t18x/quill/kernel-dtstegra186-quill-p3310-1000-c03-00-base.dts index f6067f4c0..354a704cc 100644 --- a/Linux_for_Tegra/sources/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts +++ b/Linux_for_Tegra/sources/hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts @@ -80,7 +80,6 @@ }; sdhci@3400000 { - cd-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(P, 5) 0>; nvidia,cd-wakeup-capable; };
Testing
After inserting and mounting the SD card, run the following to list bulk devices:
lsblk
- The output should be something like the following, where the SD card appears as mmcblk2 with one partition called mmcblk2p1.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT . . . mmcblk0boot1 179:64 0 4M 1 disk mmcblk0rpmb 179:96 0 4M 0 disk mmcblk2 179:128 0 29,7G 0 disk └─mmcblk2p1 179:129 0 29,7G 0 part /media/nvidia/3462-3331 zram0 252:0 0 654,7M 0 disk [SWAP] zram1 252:1 0 654,7M 0 disk [SWAP] . . .
To check whether the SD card is detected as an ultra high speed device, run the following:
dmesg | grep mmc
- In this case, the SD card corresponds to mmc2 and it is in fact being detected as an ultra high speed device.
. . . [ 1.866559] Rootfs mounted over mmcblk0p1 [ 1.913146] mmc2: hw tuning done ... [ 1.913180] mmc2: new ultra high speed SDR104 SDHC card at address e624 [ 1.913421] mmcblk2: mmc2:e624 SD32G 29.7 GiB (ro) [ 1.914616] mmcblk2: p1 [ 2.270077] EXT4-fs (mmcblk0p1): re-mounted. Opts: (null)
Note: The easiest way to mount the SD card is by using the graphical interface and clicking the SD card icon. This will automatically mount it. |
Additional notes
By looking at the sdhci-tegra.c file in the kernel, it is possible to notice that the driver looks for card-detect gpios, and if they are not defined, it assumes that the card is always present. This is the reason why just by deleting the cd-gpios property from the device tree, the card detects a signal that is usually present in SD cards and is used by the driver can be bypassed.
sdhci-tegra.c code extract
/* * If there is no card detect gpio, assume that the * card is always present. */ if (!gpio_is_valid(tegra_host->cd_gpio)) { host->mmc->rem_card_present = 1; } else { if (!host->mmc->cd_cap_invert) host->mmc->rem_card_present = (mmc_gpio_get_cd(host->mmc) == 0); else host->mmc->rem_card_present = mmc_gpio_get_cd(host->mmc); }
For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.
Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.