diff --git a/sys/shell/commands/sc_suit.c b/sys/shell/commands/sc_suit.c index 9d74bddc1f..9fc8afb84d 100644 --- a/sys/shell/commands/sc_suit.c +++ b/sys/shell/commands/sc_suit.c @@ -26,10 +26,18 @@ #include "suit/storage.h" #include "suit/transport/coap.h" +#ifdef MODULE_SUIT_STORAGE_FLASHWRITE +#include "riotboot/flashwrite.h" +#include "periph/pm.h" +#endif + static void _print_usage(char **argv) { printf("Usage: %s fetch \n", argv[0]); printf(" %s seq_no\n", argv[0]); + if (IS_USED(MODULE_SUIT_STORAGE_FLASHWRITE)) { + printf(" %s revert\n", argv[0]); + } } static int _suit_handler(int argc, char **argv) @@ -47,6 +55,18 @@ static int _suit_handler(int argc, char **argv) suit_storage_get_highest_seq_no(&seq_no); printf("seq_no: 0x%08" PRIx32 "\n", seq_no); } +#ifdef MODULE_SUIT_STORAGE_FLASHWRITE + else if (strcmp(argv[1], "revert") == 0) { + int res = riotboot_flashwrite_invalidate_latest(); + if (res) { + printf("revert failed: %d\n", res); + } + else { + printf("reverted to previous version, rebooting…\n"); + pm_reboot(); + } + } +#endif else { _print_usage(argv); return -1;