Skip to content

MCUBOOT_SWAP_STATUS_HOOKS provider-overlay seam - #2804

Open
DOAR-Infineon wants to merge 1 commit into
mcu-tools:mainfrom
DOAR-Infineon:mr/1-fingerprint-hooks
Open

MCUBOOT_SWAP_STATUS_HOOKS provider-overlay seam#2804
DOAR-Infineon wants to merge 1 commit into
mcu-tools:mainfrom
DOAR-Infineon:mr/1-fingerprint-hooks

Conversation

@DOAR-Infineon

Copy link
Copy Markdown
Contributor

Adds a new hook family, MCUBOOT_SWAP_STATUS_HOOKS, that lets a downstream
provider take ownership of swap-status bookkeeping without editing the portable
core. boot/ stays provider-agnostic — this MR adds only the seam, no provider.

What it does

  • New BOOT_STATUS_HOOK_CALL(f, ret_default, ...) in boot_hooks.h, built on
    the existing DO_HOOK_CALL / HOOK_CALL_NOP machinery, same as every other
    hook family. When the gate is undefined it compiles to ret_default — no
    call, no link dependency, vanilla path unchanged.
  • Dispatch preambles over intact upstream bodies (override style):
    boot_write_status (loader.c), swap_status_init (swap_misc.c), and
    swap_read_status_bytes (swap_offset/move/scratch). Two amend-style sites:
    before the scratch-area erase (swap_scratc
    (loader.c boot_swap_image).
  • Dedicated sentinel BOOT_STATUS_HOOK_REGULAR = INT_MIN instead of reusing
    BOOT_HOOK_REGULAR: that constant equals nd
    these hooks legitimately return BOOT_EFLASH — reusing it would misread a
    real flash error as "run the built-in path". INT_MIN collides with nothing.
  • Semantics are REPLACE: an enabled provider
    built-in status-byte path runs only when the family is compiled out.

Notes

  • With MCUBOOT_SWAP_STATUS_HOOKS undefined, behavior is identical to upstream by construction.
  • Hook implementations are strong symbols the enabling build must link; a
    #error guard in bootutil_priv.h turns a feature-without-gate
    misconfiguration into a compile-time failure.

@DOAR-Infineon DOAR-Infineon changed the title MR1 fp-hooks: MCUBOOT_SWAP_STATUS_HOOKS provider-overlay seam (boot/,… MCUBOOT_SWAP_STATUS_HOOKS provider-overlay seam Jul 27, 2026
@DOAR-Infineon
DOAR-Infineon force-pushed the mr/1-fingerprint-hooks branch from 124051f to 9d4e415 Compare July 27, 2026 08:42
… provider-agnostic)

Signed-off-by: Artem Dovhal <artem.dovhal@infineon.com>
Signed-off-by: INFINEON\DovhalA <artem.dovhal@infineon.com>
@DOAR-Infineon
DOAR-Infineon force-pushed the mr/1-fingerprint-hooks branch from 9d4e415 to 58a9ac1 Compare July 27, 2026 08:44
Comment on lines +354 to +357
int swap_status_before_scratch_erase_hook(const struct boot_loader_state *state,
const struct flash_area *fap_pri,
const struct flash_area *fap_scratch,
struct boot_status *bs);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the plan is to deprecate swap using scratch, seems a bit superfluous?

* Copyright (c) 2016-2019 JUUL Labs
* Copyright (c) 2019-2020 Arm Limited
* Copyright (c) 2025 Nordic Semiconductor ASA
* Copyright (c) 2026 Infineon Technologies AG

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* Copyright (c) 2026 Infineon Technologies AG

same as below

@nordicjm
nordicjm requested a review from d3zd3z July 28, 2026 10:51
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