UPSTREAM: mmc-utils: RPMB: add support for 4 rpmb operations
mmc rpmb write-key <rpmb device> <key file>
Program authentication key which is 32 bytes length and stored in the specified file.
Also you can specify '-' instead of key file path and utility will read the key from stdin.
BEWARE: key can be programmed only once!
Example:
$ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-key /dev/mmcblk0rpmb -
mmc rpmb read-counter <rpmb device>
Counter value for the <rpmb device> will be read to stdout.
mmc rpmb read-block <rpmb device> <address> <blocks count> <output file> [key file]
Blocks of 256 bytes will be read from <rpmb device> to output file or stdout if '-'
is specified instead of regular path. If key is specified - read data will be verified.
Instead of regular path you can specify '-' and key will be read from stdin.
Example:
$ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | \
mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block -
or read the block without verification
$ mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block
mmc rpmb write-block <rpmb device> <address> <256 byte data file> <key file>
Block of 256 bytes will be written from data file to <rpmb device>.
Also you can specify '-' instead of key file path or data file and utility will read the
data from stdin.
Example:
$ (awk 'BEGIN {while (c++<256) printf "a"}' | echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH) | \
mmc rpmb write-block /dev/mmcblk0rpmb 0x02 - -
Signed-off-by: Roman Pen <r.peniaev@gmail.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Cc: Ben Gardiner <bengardiner@nanometrics.ca>,
Signed-off-by: Chris Ball <chris@printf.net>
(cherry picked from commit c6cb053ec59e7667e2140c320e2b7d5a90592a20)
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Conflicts:
mmc.c
mmc_cmds.c
mmc_cmds.h
BUG=none
TEST=Compiled, Installed on gnawty
Change-Id: I4509aad4bd203646633c23e2afde36da75ec4852
Reviewed-on: https://chromium-review.googlesource.com/337986
Commit-Ready: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
diff --git a/mmc.c b/mmc.c
index fb346ef..f8dacdc 100644
--- a/mmc.c
+++ b/mmc.c
@@ -121,6 +121,39 @@
"Device specific hacks can be specificied.",
NULL
},
+ { do_rpmb_write_key, -1,
+ "rpmb write-key", "<rpmb device> <key file>\n"
+ "Program authentication key which is 32 bytes length and stored in the specified file.\n"
+ "Also you can specify '-' instead of key file path and utility will read the key from stdin.\n"
+ "BEWARE: key can be programmed only once!\n"
+ "Example:\n"
+ " $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb write-key /dev/mmcblk0rpmb -",
+ NULL
+ },
+ { do_rpmb_read_counter, -1,
+ "rpmb read-counter", "<rpmb device>\n"
+ "Counter value for the <rpmb device> will be read to stdout.",
+ NULL
+ },
+ { do_rpmb_read_block, -1,
+ "rpmb read-block", "<rpmb device> <address> <blocks count> <output file> [key file]\n"
+ "Blocks of 256 bytes will be read from <rpmb device> to output file or stdout if '-' is specified instead of regular path.\n"
+ "If key is specified - read data will be verified. Instead of regular path you can specify '-' and key will be read from stdin.\n"
+ "Example:\n"
+ " $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block -\n"
+ "or read two blocks without verification\n"
+ " $ mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block",
+ NULL
+ },
+ { do_rpmb_write_block, -1,
+ "rpmb write-block", "<rpmb device> <address> <256 byte data file> <key file>\n"
+ "Block of 256 bytes will be written from data file to <rpmb device>.\n"
+ "Also you can specify '-' instead of key file path or data file and utility will read the data from stdin.\n"
+ "Example:\n"
+ " $ (awk 'BEGIN {while (c++<256) printf \"a\"}' | echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH) | \\\n"
+ " mmc rpmb write-block /dev/mmcblk0rpmb 0x02 - -",
+ NULL
+ },
{ 0, 0, 0, 0 }
};