mirror of
https://git.kernel.org/pub/scm/utils/mmc/mmc-utils.git
synced 2024-11-23 09:57:04 +08:00
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>
This commit is contained in:
parent
c62dd8e415
commit
a08f08ec67
5
mmc.c
5
mmc.c
@ -58,6 +58,11 @@ static struct Command commands[] = {
|
||||
"Print extcsd data from <device>.",
|
||||
NULL
|
||||
},
|
||||
{ do_write_extcsd, 3,
|
||||
"extcsd write", "<offset> <value> <device>\n"
|
||||
"Write <value> at offset <offset> to <device>'s extcsd.",
|
||||
NULL
|
||||
},
|
||||
{ do_writeprotect_boot_get, -1,
|
||||
"writeprotect boot get", "<device>\n"
|
||||
"Print the boot partitions write protect status for <device>.",
|
||||
|
32
mmc_cmds.c
32
mmc_cmds.c
@ -1982,6 +1982,38 @@ out_free:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_write_extcsd(int nargs, char **argv)
|
||||
{
|
||||
int fd, ret;
|
||||
int offset, value;
|
||||
char *device;
|
||||
|
||||
if (nargs != 4) {
|
||||
fprintf(stderr, "Usage: mmc extcsd write <offset> <value> </path/to/mmcblkX>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
offset = strtol(argv[1], NULL, 0);
|
||||
value = strtol(argv[2], NULL, 0);
|
||||
device = argv[3];
|
||||
|
||||
fd = open(device, O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror("open");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = write_extcsd_value(fd, offset, value, 0);
|
||||
if (ret) {
|
||||
fprintf(stderr,
|
||||
"Could not write 0x%02x to EXT_CSD[%d] in %s\n",
|
||||
value, offset, device);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_sanitize(int nargs, char **argv)
|
||||
{
|
||||
int fd, ret;
|
||||
|
Loading…
Reference in New Issue
Block a user