Add failure diagnostics example on MAX32666

pull/840/head
Mattia Moffa 2026-07-16 04:36:45 +02:00 committed by Daniele Lacamera
parent 3468e965e7
commit d943538906
2 changed files with 33 additions and 0 deletions

View File

@ -25,3 +25,14 @@ WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x10088000
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10010000
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x10050000
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x10090000
# Persistent failure diagnostics (set to 1 to enable).
# The region occupies WOLFBOOT_DIAGNOSTICS_SECTORS flash sectors of 0x2000 each.
WOLFBOOT_PERSIST_FAILURE_STATUS?=0
WOLFBOOT_DIAGNOSTICS_SECTORS?=2
# Normal configuration
WOLFBOOT_DIAGNOSTICS_ADDRESS?=0x1008A000
# Debug configuration
#WOLFBOOT_DIAGNOSTICS_ADDRESS?=0x10092000

View File

@ -276,6 +276,28 @@ void main(void)
wolfBoot_printf("MAX32666 Test App v%lu\n", (unsigned long)version);
#ifdef WOLFBOOT_PERSIST_FAILURE_STATUS
{
static const char *phase_str[] = { "?", "update", "boot", "rollback",
"recovery", "self-update" };
static const char *cause_str[] = { "?", "bad header",
"hash verification failed", "signature verification failed",
"not confirmed" };
struct wolfBoot_failure_record rec;
int i, n = wolfBoot_get_failure_count();
wolfBoot_printf("Recorded failures: %d\n", n);
for (i = 0; i < n; i++) {
if (wolfBoot_get_failure(i, &rec) == 0) {
wolfBoot_printf(" [%d] %s during %s in %s partition (v%lu)\n", i,
rec.cause <= 4 ? cause_str[rec.cause] : "?",
rec.phase <= 5 ? phase_str[rec.phase] : "?",
rec.partition == PART_UPDATE ? "UPDATE" : "BOOT",
(unsigned long)rec.fw_version);
}
}
}
#endif
/* Mark boot successful to prevent rollback */
wolfBoot_success();