Skip to content

Commit d6c84fe

Browse files
committed
boot: zephyr: move CDC ACM serial to the new device stack
The new stack comes with a higher demand for flash. We need to adapt the overlay file for the platform used for testing. The legacy stack is in the process of being deprecated. The NRF52840 dongle should not enable the legacy stack by default. The Zephyr's new stack provides helper code to use CDC ACM as the serial backend. The only required change to the serial adapter code is to get the USB device instance and enable it. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent 990b1fc commit d6c84fe

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

boot/zephyr/Kconfig.serial_recovery

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ config BOOT_SERIAL_UART
3737

3838
config BOOT_SERIAL_CDC_ACM
3939
bool "CDC ACM"
40-
select USB_DEVICE_STACK
40+
select USB_DEVICE_STACK_NEXT
41+
select CDC_ACM_SERIAL_INITIALIZE_AT_BOOT
4142
help
4243
This setting will choose CDC ACM for serial recovery unless chosen
4344
"zephyr,uart-mcumgr" is present, in which case the chosen takes

boot/zephyr/boards/nrf52840_big.overlay

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
boot_partition: partition@0 {
1818
label = "mcuboot";
19-
reg = <0x000000000 0x00010000>;
19+
reg = <0x000000000 0x00012000>;
2020
};
2121
slot0_partition: partition@10000 {
2222
label = "image-0";
23-
reg = <0x000010000 0x000074000>;
23+
reg = <0x000012000 0x000073000>;
2424
};
2525
slot1_partition: partition@75000 {
2626
label = "image-1";
27-
reg = <0x00084000 0x000074000>;
27+
reg = <0x00085000 0x000073000>;
2828
};
2929
};
3030
};

boot/zephyr/boards/nrf52840dongle_nrf52840.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,4 @@ CONFIG_BOOT_SERIAL_CDC_ACM=y
1818
# Required by USB
1919
CONFIG_MULTITHREADING=y
2020

21-
# USB
22-
CONFIG_USB_DEVICE_STACK=y
23-
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
24-
CONFIG_USB_DEVICE_PRODUCT="MCUBOOT"
25-
2621
CONFIG_NORDIC_QSPI_NOR=n

boot/zephyr/serial_adapter.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <string.h>
2121
#include <zephyr/kernel.h>
2222
#include "bootutil/bootutil_log.h"
23-
#include <zephyr/usb/usb_device.h>
23+
#include <zephyr/usb/usbd.h>
2424

2525
#if defined(CONFIG_BOOT_SERIAL_UART) && defined(CONFIG_UART_CONSOLE) && \
2626
(!DT_HAS_CHOSEN(zephyr_uart_mcumgr) || \
@@ -225,7 +225,11 @@ boot_uart_fifo_init(void)
225225
}
226226

227227
#if CONFIG_BOOT_SERIAL_CDC_ACM
228-
int rc = usb_enable(NULL);
228+
struct usbd_context *uds_ctx;
229+
int rc;
230+
231+
STRUCT_SECTION_GET(usbd_context, 0, &uds_ctx);
232+
rc = usbd_enable(uds_ctx);
229233
if (rc) {
230234
return (-1);
231235
}

boot/zephyr/usb_cdc_acm_log_recovery.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ CONFIG_UART_LINE_CTRL=y
99
# MCUBoot serial
1010
CONFIG_MCUBOOT_SERIAL=y
1111
CONFIG_BOOT_SERIAL_CDC_ACM=y
12+
CONFIG_USBD_MSG_DEFERRED_MODE=n
13+
CONFIG_USBD_BOS_SUPPORT=n
14+
CONFIG_USBD_VREQ_SUPPORT=n
15+
CONFIG_CDC_ACM_SERIAL_ENABLE_AT_BOOT=n
16+
CONFIG_CDC_ACM_SERIAL_PRODUCT_STRING="MCUBOOT"

boot/zephyr/usb_cdc_acm_recovery.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
CONFIG_MCUBOOT_SERIAL=y
22
CONFIG_BOOT_SERIAL_CDC_ACM=y
33
CONFIG_UART_CONSOLE=n
4+
5+
CONFIG_USBD_MSG_DEFERRED_MODE=n
6+
CONFIG_USBD_BOS_SUPPORT=n
7+
CONFIG_USBD_VREQ_SUPPORT=n
8+
CONFIG_CDC_ACM_SERIAL_ENABLE_AT_BOOT=n
9+
CONFIG_CDC_ACM_SERIAL_PRODUCT_STRING="MCUBOOT"

0 commit comments

Comments
 (0)