DESK-MX8M-L/Peripherals/SD

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes

2022/02/17

First DESK-MX8M-L release

2023/02/24

DESK-MX8M-L-2.0.0 release

2023/08/22

DESK-MX8M-L-4.0.0 release

2024/04/11

DESK-MX8M-L-4.x.x release
2024/05/30 Fix device tree configid


Peripheral SD[edit | edit source]

Device tree configuration[edit | edit source]

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

ORCA SOM[edit | edit source]

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

From imx8mp-mito8mplus-cb1001.dts:

&usdhc2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usdhc2>, <&pinctrl_usdhc2_gpio>;
	cd-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>;
	bus-width = <4>;
	status = "okay";
};

From imx8mp-mito8mplus.dtsi:

&iomuxc {
...
...
	pinctrl_usdhc2_gpio: usdhc2grp-gpio {
		fsl,pins = <
			MX8MP_IOMUXC_SD2_CD_B__GPIO2_IO12 	0x1c4
		>;
	};

	pinctrl_usdhc2: usdhc2grp {
		fsl,pins = <
			MX8MP_IOMUXC_SD2_CLK__USDHC2_CLK	0x190
			MX8MP_IOMUXC_SD2_CMD__USDHC2_CMD	0x1d0
			MX8MP_IOMUXC_SD2_DATA0__USDHC2_DATA0	0x1d0
			MX8MP_IOMUXC_SD2_DATA1__USDHC2_DATA1	0x1d0
			MX8MP_IOMUXC_SD2_DATA2__USDHC2_DATA2	0x1d0
			MX8MP_IOMUXC_SD2_DATA3__USDHC2_DATA3	0x1d0
		>;
	};
...
...
};

MITO 8M Mini[edit | edit source]

Here below an example of device tree configuration used on standard DAVE's kit for the MITO 8M Mini SOM:

From imx8mm-mito8mmini-sbcx.dts :

...
...
&usdhc2 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_usdhc2>, <&pinctrl_usdhc2_gpio>;
	cd-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>;
	no-1-8-v;
	bus-width = <4>;
	status = "okay";
};
...
...
&iomuxc {
...
...
	pinctrl_usdhc2_gpio: usdhc2grpgpio {
		fsl,pins = <
			MX8MM_IOMUXC_SD2_CD_B_GPIO2_IO12		0x159
			MX8MM_IOMUXC_SD2_RESET_B_GPIO2_IO19	0x41
		>;
	};
...
...

From imx8mm-mito8mmini.dtsi:

...
...
&iomuxc {
...
...
	pinctrl_usdhc2: usdhc2grp {
		fsl,pins = <
			MX8MM_IOMUXC_SD2_CLK_USDHC2_CLK		0x190
			MX8MM_IOMUXC_SD2_CMD_USDHC2_CMD		0x1d0
			MX8MM_IOMUXC_SD2_DATA0_USDHC2_DATA0	0x1d0
			MX8MM_IOMUXC_SD2_DATA1_USDHC2_DATA1	0x1d0
			MX8MM_IOMUXC_SD2_DATA2_USDHC2_DATA2	0x1d0
			MX8MM_IOMUXC_SD2_DATA3_USDHC2_DATA3	0x1d0
		>;
	};
...
...
};

Accessing the peripheral in ORCA SOM[edit | edit source]

Once initialized, the SD device is mapped to the standard /dev/mmcblk1pX block device, depending on how many partition 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 partition detected like p1, p2, etc.:

...
...
[    1.282690] sdhci: Secure Digital Host Controller Interface driver
[    1.288886] sdhci: Copyright(c) Pierre Ossman
[    1.300778] sdhci-pltfm: SDHCI platform and OF driver helper
...
...
[    1.339697] mmc2: SDHCI controller on 30b60000.mmc [30b60000.mmc] using ADMA
[    1.443523] mmc2: new HS400 Enhanced strobe MMC card at address 0001
[    1.451490] mmcblk2: mmc2:0001 DG4008 7.28 GiB 
[    1.458874]  mmcblk2: p1 p2
[    1.463171] mmcblk2boot0: mmc2:0001 DG4008 4.00 MiB 
[    1.469396] mmcblk2boot1: mmc2:0001 DG4008 4.00 MiB 
[    1.475225] mmcblk2rpmb: mmc2:0001 DG4008 4.00 MiB, chardev (234:0)
[    2.295899] sdhci-esdhc-imx 30b50000.mmc: Got CD GPIO
[    2.332175] mmc1: SDHCI controller on 30b50000.mmc [30b50000.mmc] using ADMA
[    2.392913] mmc1: host does not support reading read-only switch, assuming write-enable
[    2.413335] mmc1: new high speed SDHC card at address e624
[    2.421697] mmcblk1: mmc1:e624 SA32G 29.7 GiB 
[    2.437619]  mmcblk1: p1 p2
[    2.482754] mmc0: SDHCI controller on 30b40000.mmc [30b40000.mmc] using ADMA
[    2.581058] mmc0: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes)
[    2.646670] mmc0: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes)
[    2.661025] mmc0: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff 32 00] (8 bytes)
[    2.670231] mmc0: queuing unknown CIS tuple 0x14 [] (0 bytes)
[    2.698070] mmc0: new high speed SDIO card at address 0001
...
...
[    3.459672] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[    5.948716] EXT4-fs (mmcblk1p2): re-mounted. Opts: (null). Quota mode: none.
[    8.732777] EXT4-fs (mmcblk2p1): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[    8.888051] EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
...
...

Accessing the peripheral in MITO 8M Mini[edit | edit source]

Once initialized, the SD device is mapped to the standard /dev/mmcblk1pX block device, depending on how many partition 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 partition detected like p1, p2, etc.:

...
...
[    1.379522] sdhci: Secure Digital Host Controller Interface driver
[    1.385730] sdhci: Copyright(c) Pierre Ossman
[    1.397234] sdhci-pltfm: SDHCI platform and OF driver helper
...
...
[    1.435202] mmc0: SDHCI controller on 30b40000.mmc [30b40000.mmc] using ADMA
[    1.539279] mmc0: new HS400 Enhanced strobe MMC card at address 0001
[    1.547131] mmcblk0: mmc0:0001 DG4008 7.28 GiB 
[    1.553521] mmcblk0boot0: mmc0:0001 DG4008 4.00 MiB 
[    1.559975] mmcblk0boot1: mmc0:0001 DG4008 4.00 MiB 
[    1.569632] mmcblk0rpmb: mmc0:0001 DG4008 4.00 MiB, chardev (234:0)
[    3.066839] sdhci-esdhc-imx 30b50000.mmc: Got CD GPIO
[    3.105414] mmc1: SDHCI controller on 30b50000.mmc [30b50000.mmc] using ADMA
[    3.146851] mmc1: host does not support reading read-only switch, assuming write-enable
[    3.165466] mmc1: new high speed SDHC card at address 1234
[    3.171447] mmcblk1: mmc1:1234 SA32G 28.9 GiB 
[    3.178028]  mmcblk1: p1 p2
[    3.261067] mmc2: SDHCI controller on 30b60000.mmc [30b60000.mmc] using ADMA
[    3.304829] mmc2: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes)
[    3.331827] mmc2: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes)
[    3.347607] mmc2: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff 32 00] (8 bytes)
[    3.361278] mmc2: queuing unknown CIS tuple 0x14 [] (0 bytes)
[    3.394876] mmc2: new high speed SDIO card at address 0001
...
...
[    3.450627] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null). Quota mode: none.
[    6.088500] EXT4-fs (mmcblk1p2): re-mounted. Opts: (null). Quota mode: none.
...
...

Additional information[edit | edit source]

If the root file system configuration does not automatically mount the partition, it is possible to mount the device using the following command:

root@desk-mx8mp:~# mkdir -p /mnt/boot
root@desk-mx8mp:~# mkdir -p /mnt/rfs
root@desk-mx8mp:~# mount /dev/mmcblk1p1 /mnt/boot/
root@desk-mx8mp:~# mount /dev/mmcblk1p2 /mnt/rfs/
root@desk-mx8mp:~# ls /mnt/boot/
Image  boot.scr  imx8mp-mito8mplus-cb1001.dtb  imx8mp-mito8mplus-cb1004.dtb  imx8mp-mito8mplus-cb1005.dtb  imx8mp-mito8mplus-cb1001.dtb  splash_image.bmp  stress_m7.bin  tee.bin
root@desk-mx8mp:~# ls /mnt/rfs/
bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  run  sbin  srv  sys  tmp  unit_tests  usr  var
root@desk-mx8mp:~#

and then the mounted partition are available on the /mnt/boot and /mnt/rfs root file system directories.

This instruction can be performed both on ORCA and MITO 8M MINI.