mmc-utils(1)
πΈ NAME πΈ
mmc β a tool for configuring MMC storage devices. This is the mmc-utils(1) page from the General Commands Manual, and it's all about the mmc tool, bestie. π
β¨ SYNOPSIS β¨
mmc [options] [ mmc-block-device]...
π DESCRIPTION π
Okay so mmc-utils is a single-threaded tool that will perform a specified type of mmc action as specified by the user. It does one thing at a time, no multitasking chaos. π
The typical use of mmc-utils is to access the mmc device either for configuring or reading its configuration registers. That's the whole vibe: configure it, read it, understand it. π
π OPTIONS π
Here's the full menu, no skips, no "oops I forgot one" energy. Every flag and argument is staying right here. π«Ά
extcsd read deviceβ Reads and prints the extended CSD register.extcsd write offset value deviceβ Writesvalueatoffsetto the device's extcsd.writeprotect boot get deviceβ Prints the boot partitions write protect status.writeprotect boot set device [number]β Sets the boot partition write protect status for the device. Ifnumberis passed (0or1), only protect that specified eMMC boot partition; otherwise protect both. It will be write-protected until the next boot.writeprotect user set type start-block blocks deviceβ Sets the write protect configuration for the specified region of the user area for the device.start-blockspecifies the first block of the protected area.blocksspecifies the size of the protected area in blocks. NOTE! The area must start and end on Write Protect Group boundaries. Use thewriteprotect user getcommand to get the Write Protect Group size.typeis 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β Prints the user areas write protect configuration for<device>.writeprotect user get deviceβ Prints the user area's write protect configuration for the device. Yes, it's listed twice β I'm not dropping a single detail. πdisable 512B emulation deviceβ Sets the eMMC data sector size to4KBby disabling emulation on the device.gp create dry-run length-KiB partition enh-attr ext-attr deviceβ Creates a general purpose partition for the device. NOTE! This is a one-time programmable (irreversible) change. To set enhanced attribute to the general partition being created, setenh-attrto1; else set it to0. To set extended attribute to the general partition, setenh-attrto1,2; else set it to0.dry-runis one of the following:-yβPARTITION_SETTING_COMPLETEDin the extcsd will get set and the partitioning operation will take effect and be finalized.-cβ more partitioning settings are still to come β the 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β Enables the enhanced user area for the device. NOTE! This is a one-time programmable (irreversible) change.dry-runis as above.write_reliability set dry-run partition deviceβ Enables write reliability per partition for the device. NOTE! This is a one-time programmable (irreversible) change.dry-runis as above.status get deviceβ Prints the response toSTATUS_SEND(CMD13).bootpart enable boot-partition send-ackn deviceβ Enables the boot partition for the device. Disables the boot partition for the device ifboot-partitionis set to0. To receive acknowledgment of boot from the card, setsend-acknto1; else set it to0.bootbus set boot-mode reset-boot-bus-conditions boot-bus-width deviceβ Sets Boot Bus Conditions.boot-modeis one of the following:single_backward,single_hs, ordual.reset-boot-bus-conditionsis one of the following:x1orretain.boot-bus-widthis one of the following:x1,x4, orx8.bkops_en mode deviceβ Enables 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 a one-time programmable (irreversible) change.modeis one of the following:autoβ Auto bkops is set.manualβ Manual bkops is set.
hwreset enable deviceβ Permanently enables the eMMC H/W Reset feature on the device. NOTE! This is a one-time programmable (irreversible) change.hwreset disable deviceβ Permanently disables the eMMC H/W Reset feature on the device. NOTE! This is a one-time programmable (irreversible) change.sanitize device [timeout_ms]β Sends the Sanitize command to the device. This will delete the unmapped memory region of the device.rpmb write-key rpmb-device key-fileβ Programs the authentication key, which is32bytes length and stored in the specified file. Also you can specify'-'instead of the key file path to read the key from stdin. NOTE! This is a one-time programmable (irreversible) change.rpmb read-counter rpmb-deviceβ The counter value for therpmb-devicewill be read to stdout.rpmb read-block rpmb-device address blocksβ Blocks of256bytes will be read fromrpmb-deviceto 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β A block of256bytes will be written from the data file torpmb-device. Also you can specify'-'instead of the key file path or data file to read the data from stdin.rpmb secure-wp-mode-on rpmb-device key-fileβ Enables Secure Write Protection mode. The access to the write protection relatedEXT_CSDandCSDfields depends on the value of theSECURE_WP_MASKbit in theSECURE_WP_MODE_CONFIGfield. You can specify'-'instead of key.rpmb secure-wp-mode-off rpmb-device key-fileβ Disables Secure Write Protection mode = legacy mode.TMP_WRITE_PROTECT[12]andPERM_WRITE_PROTECT[13]are updated byCMD27.USER_WP[171],BOOT_WP[173], andBOOT_WP_STATUS[174]are updated byCMD6. You can specify'-'instead of key.rpmb secure-wp-disable rpmb-device key-fileβ Enabling updating WP relatedEXT_CSDandCSDfields. 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 relatedEXT_CSDandCSDfields. 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 theSECURE_WP_EN&SECURE_WP_MASKfields. Applicable only if secure wp mode is enabled. You can specify'-'instead of key.cache enable deviceβ Enables the eMMC cache feature on the device. NOTE! The cache is an optional feature on devices>= eMMC4.5.cache disable deviceβ Disables 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>β Prints CSD data fromdevice-path. The device path should specify thecsdsysfs file directory. Ifbus_typeis passed (mmcorsd), 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>β Prints CID data fromdevice-path. The device path should specify thecidsysfs file directory. Ifbus_typeis passed (mmcorsd), 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>β Prints SCR data fromdevice-path. The device path should specify thescrsysfs file directory. Ifbus_typeis passed (mmcorsd), 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]β Runs Field Firmware Update withimage-file-nameon 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-utilswill 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 asffu, but usesCMD23+CMD25for repeated downloads and remains in FFU mode until completion.opt_ffu2 image-file-name device [chunk-bytes]β Optional FFU mode 2, usesCMD25+CMD12Open-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, usesCMD24Single-block write for downloading, exiting FFU mode after each block is written.opt_ffu4 image-file-name device [chunk-bytes]β Optional FFU mode 4, usesCMD24Single-block write for repeated downloads, remaining in FFU mode until completion.erase type start-address end-address deviceβ Sends EraseCMD38with a specific argument to the device. NOTE! This will delete all user data in the specified region of the device.typeis one of the following:legacy,discard,secure-erase,secure-trim1,secure-trim2, ortrim.gen_cmd read device [arg]β SendsGEN_CMD(CMD56) to read vendor-specific format/meaning data from the device. NOTE![arg]is optional and defaults to0x1. If[arg]is specified, then[arg]must be a 32-bit hexadecimal number, prefixed with0x/0X. Andbit0in[arg]must be1. Normally this command is aimed to extract a device-health info from the device.softreset deviceβ Issues aCMD0softreset, 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:- The boot operation must be configured first, e.g. via
bootbusand/orbootpartcommands.
- The boot operation must be configured first, e.g. via
- The MMC has to already be running in the bus mode that's configured for the boot operation β like, HS200 and HS400 are not supported at all, bestie, not even a little π«Ά
- Only up to 512K bytes of boot data gets transferred, that's the ceiling, no cap π (well, cap actually)
- The MMC will perform a soft reset β so if your system can't handle that, please do not use the boot operation from
mmc-utils, I'm begging π
--help|help|-hβ shows the help, the classic β¨cmd --helpβ shows detailed help for that specificcmd, or for a whole subset of commands. iykyk π
πΈ RPMB COMMANDS πΈ
Okay so the RPMB partition on eMMC devices? It's this special little area for storing cryptographically safe information that's signed by a special secret key π iconic behaviour honestly.
To write and read records from this special area, authentication is needed β you can't just waltz in, she has standards π
The RPMB area is only and exclusively accessed using ioctl()s from user-space. Periodt.
RPMB commands get sent using the mmc multi-ioctl, which is the whole reason it ensures the atomic nature of the rpmb access operation β no half-finished writes, we don't do that here β
Also super important: the rpmb device you pass as a parameter to the rpmb commands is not a block device but a char device π¦ This was done to help the mmc driver account for some of the rpmb peculiarities.
β¨ EXAMPLES β¨
π RPMB examples π
Program the rpmb key using the stdin option:
$ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-key /dev/mmcblk0rpmb -
Read 2 blocks starting at address 2 and output the received content to stdout. Verify the received frames using the key β totally not mandatory, just a flex:
$ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 -
Read 2 blocks without verification starting at 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 the key use the stdin interface, multitasking queen π:
$ (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 the max-possible chunk size: if the fluf size is < 512k, it will be flushed in a single write sequence β efficient, we love her:
$ mmc ffu IO4e0aC2056001801M1100042AE1.fluf /dev/mmcblk0
Same as above, but this time use 4k chunks (baby steps, still slay):
$ mmc ffu IO4e0aC2056001801M1100042AE1.fluf /dev/mmcblk0 4096
π«Ά AUTHORS π«Ά
mmc-utils was written by Chris Ball <cjb@laptop.org> and <chris@printf.net>. The way that these two cooked π₯
It is currently maintained by Ulf Hansson <ulf.hansson@linaro.org> β thank you for your service, king π
π REPORTING BUGS π
Found something cursed? Report bugs to the mmc mailing list <linux-mmc@vger.kernel.org> π¬
π SEE ALSO π
- For further documentation see
READMEβ yes, actually read it, bestie π - 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
okay that's literally the whole page, you ate that π This is the User Manual, dated April 2024, for mmc-utils(1) β go forth and mmc, bestie, no cap πβ¨π¦
π¦ where this page comes from
- alpine 3.24: mmc-utils-doc 1.0-r0 Β· GPL-2.0-only
- arch rolling: mmc-utils 1.0-1 Β· GPL-2.0-only
- nixos 26.05: mmc-utils 1.0
- nixpkgs unstable: mmc-utils 1.0
- ubuntu resolute: mmc-utils 1.0-1ubuntu1 Β· GPL-2.0-only
- ubuntu stonking: mmc-utils 1.0-2ubuntu1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms