zephyr: erase flash pages progressively

This commit adds the option to erase flash pages while receiving
the firmware, opposed to bulk-erasing the whole image area at
the beginning of the DFU process. This is required on some
hardware that has long erase times, to prevent a long wait
and possibly a timeout during DFU.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index 5633a14..ca30bb5 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -39,8 +39,6 @@
 };
 #endif
 
-struct device *boot_flash_device;
-
 void os_heap_init(void);
 
 #if defined(CONFIG_ARM)
@@ -103,8 +101,7 @@
 
     os_heap_init();
 
-    boot_flash_device = device_get_binding(FLASH_DEV_NAME);
-    if (!boot_flash_device) {
+    if (!flash_device_get_binding(FLASH_DEV_NAME)) {
         BOOT_LOG_ERR("Flash device %s not found", FLASH_DEV_NAME);
         while (1)
             ;