DESK-RZ-L/Peripherals/SD

From DAVE Developer's Wiki
Jump to: navigation, search
History
Issue Date Notes
2025/12/16 DESK-RZ-L-1.x.x


Peripheral SD[edit | edit source]

The 4-bit uSD card is mainly used as a kernel and Root File System (RFS) storage device.

N.B.: the Card Detect (CD) signal is not native in the SoC; a GPIO expander is used to hanlde it. The expander used is exp_0 on the i2c_0 bus.

The CD pin is used only by Linux. In U-Boot, since there is no support for the I2C bus, the CD pin is not used to detect whether a uSD card is present or not.

Configuration[edit | edit source]

ConfigID Note
2002 -
2003 -

Device tree configuration[edit | edit source]

Below is an example of a device tree configuration used on a standard DAVE kit for the ZERO Evaluation Kit.

From rzt2h-eb23-cb2003.dtsi:

...
// uSD
&sdhi0 {
	pinctrl-0 = <&sdhi0_pins>;
	pinctrl-names = "default";

	vmmc-supply = <&reg_3p3v>;
	bus-width = <4>;
	disable-wp;

	cd-gpios = <&exp_0 15 GPIO_ACTIVE_HIGH>;

	status = "okay";
};
...
&i2c0 {
...
	// U13
	exp_0: gpio_exp_0@74 {
		compatible = "ti,tca9539";
		reg = <0x74>;

		vcc-supply = <&reg_exp_3p3v>;

		#address-cells = <1>;
		#size-cells = <0>;

		#gpio-cells = <2>;
		gpio-controller;

	};
...
};
...
&pinctrl {
...
	sdhi0_pins: sd0 {
		sd0_data {
			pinmux =    <RZT2H_PORT_PINMUX(12, 2, 0x29)>,   /* P12_2 SD0_DATA0  | B_G20 E8 */
				        <RZT2H_PORT_PINMUX(12, 3, 0x29)>,   /* P12_3 SD0_DATA1  | B_G21 E7 */
				        <RZT2H_PORT_PINMUX(12, 4, 0x29)>,   /* P12_4 SD0_DATA2  | B_H20 B6 */
				        <RZT2H_PORT_PINMUX(12, 5, 0x29)>;   /* P12_5 SD0_DATA3  | B_H21 G7 */
		};

		sd0_ctrl {
			pinmux =    <RZT2H_PORT_PINMUX(12, 0, 0x29)>,   /* P12_0 SD0_CLK    | B_F21 D7 */
				        <RZT2H_PORT_PINMUX(12, 1, 0x29)>;   /* P12_1 SD0_CMD    | B_E20 G8 */
		};
	};
...
};

Accessing the peripheral[edit | edit source]

The uSD card appears as an MMC device with instance 0, as described in the aliases section of the DTS:

/ {
...
	aliases {
...
		mmc0 = &sdhi0;
...
	};
...
};
...


The following example uses an 8 GB uSD card is used with 2 partitions. The second partition contains the Root File System (RFS), which includes the boot directory where the kernel and DTB binaries are located.

U-boot[edit | edit source]

=> mmc dev 0
switch to partitions #0, OK
mmc0 is current device
=> mmc info
Device: mmc@92080000
Manufacturer ID: 3
OEM: 5344
Name: SA08G 
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
=> mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     4096            40660           02a87beb-01     0c
  2     44760           6687128         02a87beb-02     83

Test: load kernel *Image* from the /boot directory on the RFS partition

=> run mmc_loadk 
20515328 bytes read in 819 ms (23.9 MiB/s)

Linux[edit | edit source]

...
[    3.039309] mmc0: new high speed SDHC card at address aaaa
[    3.045360] mmcblk0: mmc0:aaaa SA08G 7.40 GiB 
[    3.055065]  mmcblk0: p1 p2
...
[    3.556655] EXT4-fs (mmcblk0p2): recovery complete
[    3.562426] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    5.349916] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
...
root@desk-t2h-usd-devel:~# lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0      179:0    0  7.4G  0 disk 
|-mmcblk0p1  179:1    0 19.9M  0 part 
`-mmcblk0p2  179:2    0  3.2G  0 part /