UPSTREAM: 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.
Conflicts:
mmc.c: Reorder command list.
BUG=None
TEST=Compile
Signed-off-by: Al Cooper <alcooperx@gmail.com>
Signed-off-by: Chris Ball <chris@printf.net>
(cherry picked from commit 0ca049f25191c32323ba25a3cfd542b9fdefb473)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Change-Id: I8119e279c2f0cea093c7ee65fbe29fb74382e83c
Reviewed-on: https://chromium-review.googlesource.com/1114439
Commit-Ready: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/mmc.c b/mmc.c
index f914629..f33a40c 100644
--- a/mmc.c
+++ b/mmc.c
@@ -63,14 +63,28 @@
"Print raw extcsd data from <device>.",
NULL
},
- { do_writeprotect_get, -1,
- "writeprotect get", "<device>\n"
- "Determine the eMMC writeprotect status of <device>.",
+ { do_writeprotect_boot_get, -1,
+ "writeprotect boot get", "<device>\n"
+ "Print the boot partitions write protect status for <device>.",
NULL
},
- { do_writeprotect_set, -1,
- "writeprotect set", "<device>\n"
- "Set the eMMC writeprotect status of <device>.\nThis sets the eMMC to be write-protected until next boot.",
+ { do_writeprotect_boot_set, -1,
+ "writeprotect boot set", "<device>\n"
+ "Set the boot partitions write protect status for <device>.\nThis sets the eMMC boot partitions to be write-protected until\nthe next boot.",
+ NULL
+ },
+ { do_writeprotect_user_set, -4,
+ "writeprotect user set", "<type>" "<start block>" "<blocks>" "<device>\n"
+#ifdef DANGEROUS_COMMANDS_ENABLED
+ "Set the write protect configuration for the specified region\nof the user area for <device>.\n<type> must be \"none|temp|pwron|perm\".\n \"none\" - Clear temporary write protection.\n \"temp\" - Set temporary write protection.\n \"pwron\" - Set write protection until the next poweron.\n \"perm\" - Set permanent write protection.\n<start block> specifies the first block of the protected area.\n<blocks> specifies the size of the protected area in blocks.\nNOTE! The area must start and end on Write Protect Group\nboundries, Use the \"writeprotect user get\" command to get the\nWrite Protect Group size.\nNOTE! \"perm\" is a one-time programmable (unreversible) change.",
+#else
+ "Set the write protect configuration for the specified region\nof the user area for <device>.\n<type> must be \"none|temp|pwron\".\n \"none\" - Clear temporary write protection.\n \"temp\" - Set temporary write protection.\n \"pwron\" - Set write protection until the next poweron.\n<start block> specifies the first block of the protected area.\n<blocks> specifies the size of the protected area in blocks.\nNOTE! The area must start and end on Write Protect Group\nboundries, Use the \"writeprotect user get\" command to get the\nWrite Protect Group size.",
+#endif /* DANGEROUS_COMMANDS_ENABLED */
+ NULL
+ },
+ { do_writeprotect_user_get, -1,
+ "writeprotect user get", "<device>\n"
+ "Print the user areas write protect configuration for <device>.",
NULL
},
{ do_disable_512B_emulation, -1,