mmc-utils(1)

NAME
mmc - a tool for configuring MMC storage devices

SYNOPSIS
mmc [options] [ mmc-block-device]...

DESCRIPTION
mmc-utils is a single-threaded tool that will perform a specified type of mmc action as specified by the user.
The typical use of mmc-utils is to access the mmc device either for configuring or reading its configuration registers.

OPTIONS

extcsd read device
    Read and prints the extended csd register

extcsd write offset value device
    Write value at offset to the device's extcsd

writeprotect boot get device
    Print the boot partitions write protect status

writeprotect boot set device [number]
    Set the boot partition write protect status for the device.
    If number is passed (0 or 1), only protect that specified eMMC boot partition, otherwise protect both.
    It will be write-protected until the next boot.

writeprotect user get device
    Print the user areas write protect configuration for <device>.

writeprotect user set type start-block blocks device
    Set the write protect configuration for the specified region of the user area for the device.
    start-block specifies the first block of the protected area.
    blocks specifies the size of the protected area in blocks.
    NOTE! The area must start and end on Write Protect Group boundaries, Use the "writeprotect user get" command to get the Write Protect Group size.
     type is one of the following:

        none
            Clear temporary write protection.

        temp
            Set temporary write protection.

        pwron
            Set write protection until the next power on.

writeprotect user get device
    Print the user area's write protect configuration for the device.

disable 512B emulation device
    Set the eMMC data sector size to 4KB by disabling emulation on the device.

gp create dry-run length-KiB partition enh-attr ext-attr device
    Create general purpose partition for the device.
    NOTE! This is a one-time programmable (irreversible) change.
    To set enhanced attribute to general partition being created set enh-attr to 1 else set it to 0.
    To set extended attribute to general partition set enh-attr to 1,2 else set it to 0.
    dry-run is one of the following:

        -y  PARTITION_SETTING_COMPLETED in the extcsd will get set and the partitioning operation will take effect and be finalized.

        -c  more partitioning settings are still to come - partitioning operation will not take effect.

        otherwise
            These changes will not take effect neither now nor after a power cycle.

enh_area set dry-run start-KiB length-KiB device
    Enable the enhanced user area for the device.
    NOTE! This is a one-time programmable (irreversible) change. dry-run is as above.

write_reliability set  dry-run  partition  device
    Enable write reliability per partition for the device.
    NOTE! This is a one-time programmable (irreversible) change. dry-run is as above.

status get device
    Print the response to STATUS_SEND (CMD13).

bootpart enable boot-partition send-ackn device
    Enable the boot partition for the device. Disable the boot partition for the device if is boot-partition set to 0.
    To receive acknowledgment of boot from the card set send-ackn to 1, else set it to 0.

bootbus set boot-mode reset-boot-bus-conditions boot-bus-width device
    Set Boot Bus Conditions.
    boot-mode is one of the following: single_backward, single_hs, or dual.
    reset-boot-bus-conditions is one of the following: x1 or retain.
    boot-bus-width is one of the following: x1, x4, or x8.

bkops_en mode device
    Enable the eMMC BKOPS feature on the device. The auto (AUTO_EN) setting is only supported on eMMC 5.0 or newer.
    NOTE! Setting manual (MANUAL_EN) is one-time programmable (irreversible) change.
    mode is one of the following:

        auto
            Auto bkops is set

        manual
            Manual bkops is set

hwreset enable device
    Permanently enable the eMMC H/W Reset feature on the device.
    NOTE! This is a one-time programmable (irreversible) change.

hwreset disable device
    Permanently disable the eMMC H/W Reset feature on the device.
    NOTE! This is a one-time programmable (irreversible) change.

sanitize device [timeout_ms]
    Send Sanitize command to the device. This will delete the unmapped memory region of the device.

rpmb write-key rpmb-device key-file
    Program authentication key which is 32 bytes length and stored in the specified file.
    Also you can specify '-' instead of key file path to read the key from stdin.
    NOTE! This is a one-time programmable (irreversible) change.

rpmb read-counter rpmb-device
    Counter value for the rpmb-device will be read to stdout.

rpmb read-block rpmb-device address blocks- output-le [key-file]
    Blocks of 256 bytes will be read from rpmb-device to output file or stdout if '-' is specified. If key is specified - read data will be verified.

rpmb write-block rpmb-device address 256-byte-data-file key-file
    Block of 256 bytes will be written from data file to rpmb-device.
    Also you can specify '-' instead of key file path or data file to read the data from stdin.

rpmb secure-wp-mode-on rpmb-device key-file
    Enable Secure Write Protection mode.
    The access to the write protection related EXT_CSD and CSD fields depends on the value of SECURE_WP_MASK bit in SECURE_WP_MODE_CONFIG field.
    You can specify '-' instead of key.

rpmb secure-wp-mode-off rpmb-device key-file
    Disable Secure Write Protection mode = legacy mode.
    TMP_WRITE_PROTECT[12] and PERM_WRITE_PROTECT[13] are updated by CMD27.
    USER_WP[171], BOOT_WP[173], and BOOT_WP_STATUS[174] are updated by CMD6.
    You can specify '-' instead of key.

rpmb secure-wp-disable rpmb-device key-file
    Enabling updating WP related EXT_CSD and CSD fields.
    Applicable only if secure wp mode is enabled.
    You can specify '-' instead of key.

rpmb secure-wp-enable rpmb-device key-file
    Disabling updating WP related EXT_CSD and CSD fields.
    Applicable only if secure wp mode is enabled.
    You can specify '-' instead of key.

rpmb secure-wp-en-read rpmb-device [key-file]
    Reads the status of the SECURE_WP_EN & SECURE_WP_MASK fields
    Applicable only if secure wp mode is enabled.
    You can specify '-' instead of key.

cache enable device
    Enable the eMMC cache feature on the device.
    NOTE! The cache is an optional feature on devices >= eMMC4.5.

cache disable device
    Disable the eMMC cache feature on the device.
    NOTE! The cache is an optional feature on devices >= eMMC4.5.

csd read [-h][-v] [-b bus_type] [-r register] <device-path>
    Print CSD data from device-path. The device path should specify the csd sysfs file directory.
    If bus_type is passed (mmc or sd), the register content must be passed as well, and no need for device path.
    It is useful for cases where we are getting the register value without having the actual platform.

cid read [-h][-v] [-b bus_type] [-r register] <device-path>
    Print CID data from device-path. The device path should specify the cid sysfs file directory.
    If bus_type is passed (mmc or sd), the register content must be passed as well, and no need for device path.
    It is useful for cases where we are getting the register value without having the actual platform.

scr read [-h][-v] [-b bus_type] [-r register] <device-path>
    Print SCR data from device-path. The device path should specify the scr sysfs file directory.
    If bus_type is passed (mmc or sd), the register content must be passed as well, and no need for device path.
    It is useful for cases where we are getting the register value without having the actual platform.

ffu image-file-name device [chunk-bytes]
    Run Field Firmware Update with image-file-name on the device.
    [chunk-bytes] is optional and defaults to its max - 512k. should be in decimal bytes and sector aligned.
    if [chunk-bytes] is omitted, mmc-utils will try to run ffu using the largest possible chunks: max(image-file, 512k).

opt_ffu1 image-file-name  device  [chunk-bytes]
    Optional FFU mode 1, it's the same as 'ffu', but uses CMD23+CMD25 for repeated downloads and remains in FFU mode until completion.

opt_ffu2 image-file-name  device  [chunk-bytes]
    Optional FFU mode 2, uses CMD25+CMD12 Open-ended Multiple-block write to download and remains in FFU mode until completion.

opt_ffu3 image-file-name  device  [chunk-bytes]
    Optional FFU mode 3, uses CMD24 Single-block write for downloading, exiting FFU mode after each block is written.

opt_ffu4 image-file-name  device  [chunk-bytes]
    Optional FFU mode 4, uses CMD24 Single-block write for repeated downloads, remaining in FFU mode until completion.

erase type start-address end-address device
    Send Erase CMD38 with specific argument to the device.
    NOTE!: This will delete all user data in the specified region of the device.
    type is one of the following: legacy, discard, secure-erase, secure-trim1, secure-trim2, or trim.

gen_cmd read device [arg]
    Send GEN_CMD (CMD56) to read vendor-specific format/meaning data from the device.
    NOTE!: [arg] is optional and defaults to 0x1. If [arg] is specified, then [arg] must be a 32-bit hexadecimal number, prefixed with 0x/0X. And bit0 in [arg] must be 1. Normally this command is aimed to extract a device-health info from the device.

softreset device
    Issues a CMD0 softreset, e.g. for testing if hardware reset for UHS works

boot_operation boot-data-file device
     Does the alternative boot operation and writes the specified starting blocks of boot data into the requested file. Note some limitations:

        1)  The boot operation must be configured first, e.g. via bootbus and/or bootpart commands

        2)  The MMC must currently be running at the bus mode that is configured for the boot operation (HS200 and HS400 not supported at all).

        3)  Only up to 512K bytes of boot data will be transferred.

        4)  The MMC will perform a soft reset, if your system cannot handle that do not use the boot operation from mmc-utils.

--help | help | -h
    Show the help

cmd --help
    Show detailed help for that specific cmd or subset of commands.

RPMB COMMANDS
The RPMB partition on the eMMC devices is a special area used for storing cryptographically safe information signed by a special secret key.
To write and read records from this special area, authentication is needed.
The RPMB area is *only* and *exclusively* accessed using ioctl()s from user-space.
RPMB commands are send using the mmc multi-ioctl, thus ensures that the atomic nature of the rpmb access operation.
The rpmb device given as a parameter to the rpmb commands is not a block device but a char device.
This was done to help the mmc driver to account for some of the rpmb peculiarities.

EXAMPLES

RPMB examples
    Program rpmb key using the stdin option:

        $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-key /dev/mmcblk0rpmb -

    Read 2 blocks starting address 2 and output the received content to stdout. Verify the received frames using the key (not mandatory):

        $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 -

    Read 2 blocks without verification starting address 2 and output the received content to /tmp/block:

        $mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block

    Write a string of 'a's to address 2. both the input and key uses stdin interface:

        $ (awk 'BEGIN {while (c++<256) printf "a"}' | echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH) | mmc rpmb write-block /dev/mmcblk0rpmb 0x02 - -

Field Firmware Update (ffu) examples
    Do ffu using max-possible chunk size: If the fluf size < 512k, it will be flushed in a single write sequence.

        $ mmc ffu IO4e0aC2056001801M1100042AE1.fluf /dev/mmcblk0

    Same as above, this time use a 4k chunks:

        $ mmc ffu IO4e0aC2056001801M1100042AE1.fluf /dev/mmcblk0 4096

AUTHORS
mmc-utils was written by Chris Ball <cjb@laptop.org> and <chris@printf.net>.
It is currently maintained by Ulf Hansson <ulfh@kernel.org>.

REPORTING BUGS
Report bugs to the mmc mailing list <linux-mmc@vger.kernel.org>.

SEE ALSO
For further documentation see README.
A short intro - https://docs.kernel.org/driver-api/mmc/mmc-tools.html
official git tree - https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git