Skip to content

Commit f6e8e88

Browse files
committed
boot: bootutil: Move erase function location
Moves the erase function from loader to bootutil misc to account for MCUboot modes that do not include the main loader file Signed-off-by: Jamie McCrae <[email protected]>
1 parent 5ef87c7 commit f6e8e88

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

boot/bootutil/src/bootutil_misc.c

+20
Original file line numberDiff line numberDiff line change
@@ -557,3 +557,23 @@ boot_read_image_size(struct boot_loader_state *state, int slot, uint32_t *size)
557557
return rc;
558558
}
559559
#endif /* !MCUBOOT_OVERWRITE_ONLY */
560+
561+
/**
562+
* Erases a region of device that requires erase prior to write; does
563+
* nothing on devices without erase.
564+
*
565+
* @param fap The flash_area containing the region to erase.
566+
* @param off The offset within the flash area to start the
567+
* erase.
568+
* @param sz The number of bytes to erase.
569+
*
570+
* @return 0 on success; nonzero on failure.
571+
*/
572+
int
573+
boot_erase_region(const struct flash_area *fap, uint32_t off, uint32_t sz)
574+
{
575+
if (device_requires_erase(fap)) {
576+
return flash_area_erase(fap, off, sz);
577+
}
578+
return 0;
579+
}

boot/bootutil/src/loader.c

-20
Original file line numberDiff line numberDiff line change
@@ -1229,26 +1229,6 @@ boot_validated_swap_type(struct boot_loader_state *state,
12291229
}
12301230
#endif
12311231

1232-
/**
1233-
* Erases a region of device that requires erase prior to write; does
1234-
* nothing on devices without erase.
1235-
*
1236-
* @param fap The flash_area containing the region to erase.
1237-
* @param off The offset within the flash area to start the
1238-
* erase.
1239-
* @param sz The number of bytes to erase.
1240-
*
1241-
* @return 0 on success; nonzero on failure.
1242-
*/
1243-
int
1244-
boot_erase_region(const struct flash_area *fap, uint32_t off, uint32_t sz)
1245-
{
1246-
if (device_requires_erase(fap)) {
1247-
return flash_area_erase(fap, off, sz);
1248-
}
1249-
return 0;
1250-
}
1251-
12521232
/**
12531233
* Removes data from specified region either by writing erase value in place of
12541234
* data or by doing erase, if device has such hardware requirement.

0 commit comments

Comments
 (0)