Skip to content

bootutil: add hooks reporting swap and serial upload progress - #2996

Draft
JayToltTech wants to merge 1 commit into
mcu-tools:mainfrom
Tolt-Technologies:feat/progress-hooks
Draft

JayToltTech wants to merge 1 commit into
mcu-tools:mainfrom
Tolt-Technologies:feat/progress-hooks

Conversation

@JayToltTech

Copy link
Copy Markdown
Contributor

A swap or a serial recovery upload of a large image can take minutes. MCUBOOT_ACTION_HOOKS tells the board an upgrade or serial recovery has started, but nothing after that, so a device with only an LED can't tell a running swap from a hung one.

This adds MCUBOOT_PROGRESS_HOOKS (CONFIG_MCUBOOT_PROGRESS_HOOKS on Zephyr) next to the action hooks. When set, MCUboot calls mcuboot_progress(type, done, total):

  • swap using scratch, move and offset, after each sector step, counted in sectors. Swap using move counts its move pass and its swap pass together, so done reaches total once, at the end.
  • serial recovery, after each uploaded chunk, counted in bytes.

A swap resumed after a reset still reports the steps it skips, so done counts from the start rather than jumping. Without the option the call compiles to nothing.

I made this a separate hook rather than extending mcuboot_status_change(), since that one takes a single enum and changing its signature breaks every existing implementation. Overwrite-only doesn't report. It copies the image in one boot_copy_region() call, so there's nowhere to hook it without restructuring the copy.

Builds on nrf52840dk with the option off. With it on, swap offset, swap move and CDC upload compile clean and the link stops only on the missing mcuboot_progress(), which is the board's to supply. Sim passes for scratch, swap-move and swap-offset, but the sim doesn't define the hook so the calls compile out there.

Thoughts on whether you'd rather this be a separate hook or folded into the action hooks?

A swap or a serial recovery upload of a large image can run for
minutes. MCUBOOT_ACTION_HOOKS tells a board when an upgrade or serial
recovery starts, but nothing reports how far it has got, so a device
with only an LED for feedback can't tell a running swap from a hung one.

Add MCUBOOT_PROGRESS_HOOKS, set on Zephyr by
CONFIG_MCUBOOT_PROGRESS_HOOKS, alongside the action hooks. When set,
MCUboot calls mcuboot_progress(type, done, total):

- swap using scratch, move and offset after each sector step, counting
  sectors. Swap using move counts both its move and its swap pass, so
  done reaches total once, at the end of the swap.
- serial recovery after each uploaded chunk, counting bytes.

A swap resumed after a reset reports the steps it skips as well, so
done still starts from the beginning. Without the option the call
compiles to nothing.

Signed-off-by: Jay Beavers <jay@tolttechnologies.com>
@de-nordic de-nordic added area: core Affects core functionality area: serial recovery labels Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Affects core functionality area: serial recovery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants