Skip to content

Record why the disk boot path refuses a slot and pass boot stage times to the OS - #1026

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:disk_boot_diag
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:disk_boot_diag

Conversation

@dgarske

@dgarske dgarske commented Dec 3, 2026

Copy link
Copy Markdown
Member

Description

  • Every slot the disk boot path refuses is recorded in the failure diagnostics store (WOLFBOOT_PERSIST_FAILURE_STATUS), with the slot as partition: header, read, decrypt, hash, signature, version and unconfirmed-slot causes. A recovery record follows when nothing boots, and the newest record prints at the next boot.
  • New causes WOLFBOOT_FAILURE_CAUSE_DECRYPT, WOLFBOOT_FAILURE_CAUSE_VERSION and WOLFBOOT_FAILURE_CAUSE_READ.
  • A slot whose header cannot be read or decrypted is recorded once, even when the other slot boots; an empty (all 0x00 or 0xFF) slot is not recorded.
  • With BOOT_BENCHMARK=1, per-stage timestamps (entry, load, decrypt, hash, verify, handoff) go to the OS as /chosen/wolfboot,boot-times.

On ZynqMP SD boot the store lives in QSPI (EXT_FLASH=1 WOLFBOOT_DIAGNOSTICS_EXT=1).

Testing

  • Unit tests for the records on the encrypted and plain disk paths and with boot confirmation (unit-update-disk-diag, -diag-plain, -confirm-diag).

Validated on a ZCU102 (SD boot, BL33) with an earlier revision of this change: a modified slot recorded in QSPI and printed at the next boot, and the boot times read from /proc/device-tree/chosen.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Boot-failure diagnostics omit a terminal recovery record, incorrectly record blank fallback slots, and lose known image versions.

3 open issues
What changed in this PR

Adds persistent failure diagnostics and OS-visible stage timing to wolfBoot’s disk boot path.

Changes:

  • Records slot refusal causes and reports the latest stored failure.
  • Exports boot-stage timestamps through /chosen/wolfboot,boot-times.
  • Adds diagnostic test variants and documents configuration and behavior.
File Description
tools/​unit-tests/​unit-update-disk.c Tests encrypted and plain disk failure records.
tools/​unit-tests/​unit-update-disk-confirm.c Tests diagnostics for unconfirmed and refused slots.
tools/​unit-tests/​Makefile Registers three diagnostic test variants.
src/​update_disk.c Adds failure recording, reporting, and boot timestamps.
include/​wolfboot/​wolfboot.h Defines decrypt, version, and read failure causes.
docs/​compile.md Documents boot-stage timing.
docs/​API.md Documents disk diagnostics and storage configuration.

Review effort: Balanced

Comment thread src/update_disk.c Resolved
Comment thread src/update_disk.c Resolved
Comment thread src/update_disk.c Resolved
@dgarske
dgarske requested review from bigbrett and danielinux and a balanced review from Copilot December 3, 2026 22:23
@dgarske dgarske assigned wolfSSL-Bot and unassigned dgarske Dec 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Empty-slot exclusions remain incomplete: stale TESTING trailers can produce rollback records for blank slots, and blank golden slots can still produce BOOT failure records.

2 open issues
3 resolved since last review

Review effort: Balanced

Comment thread src/update_disk.c Resolved
Comment thread src/update_disk.c Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The i.MX95 DTB fixup never calls the disk timing callback, so the shipped benchmark-enabled SD boot configuration fails to pass boot timestamps to Linux.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/update_disk.c Resolved

@bigbrett bigbrett left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I'm not as well versed in the disk boot flow.

One hangup is I'm not sure if the failure cause numbering skip below was intentional? If it was, LMK and I will approve.

Comment thread include/wolfboot/wolfboot.h Resolved
@dgarske
dgarske requested a review from bigbrett December 4, 2026 19:57
@dgarske dgarske assigned bigbrett and unassigned danielinux and dgarske Dec 4, 2026
@bigbrett bigbrett removed their assignment Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants