Add flash_area_read_is_empty to Zephyr port
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/zephyr/flash_map_extended.c b/boot/zephyr/flash_map_extended.c
index 4f6749b..aa472c5 100644
--- a/boot/zephyr/flash_map_extended.c
+++ b/boot/zephyr/flash_map_extended.c
@@ -69,8 +69,30 @@
return rc;
}
+#define ERASED_VAL 0xff
uint8_t flash_area_erased_val(const struct flash_area *fap)
{
(void)fap;
- return 0xff;
+ return ERASED_VAL;
+}
+
+int flash_area_read_is_empty(const struct flash_area *fa, uint32_t off,
+ void *dst, uint32_t len)
+{
+ uint8_t i;
+ uint8_t *u8dst;
+ int rc;
+
+ rc = hal_flash_read(fa->fa_device_id, fa->fa_off + off, dst, len);
+ if (rc) {
+ return -1;
+ }
+
+ for (i = 0, u8dst = (uint8_t *)dst; i < len; i++) {
+ if (u8dst[i] != ERASED_VAL) {
+ return 0;
+ }
+ }
+
+ return 1;
}