DESK-MX9-L/Peripherals/SD

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2024/01/30 DESK-MX9-L-5.0.0 release



Peripheral SD[edit | edit source]

Device tree configuration[edit | edit source]

N.B. The USDHC interface is re-configured on the carrier device tree because of the Card Detect pin (which is related to the real board hardware implementation).

Here below is an example of device tree configuration used on standard DAVE's kit for the AURA SOM:

From imx93-aura-cb2001.dts:

...
&usdhc2 {
	status = "okay";
};
...

From imx93-aura.dtsi:

...
&usdhc2 {
	pinctrl-names = "default", "state_100mhz", "state_200mhz";
	pinctrl-0 = <&pinctrl_usdhc2>, <&pinctrl_usdhc2_gpio>;
	pinctrl-1 = <&pinctrl_usdhc2>, <&pinctrl_usdhc2_gpio>;
	pinctrl-2 = <&pinctrl_usdhc2>, <&pinctrl_usdhc2_gpio>;
	cd-gpios = <&gpio3 00 GPIO_ACTIVE_LOW>;
	bus-width = <4>;
	no-sdio;
	no-mmc;
	disable-wp;
	no-1-8-v;
	status = "disabled";
};
...
&iomuxc {
...
	pinctrl_usdhc2_gpio: usdhc2gpiogrp {
		fsl,pins = <
			MX93_PAD_SD2_CD_B__GPIO3_IO00		0x31e
		>;
	};

	pinctrl_usdhc2: usdhc2grp {
		fsl,pins = <
			MX93_PAD_SD2_CLK__USDHC2_CLK		0x17fe
			MX93_PAD_SD2_CMD__USDHC2_CMD		0x13fe
			MX93_PAD_SD2_DATA0__USDHC2_DATA0	0x13fe
			MX93_PAD_SD2_DATA1__USDHC2_DATA1	0x13fe
			MX93_PAD_SD2_DATA2__USDHC2_DATA2	0x13fe
			MX93_PAD_SD2_DATA3__USDHC2_DATA3	0x13fe
			MX93_PAD_SD2_VSELECT__USDHC2_VSELECT	0x51e
		>;
	};
...
};

Accessing the peripheral[edit | edit source]

Once initialized, the SD device is mapped to the standard /dev/mmcblk1pX block device, depending on how many partitions are created on the SD card.

Linux messages at boot time[edit | edit source]

If the microSD card is inserted at boot time, the kernel - once the USDHC interface has been initialized - prints the device information and the partitions detected like p1, p2, etc.:

...
...
[    1.347520] sdhci: Secure Digital Host Controller Interface driver
[    1.353715] sdhci: Copyright(c) Pierre Ossman
[    1.365042] sdhci-pltfm: SDHCI platform and OF driver helper
...
[    1.402850] mmc0: SDHCI controller on 42850000.mmc [42850000.mmc] using ADMA
[    1.525510] mmc0: new DDR MMC card at address 0001
[    1.532646] mmcblk0: mmc0:0001 DG4008 7.28 GiB 
[    1.543004]  mmcblk0: p1 p2
[    1.549076] mmcblk0boot0: mmc0:0001 DG4008 4.00 MiB 
[    1.557364] mmcblk0boot1: mmc0:0001 DG4008 4.00 MiB 
[    1.566409] mmcblk0rpmb: mmc0:0001 DG4008 4.00 MiB, chardev (234:0)
[    1.814684] sdhci-esdhc-imx 42860000.mmc: Got CD GPIO
[    1.851039] mmc1: SDHCI controller on 42860000.mmc [42860000.mmc] using ADMA
[    1.889752] mmc1: new high speed SDHC card at address 5048
[    1.900514] mmcblk1: mmc1:5048 SD32G 28.9 GiB 
[    1.906361]  mmcblk1: p1 p2
[    2.358195] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Quota mode: none.
[    4.890543] EXT4-fs (mmcblk1p2): re-mounted. Quota mode: none.
...

Additional information[edit | edit source]

If booting from NFS, the file system configuration automatically mounts the uSD partitions.

root@desk-mx93:~# lsblk /dev/mmcblk1 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
mmcblk1     179:96   0 28.9G  0 disk 
|-mmcblk1p1 179:97   0 83.2M  0 part /run/media/boot-mmcblk1p1
`-mmcblk1p2 179:98   0  6.5G  0 part /run/media/root-mmcblk1p2
root@desk-mx93:~#