44 Commits
Author SHA1 Message Date
rich e5b504deeb Micron CMD56 Additions 2023-07-31 13:58:50 +00:00
Christian Löhle c62dd8e415 mmc-utils: Implement alternative boot operation
Implements the alternative boot operation for eMMCs.
Note the limitations of the help.

This is mostly useful for testing purposes if you set
up the boot partition configuration correctly.

Usage:
$ sudo dd if=/dev/mmcblk2boot0 of=bootdatammcblk count=2
2+0 records in
2+0 records out
1024 bytes (1.0 kB, 1.0 KiB) copied, 0.00482308 s, 212 kB/s

$ sudo ./mmc boot_operation bootdata /dev/mmcblk2

$ diff -s bootdata bootdatammcblk
Files bootdata and bootdatammcblk are identical

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/f999a7ed7bb645948ac74d5d5341e913@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-11-09 11:52:52 +01:00
Christian Löhle 4a32d090dc mmc-utils: Add CMD0 softreset and preidle command
CMD0 may be used to see if the hardware can handle a UHS card
that completed the voltage switch. If a UHS card has problems
coming back up after CMD0 your hardware may not support a hard
reset properly.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/0657285aa7c64cbe89f9275fd5598345@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-10-24 19:00:07 +02:00
Bean Huo b7e4d5a6ae mmc-utils: Add General command CMD56 read support
We can use GEN_CMD (CMD56) to read a  data block with vendor-specific
format and meaning, which is very helpful and useful for customers to
analyze device health. This patch is to add support for this command.

At the same time, in order to make CMD56 universal, let more users of
mmc-utils can benefit from this. We will allow the user to enter [arg]
for special commands. Because some eMMC vendors provide an additional
set of commands beyond the GEN_CMD (CMD56) definition in the JEDEC
specification. These additional commands are implemented using generic
CMD56 commands, and they return a wealth of useful information about the
state of the NAND device. For these special purposes, the [31:1]stuff
bits in the CMD56 argument are used. You can refer to  Micron eMMC
"TN-FC-32: e·MMC Device Health Report" as an example.

I didn't add data parsing, just print the raw data as it is vendor-specific.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Avri Altman <Avri.Altman@wdc.com>
Tested-by: Rossler Jakob (Nokia - DE/Ulm) <jakob.rossler@nokia.com>
Link: https://lore.kernel.org/r/20220417111622.621650-1-huobean@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-04-26 13:48:57 +02:00
Ulf Hansson 0d493fb091 mmc-utils: Fix build error MMC_BLOCK_MAJOR undeclared
The reported build error:
In function read_extcsd: mmc_cmds.c:72:18: error: MMC_BLOCK_MAJOR
undeclared (first use in this function)

In commit 118dc4a090 ("mmc-utils: Remove unused MMC_BLOCK_MAJOR") the
define for MMC_BLOCK_MAJOR was dropped. In a way this commit is still
correct, but unfortunately it also introduced a dependency to a commit for
the Linux kernel (83fc5dd57f86 mmc: fix compilation of user API), which
fixes the mmc uapi header file.

Rather than relying on the commit in the kernel, let's include the missing
header for MMC_BLOCK_MAJOR.

Reported-by: Ming Liu <liu.ming50@gmail.com>
Fixes: 118dc4a090 ("mmc-utils: Remove unused MMC_BLOCK_MAJOR")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220426100605.36019-1-ulf.hansson@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-04-26 13:45:29 +02:00
Shankar Athanikar 4303889c8b Enhancement to do_status_get() function for detailed Response info
This enhancement covers detailed status register decoding with
ERROR/STATUS information when host sends CMD13(with SQS=0)

Signed-off-by: Shankar Athanikar <shankar.ma@samsung.com>
Reviewed-by: Mohan Raj Veerasamy <mohanraj.v@samsung.com>
Link: https://lore.kernel.org/r/20220211120449.195052-1-shankar.ma@samsung.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-02-17 16:15:21 +01:00
Marius Strobl 118dc4a090 mmc-utils: Remove unused MMC_BLOCK_MAJOR
It was added in commit 294bf86972 ("mmc-utils: Remove dependency on
linux/major.h.") but never actually used, apparently.

Signed-off-by: Marius Strobl <marius@FreeBSD.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220205205647.7677-2-marius@FreeBSD.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-02-08 16:15:23 +01:00
Kimito Sakata 43282e80e1 mmc-utils: Add eMMC erase command support
we have been using this erase feature for a while, but it is
still not merged into the upstream mmc-utils. Especially, for
the customer, every time when they update the mmc-utils, they
should re-install this patch again, let's try to make this
erase command upstreamed in the mmc-utils.

We need to send 3 MMC commands and it is important that they
stay in sequence. Therefore we are using MMC_IOC_MULTI_CMD.

Co-developed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Kimito Sakata <kimito.sakata@oracle.com>
Reviewed-by: Kenneth Gibbons <kenny.gibbons@oracle.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20210506191041.1178-1-oracleks043021@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-05-11 12:45:55 +02:00
Lars Pedersen ad6890a2dd mmc-utils: Add AUTO_EN support in the BKOPS_EN
This patch adds support to enable auto(AUTO_EN) and
manual(MANUAL_EN) in BKOPS_EN register. Auto bkops
can only be used on eMMC 5.0 or newer.

Signed-off-by: Lars Pedersen <lapeddk@gmail.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20191111110051.16490-1-lapeddk@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:12:23 +02:00
Julius Werner be4cac34ea mmc-utils: Expand 'writeprotect boot'
This patch updates 'mmc writeprotect boot set' with a few more optional
parameters, so that it can be used to enable permanent write-protection
and so that the two boot partitions can be protected independently. It
also splits protection information output by 'mmc writeprotect boot get'
by partition.

(Note: eMMC boot partitions are named "Area 1" and "Area 2" by the eMMC
spec, but mmcblk0boot0 and mmcblk0boot1 by Linux. To avoid confusion
between the two numbering schemes, this patch uses 0 and 1 throughout,
even when defining EXT_CSD register bits.)

Signed-off-by: Julius Werner <jwerner@chromium.org>
Link: https://lore.kernel.org/r/20200316202221.107714-1-jwerner@chromium.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:09:25 +02:00
Shivamurthy Shastri (sshivamurthy) 1b8b13beb4 mmc-utils: let FFU mode use CMD23 and CMD25
As per specification, the host can use either CMD24 or CMD25 in
closed-ended or open-ended way.
CMD25 is better option as it can flash the firmware image in one go.

Signed-off-by: Shivamurthy Shastri <sshivamurthy@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Link: https://lore.kernel.org/r/MN2PR08MB63973BF8F3C6959487BF5707B86A9@MN2PR08MB6397.namprd08.prod.outlook.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 14:55:52 +02:00
Jungseung Lee d40ec535b9 mmc-utils: feature spec 5.0+, add secure removal type fields to Extended CSD
Display secure removal type when printing Extended CSD
Example:
	# mmc extcsd read /dev/mmcblk0
	...
        Secure Removal Type [SECURE_REMOVAL_TYPE]: 0x39
         information is configured to be removed using a vendor defined
         Supported Secure Removal Type:
          information removed by an erase of the physical memory
          information removed using a vendor defined

Signed-off-by: Jungseung Lee <js07.lee@samsung.com>
Reviewed-by: Avri Altman <Avri.Altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2019-08-08 18:42:38 -04:00
Uwe Kleine-König a1a6120c34 mmc-utils: move offsetof from mmc.h to only user
offsetof isn't mmc specific, so remove it from mmc.h. As there is only a
single user define it there.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Chris Ball <chris@printf.net>
2018-02-16 20:19:40 -05:00
Uwe Kleine-König d8cf8d34c0 mmc-utils: drop unused header
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Chris Ball <chris@printf.net>
2018-02-16 20:19:13 -05:00
Uwe Kleine-König fcef164b23 mmc-utils: drop macro CHECK
This macro saves a few lines of code but is harder to read than the
equivalent code spelled out. IMHO the latter is more important, so
expand the macro everywhere and drop it.

While touching this also unbreak the strings used there for better
grepability.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Chris Ball <chris@printf.net>
2018-02-16 20:17:09 -05:00
Alexander Stein c22a92f948 mmc-utils: feature spec 5.0+, Pre EOL information
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Chris Ball <chris@printf.net>
2017-03-20 09:58:40 -04:00
Boris Schmidt 34a954b87c mmc-utils: feature spec 5.0+, device life time estimation for MLC and pSLC mode
Signed-off-by: Boris Schmidt <boris.schmidt@siemens.com>
2017-03-16 12:10:37 -04:00
Adrian Hunter a3d3331e68 mmc-utils: Add Command Queue fields to Extended CSD
Display Command Queue information when printing Extended CSD
Example:

	# mmc extcsd read /dev/mmcblk0 | grep CMDQ
	Command Queue Support [CMDQ_SUPPORT]: 0x01
	Command Queue Depth [CMDQ_DEPTH]: 16
	Command Enabled [CMDQ_MODE_EN]: 0x01

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
2016-06-23 16:28:08 -04:00
Al Cooper 0ca049f251 mmc-utils: Add ability to configure write protect on an eMMC device
Add commands to get and set write protect modes for the specified
areas of the user partition. The ability to set permanent write
protect is #ifdef'd with "DANGEROUS_COMMANDS_ENABLED" because
it has the ability to make the eMMC device and possibly the system
permanently unusable.

Signed-off-by: Al Cooper <alcooperx@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-06-07 16:55:09 -04:00
Markus Schuetterle bb779acfc3 mmc-utils: Add disable partition boot to 'mmc bootpart enable'
Modified 'bootpart enable' function to disable partition boot
by setting the <partition> parameter to 0.

Signed-off-by: Markus Schuetterle <markus.schuetterle@intel.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-05-11 09:33:01 -04:00
Avi Shchislowski 89cd01ed86 mmc_utils: add ffu support
Adding support for field firmware update over multiple command ioctl.
As multiple command ioctl is supported only from kernel 4.4, this patch
should be used against kernel 4.4 and above.

Known issues:
- There is no support for Multiple Block write commands (CMD25) in existing
  IOCTL implementation
- In case MODE_OPERATION_CODES field is not supported by the device
  manual reset of the device/platform is required.
  The reset issue discussed in another email thread - " [RFC 0/6] mmc:
  Field Firmware Update"

Signed-off-by: Yaniv Agman <yaniv.agman@sandisk.com>
Signed-off-by: Avi Shchislowski <avi.shchislowski@sandisk.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-03-08 14:22:41 -05:00
Al Cooper d0b46442b5 mmc-utils: add ability to enable/disable optional eMMC cache
The MMC4.5 specification added an optional cache for eMMC devices.
This change will add the ability to enable/disable the cache.

Signed-off-by: Al Cooper <acooperx@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
2015-05-01 08:38:26 -04:00
Al Cooper 64c2de8b14 mmc-utils: Add command to set the boot bus conditions
This was added because some eMMC devices had the boot bus conditions
set incorrectly causing them to hang on boot.

Signed-off-by: Al Cooper <acooperx@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
2015-05-01 08:38:17 -04:00
Balaji T K 7891236d62 mmc-utils: add support to create gp partition
create gp partition if needed with enhanced / extended attribute.

Signed-off-by: Balaji T K <balajitk@ti.com>
Signed-off-by: Chris Ball <chris@printf.net>
2015-05-01 08:38:06 -04:00
Balaji T K 4afc8c8168 mmc-utils: add check for max enhanced user area
In addition to user area, General purpose partition can be
be marked with enhanced attribute, retain enhanced attributes of
gp partition while creating enhanced user area and add
check for max enhanced area of the device.

Signed-off-by: Balaji T K <balajitk@ti.com>
Signed-off-by: Chris Ball <chris@printf.net>
2015-05-01 08:38:00 -04:00
Roman Peniaev c6cb053ec5 mmc-utils: RPMB: add support for 4 rpmb operations
mmc 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 and utility will read the key from stdin.
  BEWARE: key can be programmed only once!
  Example:
    $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-key /dev/mmcblk0rpmb -

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

mmc rpmb read-block <rpmb device> <address> <blocks count> <output file> [key file]
  Blocks of 256 bytes will be read from <rpmb device> to output file or stdout if '-'
  is specified instead of regular path. If key is specified - read data will be verified.
  Instead of regular path you can specify '-' and key will be read from stdin.
  Example:
    $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | \
        mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block -
  or read the block without verification
    $ mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block

mmc 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 and utility will read the
  data from stdin.
  Example:
    $ (awk 'BEGIN {while (c++<256) printf "a"}' | echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH) | \
      mmc rpmb write-block /dev/mmcblk0rpmb 0x02 - -

Signed-off-by: Roman Pen <r.peniaev@gmail.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Cc: Ben Gardiner <bengardiner@nanometrics.ca>,
Signed-off-by: Chris Ball <chris@printf.net>
2014-08-12 10:30:02 -04:00
Oliver Metz 22f2641fe6 Add defines for ext_csd field MAX_ENH_SIZE_MULT
Signed-off-by: Oliver Metz <oliver@freetz.org>
Reviewed-by: Ben Gardiner <ben.l.gardiner@gmail.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-09-25 22:24:56 -04:00
Ben Gardiner 4da1c0dc8b pretty print write reliability settings
Signed-off-by: Ben Gardiner <ben.l.gardiner@gmail.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-09-25 22:11:55 -04:00
Ben Gardiner d91d3698c6 support setting the OTP enhanced user area parameters
Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Ben Gardiner f82e27a1b1 print KiB sizes for some fields
Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Ben Gardiner 4e85023654 report if card is block-addressed and effect on ENH_START_ADDR
Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Ben Gardiner 68f490b54b fix printing ENH_START_ADDR
The enhanced user area start field is 4 bytes long
according to the eMMC 4.41 spec.

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Ben Gardiner 27c357db04 Support SEND_STATUS command
mmc status get </path/to/mmcblkX>

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Ben Gardiner a6cd98de8b extract definitions for PARTITION_SETTING_COMPLETED and pretty-print
Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Ben Gardiner 82bd9504b1 extract definitions for EXT_CSD register EXT_CSD_PARTITIONING_SUPPORT
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:05 -04:00
Oleg Matcovschi 294bf86972 mmc-utils: Remove dependency on linux/major.h.
We require only MMC_BLOCK_MAJOR which is constant.

Signed-off-by: Oleg Matcovschi <olegm@lab126.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:04 -04:00
Mario Schuknecht 8c0c40d477 mmc-utils: small fixes of output
Improve "extcsd read" output of the registers.
Right-shift by 3 of EXT_CSD_BOOT_CFG_EN bits.
Expand the EXT_CSD_BOOT_CFG_ACC bit mask to 0x7.
Add case 3 RPMB partition.

Signed-off-by: Mario Schuknecht <mario.schuknecht@dresearch-fe.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 10:34:27 -04:00
Yaniv Gardi 21bb473fc5 Add method for triggering Sanitize command
This patch adds a method to trigger Sanitize command to MMC.
The Sanitize command is used for deleting the unmapped memory region
of the MMC device.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Acked-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-05-26 13:27:05 -04:00
Chris Ball f74dfe23cd Support enable/disable of eMMC H/W Reset function
(Note: one-time programmable fuse.)

$ mmc hwreset enable /dev/mmcblk0
$ mmc hwreset disable /dev/mmcblk0
2012-10-19 17:28:08 -04:00
Jaehoon Chung 8649651b74 Add method for enabling bkops via one-time fuse.
This patch added the method to enable the bkops.
In ext_csd register, BKOPS_EN bit is one-time programable.
So if you want to use the bkops, use the this command.

$ mmc bkops enable /dev/mmcblk0

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewd-by: Venkatraman S <svenkatr@ti.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2012-09-21 18:15:23 +08:00
Saugata Das b7e2599c67 Add support for disabling 512B emulation
In this patch, we add a utility to disable emulation mode in eMMC-4.5.
This is done to increase the data sector size to 4KB.

Signed-off-by: Saugata Das <saugata.das@linaro.org>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2012-05-17 09:31:12 -04:00
Giuseppe CAVALLARO 7bd1320b2c Add new "bootpart enable" command to enable boot partitions
This adds a new option to enable the boot from eMMC
by writing to the 179 ext_csd register.

The example below shows as to enable the mmcblk0boot0
partition and also set/reset the ACK bit).

$ ./mmc bootpart enable 1 1 /dev/mmcblk0boot0
$ ./mmc extcsd read /dev/mmcblk0boot0 | grep PARTITION_CON
Boot configuration bytes [PARTITION_CONFIG: 0x49]

Reported-by: Youssef TRIKI <youssef.triki@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2012-05-17 09:21:33 -04:00
Giuseppe CAVALLARO a5bf4a2030 improve the parsing of the EXT_CSD registers
This patch enhances the debug information reported
for the mmc card by parsing the extended CSD registers
obviously according to all the current specifications.

I have no HW to test eMMC 4.5 at this moment. In any case,
the patch supports JEDEC Standard No. 84-B45.
No issues on JESD84-A441 and older specs raised on my side.

This patch indeed want to start providing a full parsing
of the all EXT_CSD registers in the following layout:

Name [FIELD: <value>]

Voluntarily, I added the FIELD because it can actually help on
searching though the SPEC in case of doubts.
In fact, in this stage, not all the register bits are yet parsed.
Currently this has been done for a small subset of registers
(e.g. 173, 160 ...) where IMO it's quite useful for an end-user
to get some details. I do hope this will be improved in the near
feature (also for write operations).

P.S. The original patch posted time ago for the Kernel has been
reviewed-by Sebastian Rasmussen, acked-by: Linus Walleij and reported
by Youssef Tiki.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-20 12:14:32 -05:00
Johan RUDHOLM a8bfde77e0 Add extcsd write-protect read/write code
This was posted to linux-mmc@ by Johan Rudholm.

Signed-off-by: Chris Ball <cjb@laptop.org>
2012-02-12 11:52:25 -05:00