Skip to content

boot: bootutil: feed watchdog in bootutil_img_hash - #2824

Merged
nordicjm merged 1 commit into
mcu-tools:mainfrom
tpambor:img-hash-watchdog
Aug 11, 2026
Merged

boot: bootutil: feed watchdog in bootutil_img_hash#2824
nordicjm merged 1 commit into
mcu-tools:mainfrom
tpambor:img-hash-watchdog

Conversation

@tpambor

@tpambor tpambor commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

If the image is large and/or stored on slow memory, e.g. external flash, reading the image to calculate its hash can take a significant amount of time. Feed the watchdog while hashing is in progress to prevent a reset from happening under these conditions.

If the image is large and/or stored on slow memory, e.g. external
flash, reading the image to calculate its hash can take a significant
amount of time. Feed the watchdog while hashing is in progress to
prevent a reset from happening under these conditions.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
@tpambor
tpambor requested a review from davidvincze as a code owner August 5, 2026 15:22
@de-nordic de-nordic added area: core Affects core functionality crypto Encryption support labels Aug 5, 2026
#endif
bootutil_sha_update(&sha_ctx, tmp_buf, blk_sz);

MCUBOOT_WATCHDOG_FEED();

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.

Shouldn't the feed happen on top of for, in front of flash_read then between read and bootutil_sha_update and then after the loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I aligned this with how it's done for boot_copy_region, where the feed is placed at the end of the loop, after flash_area_read and flash_area_write.

MCUBOOT_WATCHDOG_FEED();

I think one feed per iteration is enough, but if it is preferred I can change it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@de-nordic Could you take another look? Can it stay as-is?

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.

I aligned this with how it's done for boot_copy_region, where the feed is placed at the end of the loop, after flash_area_read and flash_area_write.

MCUBOOT_WATCHDOG_FEED();

I think one feed per iteration is enough, but if it is preferred I can change it.

The iteration does not matter, The operation does. The feed is time based, so my question was whether the feed should not be updated prior and after operations that may not stuck but take longer time.

@tpambor
tpambor requested a review from de-nordic August 5, 2026 15:40

@de-nordic de-nordic left a comment

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.

Seems ok.

@nordicjm
nordicjm merged commit c024826 into mcu-tools:main Aug 11, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Affects core functionality crypto Encryption support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants