boot: zephyr: migrate CDC ACM serial recovery to USB_DEVICE_STACK_NEXT#2635
boot: zephyr: migrate CDC ACM serial recovery to USB_DEVICE_STACK_NEXT#2635JayToltTech wants to merge 1 commit intomcu-tools:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request migrates CDC ACM serial recovery from the legacy USB device stack to the new USB_DEVICE_STACK_NEXT in MCUboot. The key improvement is lazy USB initialization - USB is only initialized when serial recovery is actually triggered, avoiding interference with application USB on normal boots.
Changes:
- Adds self-contained USB CDC ACM module with configurable descriptors via Kconfig
- Implements lazy USB initialization in serial recovery path with watchdog feeding during USB host wait
- Enlarges nrf52840 boot partitions (64KB → 72KB) to accommodate larger USB stack
- Removes legacy USB stack configuration options from board files
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/readme-zephyr.md | Documents new Kconfig options for USB descriptor configuration |
| boot/zephyr/usbd_cdc_serial.h | Header for new USB CDC ACM module |
| boot/zephyr/usbd_cdc_serial.c | Self-contained USB stack setup with lazy initialization |
| boot/zephyr/usb_cdc_acm_recovery.conf | Adds product string override and flash-saving options |
| boot/zephyr/usb_cdc_acm_log_recovery.conf | Same configuration for logging variant |
| boot/zephyr/serial_adapter.c | Updates to use new USB module with lazy init and watchdog feeding |
| boot/zephyr/main.c | Adds USB cleanup on boot with -EALREADY handling for lazy init |
| boot/zephyr/boards/nrf52840dongle_nrf52840_big.overlay | New overlay with enlarged boot partition for dongle |
| boot/zephyr/boards/nrf52840dongle_nrf52840.conf | Removes legacy USB stack config options |
| boot/zephyr/boards/nrf52840_big.overlay | Enlarges boot partition from 64KB to 72KB |
| boot/zephyr/Kconfig.serial_recovery | Adds new Kconfig options for USB descriptor customization |
| boot/zephyr/CMakeLists.txt | Conditionally compiles usbd_cdc_serial.c |
| boot/zephyr/sample.yaml | Updates test configuration to use new overlay for dongle |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace the legacy USB device stack with USB_DEVICE_STACK_NEXT for CDC-ACM serial recovery. USB is initialized lazily in boot_uart_fifo_init() only when serial recovery is triggered, avoiding interference with application USB on normal boots. Add self-contained USBD CDC ACM module (usbd_cdc_serial.c/.h) that manages device context, descriptors, and configuration registration. Expose configurable USB descriptors (VID, PID, manufacturer, product, self-powered, max power) through new Kconfig options under BOOT_SERIAL_CDC_ACM. Feed the watchdog while waiting for USB host connection to prevent hardware watchdog timeout before the serial recovery loop is reached. Update nrf52840 board files: enlarge boot partitions for the larger USB stack, remove stale legacy USB Kconfig options, and add flash- saving options (disable BOS, vendor requests, deferred messages). Signed-off-by: Jay Beavers <jay@tolttechnologies.com>
1bdfcc1 to
41b043d
Compare
|
Same as with #2346, we cannot merge this without also migrating the USB DFU support the device_next. Otherwise, you will have a mix of dependencies, some of the MCUBoot code depending on the legacy stack, other on the new stack. |
Summary
USB_DEVICE_STACK_NEXTfor CDC-ACM serial recoveryboot_uart_fifo_init()only when serial recovery is triggered, avoiding interference with application USB on normal bootsusbd_cdc_serial.c/.h) with configurable USB descriptors (VID, PID, manufacturer, product, self-powered, max power) via new Kconfig optionsSupersedes #2634 (narrowed scope to CDC-ACM only, removed unrelated logging/SWO changes).
Builds on the approach from #2346 with key improvements:
CDC_ACM_SERIAL_INITIALIZE_AT_BOOTSTRUCT_SECTION_GETindexTest plan
usb_cdc_acm_log_recovery.conf(92.49% flash)usb_cdc_acm_recovery.conf(99.71% flash)