boot: zephyr: obtain FLASH_DRIVER_NAME, FLASH_ALIGN from OS
Zephyr now provides defines for FLASH_DRIVER_NAME and
FLASH_WRITE_BLOCK_SIZE (which is what we call FLASH_ALIGN) in
the SoC headers for most targets supported by mcuboot. Use that
information when it's available, falling back on MCUBOOT_TARGET_CONFIG
otherwise.
The soc_family_foo.h files remain for FLASH_AREA_IMAGE_SECTOR_SIZE. A
subsequent patch can remove these files when the relevant SoC flash
driver provides a page layout.
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
diff --git a/boot/zephyr/include/target.h b/boot/zephyr/include/target.h
index 6e4fe31..8a3b14d 100644
--- a/boot/zephyr/include/target.h
+++ b/boot/zephyr/include/target.h
@@ -6,12 +6,24 @@
#ifndef H_TARGETS_TARGET_
#define H_TARGETS_TARGET_
-/* Board-specific definitions go first, to allow maximum override. */
#if defined(MCUBOOT_TARGET_CONFIG)
+/*
+ * Target-specific definitions are permitted in legacy cases that
+ * don't provide the information via DTS, etc.
+ */
#include MCUBOOT_TARGET_CONFIG
-#endif
+#else
+/*
+ * Otherwise, the Zephyr SoC header and the DTS provide most
+ * everything we need.
+ *
+ * TODO: remove soc_family_foo.h once image sector sizes come from the
+ * flash driver.
+ */
+#include <soc.h>
-/* SoC family configuration. */
+#define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE
+
#if defined(CONFIG_SOC_FAMILY_NRF5)
#include "soc_family_nrf5.h"
#elif defined(CONFIG_SOC_FAMILY_STM32)
@@ -19,11 +31,10 @@
#elif defined(CONFIG_SOC_FAMILY_KINETIS)
#include "soc_family_kinetis.h"
#endif
+#endif /* !defined(MCUBOOT_TARGET_CONFIG) */
/*
- * This information can come from DTS, a target-specific header file,
- * or an SoC-specific header file. If any of it is missing, target
- * support is incomplete.
+ * Sanity check the target support.
*/
#if !defined(FLASH_DRIVER_NAME) || \
!defined(FLASH_ALIGN) || \