zephyr: use SYS_LOG instead of printk

Easier to manage and can be easily disabled via config.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
diff --git a/boot/zephyr/flash_map.c b/boot/zephyr/flash_map.c
index ad5cd05..2736e94 100644
--- a/boot/zephyr/flash_map.c
+++ b/boot/zephyr/flash_map.c
@@ -18,7 +18,6 @@
  */
 
 #include <zephyr.h>
-#include <misc/printk.h>
 #include <flash.h>
 
 #include MCUBOOT_TARGET_CONFIG
@@ -27,6 +26,10 @@
 #include <hal/hal_flash.h>
 #include <sysflash/sysflash.h>
 
+#define SYS_LOG_DOMAIN "BOOTLOADER"
+#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
+#include <logging/sys_log.h>
+
 extern struct device *boot_flash_device;
 
 /*
@@ -58,7 +61,8 @@
 int flash_area_open(uint8_t id, const struct flash_area **area)
 {
 	int i;
-	printk("%s: area %d\n", __func__, id);
+
+	SYS_LOG_DBG("%s: area %d", __func__, id);
 
 	for (i = 0; i < ARRAY_SIZE(part_map); i++) {
 		if (id == part_map[i].fa_id)
@@ -81,20 +85,23 @@
 int flash_area_read(const struct flash_area *area, uint32_t off, void *dst,
 		    uint32_t len)
 {
-	// printk("%s: area=%d, off=%x, len=%x\n", __func__, area->fa_id, off, len);
+	SYS_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__,
+			area->fa_id, off, len);
 	return flash_read(boot_flash_device, area->fa_off + off, dst, len);
 }
 
 int flash_area_write(const struct flash_area *area, uint32_t off, const void *src,
 		     uint32_t len)
 {
-	printk("%s: area=%d, off=%x, len=%x\n", __func__, area->fa_id, off, len);
+	SYS_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__,
+			area->fa_id, off, len);
 	return flash_write(boot_flash_device, area->fa_off + off, src, len);
 }
 
 int flash_area_erase(const struct flash_area *area, uint32_t off, uint32_t len)
 {
-	printk("%s: area=%d, off=%x, len=%x\n", __func__, area->fa_id, off, len);
+	SYS_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__,
+			area->fa_id, off, len);
 	return flash_erase(boot_flash_device, area->fa_off + off, len);
 }
 
@@ -122,7 +129,7 @@
 {
 	uint32_t off;
 
-	printk("%s: lookup area %d\n", __func__, idx);
+	SYS_LOG_DBG("%s: lookup area %d", __func__, idx);
 	/*
 	 * This simple layout has uniform slots, so just fill in the
 	 * right one.
diff --git a/boot/zephyr/hal_flash.c b/boot/zephyr/hal_flash.c
index 986ae77..cebf161 100644
--- a/boot/zephyr/hal_flash.c
+++ b/boot/zephyr/hal_flash.c
@@ -18,7 +18,6 @@
  */
 
 #include <zephyr.h>
-#include <misc/printk.h>
 
 #include MCUBOOT_TARGET_CONFIG
 
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index 026fc92..960dcf2 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -15,10 +15,13 @@
  */
 
 #include <zephyr.h>
-#include <misc/printk.h>
 #include <flash.h>
 #include <asm_inline.h>
 
+#define SYS_LOG_DOMAIN "BOOTLOADER"
+#define SYS_LOG_LEVEL SYS_LOG_LEVEL_INFO
+#include <logging/sys_log.h>
+
 #if defined(MCUBOOT_TARGET_CONFIG)
 #include MCUBOOT_TARGET_CONFIG
 #else
@@ -43,34 +46,39 @@
 	struct vector_table *vt;
 	int rc;
 
+	SYS_LOG_INF("Starting bootloader");
+
 	os_heap_init();
 
 	boot_flash_device = device_get_binding(FLASH_DRIVER_NAME);
 	if (!boot_flash_device) {
-		printk("Flash device not found\n");
+		SYS_LOG_ERR("Flash device not found");
 		while (1)
 			;
 	}
 
 	rc = boot_go(&rsp);
 	if (rc != 0) {
-		printk("Unable to find bootable image\n");
+		SYS_LOG_ERR("Unable to find bootable image");
 		while (1)
 			;
 	}
 
-	printk("Bootloader chain: 0x%x\n", rsp.br_image_addr);
+	SYS_LOG_INF("Bootloader chainload address: 0x%x", rsp.br_image_addr);
 	vt = (struct vector_table *)(rsp.br_image_addr +
 				     rsp.br_hdr->ih_hdr_size);
 	irq_lock();
 	_MspSet(vt->msp);
 
+	SYS_LOG_INF("Setting vector table to %p", vt);
+
 	/* Not all targets set the VTOR, so just set it. */
 	_scs_relocate_vector_table((void *) vt);
 
+	SYS_LOG_INF("Jumping to the first image slot");
 	((void (*)(void))vt->reset)();
 
-	printk("Never should get here\n");
+	SYS_LOG_ERR("Never should get here");
 	while (1)
 		;
 }
diff --git a/boot/zephyr/os.c b/boot/zephyr/os.c
index 80be2fa..e73edaa 100644
--- a/boot/zephyr/os.c
+++ b/boot/zephyr/os.c
@@ -18,7 +18,6 @@
  */
 
 #include <zephyr.h>
-#include <misc/printk.h>
 #include <string.h>
 
 #include "os/os_heap.h"
diff --git a/boot/zephyr/prj.conf b/boot/zephyr/prj.conf
index 2ae9fb9..f3cffde 100644
--- a/boot/zephyr/prj.conf
+++ b/boot/zephyr/prj.conf
@@ -1,5 +1,5 @@
 CONFIG_CONSOLE_HANDLER=y
-CONFIG_PRINTK=y
+CONFIG_SYS_LOG=y
 CONFIG_DEBUG=y
 
 CONFIG_MAIN_STACK_SIZE=10240