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