Fix running newtmgr when building for mcuboot
This enables mynewt to use mcuboot as a remote repository, which is only
required when using newtmgr to manage images. Since mcuboot has slightly
changed the trailer format, newtmgr built against the bundled mynewt
bootloader writes the magic and flags to the wrong location.
To build a mynewt app the wants to run with mcuboot as the bootloader
and requires newtmgr one needs to change the app's pkg.yml dependencies
as follows:
- - boot/bootutil
+ - "@mcuboot/boot/bootutil"
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/bootutil/include/bootutil/sha256.h b/boot/bootutil/include/bootutil/sha256.h
index 6dd02c7..cc52b07 100644
--- a/boot/bootutil/include/bootutil/sha256.h
+++ b/boot/bootutil/include/bootutil/sha256.h
@@ -29,12 +29,8 @@
#ifndef __BOOTUTIL_CRYPTO_H_
#define __BOOTUTIL_CRYPTO_H_
-/* FIXME: The test below will only work as long as the app name is
- * "mynewt", building for mynewt could export some __linux__, __APPLE__
- * style macro!
- */
-#ifdef APP_mynewt
-#include "mynewt/config.h"
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
#endif
#if defined(MCUBOOT_USE_MBED_TLS) && defined(MCUBOOT_USE_TINYCRYPT)
diff --git a/boot/bootutil/pkg.yml b/boot/bootutil/pkg.yml
index 2ad4724..1569dea 100644
--- a/boot/bootutil/pkg.yml
+++ b/boot/bootutil/pkg.yml
@@ -25,7 +25,14 @@
- boot
- bootloader
+pkg.apis:
+ - bootloader
+
+pkg.cflags:
+ - "-DMCUBOOT_MYNEWT"
+
pkg.deps:
+ - "@mcuboot/boot/mynewt/mcuboot_config"
- "@apache-mynewt-core/hw/hal"
- "@apache-mynewt-core/crypto/mbedtls"
- "@apache-mynewt-core/kernel/os"
diff --git a/boot/bootutil/src/image_ec.c b/boot/bootutil/src/image_ec.c
index 4b47122..aa4880a 100644
--- a/boot/bootutil/src/image_ec.c
+++ b/boot/bootutil/src/image_ec.c
@@ -19,8 +19,8 @@
#include <string.h>
-#ifdef APP_mynewt
-#include "mynewt/config.h"
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_EC
diff --git a/boot/bootutil/src/image_ec256.c b/boot/bootutil/src/image_ec256.c
index 59cda9e..e0e4f73 100644
--- a/boot/bootutil/src/image_ec256.c
+++ b/boot/bootutil/src/image_ec256.c
@@ -19,8 +19,8 @@
#include <string.h>
-#ifdef APP_mynewt
-#include "mynewt/config.h"
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_EC256
diff --git a/boot/bootutil/src/image_rsa.c b/boot/bootutil/src/image_rsa.c
index aade44e..03b8624 100644
--- a/boot/bootutil/src/image_rsa.c
+++ b/boot/bootutil/src/image_rsa.c
@@ -19,8 +19,8 @@
#include <string.h>
-#ifdef APP_mynewt
-#include "mynewt/config.h"
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_RSA
diff --git a/boot/bootutil/src/image_validate.c b/boot/bootutil/src/image_validate.c
index 2741c37..be856fd 100644
--- a/boot/bootutil/src/image_validate.c
+++ b/boot/bootutil/src/image_validate.c
@@ -28,8 +28,8 @@
#include "bootutil/sha256.h"
#include "bootutil/sign_key.h"
-#ifdef APP_mynewt
-#include "mynewt/config.h"
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
#endif
#ifdef MCUBOOT_SIGN_RSA
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index ca75a96..9de7188 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -37,8 +37,8 @@
#define BOOT_LOG_LEVEL BOOT_LOG_LEVEL_INFO
#include "bootutil/bootutil_log.h"
-#ifdef APP_mynewt
-#include "mynewt/config.h"
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
#endif
static struct boot_loader_state boot_data;