mmc-utils: Add General command CMD56 read support
PATCH v2 1/1 mmc-utils: Add General command CMD56 read support
From: Bean Huo <[email protected]>
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.
---
V2:
1. Fix coding type issue
2. Add CMD56 argument default value 0x01 support, make [arg] optional
--- mmc.c | 8 ++++++++ mmc.h | 2 ++ mmc_cmds.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mmc_cmds.h | 1 + 4 files changed, 68 insertions(+)
mmc.c +8 -0
@@ -237,6 +237,14 @@ static struct Command commands[] = { "secure-trim1 | secure-trim2 | trim \n", NULL }, + { do_general_cmd_read,-1 , +"gen_cmd read" ,"<device> [arg]\n" +"Send GEN_CMD (CMD56) to read vendor-specific format/meaning data from <device>\n\n" +"NOTE!: [arg] is optional and defaults to 0x1. If [arg] is specified, then [arg]\n" +"must be a 32-bit hexadecimal number, prefixed with 0x/0X. And bit0 in [arg] must\n" +"be 1." , +NULL + }, { 0, 0, 0, 0 } };
mmc.h +2 -0
@@ -41,6 +41,8 @@[1] Discard Enable [0] Identify Write Blocks for Erase (or TRIM Enable) R1b */ +#define MMC_GEN_CMD 56/* adtc [31:1] stuff bits. +[0]: RD/WR1 R1 */ #define R1_OUT_OF_RANGE (1 << 31)/* er, c */ #define R1_ADDRESS_ERROR (1 << 30)/* erx, c */
mmc_cmds.c +57 -0
60 lines not on this page · raw message
mmc_cmds.h +1 -0
@@ -46,3 +46,4 @@ int do_read_scr(int argc, char **argv);int do_read_cid (int argc,char **argv);int do_read_csd (int argc,char **argv);int do_erase (int nargs,char **argv); +int do_general_cmd_read (int nargs,char **argv);
Signature · 1 line
2.34.1
Quoted 19 lines · Bean Huo
From: Bean Huo <[email protected]>
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 theGEN_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.
Quoted 7 lines
I didn't add data parsing, just print the raw data as it is vendor- specific.
Signed-off-by Bean Huo <[email protected]>Acked-by Avri Altman <[email protected]>---
Hi Ullf,
Would you be willing to merge this patch into your mmc-utils git repo?
Kind regards,
Bean
Ulf Hansson
AppliedQuoted 24 lines · Bean Huo
Quoted 22 lines · Bean Huo
From: Bean Huo <[email protected]>
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 theGEN_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.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Bean Huo <[email protected]>Acked-by Avri Altman <[email protected]>---
Hi Ullf,
Would you be willing to merge this patch into your mmc-utils git repo?
Certainly! My apologies for the delay!
Applied to mmc-utils.git master, thanks!
Kind regards
Uffe