On Fri, 16 Dec 2022 at 17:16, Sean Anderson <sean.anderson@xxxxxxxx> wrote: > > 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@xxxxxxxxxxxx> > [ rebased onto latest master and updated commit message ] > Signed-off-by: Sean Anderson <sean.anderson@xxxxxxxx> Applied to git.kernel.org/pub/scm/utils/mmc/mmc-utils.git master, thanks! Kind regards Uffe > --- > > mmc.c | 5 +++++ > mmc_cmds.c | 32 ++++++++++++++++++++++++++++++++ > 2 files changed, 37 insertions(+) > > diff --git a/mmc.c b/mmc.c > index adcd814..b9aa478 100644 > --- a/mmc.c > +++ b/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>.", > diff --git a/mmc_cmds.c b/mmc_cmds.c > index e6d3273..33b9e43 100644 > --- a/mmc_cmds.c > +++ b/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; > -- > 2.35.1.1320.gc452695387.dirty >