dfu: mcuboot_shell: Add command to enter serial recovery
Adds a command which can be used to enter mcuboot's serial recovery mode when the retention subsystem is enabled. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
7e11b6392b
commit
5e8b067364
2 changed files with 35 additions and 1 deletions
|
@ -12,6 +12,13 @@
|
|||
|
||||
#include "mcuboot_priv.h"
|
||||
|
||||
#ifdef CONFIG_RETENTION_BOOT_MODE
|
||||
#include <zephyr/retention/bootmode.h>
|
||||
#ifdef CONFIG_REBOOT
|
||||
#include <zephyr/sys/reboot.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct area_desc {
|
||||
const char *name;
|
||||
unsigned int id;
|
||||
|
@ -129,6 +136,30 @@ static int cmd_mcuboot_request_upgrade(const struct shell *sh, size_t argc,
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RETENTION_BOOT_MODE
|
||||
static int cmd_mcuboot_serial_recovery(const struct shell *sh, size_t argc,
|
||||
char **argv)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = bootmode_set(BOOT_MODE_TYPE_BOOTLOADER);
|
||||
|
||||
if (rc) {
|
||||
shell_error(sh, "Failed to set serial recovery mode: %d", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_REBOOT
|
||||
sys_reboot(SYS_REBOOT_COLD);
|
||||
#else
|
||||
shell_error(sh, "mcuboot serial recovery mode set, please reboot your device");
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int cmd_mcuboot_info_area(const struct shell *sh,
|
||||
const struct area_desc *area)
|
||||
{
|
||||
|
@ -196,6 +227,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(mcuboot_cmds,
|
|||
SHELL_CMD_ARG(erase, NULL, "erase <area_id>", cmd_mcuboot_erase, 2, 0),
|
||||
SHELL_CMD_ARG(request_upgrade, NULL, "request_upgrade [permanent]",
|
||||
cmd_mcuboot_request_upgrade, 1, 1),
|
||||
#ifdef CONFIG_RETENTION_BOOT_MODE
|
||||
SHELL_CMD_ARG(serial_recovery, NULL, "serial_recovery", cmd_mcuboot_serial_recovery, 1, 0),
|
||||
#endif
|
||||
SHELL_SUBCMD_SET_END /* Array terminated. */
|
||||
);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ int bootmode_check(uint8_t boot_mode)
|
|||
|
||||
rc = retention_is_valid(boot_mode_dev);
|
||||
|
||||
if (rc == 1) {
|
||||
if (rc == 1 || rc == -ENOTSUP) {
|
||||
uint8_t stored_mode;
|
||||
|
||||
rc = retention_read(boot_mode_dev, 0, &stored_mode, sizeof(stored_mode));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue