@@ -490,35 +490,6 @@ find_last_sector_idx(const struct boot_loader_state *state, uint32_t copy_size)
490
490
return last_sector_idx ;
491
491
}
492
492
493
- /**
494
- * Finds the number of swap operations that have to be performed to swap the two images.
495
- *
496
- * @param state Current bootloader's state.
497
- * @param copy_size Total number of bytes to swap.
498
- *
499
- * @return The number of swap operations that have to be performed.
500
- */
501
- static uint32_t
502
- find_swap_count (const struct boot_loader_state * state , uint32_t copy_size )
503
- {
504
- int first_sector_idx ;
505
- int last_sector_idx ;
506
- uint32_t swap_count ;
507
-
508
- last_sector_idx = find_last_sector_idx (state , copy_size );
509
-
510
- swap_count = 0 ;
511
-
512
- while (last_sector_idx >= 0 ) {
513
- boot_copy_sz (state , last_sector_idx , & first_sector_idx );
514
-
515
- last_sector_idx = first_sector_idx - 1 ;
516
- swap_count ++ ;
517
- }
518
-
519
- return swap_count ;
520
- }
521
-
522
493
/**
523
494
* Swaps the contents of two flash regions within the two image slots.
524
495
*
@@ -759,6 +730,37 @@ swap_run(struct boot_loader_state *state, struct boot_status *bs,
759
730
}
760
731
#endif /* !MCUBOOT_OVERWRITE_ONLY */
761
732
733
+ #ifdef MCUBOOT_SWAP_USING_SCRATCH
734
+ /**
735
+ * Finds the number of swap operations that have to be performed to swap the two images.
736
+ *
737
+ * @param state Current bootloader's state.
738
+ * @param copy_size Total number of bytes to swap.
739
+ *
740
+ * @return The number of swap operations that have to be performed.
741
+ */
742
+ static uint32_t
743
+ find_swap_count (const struct boot_loader_state * state , uint32_t copy_size )
744
+ {
745
+ int first_sector_idx ;
746
+ int last_sector_idx ;
747
+ uint32_t swap_count ;
748
+
749
+ last_sector_idx = find_last_sector_idx (state , copy_size );
750
+
751
+ swap_count = 0 ;
752
+
753
+ while (last_sector_idx >= 0 ) {
754
+ boot_copy_sz (state , last_sector_idx , & first_sector_idx );
755
+
756
+ last_sector_idx = first_sector_idx - 1 ;
757
+ swap_count ++ ;
758
+ }
759
+
760
+ return swap_count ;
761
+ }
762
+ #endif /* MCUBOOT_SWAP_USING_SCRATCH */
763
+
762
764
int app_max_size (struct boot_loader_state * state )
763
765
{
764
766
size_t num_sectors_primary ;
0 commit comments