Fix serial boot functionality for Mynewt

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/mynewt/pkg.yml b/boot/mynewt/pkg.yml
index 1d563b8..b81966b 100644
--- a/boot/mynewt/pkg.yml
+++ b/boot/mynewt/pkg.yml
@@ -25,12 +25,14 @@
 pkg.keywords:
     - loader
 
+pkg.cflags:
+    - "-DMCUBOOT_MYNEWT"
+
 pkg.deps:
     - "@mcuboot/boot/mynewt/mcuboot_config"
     - "@mcuboot/boot/bootutil"
     - "@apache-mynewt-core/kernel/os"
-    - "@apache-mynewt-core/sys/console/stub"
+    - "@apache-mynewt-core/sys/console/minimal"
 
 pkg.deps.BOOT_SERIAL.OVERWRITE:
-    - "@apache-mynewt-core/sys/console/full"
     - "@mcuboot/boot/boot_serial"
diff --git a/boot/mynewt/src/main.c b/boot/mynewt/src/main.c
index 9971c9f..3033d07 100755
--- a/boot/mynewt/src/main.c
+++ b/boot/mynewt/src/main.c
@@ -17,6 +17,10 @@
  * under the License.
  */
 
+#ifdef MCUBOOT_MYNEWT
+#include "mcuboot_config/mcuboot_config.h"
+#endif
+
 #include <assert.h>
 #include <stddef.h>
 #include <inttypes.h>
@@ -74,8 +78,15 @@
      * Configure a GPIO as input, and compare it against expected value.
      * If it matches, await for download commands from serial.
      */
+#ifdef MCUBOOT_MYNEWT
+    hal_gpio_init_in(MYNEWT_VAL(BOOT_SERIAL_DETECT_PIN),
+                     MYNEWT_VAL(BOOT_SERIAL_DETECT_PIN_CFG));
+    if (hal_gpio_read(MYNEWT_VAL(BOOT_SERIAL_DETECT_PIN)) ==
+                      MYNEWT_VAL(BOOT_SERIAL_DETECT_PIN_VAL)) {
+#else
     hal_gpio_init_in(BOOT_SERIAL_DETECT_PIN, BOOT_SERIAL_DETECT_PIN_CFG);
     if (hal_gpio_read(BOOT_SERIAL_DETECT_PIN) == BOOT_SERIAL_DETECT_PIN_VAL) {
+#endif
         boot_serial_start(BOOT_SER_CONS_INPUT);
         assert(0);
     }
diff --git a/boot/mynewt/syscfg.yml b/boot/mynewt/syscfg.yml
index 0ab9a14..778ba5f 100644
--- a/boot/mynewt/syscfg.yml
+++ b/boot/mynewt/syscfg.yml
@@ -30,3 +30,4 @@
     SYSINIT_CONSTRAIN_INIT: 0
     OS_SCHEDULING: 0
     OS_CPUTIME_TIMER_NUM: -1
+    CONSOLE_COMPAT: 1