Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configurable hooks framework to let downstream users inject custom logic at key boot/loader/panic points without patching wolfBoot, and updates panic handling to be syntactically safe in single-line if statements.
Changes:
- Introduces
include/hooks.hand integrates hook invocation points (pre-init, post-init, boot, panic) guarded by build macros. - Extends the build system (
options.mk) to compile a user-supplied hooks source file and define per-hook feature macros. - Adds documentation and CI coverage for hooks behavior on the simulator; updates
wolfBoot_panic()macro for statement-safety.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/update_ram.c | Calls boot hook prior to do_boot() when enabled. |
| src/update_flash_hwswap.c | Calls boot hook prior to do_boot() when enabled. |
| src/update_flash.c | Calls boot hook prior to do_boot() when enabled. |
| src/update_disk.c | Calls boot hook prior to do_boot() when enabled. |
| src/loader.c | Adds preinit/postinit hook call sites in loader flow. |
| options.mk | Adds hook build knobs and compiles user hook file into the build. |
| include/loader.h | Integrates panic hook and wraps armored panic macro in do { } while (0). |
| include/hooks.h | New public hook API header and per-hook prototypes. |
| include/hal.h | Removes stray whitespace line. |
| docs/hooks.md | New user documentation for hook API, timing, and build flags. |
| docs/README.md | Links to hooks documentation. |
| .github/workflows/test-hooks-simulator.yml | CI coverage to validate hook invocation counts per scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a generic hook framework allowing users to inject custom logic at defined points in the boot process (pre-init, post-init, boot, panic). Each hook is independently enabled via build macros and implemented in a user-supplied source file.
This is useful for the large number of customers that want to use the upstream HAL for their part without modifying it, but might need to do additional work to support board-specific hardware, safe state setting, etc.
Semi-related fix: Wraps
wolfBoot_panic()definition indo {} while (0)for syntactic correctness when used in single-line if statements (currently was broken inhal/pic32c.c, and a few other locations)