zephyr: get CDC ACM UART device from devicetree

Adapt to Zephyr OS changes to get CDC ACM UART device.
Remove RECOVERY_UART_DEV_NAME Kconfig option and
use DEVICE_DT_GET() in serial_adapter.c

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2021-07-30 16:01:03 +02:00 committed by Andrzej Puzdrowski
parent 1fceb9bdba
commit a6e1e9e339
4 changed files with 19 additions and 25 deletions

View File

@ -477,7 +477,6 @@ config BOOT_SERIAL_UART
config BOOT_SERIAL_CDC_ACM
bool "CDC ACM"
select USB_DEVICE_STACK
select USB_CDC_ACM
endchoice
@ -543,18 +542,6 @@ config BOOT_SERIAL_DETECT_DELAY
Useful for powering on when using the same button as
the one used to place the device in bootloader mode.
# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_CONSOLE := zephyr,console
config RECOVERY_UART_DEV_NAME
string "UART Device Name for Recovery UART"
default "$(dt_chosen_label,$(DT_CHOSEN_Z_CONSOLE))" if HAS_DTS
default "UART_0"
depends on BOOT_SERIAL_UART
help
This option specifies the name of UART device to be used for
serial recovery.
config BOOT_ERASE_PROGRESSIVELY
bool "Erase flash progressively when receiving new firmware"
default y if SOC_FAMILY_NRF

View File

@ -26,6 +26,5 @@ CONFIG_MULTITHREADING=y
# USB
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="MCUBOOT"
CONFIG_USB_CDC_ACM=y
CONFIG_USB_COMPOSITE_DEVICE=n
CONFIG_USB_MASS_STORAGE=n

View File

@ -3,3 +3,10 @@
zephyr,code-partition = &boot_partition;
};
};
&zephyr_udc0 {
cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM_0";
};
};

View File

@ -192,27 +192,28 @@ static int
boot_uart_fifo_init(void)
{
#ifdef CONFIG_BOOT_SERIAL_UART
uart_dev = device_get_binding(CONFIG_RECOVERY_UART_DEV_NAME);
uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
#elif CONFIG_BOOT_SERIAL_CDC_ACM
uart_dev = device_get_binding(CONFIG_USB_CDC_ACM_DEVICE_NAME "_0");
if (uart_dev) {
int rc;
rc = usb_enable(NULL);
if (rc) {
return (-1);
}
}
uart_dev = DEVICE_DT_GET_ONE(zephyr_cdc_acm_uart);
#endif
uint8_t c;
if (!uart_dev) {
if (!device_is_ready(uart_dev)) {
return (-1);
}
#if CONFIG_BOOT_SERIAL_CDC_ACM
int rc = usb_enable(NULL);
if (rc) {
return (-1);
}
#endif
uart_irq_callback_set(uart_dev, boot_uart_fifo_callback);
/* Drain the fifo */
if (uart_irq_rx_ready(uart_dev)) {
uint8_t c;
while (uart_fifo_read(uart_dev, &c, 1)) {
;
}