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: Use BOOT_IMG_AREA to get boot_loader_state area #2204

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion boot/bootutil/src/bootutil_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ boot_img_num_sectors(const struct boot_loader_state *state, size_t slot)
static inline uint32_t
boot_img_slot_off(struct boot_loader_state *state, size_t slot)
{
return flash_area_get_off(BOOT_IMG(state, slot).area);
return flash_area_get_off(BOOT_IMG_AREA(state, slot));
}

#ifndef MCUBOOT_USE_FLASH_AREA_GET_SECTORS
Expand Down
8 changes: 4 additions & 4 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2213,15 +2213,15 @@ check_downgrade_prevention(struct boot_loader_state *state)
if (MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER) {
/* If there was security no counter in slot 0, allow swap */
rc = bootutil_get_img_security_cnt(state, BOOT_PRIMARY_SLOT,
BOOT_IMG(state, 0).area,
BOOT_IMG_AREA(state, 0),
&security_counter[0]);
if (rc != 0) {
return 0;
}
/* If there is no security counter in slot 1, or it's lower than
* that of slot 0, prevent downgrade */
rc = bootutil_get_img_security_cnt(state, BOOT_SECONDARY_SLOT,
BOOT_IMG(state, 1).area,
BOOT_IMG_AREA(state, 1),
&security_counter[1]);
if (rc != 0 || security_counter[0] > security_counter[1]) {
rc = -1;
Expand All @@ -2234,8 +2234,8 @@ check_downgrade_prevention(struct boot_loader_state *state)
if (rc < 0) {
/* Image in slot 0 prevents downgrade, delete image in slot 1 */
BOOT_LOG_INF("Image %d in slot 1 erased due to downgrade prevention", BOOT_CURR_IMG(state));
flash_area_erase(BOOT_IMG(state, 1).area, 0,
flash_area_get_size(BOOT_IMG(state, 1).area));
flash_area_erase(BOOT_IMG_AREA(state, 1), 0,
flash_area_get_size(BOOT_IMG_AREA(state, 1)));
} else {
rc = 0;
}
Expand Down
Loading