77 Commits
Author SHA1 Message Date
rich 9b1a67218d Micron CMD56 Additions 2023-07-31 14:02:02 +00:00
Avri Altman 6d593efc3c mmc-utils: Assert MMC_IOC_MULTI_CMD in compile time
Notify of mult-ioctl violation during preprocessing instead of bailing out
in runtime. This prevents bogus copies of mmc-utils binaries wondering
about out there.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20230609083425.765-1-avri.altman@wdc.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-06-12 16:10:11 +02:00
Christian Löhle d4c2910981 mmc-utils: Add basic erase error check
Check for erase specific R1 errors so e.g. an OOR erase is not
reported as successful when it never executed.

There could be checks for more error bits but R1_ERASE_SEQ_ERROR
on CMD38 should catch all that are reported by hardware anyway.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/c91cdde6288d4db6aad45f5d50d129c8@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-02-09 15:16:51 +01:00
Sean Anderson a08f08ec67 mmc-utils: Add a command to write extcsd registers
There is a command to read the extcsd and some commands to configure
particular features, but no generic write extcsd command. Such a command
may be useful for not-yet-supported features and manufacturer-specific
registers.

Signed-off-by: Philippe Reynes <philippe.reynes@sagemcom.com>
[ rebased onto latest master and updated commit message ]
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Link: https://lore.kernel.org/r/20221216161625.2924013-1-sean.anderson@seco.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-02-09 15:10:21 +01: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
Christian Löhle 34577b2378 mmc-utils: Allow for custom sanitize timeout
Some cards with certain preconditioning require a higher timeout
when sanitizing. Let the user set the maximum timeout.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/4ddb5a5510d74645b2724d274c96ab02@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-10-24 18:59:46 +02:00
Christian Löhle d939fb5c0f mmc-utils: Refactor switch to allow custom timeout
Certain commands require a longer switch timeout.
Refactor accordingly to allow e.g. for future sanitize change.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/a64ce8be9687452b8da6c9816ca42b5b@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-10-24 18:58:53 +02:00
Bruno Matic 2a934139cf mmc-utils: Fix ffu in case of unsupported MODE_OPERATION_CODES
Move up the return in case MODE_OPERATION_CODES is not supported.
According to the specification when MODE_OPERATION_CODES is not
supported no checks should be done against NUM_OF_FW_SEC_PROG.

Signed-off-by: Bruno Matic <bruno.matic@nokia.com>
Fixes: 89cd01ed86 (mmc_utils: add ffu support)
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220920124749.24073-1-bruno.matic@nokia.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-09-21 14:51:45 +02:00
Giulio Benetti 5086e7c0de mmc-utils: fix warning on uninitialized 'cnt'
When building following warning shows up:
```
In function '__bswap_32',
    inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
/home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be used uninitialized [-Werror=maybe-uninitialized]
   52 |   return __builtin_bswap32 (__bsx);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~
mmc_cmds.c: In function 'do_rpmb_write_block':
mmc_cmds.c:2270:22: note: 'cnt' was declared here
2270 |         unsigned int cnt;
      |                      ^~~
cc1: all warnings being treated as errors
```
This is due to function rpmb_read_counter() that doesn't set its
argument 'unsigned int *cnt' in all return points. So let's set
*cnt to 0 in the return point that misses to initialize it.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220918161751.1132590-1-giulio.benetti@benettiengineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-09-20 11:41:51 +02:00
Bruno Matic c12b53155f mmc-utils: correct and clean up the file handling
Add the check if the whole firmware was loaded.  Cleaned up the leftovers
of handling the file in chunks.

Signed-off-by: Bruno Matic <bruno.matic@nokia.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220909110322.25141-1-bruno.matic@nokia.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-09-19 16:00:06 +02:00
Christian Löhle d7b343fd26 mmc-utils: Fix 4k sector size block count in FFU
FFU used the wrong assumption, that CMD23 work in
4k sector chunks when setting the block count.
Instead the CMD23 block count argument just needs
to be a multiple of 8, which the fw_size is anyway.

Fixes: 89cd01ed86 (mmc_utils: add ffu support)
Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/54477cf05b9148109996dd85c9afc30f@hyperstone.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-07-13 12:57:35 +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
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 4637a7c0df mmc-utils: Display STROBE_SUPPORT when printing EXT_CSD
Support for Enhanced Strobe mode introduced in eMMC 5.1 JESD84-B51
can be determined via EXT_CSD[184]. Along with the identification of
HS400 data rates added in commit 3969aa4804 ("mmc_cmds: add HS400
data rates"), this allows to differentiate support for HS400/HS400ES.

Signed-off-by: Marius Strobl <marius@FreeBSD.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20220205205647.7677-3-marius@FreeBSD.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-02-08 16:15:35 +01:00
Shankar Athanikar fd41dca5b1 mmc_cmds: Display BARRIER_CTRL Status when printing EXT_CSD
The status of BARRIER_CTRL can be read from this byte: EXT_CSD[31](R/W)
Signed-off-by: Shankar Athanikar <shankar.ma@samsung.com>
Reviewed-by: <mohanraj.v@samsung.com>
Link: https://lore.kernel.org/r/20211224111917.707440-1-shankar.ma@samsung.com
[Ulf: Cleaned up whitespace and corrected sob-tag]
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-01-25 18:29:56 +01:00
Quentin Schulz 3969aa4804 mmc_cmds: add HS400 data rates
JEDEC 5.1 JESD84-B50.1 DEVICE_TYPE [196] specifies that bit 6 is for
"HS400 Dual Data Rate e•MMC at 200 MHz – 1.8 V I/O" and bit 7 for
"HS400 Dual Data Rate e•MMC at 200 MHz – 1.2 V I/O" so let's add those.

Cc: Quentin Schulz <foss+kernel@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Link: https://lore.kernel.org/r/20211202161910.3944640-1-quentin.schulz@theobroma-systems.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-12-20 11:04:18 +01:00
Oleh Kravchenko a1b233c2a3 mmc-utils: Use printf() to extract and print fw version
This patch also fixes a compile error with a newer version of GCC:
error: '__builtin_strncpy' output may be truncated copying 8 bytes from
a string of length 511 [-Werror=stringop-truncation]

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Fixes: 0eea71e4f2 (mmc-utils: Fix for Firmware Version string printing)
Link: https://lore.kernel.org/r/20211130142715.11014-1-oleg@kaa.org.ua
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-12-02 15:23:52 +01:00
Bean Huo ad3fb9fe14 mmc-utils: Add note for CMDQ_MODE_EN runtime value
Since the Linux kernel commit 70b52f090805 ("mmc: block: Disable CMDQ on
the ioctl path"), CMDQ in CMDQ_MODE_EN[15] is disabled before reading EXT_CSD.
Therefore, it is more accurate to use sysfs node to check CMDQ_MODE_EN value.
Add a note print to highlight.

Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20211114204331.39555-3-huobean@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-11-15 15:59:55 +01:00
Kimito Sakata 0eea71e4f2 mmc-utils: Fix for Firmware Version string printing
Added a local buffer to create a NULL terminated string to print the
Firmware Version instead of attempting to print directly from
ext_csd buffer. The last byte of the Firmware Version field may not
be NULL and the next field may also not be which may cause it to
print garbage.

Tested on x86 platform.

Signed-off-by: Kimito Sakata <kimito.sakata@oracle.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Fixes: 89cd01ed86 (mmc_utils: add ffu support)
Link: https://lore.kernel.org/r/20210713053458.1441-1-oracleks043021@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-08-24 10:57:33 +02: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
Stephane Fillod e9654ebc4a Various fixes
These warnings were mainly found using cppcheck.

Signed-off-by: Stephane Fillod <f8cfe@free.fr>
Reviewed-by: Michael Heimpold <mhei@heimpold.de>
Link: https://lore.kernel.org/r/1254580747.16828401.1547561163645.JavaMail.root@zimbra64-e11.priv.proxad.net
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:28:34 +02:00
Fabrice Fontaine 520f54eb94 mmc_cmds.c: fix build with gcc 4.9
Fix following error with gcc 4.9:

mmc_cmds.c:1918:9: error: missing braces around initializer [-Werror=missing-braces]
  struct rpmb_frame frame_status = {0};

Fixes:
 - http://autobuild.buildroot.org/results/bf3b6f9f6ef39b99842b3c92495b7bf359c68158

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Link: https://lore.kernel.org/r/20190928185107.21125-1-fontaine.fabrice@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:17:07 +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
Patrick Oppenlander 5b3e56f708 mmc-utils: Fix scaling of cache size
JESD84-B51 7.4.30 CACHE_SIZE [252:249] states that "the size is
indicated as multiple of kilobits". This is also supported by Table 39,
"e.MMC internal sizes and related Units / Granularities" which lists
"32Kb (=4KB)" as the cache size granularity for 4KiB native devices.

Signed-off-by: Patrick Oppenlander <patrick.oppenlander@gmail.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20200401221453.267360-1-patrick.oppenlander@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:05:57 +02:00
John Ernberg 271bdfc6f2 rpmb: Zero-init MMC_IOC_MULTI_CMD structures
On our board we would occationally see what looked like a
kernel hang while doing RPMB operations, some additional
printk debugging revealed that in the trouble case data
such as this was being sent to the kernel:

    [  109.076981] idata[0]->ic->opcode = 0x19
    [  109.077027] idata[0]->ic->arg = 0x0
    [  109.080954] idata[0]->ic->write_flag = 0x1
    [  109.084691] idata[0]->ic->is_acmd = 0x0
    [  109.089007] idata[0]->ic->flags = 0xb5
    [  109.092949] idata[0]->ic->blocks = 0x1
    [  109.096865] idata[0]->ic->blksz = 0x200
    [  109.100791] idata[0]->ic->postsleep_min_us = 0x7473696e
    [  109.104745] idata[0]->ic->postsleep_max_us = 0x34383370
    [  109.110167] idata[0]->ic->data_timeout_ns = 0x7265632d
    [  109.115494] idata[0]->ic->data_ptr = 00000000e7ddd4cd
    [  109.120832] idata[0]->rpmb = 00000000ffab5640
    [  109.126077] idata[1]->ic->opcode = 0x12
    [  109.130622] idata[1]->ic->arg = 0x0
    [  109.135451] idata[1]->ic->write_flag = 0x0
    [  109.139153] idata[1]->ic->is_acmd = 0x0
    [  109.143437] idata[1]->ic->flags = 0xb5
    [  109.147553] idata[1]->ic->blocks = 0x1
    [  109.151420] idata[1]->ic->blksz = 0x200
    [  109.155251] idata[1]->ic->postsleep_min_us = 0x652d6873
    [  109.159166] idata[1]->ic->postsleep_max_us = 0x35353264
    [  109.164561] idata[1]->ic->data_timeout_ns = 0x632d3931
    [  109.169915] idata[1]->ic->data_ptr = 00000000bc641ed4
    [  109.175152] idata[1]->rpmb = 00000000ffab5640

Therefor, zero-init the MMC_IOC_MULTI_CMD structures to
avoid the obscene sleep values.

Signed-off-by: John Ernberg <john.ernberg@actia.se>
Link: https://lore.kernel.org/r/20201216093146.6218-1-john.ernberg@actia.se
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2021-03-30 15:02:54 +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
Nikita Maslov aef913e31b mmc-utils: use MMC_IOC_MULTI_CMD for RPMB access
On some systems which use MMC as a main storage device
it is possible that RPMB commands are mixed with
generic MMC access commands which invalidates RPMB.

This patch uses MMC_IOC_MULTI_CMD.

Signed-off-by: Clément Péron <peron.clem@gmail.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Chris Ball <chris@printf.net>
2018-12-14 20:11:14 -05:00
Wolfram Sang 485b05ec40 use proper type for RPMB blocks_cnt
The JEDEC standard is confusing. The number of max blocks for reading
RPMB is determined by CMD23 which can hold an unsigned int and not only
u16. It is true that the current maximum is 64K of blocks, yet this may
be extended in the future. Let's not apply a limit here which should be
checked by the card.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Chris Ball <chris@printf.net>
2018-12-08 00:51:37 -05:00
jason.zeng b4fe0c8c0e fix ENH_START_ADDR overflow
Fix enh_start_addr overflow when converting emmc enh_area which will
cause do_enh_area_set failure.

Signed-off-by: jason.zeng <jasonzvz@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
2018-03-27 02:17:10 -04:00
Uwe Kleine-König 247191a0f7 mmc-utils: remove unused #includes
I didn't find any functions used for which the documentation specifies to
use (at least) one of the dropped headers.

The only Linux specific header <linux/fs.h> is needed for BLKGETSIZE,
document that.

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:43 -05: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 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 37c86e60c0 mmc-utils: Check for ext_csd_rev only once
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Chris Ball <chris@printf.net>
2017-03-20 09:58:49 -04: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
Tomas Melin 2cb6695e8d Add missing -c for write_reliability
Fixes upstream-merge in 752072dafe
Write_reliability -c addition from patch was missing.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-09-01 11:49:01 -04:00
Tomas Melin e094e28d56 Fix return value check from set_partitioning_setting_completed()
Test was wrong way around. Function returns non-zero value on fail.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-08-29 12:03:17 -04:00
Tomas Melin 752072dafe Add -c option for partitioning commands
Adding 'continue' option to:
gp create
enh_area set
write_reliability set

Partitioning commands are connected, register PARTITION_SETTING_COMPLETED
should not be written until all settings have been done.
The continue option enables writing more than one partitioning setting before
sealing settings.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-08-29 12:03:14 -04:00
Tomas Melin 55380d9748 Register being set is other than mentioned in printed message.
Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-08-29 12:03:06 -04:00
Tomas Melin 3c02759595 Fix reported offset for enhanced user area start address
Block-addressed devices should have address multiplied with sector size.

Clarify with comment how is_blockaddressed() is calculated.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-08-29 12:02:59 -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
Marcus Folkesson 928ff072be mmc_utils: gp create: only allow partition [1-4] to be selected
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
2015-11-18 15:06:16 -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