1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

sys/shell/commands: add suit revert sub-command

This commit is contained in:
Benjamin Valentin 2022-09-04 23:26:30 +02:00
parent 711f4df101
commit 6ed2394dde

View File

@ -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 <manifest url>\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;