zephyr: add "real" target header
MCUBOOT_TARGET_CONFIG is included in several places now,
not just boot/zephyr/main.c. This seems likely to continue.
Let's avoid trouble and make it a real header file, target.h, that
pulls in MCUBOOT_TARGET_CONFIG. That done, include target.h instead
everywhere MCUBOOT_TARGET_CONFIG is included.
This will make it easier to provide values at an SoC/family level
later. We can expect different Zephyr boards to have the same SoC and
thus likely the same mcuboot flash layout, so this will avoid
duplication.
All supported boards are compile-tested.
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
diff --git a/boot/zephyr/flash_map.c b/boot/zephyr/flash_map.c
index 17cb32a..431eacf 100644
--- a/boot/zephyr/flash_map.c
+++ b/boot/zephyr/flash_map.c
@@ -20,7 +20,7 @@
#include <zephyr.h>
#include <flash.h>
-#include MCUBOOT_TARGET_CONFIG
+#include "target.h"
#include <flash_map/flash_map.h>
#include <hal/hal_flash.h>
diff --git a/boot/zephyr/hal_flash.c b/boot/zephyr/hal_flash.c
index 9a78163..552f767 100644
--- a/boot/zephyr/hal_flash.c
+++ b/boot/zephyr/hal_flash.c
@@ -19,7 +19,7 @@
#include <zephyr.h>
-#include MCUBOOT_TARGET_CONFIG
+#include "target.h"
#include "hal/hal_flash.h"
diff --git a/boot/zephyr/include/target.h b/boot/zephyr/include/target.h
new file mode 100644
index 0000000..6f85e5b
--- /dev/null
+++ b/boot/zephyr/include/target.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2017, Linaro Ltd
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef H_TARGETS_TARGET_
+#define H_TARGETS_TARGET_
+
+#if defined(MCUBOOT_TARGET_CONFIG)
+#include MCUBOOT_TARGET_CONFIG
+#else
+#error "Board is currently not supported by bootloader"
+#endif
+
+#endif
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index ee0b36b..f037a2b 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -19,15 +19,10 @@
#include <asm_inline.h>
#include <drivers/system_timer.h>
+#include "target.h"
+
#define BOOT_LOG_LEVEL BOOT_LOG_LEVEL_INFO
#include "bootutil/bootutil_log.h"
-
-#if defined(MCUBOOT_TARGET_CONFIG)
-#include MCUBOOT_TARGET_CONFIG
-#else
-#error "Board is currently not supported by bootloader"
-#endif
-
#include "bootutil/image.h"
#include "bootutil/bootutil.h"