Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | mmc command |
Heinrich Schuchardt | b72160b | 2023-10-28 11:59:32 +0200 | [diff] [blame] | 4 | =========== |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 5 | |
| 6 | Synopsis |
| 7 | -------- |
| 8 | |
| 9 | :: |
| 10 | |
| 11 | mmc info |
| 12 | mmc read addr blk# cnt |
| 13 | mmc write addr blk# cnt |
| 14 | mmc erase blk# cnt |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 15 | mmc rescan [mode] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 16 | mmc part |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 17 | mmc dev [dev] [part] [mode] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 18 | mmc list |
| 19 | mmc wp |
| 20 | mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode> |
| 21 | mmc bootpart-resize <dev> <dev part size MB> <RPMB part size MB> |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 22 | mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 23 | mmc rst-function <dev> <value> |
Marek Vasut | 1f692e3 | 2023-10-31 13:20:17 +0100 | [diff] [blame] | 24 | mmc reg read <reg> <offset> [env] |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 25 | |
| 26 | Description |
| 27 | ----------- |
| 28 | |
| 29 | The mmc command is used to control MMC(eMMC/SD) device. |
| 30 | |
| 31 | The 'mmc info' command displays information (Manufacturer ID, OEM, Name, Bus Speed, Mode, ...) of MMC device. |
| 32 | |
| 33 | The 'mmc read' command reads raw data to memory address from MMC device with block offset and count. |
| 34 | |
| 35 | The 'mmc write' command writes raw data to MMC device from memory address with block offset and count. |
| 36 | |
| 37 | addr |
| 38 | memory address |
| 39 | blk# |
| 40 | start block offset |
| 41 | cnt |
| 42 | block count |
| 43 | |
Jaehoon Chung | f14d260 | 2021-05-10 16:04:02 +0900 | [diff] [blame] | 44 | The 'mmc erase' command erases *cnt* blocks on the MMC device starting at block *blk#*. |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 45 | |
| 46 | blk# |
| 47 | start block offset |
| 48 | cnt |
| 49 | block count |
| 50 | |
| 51 | The 'mmc rescan' command scans the available MMC device. |
| 52 | |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 53 | mode |
| 54 | speed mode to set. |
Heinrich Schuchardt | 44acc5f | 2021-11-05 16:35:44 +0100 | [diff] [blame] | 55 | CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is |
| 56 | passed as a decimal number according to the following table: |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 57 | |
Heinrich Schuchardt | 44acc5f | 2021-11-05 16:35:44 +0100 | [diff] [blame] | 58 | ========== ========================== |
| 59 | Speed mode Description |
| 60 | ========== ========================== |
| 61 | 0 MMC legacy |
| 62 | 1 MMC High Speed (26MHz) |
| 63 | 2 SD High Speed (50MHz) |
| 64 | 3 MMC High Speed (52MHz) |
| 65 | 4 MMC DDR52 (52MHz) |
| 66 | 5 UHS SDR12 (25MHz) |
| 67 | 6 UHS SDR25 (50MHz) |
| 68 | 7 UHS SDR50 (100MHz) |
| 69 | 8 UHS DDR50 (50MHz) |
| 70 | 9 UHS SDR104 (208MHz) |
| 71 | 10 HS200 (200MHz) |
| 72 | 11 HS400 (200MHz) |
| 73 | 12 HS400ES (200MHz) |
| 74 | ========== ========================== |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 75 | |
| 76 | A speed mode can be set only if it has already been enabled in the device tree |
| 77 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 78 | The 'mmc part' command displays the list available partition on current mmc device. |
| 79 | |
| 80 | The 'mmc dev' command shows or set current mmc device. |
| 81 | |
| 82 | dev |
| 83 | device number to change |
| 84 | part |
| 85 | partition number to change |
| 86 | |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 87 | mode |
| 88 | speed mode to set. |
Patrick Delaunay | 2ad5b09 | 2022-03-29 16:01:13 +0200 | [diff] [blame] | 89 | CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is |
| 90 | passed as a decimal number according to the following table: |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 91 | |
Patrick Delaunay | 2ad5b09 | 2022-03-29 16:01:13 +0200 | [diff] [blame] | 92 | ========== ========================== |
| 93 | Speed mode Description |
| 94 | ========== ========================== |
| 95 | 0 MMC legacy |
| 96 | 1 MMC High Speed (26MHz) |
| 97 | 2 SD High Speed (50MHz) |
| 98 | 3 MMC High Speed (52MHz) |
| 99 | 4 MMC DDR52 (52MHz) |
| 100 | 5 UHS SDR12 (25MHz) |
| 101 | 6 UHS SDR25 (50MHz) |
| 102 | 7 UHS SDR50 (100MHz) |
| 103 | 8 UHS DDR50 (50MHz) |
| 104 | 9 UHS SDR104 (208MHz) |
| 105 | 10 HS200 (200MHz) |
| 106 | 11 HS400 (200MHz) |
| 107 | 12 HS400ES (200MHz) |
| 108 | ========== ========================== |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 109 | |
| 110 | A speed mode can be set only if it has already been enabled in the device tree |
| 111 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 112 | The 'mmc list' command displays the list available devices. |
| 113 | |
| 114 | The 'mmc wp' command enables "power on write protect" function for boot partitions. |
| 115 | |
| 116 | The 'mmc bootbus' command sets the BOOT_BUS_WIDTH field. (*Refer to eMMC specification*) |
| 117 | |
| 118 | boot_bus_width |
| 119 | 0x0 |
| 120 | x1 (sdr) or x4(ddr) buswidth in boot operation mode (default) |
| 121 | 0x1 |
| 122 | x4 (sdr/ddr) buswidth in boot operation mode |
| 123 | 0x2 |
| 124 | x8 (sdr/ddr) buswidth in boot operation mode |
| 125 | 0x3 |
| 126 | Reserved |
| 127 | |
| 128 | reset_boot_bus_width |
| 129 | 0x0 |
| 130 | Reset buswidth to x1, Single data reate and backward compatible timing after boot operation (default) |
| 131 | 0x1 |
| 132 | Retain BOOT_BUS_WIDTH and BOOT_MODE value after boot operation. This is relevant to Push-pull mode operation only |
| 133 | |
| 134 | boot_mode |
| 135 | 0x0 |
| 136 | Use single data rate + backward compatible timing in boot operation (default) |
| 137 | 0x1 |
| 138 | Use single data rate + High Speed timing in boot operation mode |
| 139 | 0x2 |
| 140 | Use dual data rate in boot operation |
| 141 | 0x3 |
| 142 | Reserved |
| 143 | |
| 144 | The 'mmc partconf' command shows or changes PARTITION_CONFIG field. |
| 145 | |
Reuben Dowle | 55a81ad | 2021-05-14 10:15:43 +1200 | [diff] [blame] | 146 | varname |
| 147 | When showing the PARTITION_CONFIG, an optional environment variable to store the current boot_partition value into. |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 148 | boot_ack |
| 149 | boot acknowledge value |
| 150 | boot_partition |
| 151 | boot partition to enable for boot |
| 152 | 0x0 |
| 153 | Device not boot enabled(default) |
| 154 | 0x1 |
| 155 | Boot partition1 enabled for boot |
| 156 | 0x2 |
| 157 | Boot partition2 enabled for boot |
| 158 | 0x7 |
| 159 | User area enabled for boot |
| 160 | others |
| 161 | Reserved |
| 162 | partition_access |
| 163 | partitions to access |
| 164 | |
| 165 | The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions. |
Jaehoon Chung | f14d260 | 2021-05-10 16:04:02 +0900 | [diff] [blame] | 166 | |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 167 | dev |
| 168 | device number |
| 169 | boot part size MB |
| 170 | target size of boot partition |
| 171 | RPMB part size MB |
| 172 | target size of RPMB partition |
| 173 | |
| 174 | The 'mmc rst-function' command changes the RST_n_FUNCTION field. |
| 175 | **WARNING** : This is a write-once field. (*Refer to eMMC specification*) |
| 176 | |
| 177 | value |
| 178 | 0x0 |
| 179 | RST_n signal is temporarily disabled (default) |
| 180 | 0x1 |
| 181 | RST_n signal is permanently enabled |
| 182 | 0x2 |
| 183 | RST_n signal is permanently disabled |
| 184 | 0x3 |
| 185 | Reserved |
| 186 | |
Marek Vasut | 1f692e3 | 2023-10-31 13:20:17 +0100 | [diff] [blame] | 187 | The 'mmc reg read <reg> <offset> [env]' reads eMMC card register and |
| 188 | either print it to standard output, or store the value in environment |
| 189 | variable. |
| 190 | |
| 191 | <reg> with |
| 192 | optional offset <offset> into the register array, and print it to |
| 193 | standard output or store it into environment variable [env]. |
| 194 | |
| 195 | reg |
| 196 | cid |
| 197 | The Device IDentification (CID) register. Uses offset. |
| 198 | csd |
| 199 | The Device-Specific Data (CSD) register. Uses offset. |
| 200 | dsr |
| 201 | The driver stage register (DSR). |
| 202 | ocr |
| 203 | The operation conditions register (OCR). |
| 204 | rca |
| 205 | The relative Device address (RCA) register. |
| 206 | extcsd |
| 207 | The Extended CSD register. Uses offset. |
| 208 | offset |
| 209 | For 'cid'/'csd' 128 bit registers '[0..3]' in 32-bit increments. For 'extcsd' 512 bit register '[0..512,all]' in 8-bit increments, or 'all' to read the entire register. |
| 210 | env |
| 211 | Optional environment variable into which 32-bit value read from register should be stored. |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 212 | |
| 213 | Examples |
| 214 | -------- |
| 215 | |
| 216 | The 'mmc info' command displays device's capabilities: |
| 217 | :: |
| 218 | |
| 219 | => mmc info |
| 220 | Device: EXYNOS DWMMC |
| 221 | Manufacturer ID: 45 |
| 222 | OEM: 100 |
| 223 | Name: SDW16 |
| 224 | Bus Speed: 52000000 |
| 225 | Mode: MMC DDR52 (52MHz) |
| 226 | Rd Block Len: 512 |
| 227 | MMC version 5.0 |
| 228 | High Capacity: Yes |
| 229 | Capacity: 14.7 GiB |
| 230 | Bus Width: 8-bit DDR |
| 231 | Erase Group Size: 512 KiB |
| 232 | HC WP Group Size: 8 MiB |
| 233 | User Capacity: 14.7 GiB WRREL |
| 234 | Boot Capacity: 4 MiB ENH |
| 235 | RPMB Capacity: 4 MiB ENH |
| 236 | Boot area 0 is not write protected |
| 237 | Boot area 1 is not write protected |
| 238 | |
| 239 | The raw data can be read/written via 'mmc read/write' command: |
| 240 | :: |
| 241 | |
Alexander Shirokov | a705cab | 2023-04-27 12:12:07 +0200 | [diff] [blame] | 242 | => mmc read 40000000 5000 100 |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 243 | MMC read: dev # 0, block # 20480, count 256 ... 256 blocks read: OK |
| 244 | |
Alexander Shirokov | a705cab | 2023-04-27 12:12:07 +0200 | [diff] [blame] | 245 | => mmc write 40000000 5000 100 |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 246 | MMC write: dev # 0, block # 20480, count 256 ... 256 blocks written: OK |
| 247 | |
| 248 | The partition list can be shown via 'mmc part' command: |
| 249 | :: |
| 250 | |
| 251 | => mmc part |
| 252 | Partition Map for MMC device 0 -- Partition Type: DOS |
| 253 | |
| 254 | Part Start Sector Num Sectors UUID Type |
| 255 | 1 8192 131072 dff8751a-01 0e Boot |
| 256 | 2 139264 6291456 dff8751a-02 83 |
| 257 | 3 6430720 1048576 dff8751a-03 83 |
| 258 | 4 7479296 23298048 dff8751a-04 05 Extd |
| 259 | 5 7481344 307200 dff8751a-05 83 |
| 260 | 6 7790592 65536 dff8751a-06 83 |
| 261 | 7 7858176 16384 dff8751a-07 83 |
| 262 | 8 7876608 22900736 dff8751a-08 83 |
| 263 | |
| 264 | The current device can be shown or set via 'mmc dev' command: |
| 265 | :: |
| 266 | |
| 267 | => mmc dev |
| 268 | switch to partitions #0, OK |
| 269 | mmc0(part0) is current device |
| 270 | => mmc dev 2 0 |
| 271 | switch to partitions #0, OK |
| 272 | mmc2 is current device |
Aswath Govindraju | 6bc3dd6 | 2021-08-13 23:04:42 +0530 | [diff] [blame] | 273 | => mmc dev 0 1 4 |
| 274 | switch to partitions #1, OK |
| 275 | mmc0(part 1) is current device |
Jaehoon Chung | 277b7cd | 2021-04-02 09:15:32 +0900 | [diff] [blame] | 276 | |
| 277 | The list of available devices can be shown via 'mmc list' command: |
| 278 | :: |
| 279 | |
| 280 | => mmc list |
| 281 | mmc list |
| 282 | EXYNOS DWMMC: 0 (eMMC) |
| 283 | EXYNOS DWMMC: 2 (SD) |
| 284 | |
| 285 | Configuration |
| 286 | ------------- |
| 287 | |
| 288 | The mmc command is only available if CONFIG_CMD_MMC=y. |
| 289 | Some commands need to enable more configuration. |
| 290 | |
| 291 | write, erase |
| 292 | CONFIG_MMC_WRITE |
| 293 | bootbus, bootpart-resize, partconf, rst-function |
| 294 | CONFIG_SUPPORT_EMMC_BOOT=y |