blob: e16fcf4424dc69cf41527c9e4a3019014e919940 [file] [log] [blame]
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +02001// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2/*
3 * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
4 */
5
6#include <common.h>
7#include <command.h>
8#include <console.h>
Patrick Delaunayeb653ac2020-11-06 19:01:29 +01009#include <log.h>
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +020010#include <misc.h>
Patrick Delaunay33a909a2023-01-06 13:20:15 +010011#include <asm/arch/bsec.h>
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +020012#include <dm/device.h>
13#include <dm/uclass.h>
Simon Glass1e94b462023-09-14 18:21:46 -060014#include <linux/printk.h>
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +020015
Patrick Delaunaye83cef82022-09-15 18:11:41 +020016/*
17 * Closed device: OTP0
18 * STM32MP15x: bit 6 of OPT0
19 * STM32MP13x: 0b111111 = 0x3F for OTP_SECURED closed device
20 */
Patrick Delaunayd3551b82021-06-28 14:56:02 +020021#define STM32_OTP_CLOSE_ID 0
Patrick Delaunaye83cef82022-09-15 18:11:41 +020022#define STM32_OTP_STM32MP13x_CLOSE_MASK 0x3F
23#define STM32_OTP_STM32MP15x_CLOSE_MASK BIT(6)
Patrick Delaunayd3551b82021-06-28 14:56:02 +020024
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +020025/* PKH is the first element of the key list */
26#define STM32KEY_PKH 0
27
28struct stm32key {
29 char *name;
30 char *desc;
31 u8 start;
32 u8 size;
33};
34
Patrick Delaunaye83cef82022-09-15 18:11:41 +020035const struct stm32key stm32mp13_list[] = {
36 [STM32KEY_PKH] = {
37 .name = "PKHTH",
38 .desc = "Hash of the 8 ECC Public Keys Hashes Table (ECDSA is the authentication algorithm)",
39 .start = 24,
40 .size = 8,
41 },
42 {
43 .name = "EDMK",
44 .desc = "Encryption/Decryption Master Key",
45 .start = 92,
46 .size = 4,
47 }
48};
49
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +020050const struct stm32key stm32mp15_list[] = {
51 [STM32KEY_PKH] = {
52 .name = "PKH",
53 .desc = "Hash of the ECC Public Key (ECDSA is the authentication algorithm)",
54 .start = 24,
55 .size = 8,
56 }
57};
58
59/* index of current selected key in stm32key list, 0 = PKH by default */
60static u8 stm32key_index;
61
62static u8 get_key_nb(void)
63{
Patrick Delaunaye83cef82022-09-15 18:11:41 +020064 if (IS_ENABLED(CONFIG_STM32MP13x))
65 return ARRAY_SIZE(stm32mp13_list);
66
67 if (IS_ENABLED(CONFIG_STM32MP15x))
68 return ARRAY_SIZE(stm32mp15_list);
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +020069}
70
71static const struct stm32key *get_key(u8 index)
72{
Patrick Delaunaye83cef82022-09-15 18:11:41 +020073 if (IS_ENABLED(CONFIG_STM32MP13x))
74 return &stm32mp13_list[index];
75
76 if (IS_ENABLED(CONFIG_STM32MP15x))
77 return &stm32mp15_list[index];
78}
79
80static u32 get_otp_close_mask(void)
81{
82 if (IS_ENABLED(CONFIG_STM32MP13x))
83 return STM32_OTP_STM32MP13x_CLOSE_MASK;
84
85 if (IS_ENABLED(CONFIG_STM32MP15x))
86 return STM32_OTP_STM32MP15x_CLOSE_MASK;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +020087}
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +020088
Patrick Delaunaye00e1f32021-06-28 14:56:01 +020089static int get_misc_dev(struct udevice **dev)
90{
91 int ret;
92
93 ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(stm32mp_bsec), dev);
94 if (ret)
95 log_err("Can't find stm32mp_bsec driver\n");
96
97 return ret;
98}
99
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200100static void read_key_value(const struct stm32key *key, u32 addr)
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200101{
102 int i;
103
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200104 for (i = 0; i < key->size; i++) {
105 printf("%s OTP %i: [%08x] %08x\n", key->name, key->start + i,
106 addr, __be32_to_cpu(*(u32 *)addr));
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200107 addr += 4;
108 }
109}
110
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200111static int read_key_otp(struct udevice *dev, const struct stm32key *key, bool print, bool *locked)
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200112{
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200113 int i, word, ret;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200114 int nb_invalid = 0, nb_zero = 0, nb_lock = 0, nb_lock_err = 0;
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200115 u32 val, lock;
116 bool status;
117
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200118 for (i = 0, word = key->start; i < key->size; i++, word++) {
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200119 ret = misc_read(dev, STM32_BSEC_OTP(word), &val, 4);
120 if (ret != 4)
121 val = ~0x0;
122 ret = misc_read(dev, STM32_BSEC_LOCK(word), &lock, 4);
123 if (ret != 4)
Patrick Delaunayc6327ba2022-09-15 18:11:38 +0200124 lock = BSEC_LOCK_ERROR;
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200125 if (print)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200126 printf("%s OTP %i: %08x lock : %08x\n", key->name, word, val, lock);
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200127 if (val == ~0x0)
128 nb_invalid++;
129 else if (val == 0x0)
130 nb_zero++;
Patrick Delaunayc6327ba2022-09-15 18:11:38 +0200131 if (lock & BSEC_LOCK_PERM)
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200132 nb_lock++;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200133 if (lock & BSEC_LOCK_ERROR)
134 nb_lock_err++;
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200135 }
136
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200137 status = nb_lock_err || (nb_lock == key->size);
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200138 if (locked)
139 *locked = status;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200140 if (nb_lock_err && print)
141 printf("%s lock is invalid!\n", key->name);
142 else if (!status && print)
143 printf("%s is not locked!\n", key->name);
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200144
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200145 if (nb_invalid == key->size) {
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200146 if (print)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200147 printf("%s is invalid!\n", key->name);
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200148 return -EINVAL;
149 }
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200150 if (nb_zero == key->size) {
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200151 if (print)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200152 printf("%s is free!\n", key->name);
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200153 return -ENOENT;
154 }
155
156 return 0;
157}
158
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200159static int read_close_status(struct udevice *dev, bool print, bool *closed)
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200160{
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200161 int word, ret, result;
Patrick Delaunaye83cef82022-09-15 18:11:41 +0200162 u32 val, lock, mask;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200163 bool status;
164
165 result = 0;
166 word = STM32_OTP_CLOSE_ID;
167 ret = misc_read(dev, STM32_BSEC_OTP(word), &val, 4);
168 if (ret < 0)
169 result = ret;
170 if (ret != 4)
171 val = 0x0;
172
173 ret = misc_read(dev, STM32_BSEC_LOCK(word), &lock, 4);
174 if (ret < 0)
175 result = ret;
176 if (ret != 4)
177 lock = BSEC_LOCK_ERROR;
178
Patrick Delaunaye83cef82022-09-15 18:11:41 +0200179 mask = get_otp_close_mask();
180 status = (val & mask) == mask;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200181 if (closed)
182 *closed = status;
183 if (print)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200184 printf("OTP %d: closed status: %d lock : %08x\n", word, status, lock);
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200185
186 return result;
187}
188
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200189static int fuse_key_value(struct udevice *dev, const struct stm32key *key, u32 addr, bool print)
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200190{
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200191 u32 word, val;
192 int i, ret;
193
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200194 for (i = 0, word = key->start; i < key->size; i++, word++, addr += 4) {
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200195 val = __be32_to_cpu(*(u32 *)addr);
Patrick Delaunayfe240902021-06-28 14:55:59 +0200196 if (print)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200197 printf("Fuse %s OTP %i : %08x\n", key->name, word, val);
Patrick Delaunayfe240902021-06-28 14:55:59 +0200198
199 ret = misc_write(dev, STM32_BSEC_OTP(word), &val, 4);
200 if (ret != 4) {
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200201 log_err("Fuse %s OTP %i failed\n", key->name, word);
Patrick Delaunayfe240902021-06-28 14:55:59 +0200202 return ret;
203 }
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200204 /* on success, lock the OTP for the key */
Patrick Delaunayc6327ba2022-09-15 18:11:38 +0200205 val = BSEC_LOCK_PERM;
Patrick Delaunay3da25522021-06-28 14:56:00 +0200206 ret = misc_write(dev, STM32_BSEC_LOCK(word), &val, 4);
207 if (ret != 4) {
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200208 log_err("Lock %s OTP %i failed\n", key->name, word);
Patrick Delaunay3da25522021-06-28 14:56:00 +0200209 return ret;
210 }
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200211 }
Patrick Delaunayfe240902021-06-28 14:55:59 +0200212
213 return 0;
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200214}
215
216static int confirm_prog(void)
217{
218 puts("Warning: Programming fuses is an irreversible operation!\n"
219 " This may brick your system.\n"
220 " Use this command only if you are sure of what you are doing!\n"
221 "\nReally perform this fuse programming? <y/N>\n");
222
223 if (confirm_yesno())
224 return 1;
225
226 puts("Fuse programming aborted\n");
227 return 0;
228}
229
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200230static void display_key_info(const struct stm32key *key)
231{
232 printf("%s : %s\n", key->name, key->desc);
233 printf("\tOTP%d..%d\n", key->start, key->start + key->size);
234}
235
236static int do_stm32key_list(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
237{
238 int i;
239
240 for (i = 0; i < get_key_nb(); i++)
241 display_key_info(get_key(i));
242
243 return CMD_RET_SUCCESS;
244}
245
246static int do_stm32key_select(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
247{
248 const struct stm32key *key;
249 int i;
250
251 if (argc == 1) {
252 printf("Selected key:\n");
253 key = get_key(stm32key_index);
254 display_key_info(key);
255 return CMD_RET_SUCCESS;
256 }
257
258 for (i = 0; i < get_key_nb(); i++) {
259 key = get_key(i);
260 if (!strcmp(key->name, argv[1])) {
261 printf("%s selected\n", key->name);
262 stm32key_index = i;
263 return CMD_RET_SUCCESS;
264 }
265 }
266
267 printf("Unknown key %s\n", argv[1]);
268
269 return CMD_RET_FAILURE;
270}
271
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200272static int do_stm32key_read(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200273{
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200274 const struct stm32key *key;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200275 struct udevice *dev;
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200276 u32 addr;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200277 int ret, i;
278 int result;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200279
280 ret = get_misc_dev(&dev);
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200281
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200282 if (argc == 1) {
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200283 if (ret)
284 return CMD_RET_FAILURE;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200285 key = get_key(stm32key_index);
286 ret = read_key_otp(dev, key, true, NULL);
287 if (ret != -ENOENT)
288 return CMD_RET_FAILURE;
289 return CMD_RET_SUCCESS;
290 }
291
292 if (!strcmp("-a", argv[1])) {
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200293 if (ret)
294 return CMD_RET_FAILURE;
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200295 result = CMD_RET_SUCCESS;
296 for (i = 0; i < get_key_nb(); i++) {
297 key = get_key(i);
298 ret = read_key_otp(dev, key, true, NULL);
299 if (ret != -ENOENT)
300 result = CMD_RET_FAILURE;
301 }
302 ret = read_close_status(dev, true, NULL);
303 if (ret)
304 result = CMD_RET_FAILURE;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200305
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200306 return result;
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200307 }
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200308
Simon Glass7e5f4602021-07-24 09:03:29 -0600309 addr = hextoul(argv[1], NULL);
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200310 if (!addr)
311 return CMD_RET_USAGE;
312
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200313 key = get_key(stm32key_index);
314 printf("Read %s at 0x%08x\n", key->name, addr);
315 read_key_value(key, addr);
Patrick Delaunayf4cb5d62019-07-05 17:20:17 +0200316
317 return CMD_RET_SUCCESS;
318}
319
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200320static int do_stm32key_fuse(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
321{
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200322 const struct stm32key *key = get_key(stm32key_index);
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200323 struct udevice *dev;
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200324 u32 addr;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200325 int ret;
326 bool yes = false, lock;
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200327
328 if (argc < 2)
329 return CMD_RET_USAGE;
330
331 if (argc == 3) {
332 if (strcmp(argv[1], "-y"))
333 return CMD_RET_USAGE;
334 yes = true;
335 }
336
Simon Glass7e5f4602021-07-24 09:03:29 -0600337 addr = hextoul(argv[argc - 1], NULL);
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200338 if (!addr)
339 return CMD_RET_USAGE;
340
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200341 ret = get_misc_dev(&dev);
342 if (ret)
343 return CMD_RET_FAILURE;
344
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200345 if (read_key_otp(dev, key, !yes, &lock) != -ENOENT) {
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200346 printf("Error: can't fuse again the OTP\n");
347 return CMD_RET_FAILURE;
348 }
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200349 if (lock) {
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200350 printf("Error: %s is locked\n", key->name);
Patrick Delaunayd3551b82021-06-28 14:56:02 +0200351 return CMD_RET_FAILURE;
352 }
353
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200354 if (!yes) {
355 printf("Writing %s with\n", key->name);
356 read_key_value(key, addr);
357 }
358
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200359 if (!yes && !confirm_prog())
360 return CMD_RET_FAILURE;
361
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200362 if (fuse_key_value(dev, key, addr, !yes))
Patrick Delaunayfe240902021-06-28 14:55:59 +0200363 return CMD_RET_FAILURE;
364
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200365 printf("%s updated !\n", key->name);
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200366
367 return CMD_RET_SUCCESS;
368}
369
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200370static int do_stm32key_close(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
371{
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200372 const struct stm32key *key;
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200373 bool yes, lock, closed;
374 struct udevice *dev;
375 u32 val;
376 int ret;
377
378 yes = false;
379 if (argc == 2) {
380 if (strcmp(argv[1], "-y"))
381 return CMD_RET_USAGE;
382 yes = true;
383 }
384
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200385 ret = get_misc_dev(&dev);
386 if (ret)
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200387 return CMD_RET_FAILURE;
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200388
389 if (read_close_status(dev, !yes, &closed))
390 return CMD_RET_FAILURE;
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200391
392 if (closed) {
393 printf("Error: already closed!\n");
394 return CMD_RET_FAILURE;
395 }
396
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200397 /* check PKH status before to close */
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200398 key = get_key(STM32KEY_PKH);
399 ret = read_key_otp(dev, key, !yes, &lock);
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200400 if (ret) {
401 if (ret == -ENOENT)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200402 printf("Error: %s not programmed!\n", key->name);
Patrick Delaunay8921b3d2022-09-15 18:11:39 +0200403 return CMD_RET_FAILURE;
404 }
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200405 if (!lock)
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200406 printf("Warning: %s not locked!\n", key->name);
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200407
408 if (!yes && !confirm_prog())
409 return CMD_RET_FAILURE;
410
Patrick Delaunaye83cef82022-09-15 18:11:41 +0200411 val = get_otp_close_mask();
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200412 ret = misc_write(dev, STM32_BSEC_OTP(STM32_OTP_CLOSE_ID), &val, 4);
413 if (ret != 4) {
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200414 printf("Error: can't update OTP %d\n", STM32_OTP_CLOSE_ID);
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200415 return CMD_RET_FAILURE;
416 }
417
418 printf("Device is closed !\n");
419
420 return CMD_RET_SUCCESS;
421}
422
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200423static char stm32key_help_text[] =
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200424 "list : list the supported key with description\n"
425 "stm32key select [<key>] : Select the key identified by <key> or display the key used for read/fuse command\n"
426 "stm32key read [<addr> | -a ] : Read the curent key at <addr> or current / all (-a) key in OTP\n"
427 "stm32key fuse [-y] <addr> : Fuse the current key at addr in OTP\n"
428 "stm32key close [-y] : Close the device\n";
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200429
Patrick Delaunayfd1f4c92022-09-15 18:11:40 +0200430U_BOOT_CMD_WITH_SUBCMDS(stm32key, "Manage key on STM32", stm32key_help_text,
431 U_BOOT_SUBCMD_MKENT(list, 1, 0, do_stm32key_list),
432 U_BOOT_SUBCMD_MKENT(select, 2, 0, do_stm32key_select),
Patrick Delaunaybc78d5f2021-06-28 14:55:58 +0200433 U_BOOT_SUBCMD_MKENT(read, 2, 0, do_stm32key_read),
Patrick Delaunay80cfc6c2021-06-28 14:56:03 +0200434 U_BOOT_SUBCMD_MKENT(fuse, 3, 0, do_stm32key_fuse),
435 U_BOOT_SUBCMD_MKENT(close, 2, 0, do_stm32key_close));