@@ -1388,6 +1388,11 @@ boot_update_security_counter(uint8_t image_index, int slot,
13881388#define SEC_SLOT_TOUCHED 1
13891389#define SEC_SLOT_ASSIGNED 2
13901390
1391+ #if !defined(LEGACY_CHILD_PARENT_S0_S1_UPDATE_ENABLED )
1392+ /* Sysbuild */
1393+ static uint8_t sec_slot_assignmnet [MCUBOOT_IMAGE_NUMBER ] = {0 };
1394+ #else
1395+ /* Legacy child/parent image */
13911396#if (MCUBOOT_IMAGE_NUMBER == 2 ) && defined(PM_B0_ADDRESS ) && \
13921397 !defined(CONFIG_NRF53_MULTI_IMAGE_UPDATE )
13931398/* This configuration is peculiar - the one physical secondary slot is
@@ -1399,21 +1404,46 @@ boot_update_security_counter(uint8_t image_index, int slot,
13991404#endif
14001405
14011406static uint8_t sec_slot_assignmnet [SEC_SLOT_PHYSICAL_CNT ] = {0 };
1407+ #endif
14021408
14031409static inline void sec_slot_touch (struct boot_loader_state * state )
14041410{
1411+ #if !defined(LEGACY_CHILD_PARENT_S0_S1_UPDATE_ENABLED )
1412+ /* Sysbuild */
1413+ if (BOOT_CURR_IMG (state ) == CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER ) {
1414+ if (sec_slot_assignmnet [CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER ] == SEC_SLOT_VIRGIN ) {
1415+ sec_slot_assignmnet [CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER ] = SEC_SLOT_TOUCHED ;
1416+ }
1417+ }
1418+
1419+ if (sec_slot_assignmnet [BOOT_CURR_IMG (state )] == SEC_SLOT_VIRGIN ) {
1420+ sec_slot_assignmnet [BOOT_CURR_IMG (state )] = SEC_SLOT_TOUCHED ;
1421+ }
1422+ #else
1423+ /* Legacy child/parent image */
14051424 uint8_t idx = (SEC_SLOT_PHYSICAL_CNT == 1 ) ? 0 : BOOT_CURR_IMG (state );
14061425
14071426 if (SEC_SLOT_VIRGIN == sec_slot_assignmnet [idx ]) {
14081427 sec_slot_assignmnet [idx ] = SEC_SLOT_TOUCHED ;
14091428 }
1429+ #endif
14101430}
14111431
14121432static inline void sec_slot_mark_assigned (struct boot_loader_state * state )
14131433{
1434+ #if !defined(LEGACY_CHILD_PARENT_S0_S1_UPDATE_ENABLED )
1435+ /* Sysbuild */
1436+ if (BOOT_CURR_IMG (state ) == CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER ) {
1437+ sec_slot_assignmnet [CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER ] = SEC_SLOT_ASSIGNED ;
1438+ }
1439+
1440+ sec_slot_assignmnet [BOOT_CURR_IMG (state )] = SEC_SLOT_ASSIGNED ;
1441+ #else
1442+ /* Legacy child/parent image */
14141443 uint8_t idx = (SEC_SLOT_PHYSICAL_CNT == 1 ) ? 0 : BOOT_CURR_IMG (state );
14151444
14161445 sec_slot_assignmnet [idx ] = SEC_SLOT_ASSIGNED ;
1446+ #endif
14171447}
14181448
14191449/**
@@ -1429,7 +1459,13 @@ static void sec_slot_cleanup_if_unusable(void)
14291459{
14301460 uint8_t idx ;
14311461
1462+ #if !defined(LEGACY_CHILD_PARENT_S0_S1_UPDATE_ENABLED )
1463+ /* Sysbuild */
1464+ for (idx = 0 ; idx < MCUBOOT_IMAGE_NUMBER ; idx ++ ) {
1465+ #else
1466+ /* Legacy child/parent image */
14321467 for (idx = 0 ; idx < SEC_SLOT_PHYSICAL_CNT ; idx ++ ) {
1468+ #endif
14331469 if (SEC_SLOT_TOUCHED == sec_slot_assignmnet [idx ]) {
14341470 const struct flash_area * secondary_fa ;
14351471 int rc ;
@@ -1439,12 +1475,12 @@ static void sec_slot_cleanup_if_unusable(void)
14391475 if (!rc ) {
14401476 rc = flash_area_erase (secondary_fa , 0 , secondary_fa -> fa_size );
14411477 if (!rc ) {
1442- BOOT_LOG_ERR ("Cleaned-up secondary slot of %d. image. " , idx );
1478+ BOOT_LOG_ERR ("Cleaned-up secondary slot of image %d " , idx );
14431479 }
14441480 }
14451481
14461482 if (rc ) {
1447- BOOT_LOG_ERR ("Can not cleanup secondary slot of %d. image. " , idx );
1483+ BOOT_LOG_ERR ("Failed to clean-up secondary slot of image %d: %d " , idx , rc );
14481484 }
14491485 }
14501486 }
0 commit comments