Skip to content

Commit 98b9e4b

Browse files
de-nordicjukkar
authored andcommitted
[nrf noup] loader: Use BOOT_SLOT_PRIMARY and BOOT_SLOT_SECONDARY
nrf-squash! [nrf noup] loader: Add firmware version check downgrade prevention The commit replaces BOOT_PRIMARY_SLOT and BOOT_SECONDARY_SLOT with BOOT_SLOT_PRIMARY and BOOT_SLOT_SECONDARY respectively. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 0d5b49d commit 98b9e4b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

boot/bootutil/src/loader.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,11 +1071,11 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
10711071
#if defined(CONFIG_SOC_NRF5340_CPUAPP) && defined(CONFIG_NRF53_MULTI_IMAGE_UPDATE) \
10721072
&& defined(CONFIG_PCD_APP) && defined(CONFIG_PCD_READ_NETCORE_APP_VERSION)
10731073
if (BOOT_CURR_IMG(state) == CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER) {
1074-
rc = pcd_version_cmp_net(fap, boot_img_hdr(state, BOOT_SECONDARY_SLOT));
1074+
rc = pcd_version_cmp_net(fap, boot_img_hdr(state, BOOT_SLOT_SECONDARY));
10751075
} else {
10761076
rc = boot_version_cmp(
1077-
&boot_img_hdr(state, BOOT_SECONDARY_SLOT)->ih_ver,
1078-
&boot_img_hdr(state, BOOT_PRIMARY_SLOT)->ih_ver);
1077+
&boot_img_hdr(state, BOOT_SLOT_SECONDARY)->ih_ver,
1078+
&boot_img_hdr(state, BOOT_SLOT_PRIMARY)->ih_ver);
10791079

10801080
#if CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER != -1
10811081
if (rc >= 0 && BOOT_CURR_IMG(state) == CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER) {
@@ -1096,8 +1096,8 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
10961096
}
10971097
#else
10981098
rc = boot_version_cmp(
1099-
&boot_img_hdr(state, BOOT_SECONDARY_SLOT)->ih_ver,
1100-
&boot_img_hdr(state, BOOT_PRIMARY_SLOT)->ih_ver);
1099+
&boot_img_hdr(state, BOOT_SLOT_SECONDARY)->ih_ver,
1100+
&boot_img_hdr(state, BOOT_SLOT_PRIMARY)->ih_ver);
11011101

11021102
#if CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER != -1
11031103
if (rc >= 0 && BOOT_CURR_IMG(state) == CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER) {
@@ -1116,7 +1116,7 @@ boot_validate_slot(struct boot_loader_state *state, int slot,
11161116
}
11171117
#endif
11181118
#endif
1119-
if (rc < 0 && boot_check_header_erased(state, BOOT_PRIMARY_SLOT)) {
1119+
if (rc < 0 && boot_check_header_erased(state, BOOT_SLOT_PRIMARY)) {
11201120
BOOT_LOG_ERR("insufficient version in secondary slot");
11211121
boot_scramble_slot(fap, slot);
11221122
/* Image in the secondary slot does not satisfy version requirement.

0 commit comments

Comments
 (0)