Boot: Enable overwriting upgrade with 0 size scratch

Previously the bootloader always checked whether the size of the scratch
area is sufficient. In case of the overwrite upgrade strategy this check
is not necessary since it doesn't use the scratch. However, if the
FLASH_AREA_SCRATCH_SIZE was set to 0 it caused an error which prevented
any image upgrade attempts. This issue has already been fixed in the
upstream MCUBoot repository (commit hash:
74aef312df0d8f426a8ac04f359a377f7674dc7c). This patch simply copies the
fix from there and applies it to the forked MCUBoot in TF-M.

Change-Id: I7ffb8356239a1cf882be9c9c3a4e148b15bc7fa2
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/bl2/ext/mcuboot/bootutil/src/loader.c b/bl2/ext/mcuboot/bootutil/src/loader.c
index a3301cf..e7c287b 100644
--- a/bl2/ext/mcuboot/bootutil/src/loader.c
+++ b/bl2/ext/mcuboot/bootutil/src/loader.c
@@ -668,7 +668,7 @@
 }
 
 /*
- * Slots are compatible when all sectors that store upto to size of the image
+ * Slots are compatible when all sectors that store up to to size of the image
  * round up to sector size, in both slot's are able to fit in the scratch
  * area, and have sizes that are a multiple of each other (powers of two
  * presumably!).
@@ -680,7 +680,9 @@
     size_t num_sectors_secondary;
     size_t sz0, sz1;
     size_t primary_slot_sz, secondary_slot_sz;
+#ifndef MCUBOOT_OVERWRITE_ONLY
     size_t scratch_sz;
+#endif
     size_t i, j;
     int8_t smaller;
 
@@ -692,7 +694,9 @@
         return 0;
     }
 
+#ifndef MCUBOOT_OVERWRITE_ONLY
     scratch_sz = boot_scratch_area_size(state);
+#endif
 
     /*
      * The following loop scans all sectors in a linear fashion, assuring that
@@ -735,6 +739,7 @@
             smaller = 2;
             j++;
         }
+#ifndef MCUBOOT_OVERWRITE_ONLY
         if (sz0 == sz1) {
             primary_slot_sz += sz0;
             secondary_slot_sz += sz1;
@@ -748,6 +753,7 @@
             }
             smaller = sz0 = sz1 = 0;
         }
+#endif
     }
 
     if ((i != num_sectors_primary) ||