2019-07-05 15:20:17 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019, STMicroelectronics - All Rights Reserved
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <console.h>
|
2020-11-06 18:01:29 +00:00
|
|
|
#include <log.h>
|
2019-07-05 15:20:17 +00:00
|
|
|
#include <misc.h>
|
2023-01-06 12:20:15 +00:00
|
|
|
#include <asm/arch/bsec.h>
|
2019-07-05 15:20:17 +00:00
|
|
|
#include <dm/device.h>
|
|
|
|
#include <dm/uclass.h>
|
|
|
|
|
2022-09-15 16:11:41 +00:00
|
|
|
/*
|
|
|
|
* Closed device: OTP0
|
|
|
|
* STM32MP15x: bit 6 of OPT0
|
|
|
|
* STM32MP13x: 0b111111 = 0x3F for OTP_SECURED closed device
|
|
|
|
*/
|
2021-06-28 12:56:02 +00:00
|
|
|
#define STM32_OTP_CLOSE_ID 0
|
2022-09-15 16:11:41 +00:00
|
|
|
#define STM32_OTP_STM32MP13x_CLOSE_MASK 0x3F
|
|
|
|
#define STM32_OTP_STM32MP15x_CLOSE_MASK BIT(6)
|
2021-06-28 12:56:02 +00:00
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
/* PKH is the first element of the key list */
|
|
|
|
#define STM32KEY_PKH 0
|
|
|
|
|
|
|
|
struct stm32key {
|
|
|
|
char *name;
|
|
|
|
char *desc;
|
|
|
|
u8 start;
|
|
|
|
u8 size;
|
|
|
|
};
|
|
|
|
|
2022-09-15 16:11:41 +00:00
|
|
|
const struct stm32key stm32mp13_list[] = {
|
|
|
|
[STM32KEY_PKH] = {
|
|
|
|
.name = "PKHTH",
|
|
|
|
.desc = "Hash of the 8 ECC Public Keys Hashes Table (ECDSA is the authentication algorithm)",
|
|
|
|
.start = 24,
|
|
|
|
.size = 8,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "EDMK",
|
|
|
|
.desc = "Encryption/Decryption Master Key",
|
|
|
|
.start = 92,
|
|
|
|
.size = 4,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
const struct stm32key stm32mp15_list[] = {
|
|
|
|
[STM32KEY_PKH] = {
|
|
|
|
.name = "PKH",
|
|
|
|
.desc = "Hash of the ECC Public Key (ECDSA is the authentication algorithm)",
|
|
|
|
.start = 24,
|
|
|
|
.size = 8,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* index of current selected key in stm32key list, 0 = PKH by default */
|
|
|
|
static u8 stm32key_index;
|
|
|
|
|
|
|
|
static u8 get_key_nb(void)
|
|
|
|
{
|
2022-09-15 16:11:41 +00:00
|
|
|
if (IS_ENABLED(CONFIG_STM32MP13x))
|
|
|
|
return ARRAY_SIZE(stm32mp13_list);
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_STM32MP15x))
|
|
|
|
return ARRAY_SIZE(stm32mp15_list);
|
2022-09-15 16:11:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct stm32key *get_key(u8 index)
|
|
|
|
{
|
2022-09-15 16:11:41 +00:00
|
|
|
if (IS_ENABLED(CONFIG_STM32MP13x))
|
|
|
|
return &stm32mp13_list[index];
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_STM32MP15x))
|
|
|
|
return &stm32mp15_list[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 get_otp_close_mask(void)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_STM32MP13x))
|
|
|
|
return STM32_OTP_STM32MP13x_CLOSE_MASK;
|
|
|
|
|
|
|
|
if (IS_ENABLED(CONFIG_STM32MP15x))
|
|
|
|
return STM32_OTP_STM32MP15x_CLOSE_MASK;
|
2022-09-15 16:11:40 +00:00
|
|
|
}
|
2019-07-05 15:20:17 +00:00
|
|
|
|
2021-06-28 12:56:01 +00:00
|
|
|
static int get_misc_dev(struct udevice **dev)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(stm32mp_bsec), dev);
|
|
|
|
if (ret)
|
|
|
|
log_err("Can't find stm32mp_bsec driver\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
static void read_key_value(const struct stm32key *key, u32 addr)
|
2019-07-05 15:20:17 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
for (i = 0; i < key->size; i++) {
|
|
|
|
printf("%s OTP %i: [%08x] %08x\n", key->name, key->start + i,
|
|
|
|
addr, __be32_to_cpu(*(u32 *)addr));
|
2019-07-05 15:20:17 +00:00
|
|
|
addr += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
static int read_key_otp(struct udevice *dev, const struct stm32key *key, bool print, bool *locked)
|
2021-06-28 12:56:02 +00:00
|
|
|
{
|
|
|
|
int i, word, ret;
|
2022-09-15 16:11:40 +00:00
|
|
|
int nb_invalid = 0, nb_zero = 0, nb_lock = 0, nb_lock_err = 0;
|
2021-06-28 12:56:02 +00:00
|
|
|
u32 val, lock;
|
|
|
|
bool status;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
for (i = 0, word = key->start; i < key->size; i++, word++) {
|
2021-06-28 12:56:02 +00:00
|
|
|
ret = misc_read(dev, STM32_BSEC_OTP(word), &val, 4);
|
|
|
|
if (ret != 4)
|
|
|
|
val = ~0x0;
|
|
|
|
ret = misc_read(dev, STM32_BSEC_LOCK(word), &lock, 4);
|
|
|
|
if (ret != 4)
|
2022-09-15 16:11:38 +00:00
|
|
|
lock = BSEC_LOCK_ERROR;
|
2021-06-28 12:56:02 +00:00
|
|
|
if (print)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("%s OTP %i: %08x lock : %08x\n", key->name, word, val, lock);
|
2021-06-28 12:56:02 +00:00
|
|
|
if (val == ~0x0)
|
|
|
|
nb_invalid++;
|
|
|
|
else if (val == 0x0)
|
|
|
|
nb_zero++;
|
2022-09-15 16:11:38 +00:00
|
|
|
if (lock & BSEC_LOCK_PERM)
|
2021-06-28 12:56:02 +00:00
|
|
|
nb_lock++;
|
2022-09-15 16:11:40 +00:00
|
|
|
if (lock & BSEC_LOCK_ERROR)
|
|
|
|
nb_lock_err++;
|
2021-06-28 12:56:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
status = nb_lock_err || (nb_lock == key->size);
|
2021-06-28 12:56:02 +00:00
|
|
|
if (locked)
|
|
|
|
*locked = status;
|
2022-09-15 16:11:40 +00:00
|
|
|
if (nb_lock_err && print)
|
|
|
|
printf("%s lock is invalid!\n", key->name);
|
|
|
|
else if (!status && print)
|
|
|
|
printf("%s is not locked!\n", key->name);
|
2021-06-28 12:56:02 +00:00
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
if (nb_invalid == key->size) {
|
2021-06-28 12:56:02 +00:00
|
|
|
if (print)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("%s is invalid!\n", key->name);
|
2021-06-28 12:56:02 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2022-09-15 16:11:40 +00:00
|
|
|
if (nb_zero == key->size) {
|
2021-06-28 12:56:02 +00:00
|
|
|
if (print)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("%s is free!\n", key->name);
|
2021-06-28 12:56:02 +00:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:39 +00:00
|
|
|
static int read_close_status(struct udevice *dev, bool print, bool *closed)
|
|
|
|
{
|
|
|
|
int word, ret, result;
|
2022-09-15 16:11:41 +00:00
|
|
|
u32 val, lock, mask;
|
2022-09-15 16:11:39 +00:00
|
|
|
bool status;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
word = STM32_OTP_CLOSE_ID;
|
|
|
|
ret = misc_read(dev, STM32_BSEC_OTP(word), &val, 4);
|
|
|
|
if (ret < 0)
|
|
|
|
result = ret;
|
|
|
|
if (ret != 4)
|
|
|
|
val = 0x0;
|
|
|
|
|
|
|
|
ret = misc_read(dev, STM32_BSEC_LOCK(word), &lock, 4);
|
|
|
|
if (ret < 0)
|
|
|
|
result = ret;
|
|
|
|
if (ret != 4)
|
|
|
|
lock = BSEC_LOCK_ERROR;
|
|
|
|
|
2022-09-15 16:11:41 +00:00
|
|
|
mask = get_otp_close_mask();
|
|
|
|
status = (val & mask) == mask;
|
2022-09-15 16:11:39 +00:00
|
|
|
if (closed)
|
|
|
|
*closed = status;
|
|
|
|
if (print)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("OTP %d: closed status: %d lock : %08x\n", word, status, lock);
|
2022-09-15 16:11:39 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
static int fuse_key_value(struct udevice *dev, const struct stm32key *key, u32 addr, bool print)
|
2019-07-05 15:20:17 +00:00
|
|
|
{
|
|
|
|
u32 word, val;
|
|
|
|
int i, ret;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
for (i = 0, word = key->start; i < key->size; i++, word++, addr += 4) {
|
2019-07-05 15:20:17 +00:00
|
|
|
val = __be32_to_cpu(*(u32 *)addr);
|
2021-06-28 12:55:59 +00:00
|
|
|
if (print)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("Fuse %s OTP %i : %08x\n", key->name, word, val);
|
2021-06-28 12:55:59 +00:00
|
|
|
|
|
|
|
ret = misc_write(dev, STM32_BSEC_OTP(word), &val, 4);
|
|
|
|
if (ret != 4) {
|
2022-09-15 16:11:40 +00:00
|
|
|
log_err("Fuse %s OTP %i failed\n", key->name, word);
|
2021-06-28 12:55:59 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2022-09-15 16:11:40 +00:00
|
|
|
/* on success, lock the OTP for the key */
|
2022-09-15 16:11:38 +00:00
|
|
|
val = BSEC_LOCK_PERM;
|
2021-06-28 12:56:00 +00:00
|
|
|
ret = misc_write(dev, STM32_BSEC_LOCK(word), &val, 4);
|
|
|
|
if (ret != 4) {
|
2022-09-15 16:11:40 +00:00
|
|
|
log_err("Lock %s OTP %i failed\n", key->name, word);
|
2021-06-28 12:56:00 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2019-07-05 15:20:17 +00:00
|
|
|
}
|
2021-06-28 12:55:59 +00:00
|
|
|
|
|
|
|
return 0;
|
2019-07-05 15:20:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int confirm_prog(void)
|
|
|
|
{
|
|
|
|
puts("Warning: Programming fuses is an irreversible operation!\n"
|
|
|
|
" This may brick your system.\n"
|
|
|
|
" Use this command only if you are sure of what you are doing!\n"
|
|
|
|
"\nReally perform this fuse programming? <y/N>\n");
|
|
|
|
|
|
|
|
if (confirm_yesno())
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
puts("Fuse programming aborted\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
static void display_key_info(const struct stm32key *key)
|
|
|
|
{
|
|
|
|
printf("%s : %s\n", key->name, key->desc);
|
|
|
|
printf("\tOTP%d..%d\n", key->start, key->start + key->size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_stm32key_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < get_key_nb(); i++)
|
|
|
|
display_key_info(get_key(i));
|
|
|
|
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_stm32key_select(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
|
|
{
|
|
|
|
const struct stm32key *key;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
printf("Selected key:\n");
|
|
|
|
key = get_key(stm32key_index);
|
|
|
|
display_key_info(key);
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < get_key_nb(); i++) {
|
|
|
|
key = get_key(i);
|
|
|
|
if (!strcmp(key->name, argv[1])) {
|
|
|
|
printf("%s selected\n", key->name);
|
|
|
|
stm32key_index = i;
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Unknown key %s\n", argv[1]);
|
|
|
|
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:55:58 +00:00
|
|
|
static int do_stm32key_read(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2019-07-05 15:20:17 +00:00
|
|
|
{
|
2022-09-15 16:11:40 +00:00
|
|
|
const struct stm32key *key;
|
2022-09-15 16:11:39 +00:00
|
|
|
struct udevice *dev;
|
2019-07-05 15:20:17 +00:00
|
|
|
u32 addr;
|
2022-09-15 16:11:40 +00:00
|
|
|
int ret, i;
|
|
|
|
int result;
|
2022-09-15 16:11:39 +00:00
|
|
|
|
|
|
|
ret = get_misc_dev(&dev);
|
2019-07-05 15:20:17 +00:00
|
|
|
|
2021-06-28 12:56:02 +00:00
|
|
|
if (argc == 1) {
|
2022-09-15 16:11:39 +00:00
|
|
|
if (ret)
|
|
|
|
return CMD_RET_FAILURE;
|
2022-09-15 16:11:40 +00:00
|
|
|
key = get_key(stm32key_index);
|
|
|
|
ret = read_key_otp(dev, key, true, NULL);
|
|
|
|
if (ret != -ENOENT)
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcmp("-a", argv[1])) {
|
2022-09-15 16:11:39 +00:00
|
|
|
if (ret)
|
|
|
|
return CMD_RET_FAILURE;
|
2022-09-15 16:11:40 +00:00
|
|
|
result = CMD_RET_SUCCESS;
|
|
|
|
for (i = 0; i < get_key_nb(); i++) {
|
|
|
|
key = get_key(i);
|
|
|
|
ret = read_key_otp(dev, key, true, NULL);
|
|
|
|
if (ret != -ENOENT)
|
|
|
|
result = CMD_RET_FAILURE;
|
|
|
|
}
|
|
|
|
ret = read_close_status(dev, true, NULL);
|
|
|
|
if (ret)
|
|
|
|
result = CMD_RET_FAILURE;
|
2022-09-15 16:11:39 +00:00
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
return result;
|
2021-06-28 12:56:02 +00:00
|
|
|
}
|
2019-07-05 15:20:17 +00:00
|
|
|
|
2021-07-24 15:03:29 +00:00
|
|
|
addr = hextoul(argv[1], NULL);
|
2019-07-05 15:20:17 +00:00
|
|
|
if (!addr)
|
|
|
|
return CMD_RET_USAGE;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
key = get_key(stm32key_index);
|
|
|
|
printf("Read %s at 0x%08x\n", key->name, addr);
|
|
|
|
read_key_value(key, addr);
|
2021-06-28 12:55:58 +00:00
|
|
|
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_stm32key_fuse(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
|
|
{
|
2022-09-15 16:11:40 +00:00
|
|
|
const struct stm32key *key = get_key(stm32key_index);
|
2022-09-15 16:11:39 +00:00
|
|
|
struct udevice *dev;
|
2021-06-28 12:55:58 +00:00
|
|
|
u32 addr;
|
2022-09-15 16:11:39 +00:00
|
|
|
int ret;
|
|
|
|
bool yes = false, lock;
|
2019-07-05 15:20:17 +00:00
|
|
|
|
2021-06-28 12:55:58 +00:00
|
|
|
if (argc < 2)
|
|
|
|
return CMD_RET_USAGE;
|
|
|
|
|
|
|
|
if (argc == 3) {
|
|
|
|
if (strcmp(argv[1], "-y"))
|
|
|
|
return CMD_RET_USAGE;
|
|
|
|
yes = true;
|
2019-07-05 15:20:17 +00:00
|
|
|
}
|
|
|
|
|
2021-07-24 15:03:29 +00:00
|
|
|
addr = hextoul(argv[argc - 1], NULL);
|
2021-06-28 12:55:58 +00:00
|
|
|
if (!addr)
|
|
|
|
return CMD_RET_USAGE;
|
|
|
|
|
2022-09-15 16:11:39 +00:00
|
|
|
ret = get_misc_dev(&dev);
|
|
|
|
if (ret)
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
if (read_key_otp(dev, key, !yes, &lock) != -ENOENT) {
|
2021-06-28 12:56:02 +00:00
|
|
|
printf("Error: can't fuse again the OTP\n");
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
2022-09-15 16:11:39 +00:00
|
|
|
if (lock) {
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("Error: %s is locked\n", key->name);
|
2021-06-28 12:56:02 +00:00
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
if (!yes) {
|
|
|
|
printf("Writing %s with\n", key->name);
|
|
|
|
read_key_value(key, addr);
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:55:58 +00:00
|
|
|
if (!yes && !confirm_prog())
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
if (fuse_key_value(dev, key, addr, !yes))
|
2021-06-28 12:55:59 +00:00
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("%s updated !\n", key->name);
|
2021-06-28 12:55:58 +00:00
|
|
|
|
2019-07-05 15:20:17 +00:00
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:56:03 +00:00
|
|
|
static int do_stm32key_close(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
|
|
|
{
|
2022-09-15 16:11:40 +00:00
|
|
|
const struct stm32key *key;
|
2021-06-28 12:56:03 +00:00
|
|
|
bool yes, lock, closed;
|
|
|
|
struct udevice *dev;
|
|
|
|
u32 val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
yes = false;
|
|
|
|
if (argc == 2) {
|
|
|
|
if (strcmp(argv[1], "-y"))
|
|
|
|
return CMD_RET_USAGE;
|
|
|
|
yes = true;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:39 +00:00
|
|
|
ret = get_misc_dev(&dev);
|
|
|
|
if (ret)
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
|
|
|
|
if (read_close_status(dev, !yes, &closed))
|
2021-06-28 12:56:03 +00:00
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
|
|
|
|
if (closed) {
|
|
|
|
printf("Error: already closed!\n");
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
|
|
|
|
2022-09-15 16:11:39 +00:00
|
|
|
/* check PKH status before to close */
|
2022-09-15 16:11:40 +00:00
|
|
|
key = get_key(STM32KEY_PKH);
|
|
|
|
ret = read_key_otp(dev, key, !yes, &lock);
|
2022-09-15 16:11:39 +00:00
|
|
|
if (ret) {
|
|
|
|
if (ret == -ENOENT)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("Error: %s not programmed!\n", key->name);
|
2022-09-15 16:11:39 +00:00
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
2021-06-28 12:56:03 +00:00
|
|
|
if (!lock)
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("Warning: %s not locked!\n", key->name);
|
2021-06-28 12:56:03 +00:00
|
|
|
|
|
|
|
if (!yes && !confirm_prog())
|
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
|
2022-09-15 16:11:41 +00:00
|
|
|
val = get_otp_close_mask();
|
2021-06-28 12:56:03 +00:00
|
|
|
ret = misc_write(dev, STM32_BSEC_OTP(STM32_OTP_CLOSE_ID), &val, 4);
|
|
|
|
if (ret != 4) {
|
2022-09-15 16:11:40 +00:00
|
|
|
printf("Error: can't update OTP %d\n", STM32_OTP_CLOSE_ID);
|
2021-06-28 12:56:03 +00:00
|
|
|
return CMD_RET_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Device is closed !\n");
|
|
|
|
|
|
|
|
return CMD_RET_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2021-06-28 12:55:58 +00:00
|
|
|
static char stm32key_help_text[] =
|
2022-09-15 16:11:40 +00:00
|
|
|
"list : list the supported key with description\n"
|
|
|
|
"stm32key select [<key>] : Select the key identified by <key> or display the key used for read/fuse command\n"
|
|
|
|
"stm32key read [<addr> | -a ] : Read the curent key at <addr> or current / all (-a) key in OTP\n"
|
|
|
|
"stm32key fuse [-y] <addr> : Fuse the current key at addr in OTP\n"
|
|
|
|
"stm32key close [-y] : Close the device\n";
|
|
|
|
|
|
|
|
U_BOOT_CMD_WITH_SUBCMDS(stm32key, "Manage key on STM32", stm32key_help_text,
|
|
|
|
U_BOOT_SUBCMD_MKENT(list, 1, 0, do_stm32key_list),
|
|
|
|
U_BOOT_SUBCMD_MKENT(select, 2, 0, do_stm32key_select),
|
2021-06-28 12:55:58 +00:00
|
|
|
U_BOOT_SUBCMD_MKENT(read, 2, 0, do_stm32key_read),
|
2021-06-28 12:56:03 +00:00
|
|
|
U_BOOT_SUBCMD_MKENT(fuse, 3, 0, do_stm32key_fuse),
|
|
|
|
U_BOOT_SUBCMD_MKENT(close, 2, 0, do_stm32key_close));
|