Boot: Add multiple flash driver support

(T862) External flash support on stm uses 2 drivers :
- internal flash slot 0/1, scratch : driver internal flash
- external flash slot 2/3 : octospi driver external flash

Change-Id: I58d86a48081ad0bca3dda961318a15fe17248a93
Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
diff --git a/bl2/ext/mcuboot/include/flash_map/flash_map.h b/bl2/ext/mcuboot/include/flash_map/flash_map.h
index d858ef4..b66dfc0 100644
--- a/bl2/ext/mcuboot/include/flash_map/flash_map.h
+++ b/bl2/ext/mcuboot/include/flash_map/flash_map.h
@@ -50,6 +50,7 @@
  */
 #include <inttypes.h>
 #include "region_defs.h"
+#include "Driver_Flash.h"
 
 /*
  * For now, we only support one flash device.
@@ -91,6 +92,11 @@
     uint16_t pad16;
 
     /**
+     * Pointer to driver
+     */
+    ARM_DRIVER_FLASH *fa_driver;
+
+    /**
      * This area's offset, relative to the beginning of its flash
      * device's storage.
      */
@@ -121,6 +127,12 @@
     uint32_t fs_size;
 };
 
+/**
+ * @brief Macro retrieving driver from struct flash area
+ *
+ */
+#define DRV_FLASH_AREA(area) ((area)->fa_driver)
+
 /*
  * Start using flash area.
  */
diff --git a/bl2/ext/mcuboot/include/target.h b/bl2/ext/mcuboot/include/target.h
index d4350b0..9ead129 100644
--- a/bl2/ext/mcuboot/include/target.h
+++ b/bl2/ext/mcuboot/include/target.h
@@ -47,6 +47,11 @@
 #error "FLASH_AREA_0_SIZE must be defined by the target"
 #endif
 
+#if defined(FLASH_DEV_NAME_0) != defined(FLASH_DEVICE_ID_0)
+#error "FLASH DEV_NAME_0 and DEVICE_ID_0 must be simultaneously defined or not \
+by target"
+#endif
+
 #ifndef FLASH_AREA_2_OFFSET
 #error "FLASH_AREA_2_OFFSET must be defined by the target"
 #endif
@@ -55,6 +60,11 @@
 #error "FLASH_AREA_2_SIZE must be defined by the target"
 #endif
 
+#if defined(FLASH_DEV_NAME_2) != defined(FLASH_DEVICE_ID_2)
+#error "FLASH DEV_NAME_2 and DEVICE_ID_2 must be simultaneously defined or not \
+by target"
+#endif
+
 #if (MCUBOOT_IMAGE_NUMBER == 2)
 #ifndef FLASH_AREA_1_OFFSET
 #error "FLASH_AREA_1_OFFSET must be defined by the target"
@@ -64,6 +74,11 @@
 #error "FLASH_AREA_1_SIZE must be defined by the target"
 #endif
 
+#if defined(FLASH_DEV_NAME_1) != defined(FLASH_DEVICE_ID_1)
+#error "FLASH DEV_NAME_1 and DEVICE_ID_1 must be simultaneously defined or not \
+by target"
+#endif
+
 #ifndef FLASH_AREA_3_OFFSET
 #error "FLASH_AREA_3_OFFSET must be defined by the target"
 #endif
@@ -71,6 +86,11 @@
 #ifndef FLASH_AREA_3_SIZE
 #error "FLASH_AREA_3_SIZE must be defined by the target"
 #endif
+
+#if defined(FLASH_DEV_NAME_3) != defined(FLASH_DEVICE_ID_3)
+#error "FLASH DEV_NAME_3 and DEVICE_ID_3 must be simultaneously defined or not \
+by target"
+#endif
 #endif /* (MCUBOOT_IMAGE_NUMBER == 2) */
 
 #ifndef FLASH_AREA_SCRATCH_OFFSET
@@ -81,6 +101,11 @@
 #error "FLASH_AREA_SCRATCH_SIZE must be defined by the target"
 #endif
 
+#if defined(FLASH_DEV_NAME_SCRATCH) != defined(FLASH_DEVICE_ID_SCRATCH)
+#error "FLASH DEV_NAME_SCRATCH and DEVICE_ID_SCRATCH must be simultaneously defined \
+or not by target"
+#endif
+
 #ifndef FLASH_DEV_NAME
 #error "BL2 supports CMSIS flash interface and device name must be specified"
 #endif