Commit Graph

59 Commits

Author SHA1 Message Date
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
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
f90eac4ecc Add help texts for -c option
-c option added to gp create, enh_area set and write_reliability set
commands.

Signed-off by: Tomas Melin <tomas.melin@vaisala.com>
Signed-off-by: Chris Ball <chris@printf.net>
2016-08-29 12:03:16 -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
Sebastian Rasmussen
4af1749d23 mmc-utils: Merge the lsmmc tool into mmc-utils
The lsmmc tools contains an extensive parser of the CID, CSD, SCR
registers from userspace. The utility works as-is and uses sysfs
to read the register values.

The original code is created by Sebastian Rasmussen and still lives
in an attachment in the mail archive of linux-mmc. It need to be merged
into mmc-utils repository, which is convenient for testing MMC device
from userspace.

Change since v3:
 - Remove the unused EXT_CSD parser in lsmmc.c file.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
2016-02-26 09:42:38 -05:00
Marcus Folkesson
44f94b9258 mmc_utils: doc: add man-page
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
2015-11-18 15:11:14 -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
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
Yaniv Gardi
50b68547ad fix building errors on Android
3rd party HMAC SHA256 implementation has been added to the driver,
and since driver common code (mmc_cmds.c) includes calling to
routines and data structures that reside in these 3rd party files
(under 3rdparty\hmac_sha) these files should be compiled as well
in Android.mk makefile.

Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Chris Ball <chris@printf.net>
2015-03-24 22:09:55 -04:00
Chris Ball
f4eb241519 Fit usage to 80 cols
Signed-off-by: Chris Ball <chris@printf.net>
2014-08-12 10:44:52 -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
Roman Peniaev
35c31feacf mmc-utils: RPMB: add HMAC SHA256 support
RPMB requires digital signature of the message.  Take the implementation
of HMAC SHA256 from this place https://github.com/ogay/hmac.git

Actually this is BSD license, IANAL but according to my understanding
nothing terrible will happen if we provide all the original copyrights.

Signed-off-by: Roman Pen <r.peniaev@gmail.com>
Cc: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <chris@printf.net>
2014-08-12 10:29:37 -04:00
Mike Frysinger
a8276f539b fix make handling
Fix the recurisve make targets by using $(MAKE).  Otherwise we get lots of
warnings and issues with parallel builds.

Fix the install target -- the man subdir was missing a dummy target.

Add proper .PHONY markings.

Change-Id: I640d42af0bdf96baf6ff0ca022fd3f7f444b2d05
Signed-off-by: Mike Frysinger <vapier@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179621
Reviewed-by: Grant Grundler <grundler@chromium.org>
Signed-off-by: Chris Ball <chris@printf.net>
2014-01-23 14:24:41 -05:00
Oliver Metz
11f2ceabc4 Don't use u8 for fields with more than 1 byte
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:28:32 -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
196d0d2958 support setting the OTP 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:12:00 -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
e6e84e96ac extract PARTITION_SETTING_COMPLETE function
Extract a function which sets the OTP PARTITION_SETTING_COMPLETE
bit; once this bit is set there are many other parameters in
EXT_CSD which can no longer be set.

Multiple OTP partition settings can be achieved by calling 'set'
commands with '-n' on all except for the last.

Signed-off-by: Ben Gardiner <ben.l.gardiner@gmail.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-09-25 22:11:46 -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
Ben Gardiner
6117755361 allow environment and command-line supplied make vars
Most useful when cross-compiling.

Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:04 -04:00
Oleg Matcovschi
64f63a3d26 mmc-utils: Correctly handle CARD_TYPE.
Analysis was based on value of EXT_CSD_BOOT_INFO, not CARD_TYPE.
CARD_TYPE should be handled using bitmask, not values.

Signed-off-by: Oleg Matcovschi <olegm@lab126.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-06-27 11:11:04 -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
Yaniv Gardi
1fc81f3a41 mmc-utils: adding support for Android compilation
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
2013-05-26 13:22:32 -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
Chris Ball
bf4ae7d4e9 Add .gitignore for binaries 2012-10-19 16:13:43 -04:00
Chris Ball
6599780fda Improve/clarify usage descriptions 2012-09-21 18:19:25 +08:00
Chris Ball
d4faeabb78 Turn on gcc optimization (-O2)
This is required by distros that use Fortify.
2012-09-21 18:16:22 +08: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