diff options
Diffstat (limited to 'projects/cli-test/mgmt-masterkey.c')
-rw-r--r-- | projects/cli-test/mgmt-masterkey.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/projects/cli-test/mgmt-masterkey.c b/projects/cli-test/mgmt-masterkey.c index 7938e33..69dc430 100644 --- a/projects/cli-test/mgmt-masterkey.c +++ b/projects/cli-test/mgmt-masterkey.c @@ -32,14 +32,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* Rename both CMSIS HAL_OK and libhal HAL_OK to disambiguate */ #define HAL_OK CMSIS_HAL_OK - #include "stm-init.h" #include "stm-uart.h" #include "mgmt-cli.h" #include "mgmt-masterkey.h" -/* Rename both CMSIS HAL_OK and libhal HAL_OK to disambiguate */ #undef HAL_OK #define LIBHAL_OK HAL_OK #include <hal.h> @@ -74,7 +73,7 @@ static int _parse_hex_groups(uint8_t *buf, size_t len, char *argv[], int argc) for (i = 0; i < argc; i++) { if (dst >= end) return -1; - *dst++ = strtol(argv[i], &err_ptr, 16); + *dst++ = strtoul(argv[i], &err_ptr, 16); if (*err_ptr) return -2; } @@ -191,19 +190,22 @@ static int cmd_masterkey_unsecure_erase(struct cli_def *cli, const char *command void configure_cli_masterkey(struct cli_def *cli) { - /* masterkey */ - cli_command_root(masterkey); + struct cli_command *c = cli_register_command(cli, NULL, "masterkey", NULL, 0, 0, NULL); + /* masterkey status */ - cli_command_node(masterkey, status, "Show status of master key in RAM/flash"); + cli_register_command(cli, c, "status", cmd_masterkey_status, 0, 0, "Show status of master key in RAM/flash"); /* masterkey set */ - cli_command_node(masterkey, set, "Set the master key in the volatile Master Key Memory"); + cli_register_command(cli, c, "set", cmd_masterkey_set, 0, 0, "Set the master key in the volatile Master Key Memory"); + /* masterkey erase */ - cli_command_node(masterkey, erase, "Erase the master key from the volatile Master Key Memory"); + cli_register_command(cli, c, "erase", cmd_masterkey_erase, 0, 0, "Erase the master key from the volatile Master Key Memory"); + + struct cli_command *c_unsecure = cli_register_command(cli, c, "unsecure", NULL, 0, 0, NULL); - cli_command_branch(masterkey, unsecure); /* masterkey unsecure set */ - cli_command_node(masterkey_unsecure, set, "Set master key in unprotected flash memory (if unsure, DON'T)"); + cli_register_command(cli, c_unsecure, "set", cmd_masterkey_unsecure_set, 0, 0, "Set master key in unprotected flash memory (if unsure, DON'T)"); + /* masterkey unsecure erase */ - cli_command_node(masterkey_unsecure, erase, "Erase master key from unprotected flash memory"); + cli_register_command(cli, c_unsecure, "erase", cmd_masterkey_unsecure_erase, 0, 0, "Erase master key from unprotected flash memory"); } |