boot: bootutil: feed watchdog in bootutil_img_hash - #2824
Conversation
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>
| #endif | ||
| bootutil_sha_update(&sha_ctx, tmp_buf, blk_sz); | ||
|
|
||
| MCUBOOT_WATCHDOG_FEED(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/boot/bootutil/src/loader.c
Line 906 in 5098d8e
I think one feed per iteration is enough, but if it is preferred I can change it.
There was a problem hiding this comment.
@de-nordic Could you take another look? Can it stay as-is?
There was a problem hiding this comment.
I aligned this with how it's done for
boot_copy_region, where the feed is placed at the end of the loop, afterflash_area_readandflash_area_write.mcuboot/boot/bootutil/src/loader.c
Line 906 in 5098d8e
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.
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.