mmc-utils changes for Erase commands.
mmc.h
36a37,45
Quoted 9 lines
#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */
#define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */
#define MMC_ERASE 38 /* ac [31] Secure request
[30:16] set to 0
[15] Force Garbage Collect request4 [14:2] set to 0
[1] Discard Enable
[0] Identify Write Blocks for Erase (or TRIM Enable) R1b */
mmc_cmds.h
33a34
Quoted 1 line
int
do_erase(int nargs, char **argv);
mmc_cmds.c
226a227,291
Quoted 62 lines
int
erase(int fd, __u32 argin, __u32 start, __u32 end){
int ret = 0;
structmmc_ioc_cmdidata;
__u32 response;// Set Start address
memset(&idata, 0, sizeof(idata));
idata.opcode =MMC_ERASE_GROUP_START;
idata.arg = start;
idata.flags =MMC_RSP_R1|MMC_CMD_AC;
ret =ioctl(fd, MMC_IOC_CMD, &idata);
if (ret) {
perror("ioctl");
printf("Erase Group Start Address command failed\n"); return ret;
}
ret =send_status(fd, &response);
if (response &0xFFF900C0) {
printf("CMD13 returns: 0x%08x during CMD35\n", response); }// Set end address
memset(&idata, 0, sizeof(idata));
idata.opcode =MMC_ERASE_GROUP_END;
idata.arg = end;
idata.flags =MMC_RSP_R1|MMC_CMD_AC;
ret =ioctl(fd, MMC_IOC_CMD, &idata);
if (ret) {
perror("ioctl");
printf("Erase Group End Address command failed\n"); return ret;
}
ret =send_status(fd, &response);
if (response &0xFFF900C0)
printf("CMD13 returns: 0x%08x during CMD36\n", response);// Send Erase Command
memset(&idata, 0, sizeof(idata));
idata.opcode =MMC_ERASE;
idata.arg = argin;
idata.cmd_timeout_ms = 60000;
idata.data_timeout_ns = 60000000;
idata.flags =MMC_RSP_R1B|MMC_CMD_AC;
ret =ioctl(fd, MMC_IOC_CMD, &idata);
if (ret) {
perror("ioctl");
printf("Erase command failed\n");
return ret;
}// Send Status Command
// 1098 7654 3210 9876 5432 1098 7654 3210
// 3322 2222 2222 1111 1111 1100 0000 0000
// 1111 1111 1111 1xx1 xxxx xxxx 11xx xxxx Device Status Error bits // F F F 9 0 0 C 00xFFF900C0ret =send_status(fd, &response);
if (response &0xFFF900C0)
printf("CMD13 returns: 0x%08x during CMD38\n", response); if (ret)
printf("Send Status Command returned 0x%08X\n", response);
Quoted 3 lines
return ret;
}
1150a1216
Quoted 1 line
1842a1909,1985
Quoted 71 lines
int
do_erase(int nargs, char **argv)
{
int fd, ret;
char *device;
char **eptr=NULL;
__u32 argin, start, end;if (nargs != 5) {
fprintf(stderr, "Usage: mmc erase <arg> <start address> <end address> </path/to/mmcblkX>\n"); exit(1);
}if ((argv[1][0] == '0') && (argv[1][1] == 'x')) argin =
strtol(argv[1], eptr, 16); else
argin =strtol(argv[1], eptr, 10);
if ((argv[2][0] == '0') && (argv[2][1] == 'x')) start =strtol(argv[2], eptr, 16); else
start =strtol(argv[2], eptr, 10);
if ((argv[3][0] == '0') && (argv[3][1] == 'x')) end =strtol(argv[3], eptr, 16); else
end =strtol(argv[3], eptr, 10); device = argv[4];fd =
open(device, O_RDWR);
if (fd < 0) {
perror("open");
exit(1);
}
printf("Executing (0x%08X): ", argin); switch(argin) {
case0x00000000:
printf("Erase ");
break;
case0x00000003:
printf("Discard ");
break;
case0x80000000:
printf("Secure Erase ");
break;
case0x80008000:
printf("Secure Trim Step 2 "); break;
case0x80000001:
printf("Secure Trim Step 1 "); break;
case0x00000001:
printf("Trim ");
break;
default:
printf("Unknown Argument ");
}
printf("From:0x%08X To:0x%08X\n", start, end);ret =
erase(fd, argin, start, end);
if (ret) {
fprintf(stderr, "Error in Erase Command to %s with Arg=0x%08X Start=0x%08X End=0x%08X\n", device,
argin,
start,
end);
exit(1);
}
Quoted 6 lines
return ret;
}
mmc.c
29c29
< #define MMC_VERSION "0.1"
---
Quoted 1 line
#define MMC_VERSION "0.1_KS"
135a136,140
Quoted 5 lines
NULL
},
{do_erase, -4,
"erase", "<arg> " "<start address> " "<end address> " "<device>\n"
"Send Erase command to the <device>.\nThis will delete all user data in the specified region of the device.",
Please send your patch in the appropriate format,
So it can be reviewed.
Thanks,
Avri
Quoted 178 lines
mmc.h
36a37,45Quoted 4 lines
#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */ #define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */ #define MMC_ERASE 38 /* ac [31] Secure request[30:16] set to 0 > [15] Force
Garbage Collect request4 > [14:2] set to 0
Quoted 1 line
[1] Discard Enable > [0]
Identify Write Blocks for Erase (or TRIM Enable) > R1b */
mmc_cmds.h
33a34Quoted 1 line
int
do_erase(int nargs, char **argv);
mmc_cmds.c
226a227,291Quoted 54 lines
int erase(int fd, __u32 argin, __u32 start, __u32 end) > { > int ret = 0; struct mmc_ioc_cmd idata; __u32 response; // Set Start address memset(&idata, 0, sizeof(idata)); idata.opcode = MMC_ERASE_GROUP_START; idata.arg = start; idata.flags = MMC_RSP_R1 | MMC_CMD_AC; ret = ioctl(fd, MMC_IOC_CMD, &idata); if (ret) { perror("ioctl"); printf("Erase Group Start Address command failed\n"); return ret; } ret = send_status(fd, &response); if (response & 0xFFF900C0) { printf("CMD13 returns: 0x%08x during CMD35\n", response); } // Set end address memset(&idata, 0, sizeof(idata)); idata.opcode = MMC_ERASE_GROUP_END; idata.arg = end; idata.flags = MMC_RSP_R1 | MMC_CMD_AC; ret = ioctl(fd, MMC_IOC_CMD, &idata); if (ret) { perror("ioctl"); printf("Erase Group End Address command failed\n"); return ret; } ret = send_status(fd, &response); if (response & 0xFFF900C0) printf("CMD13 returns: 0x%08x during CMD36\n", response); // Send Erase Command memset(&idata, 0, sizeof(idata)); idata.opcode = MMC_ERASE; idata.arg = argin; idata.cmd_timeout_ms = 60000; idata.data_timeout_ns = 60000000; idata.flags = MMC_RSP_R1B | MMC_CMD_AC; ret = ioctl(fd, MMC_IOC_CMD, &idata); if (ret) { perror("ioctl"); printf("Erase command failed\n"); return ret; } // Send Status Command // 1098 7654 3210 9876 5432 1098 7654 3210 // 3322 2222 2222 1111 1111 1100 0000 0000 // 1111 1111 1111 1xx1 xxxx xxxx 11xx xxxx Device Status Error bits // F F F 9 0 0 C 0 0xFFF900C0Quoted 9 lines
ret = send_status(fd, &response); if (response & 0xFFF900C0) printf("CMD13 returns: 0x%08x during CMD38\n", response); if (ret) printf("Send Status Command returned 0x%08X\n", response); return ret; }
1150a1216Quoted 1 line
1842a1909,1985
Quoted 4 lines
int
do_erase(int nargs, char **argv)Quoted 9 lines
{ int fd, ret; char *device; char **eptr=NULL; __u32 argin, start, end; if (nargs != 5) { fprintf(stderr, "Usage: mmc erase <arg> <start address> <endaddress> </path/to/mmcblkX>\n");
Quoted 43 lines
exit(1); } if ((argv[1][0] == '0') && (argv[1][1] == 'x')) argin = strtol(argv[1], eptr, 16); else argin = strtol(argv[1], eptr, 10); if ((argv[2][0] == '0') && (argv[2][1] == 'x')) start = strtol(argv[2], eptr, 16); else start = strtol(argv[2], eptr, 10); if ((argv[3][0] == '0') && (argv[3][1] == 'x')) end = strtol(argv[3], eptr, 16); else end = strtol(argv[3], eptr, 10); device = argv[4]; fd = open(device, O_RDWR); if (fd < 0) { perror("open"); exit(1); } printf("Executing (0x%08X): ", argin); switch(argin) { case 0x00000000: printf("Erase "); break; case 0x00000003: printf("Discard "); break; case 0x80000000: printf("Secure Erase "); break; case 0x80008000: printf("Secure Trim Step 2 "); break; case 0x80000001: printf("Secure Trim Step 1 "); break; case 0x00000001: printf("Trim "); break;Quoted 8 lines
default: printf("Unknown Argument "); } printf("From:0x%08X To:0x%08X\n", start, end); ret = erase(fd, argin, start, end); if (ret) { fprintf(stderr, "Error in Erase Command to %s with Arg=0x%08XStart=0x%08X End=0x%08X\n",
Quoted 9 lines
device, argin, start, end); exit(1); } return ret;Quoted 4 lines
}
mmc.c
29c29
< #defineMMC_VERSION"0.1"
---Quoted 1 line
#define
MMC_VERSION"0.1_KS"135a136,140
Quoted 5 lines
NULL }, { do_erase, -4, "erase", "<arg> " "<start address> " "<end address> " "<device>\n" "Send Erase command to the <device>.\nThis will delete alluser data in the specified region of the device.",
Avri
Sorry new to this. Is there a doc on the "format" I can reference to?
Kimito
Quoted 183 lines · Avri Altman
Please send your patch in the appropriate format,
So it can be reviewed.Thanks,
AvriQuoted 177 lines
mmc.h
36a37,45Quoted 4 lines
#define MMC_ERASE_GROUP_START 35 /* ac [31:0] data addr R1 */ #define MMC_ERASE_GROUP_END 36 /* ac [31:0] data addr R1 */ #define MMC_ERASE 38 /* ac [31] Secure request[30:16] set to 0 > [15] Force
Garbage Collect request4 > [14:2] set to 0
Quoted 1 line
[1] Discard Enable > [0]
Identify Write Blocks for Erase (or TRIM Enable) > R1b */
mmc_cmds.h
33a34Quoted 1 line
int
do_erase(int nargs, char **argv);
mmc_cmds.c
226a227,291Quoted 54 lines
int erase(int fd, __u32 argin, __u32 start, __u32 end) > { > int ret = 0; struct mmc_ioc_cmd idata; __u32 response; // Set Start address memset(&idata, 0, sizeof(idata)); idata.opcode = MMC_ERASE_GROUP_START; idata.arg = start; idata.flags = MMC_RSP_R1 | MMC_CMD_AC; ret = ioctl(fd, MMC_IOC_CMD, &idata); if (ret) { perror("ioctl"); printf("Erase Group Start Address command failed\n"); return ret; } ret = send_status(fd, &response); if (response & 0xFFF900C0) { printf("CMD13 returns: 0x%08x during CMD35\n", response); } // Set end address memset(&idata, 0, sizeof(idata)); idata.opcode = MMC_ERASE_GROUP_END; idata.arg = end; idata.flags = MMC_RSP_R1 | MMC_CMD_AC; ret = ioctl(fd, MMC_IOC_CMD, &idata); if (ret) { perror("ioctl"); printf("Erase Group End Address command failed\n"); return ret; } ret = send_status(fd, &response); if (response & 0xFFF900C0) printf("CMD13 returns: 0x%08x during CMD36\n", response); // Send Erase Command memset(&idata, 0, sizeof(idata)); idata.opcode = MMC_ERASE; idata.arg = argin; idata.cmd_timeout_ms = 60000; idata.data_timeout_ns = 60000000; idata.flags = MMC_RSP_R1B | MMC_CMD_AC; ret = ioctl(fd, MMC_IOC_CMD, &idata); if (ret) { perror("ioctl"); printf("Erase command failed\n"); return ret; } // Send Status Command // 1098 7654 3210 9876 5432 1098 7654 3210 // 3322 2222 2222 1111 1111 1100 0000 0000 // 1111 1111 1111 1xx1 xxxx xxxx 11xx xxxx Device Status Error bits // F F F 9 0 0 C 0 0xFFF900C0Quoted 9 lines
ret = send_status(fd, &response); if (response & 0xFFF900C0) printf("CMD13 returns: 0x%08x during CMD38\n", response); if (ret) printf("Send Status Command returned 0x%08X\n", response); return ret; }
1150a1216Quoted 1 line
1842a1909,1985
Quoted 4 lines
int
do_erase(int nargs, char **argv)Quoted 9 lines
{ int fd, ret; char *device; char **eptr=NULL; __u32 argin, start, end; if (nargs != 5) { fprintf(stderr, "Usage: mmc erase <arg> <start address> <endaddress> </path/to/mmcblkX>\n");
Quoted 43 lines
exit(1); } if ((argv[1][0] == '0') && (argv[1][1] == 'x')) argin = strtol(argv[1], eptr, 16); else argin = strtol(argv[1], eptr, 10); if ((argv[2][0] == '0') && (argv[2][1] == 'x')) start = strtol(argv[2], eptr, 16); else start = strtol(argv[2], eptr, 10); if ((argv[3][0] == '0') && (argv[3][1] == 'x')) end = strtol(argv[3], eptr, 16); else end = strtol(argv[3], eptr, 10); device = argv[4]; fd = open(device, O_RDWR); if (fd < 0) { perror("open"); exit(1); } printf("Executing (0x%08X): ", argin); switch(argin) { case 0x00000000: printf("Erase "); break; case 0x00000003: printf("Discard "); break; case 0x80000000: printf("Secure Erase "); break; case 0x80008000: printf("Secure Trim Step 2 "); break; case 0x80000001: printf("Secure Trim Step 1 "); break; case 0x00000001: printf("Trim "); break;Quoted 8 lines
default: printf("Unknown Argument "); } printf("From:0x%08X To:0x%08X\n", start, end); ret = erase(fd, argin, start, end); if (ret) { fprintf(stderr, "Error in Erase Command to %s with Arg=0x%08XStart=0x%08X End=0x%08X\n",
Quoted 9 lines
device, argin, start, end); exit(1); } return ret;Quoted 4 lines
}
mmc.c
29c29
< #defineMMC_VERSION"0.1"
---Quoted 1 line
#define
MMC_VERSION"0.1_KS"135a136,140
Quoted 5 lines
NULL }, { do_erase, -4, "erase", "<arg> " "<start address> " "<end address> " "<device>\n" "Send Erase command to the <device>.\nThis will delete alluser data in the specified region of the device.",