DESK-MP1-L/Peripherals/micro SD

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2023/08/02 DESK-MP1-L-1.0.0 release


Peripheral SD[edit | edit source]

Device tree configuration[edit | edit source]

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

From kernel device tree stm32mp157a-dcsb5000dd1r.dts:

&pinctrl {
...
...
	sdmmc1_pins_mx: sdmmc1_mx-0 {
		u-boot,dm-pre-reloc;
		pins1 {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('C', 8, AF12)>, /* SDMMC1_D0 */
					 <STM32_PINMUX('C', 9, AF12)>, /* SDMMC1_D1 */
					 <STM32_PINMUX('C', 11, AF12)>, /* SDMMC1_D3 */
					 <STM32_PINMUX('D', 2, AF12)>, /* SDMMC1_CMD */
					 <STM32_PINMUX('E', 6, AF8)>; /* SDMMC1_D2 */
			bias-disable;
			drive-push-pull;
			slew-rate = <1>;
		};
		pins2 {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('C', 12, AF12)>; /* SDMMC1_CK */
			bias-disable;
			drive-push-pull;
			slew-rate = <3>;
		};
	};

	sdmmc1_opendrain_pins_mx: sdmmc1_opendrain_mx-0 {
		u-boot,dm-pre-reloc;
		pins1 {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('C', 8, AF12)>, /* SDMMC1_D0 */
					 <STM32_PINMUX('C', 9, AF12)>, /* SDMMC1_D1 */
					 <STM32_PINMUX('C', 11, AF12)>, /* SDMMC1_D3 */
					 <STM32_PINMUX('E', 6, AF8)>; /* SDMMC1_D2 */
			bias-disable;
			drive-push-pull;
			slew-rate = <1>;
		};
		pins2 {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('C', 12, AF12)>; /* SDMMC1_CK */
			bias-disable;
			drive-push-pull;
			slew-rate = <3>;
		};
		pins3 {
			u-boot,dm-pre-reloc;
			pinmux = <STM32_PINMUX('D', 2, AF12)>; /* SDMMC1_CMD */
			bias-disable;
			drive-open-drain;
			slew-rate = <1>;
		};
	};

	sdmmc1_sleep_pins_mx: sdmmc1_sleep_mx-0 {
		pins {
			pinmux = <STM32_PINMUX('C', 8, ANALOG)>, /* SDMMC1_D0 */
					 <STM32_PINMUX('C', 9, ANALOG)>, /* SDMMC1_D1 */
					 <STM32_PINMUX('C', 11, ANALOG)>, /* SDMMC1_D3 */
					 <STM32_PINMUX('C', 12, ANALOG)>, /* SDMMC1_CK */
					 <STM32_PINMUX('D', 2, ANALOG)>, /* SDMMC1_CMD */
					 <STM32_PINMUX('E', 6, ANALOG)>; /* SDMMC1_D2 */
		};
	};
...
...
};
...
...
&sdmmc1{
	pinctrl-names = "default", "opendrain", "sleep";
	pinctrl-0 = <&sdmmc1_pins_mx>;
	pinctrl-1 = <&sdmmc1_opendrain_pins_mx>;
	pinctrl-2 = <&sdmmc1_sleep_pins_mx>;
	status = "okay";

	/* USER CODE BEGIN sdmmc1 */
	cd-gpios = <&gpioe 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
	disable-wp;
	st,neg-edge;
	bus-width = <4>;
	vmmc-supply = <&v3v3>;
	/* USER CODE END sdmmc1 */
};
...
...

Accessing the peripheral[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.:

root@desk-mp1:~# dmesg | grep mmc
[    0.000000] Kernel command line: root=/dev/mmcblk1p10 rootwait rw console=ttySTM0,115200
[    2.216453] mmci-pl18x 48004000.mmc: mmc0: PL180 manf 53 rev2 at 0x48004000 irq 38,0 (pio)
[    2.417608] mmci-pl18x 58005000.mmc: Got CD GPIO
[    2.422190] mmci-pl18x 58005000.mmc: mmc1: PL180 manf 53 rev2 at 0x58005000 irq 42,0 (pio)
[    2.447764] mmc0: queuing unknown CIS tuple 0x01 [d9 01 ff] (3 bytes)
[    2.459096] mmci-pl18x 58007000.mmc: mmc2: PL180 manf 53 rev2 at 0x58007000 irq 43,0 (pio)
[    2.467440] mmc0: queuing unknown CIS tuple 0x1a [01 01 00 02 07] (5 bytes)
[    2.476177] mmc0: queuing unknown CIS tuple 0x1b [c1 41 30 30 ff ff 32 00] (8 bytes)
[    2.484060] mmc0: queuing unknown CIS tuple 0x14 [] (0 bytes)
[    2.495219] mmc0: new high speed SDIO card at address 0001
[    2.502454] mmc1: new high speed SDHC card at address 59b4
[    2.509422] mmcblk1: mmc1:59b4 USDU1 14.9 GiB 
[    2.532495] mmcblk1: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11
[    2.598234] mmc2: new DDR MMC card at address 0001
[    2.603366] mmcblk2: mmc2:0001 W62704 3.53 GiB 
[    2.612505] mmcblk2boot0: mmc2:0001 W62704 2.00 MiB 
[    2.619409] mmcblk2boot1: mmc2:0001 W62704 2.00 MiB 
[    2.625675] mmcblk2rpmb: mmc2:0001 W62704 512 KiB, chardev (240:0)
[    3.320665] EXT4-fs (mmcblk1p10): recovery complete
[    3.328018] EXT4-fs (mmcblk1p10): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
[    8.586451] EXT4-fs (mmcblk1p10): re-mounted. Opts: (null). Quota mode: disabled.
[    8.819545] EXT4-fs (mmcblk1p8): recovery complete
[    8.822966] EXT4-fs (mmcblk1p8): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
[    9.403677] EXT4-fs (mmcblk1p9): recovery complete
[    9.411111] EXT4-fs (mmcblk1p9): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.
[    9.745622] EXT4-fs (mmcblk1p11): recovery complete
[    9.749683] EXT4-fs (mmcblk1p11): mounted filesystem with ordered data mode. Opts: (null). Quota mode: disabled.

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-mp1:~# mkdir -p /mnt/boot
root@desk-mp1:~# mkdir -p /mnt/rfs
root@desk-mp1:~# mount /dev/mmcblk1p1 /mnt/boot/
root@desk-mp1:~# mount /dev/mmcblk1p2 /mnt/rfs/
root@desk-mp1:~# ls /mnt/boot/
boot.scr  lost+found  stm32mp157a-dcsb5000dd1r.dtb  uImage
root@desk-mp1:~# ls /mnt/rfs/
bin  boot  dev  etc  home  lib  lost+found  media  mnt  proc  run  sbin  srv  sys  tmp  usr  var  vendor
root@desk-mp1:~#

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