Skip to content

Add pre-boot hook, DTB accessor and FDT alias/reg helpers - #898

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

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

Conversation

@dgarske

@dgarske dgarske commented Sep 16, 2026

Copy link
Copy Markdown
Member

Adds WOLFBOOT_HOOK_PREBOOT, which fires immediately before hal_prepare_boot(). That is where ports tear the environment down for handoff, and several do something irreversible there: flushing or disabling caches, disabling the MMU (hal/cm4.c), leaving 4-byte flash addressing (hal/zynq.c). Work that needs DMA, a live MMU mapping or external flash has had nowhere to run; the existing WOLFBOOT_HOOK_BOOT stays for whatever must happen last.

@dgarske dgarske self-assigned this Sep 16, 2026
Copilot AI lite review requested due to automatic review settings September 16, 2026 21:36

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds a pre-boot hook that runs immediately before hal_prepare_boot(), exposes the validated DTB to hooks, and adds FDT helpers for parent lookup, alias resolution, and reg decoding.

Changes:

  • Adds WOLFBOOT_HOOK_PREBOOT support across update strategies, build options, documentation, and simulator tests.
  • Adds wolfBoot_get_dts_address() and publishes the DTB before the pre-boot hook.
  • Adds fdt_parent_offset(), fdt_get_alias(), fdt_get_reg(), and unit tests covering common cell layouts and invalid inputs.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/unit-tests/unit-fdt.c Adds FDT helper tests and a compiled DTB fixture.
src/update_ram.c Publishes the DTB and invokes the pre-boot hook.
src/update_flash_hwswap.c Adds the DTB accessor stub and pre-boot hook invocation.
src/update_flash.c Adds the DTB accessor stub and pre-boot hook invocation.
src/update_disk.c Publishes the DTB and invokes the pre-boot hook.
src/fdt.c Implements parent, alias, and reg helpers.
options.mk Enables the pre-boot hook build option.
include/hooks.h Declares the pre-boot hook and DTB accessor.
include/fdt.h Documents the new FDT APIs.
docs/hooks.md Documents hook timing and DTB access.
.github/workflows/test-hooks-simulator.yml Tests pre-boot hook invocation and accessor definitions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread include/hooks.h
/* The device tree wolfBoot is about to hand to the OS, or NULL. Valid from
* wolfBoot_hook_preboot() on, once the DTB is located, relocated and (where
* a digest is bound) authenticated. Read-only. */
void* wolfBoot_get_dts_address(void);
Comment thread src/fdt.c
Comment on lines +1000 to +1002
if ((uint32_t)index >= ((uint32_t)len / entry)) {
return -FDT_ERR_NOTFOUND;
}
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.

2 participants