Fix mynewt assert reading header from scratch

For mynewt flash map only accepts values for slot 0 and 1. This
code was trying to read the image header on the scratch area using
the same interface and was segfaulting when slot0 and slot1 had
similarly sized images.

Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index 2b0002f..782d860 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -222,6 +222,26 @@
 }
 
 static int
+boot_read_header_from_scratch(struct image_header *out_hdr)
+{
+    const struct flash_area *fap;
+    int rc;
+
+    rc = flash_area_open(FLASH_AREA_IMAGE_SCRATCH, &fap);
+    if (rc != 0) {
+        return BOOT_EFLASH;
+    }
+
+    rc = flash_area_read(fap, 0, out_hdr, sizeof *out_hdr);
+    if (rc != 0) {
+        rc = BOOT_EFLASH;
+    }
+
+    flash_area_close(fap);
+    return rc;
+}
+
+static int
 boot_read_image_header(int slot, struct image_header *out_hdr)
 {
     const struct flash_area *fap;
@@ -1027,7 +1047,7 @@
     }
 
     if (!size || !copy_size || size == copy_size) {
-        rc = boot_read_image_header(2, &tmp_hdr);
+        rc = boot_read_header_from_scratch(&tmp_hdr);
         assert(rc == 0);
 
         hdr = &tmp_hdr;