From c4bf78009c61acfbc25d5b86fa274ccef1a6294b Mon Sep 17 00:00:00 2001 From: Emanuele Di Santo Date: Fri, 20 Jul 2018 11:39:57 +0200 Subject: [PATCH] zephyr: selectable serial device for recovery This commit adds a choice for the device to use for serial recovery. Signed-off-by: Emanuele Di Santo Signed-off-by: Andrzej Puzdrowski fixup --- boot/zephyr/Kconfig | 17 +++++++++++++++++ boot/zephyr/main.c | 5 +++++ boot/zephyr/serial_adapter.c | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/boot/zephyr/Kconfig b/boot/zephyr/Kconfig index 3502481d..4b8801ed 100644 --- a/boot/zephyr/Kconfig +++ b/boot/zephyr/Kconfig @@ -127,6 +127,23 @@ menuconfig MCUBOOT_SERIAL if MCUBOOT_SERIAL +choice + prompt "Serial device" + default BOOT_SERIAL_UART if !BOARD_NRF52840_PCA10059 + default BOOT_SERIAL_CDC_ACM if BOARD_NRF52840_PCA10059 + +config BOOT_SERIAL_UART + bool "UART" + # SERIAL and UART_INTERRUPT_DRIVEN already selected + +config BOOT_SERIAL_CDC_ACM + bool "CDC ACM" + select USB + select USB_DEVICE_STACK + select USB_CDC_ACM + +endchoice + config BOOT_MAX_LINE_INPUT_LEN int "Maximum command line length" default 512 diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c index ca30bb5c..234ad4c9 100644 --- a/boot/zephyr/main.c +++ b/boot/zephyr/main.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "target.h" @@ -66,6 +67,10 @@ static void do_boot(struct boot_rsp *rsp) rsp->br_hdr->ih_hdr_size); irq_lock(); sys_clock_disable(); +#ifdef CONFIG_BOOT_SERIAL_CDC_ACM + /* Disable the USB to prevent it from firing interrupts */ + usb_disable(); +#endif __set_MSP(vt->msp); ((void (*)(void))vt->reset)(); } diff --git a/boot/zephyr/serial_adapter.c b/boot/zephyr/serial_adapter.c index 92aa6c68..fc39f716 100644 --- a/boot/zephyr/serial_adapter.c +++ b/boot/zephyr/serial_adapter.c @@ -188,7 +188,11 @@ boot_uart_fifo_getline(char **line) static int boot_uart_fifo_init(void) { +#ifdef CONFIG_BOOT_SERIAL_UART uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); +#elif CONFIG_BOOT_SERIAL_CDC_ACM + uart_dev = device_get_binding(CONFIG_CDC_ACM_PORT_NAME); +#endif u8_t c; if (!uart_dev) {