Skip to content

Commit 6d0edaf

Browse files
committed
[nrf noup] bootutil: loader: fix a hardfault when the external secondary address greater than 1MB
hdr->ih_magic is an internal Flash address though the secondary slot is on external Flash. Without this fix, hdr->ih_magic would cause a hardfault if the external address is greater than 1MB. In addition, this fix also moves network_core_update() to nrf53_hooks.c to have a better consistency. Signed-off-by: Kevin Ai <kevin.ai@nordicsemi.no>
1 parent 6097de2 commit 6d0edaf

File tree

1 file changed

+3
-34
lines changed

1 file changed

+3
-34
lines changed

boot/bootutil/src/loader.c

+3-34
Original file line numberDiff line numberDiff line change
@@ -911,9 +911,8 @@ boot_validated_swap_type(struct boot_loader_state *state,
911911
{
912912
int swap_type;
913913
fih_int fih_rc = FIH_FAILURE;
914-
bool upgrade_valid = false;
915914

916-
#if defined(PM_S1_ADDRESS) || defined(CONFIG_SOC_NRF5340_CPUAPP)
915+
#if defined(PM_S1_ADDRESS)
917916
const struct flash_area *secondary_fa =
918917
BOOT_IMG_AREA(state, BOOT_SECONDARY_SLOT);
919918
struct image_header *hdr = (struct image_header *)secondary_fa->fa_off;
@@ -956,7 +955,7 @@ boot_validated_swap_type(struct boot_loader_state *state,
956955
}
957956
#endif /* PM_S1_ADDRESS */
958957
}
959-
#endif /* PM_S1_ADDRESS || CONFIG_SOC_NRF5340_CPUAPP */
958+
#endif /* PM_S1_ADDRESS */
960959

961960
swap_type = boot_swap_type_multi(BOOT_CURR_IMG(state));
962961
if (BOOT_IS_UPGRADE(swap_type)) {
@@ -970,37 +969,7 @@ boot_validated_swap_type(struct boot_loader_state *state,
970969
} else {
971970
swap_type = BOOT_SWAP_TYPE_FAIL;
972971
}
973-
} else {
974-
upgrade_valid = true;
975-
}
976-
977-
#if defined(CONFIG_SOC_NRF5340_CPUAPP) && defined(PM_CPUNET_B0N_ADDRESS)
978-
/* If the update is valid, and it targets the network core: perform the
979-
* update and indicate to the caller of this function that no update is
980-
* available
981-
*/
982-
if (upgrade_valid && reset_addr > PM_CPUNET_B0N_ADDRESS) {
983-
uint32_t fw_size = hdr->ih_img_size;
984-
985-
BOOT_LOG_INF("Starting network core update");
986-
int rc = pcd_network_core_update(vtable, fw_size);
987-
988-
if (rc != 0) {
989-
swap_type = BOOT_SWAP_TYPE_FAIL;
990-
} else {
991-
BOOT_LOG_INF("Done updating network core");
992-
#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SWAP_USING_MOVE)
993-
/* swap_erase_trailer_sectors is undefined if upgrade only
994-
* method is used. There is no need to erase sectors, because
995-
* the image cannot be reverted.
996-
*/
997-
rc = swap_erase_trailer_sectors(state,
998-
secondary_fa);
999-
#endif
1000-
swap_type = BOOT_SWAP_TYPE_NONE;
1001-
}
1002-
}
1003-
#endif /* CONFIG_SOC_NRF5340_CPUAPP */
972+
}
1004973
}
1005974

1006975
return swap_type;

0 commit comments

Comments
 (0)