Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot: bootutil: swap_scratch: Fix compressed image sector size check #2085

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion boot/bootutil/src/swap_scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,17 @@ boot_slots_compatible(struct boot_loader_state *state)
smaller = 1;
i++;
} else {
sz1 += boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);
size_t sector_size = boot_img_sector_size(state, BOOT_SECONDARY_SLOT, j);

#ifdef MCUBOOT_DECOMPRESS_IMAGES
if (sector_size == 0) {
/* Since this supports decompressed images, we can safely exit if slot1 is
* smaller than slot0.
*/
break;
}
#endif
sz1 += sector_size;
Comment on lines +194 to +204
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we even have a full run of the function boot_slots_compatible when decompression is enabled? It seems that we are going to ignore the difference anyway, so we could just skip the check at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Slot 0 should still be larger than slot 1, plus it can be possibly enhanced in future if only some slots support compression

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK.
Note for the future: for devices that have uniform erase block size and block sizes that equal for partitions, if the are placed on different devices, we should figure out compile time check for this.

/* Guarantee that multiple sectors of the primary slot
* fit into the secondary slot.
*/
Expand Down
Loading