logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

mmc - a tool for configuring MMC storage devices

Authors

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

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.

Examples

RPMBexamples
              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 - -

       FieldFirmwareUpdate(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

Name

       mmc -  a tool for configuring MMC storage devices

Options

extcsdreaddevice
              Read and prints the extended csd register

       extcsdwriteoffsetvaluedevice
              Write value at offset to the device's extcsd

       writeprotectbootgetdevice
              Print the boot partitions write protect status

       writeprotectbootsetdevice[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.

       writeprotectusersettypestart-blockblocksdevice
              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.

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

       disable512Bemulationdevice
              Set the eMMC data sector size to 4KB by disabling emulation on the device.

       gpcreatedry-runlength-KiBpartitionenh-attrext-attrdevice
              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_areasetdry-runstart-KiBlength-KiBdevice
              Enable the enhanced user area for the device.
              NOTE!  This is a one-time programmable (irreversible) change.  dry-run is as above.

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

       statusgetdevice
              Print the response to STATUS_SEND (CMD13).

       bootpartenableboot-partitionsend-ackndevice
              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.

       bootbussetboot-modereset-boot-bus-conditionsboot-bus-widthdevice
              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_enmodedevice
              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

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

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

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

       rpmbwrite-keyrpmb-devicekey-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.

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

       rpmbread-blockrpmb-deviceaddressblocks-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.

       rpmbwrite-blockrpmb-deviceaddress256-byte-data-filekey-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.

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

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

       csdreaddevice-path
              Print CSD data from device-path.  The device path should specify the csd sysfs file directory.

       cidreaddevice-path
              Print CID data from device-path.  The device path should specify the cid sysfs file directory.

       scrreaddevice-path
              Print SCR data from device-path.  The device path should specify the scr sysfs file directory.

       ffuimage-file-namedevice[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).

       erasetypestart-addressend-addressdevice
              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_cmdreaddevice [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.

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

       boot_operationboot-data-filedevice
               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.

Reporting Bugs

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

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.

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

User Manual                                        April 2024                                       mmc-utils(1)

Synopsis

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

See Also