-
Notifications
You must be signed in to change notification settings - Fork 1.5k
USB CDC ACM serial firmware loader + dfu/single_slot sample project integration #27185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
49c231f
c35c73a
e7c6fc2
342ce86
039b707
ee21e33
ff3782b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(usb_mcumgr) | ||
|
|
||
| target_sources(app PRIVATE ${ZEPHYR_BASE}/samples/subsys/mgmt/mcumgr/smp_svr/src/main.c) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| .. _fw_loader_usb_mcumgr: | ||
|
|
||
| Minimal USB virtual serial port SMP firmware loader | ||
| ################################################### | ||
|
|
||
| .. contents:: | ||
| :local: | ||
| :depth: 2 | ||
|
|
||
| This sample provides the minimal and recommended configuration for the Firmware Loader application to run on the :zephyr:board:`nrf54lm20dk`. | ||
| It uses code from Zephyr's :zephyr:code-sample:`smp-svr` sample to enable the USB serial Simple Management Protocol (SMP) server functionality. | ||
|
|
||
| This sample is not intended to function as a standalone sample. | ||
| Instead, it serves as a starting point for developing a custom Firmware Loader application that works with the MCUboot bootloader. | ||
|
nvlsianpu marked this conversation as resolved.
|
||
|
|
||
| .. _fw_loader_usb_minimal_overview: | ||
|
|
||
| Requirements | ||
| ************ | ||
|
|
||
| The sample supports the following development kit: | ||
|
|
||
| .. table-from-sample-yaml:: | ||
|
|
||
| .. _fw_loader_usb_minimal_build_run: | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| The application uses the SMP over Bluetooth LE to perform firmware updates and manage device operations. | ||
|
nvlsianpu marked this conversation as resolved.
|
||
| It is optimized for minimal memory usage and contains only the essential functionalities required for firmware loading. | ||
|
|
||
| The firmware loader over USB CDC ACM virtual serial port accepts SMP commands for: | ||
|
|
||
| * Image upload and management | ||
| * Device information queries | ||
| * Bootloader information | ||
|
|
||
| .. _fw_loader_usb_minimal_reqs: | ||
|
|
||
| Building and running | ||
| ******************** | ||
|
|
||
| This sample is not intended for standalone building. | ||
| It is automatically included and built when the following Kconfig options are enabled in a project configuration: | ||
|
|
||
| * :kconfig:option:`SB_CONFIG_BOOTLOADER_MCUBOOT` | ||
| * :kconfig:option:`SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER` | ||
| * :kconfig:option:`SB_CONFIG_FIRMWARE_LOADER_IMAGE_USB_MCUMGR` | ||
|
|
||
|
|
||
| Testing | ||
| ======= | ||
|
|
||
| This sample is not intended for standalone testing. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2026 Nordic Semiconductor ASA | ||||||
| * | ||||||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||||||
| */ | ||||||
|
|
||||||
| / { | ||||||
| chosen { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems this file won't be necessary at all in case of the dongle due to the line (this will already be done by default on the dongle):
This all will happen automatically there. Perhaps here you should also simply include the file from zephyr: Also - take a look at
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case of the dongle configuration will be more complex (firmware_loader) that this and what you pointed:
|
||||||
| zephyr,uart-mcumgr = &cdc_acm_uart0; | ||||||
| }; | ||||||
| }; | ||||||
|
|
||||||
| &zephyr_udc0 { | ||||||
| cdc_acm_uart0: cdc_acm_uart0 { | ||||||
| compatible = "zephyr,cdc-acm-uart"; | ||||||
| }; | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright (c) 2026 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| */ | ||
|
|
||
| /delete-node/ &boot_partition; | ||
| /delete-node/ &slot0_partition; | ||
| /delete-node/ &slot1_partition; | ||
| /delete-node/ &storage_partition; | ||
|
|
||
| &cpuapp_rram { | ||
| reg = <0x0 DT_SIZE_K(1940)>; | ||
|
|
||
| partitions { | ||
| boot_partition: partition@0 { | ||
| label = "mcuboot"; | ||
| reg = <0x0 DT_SIZE_K(24)>; | ||
| }; | ||
|
|
||
| slot0_partition: partition@6000 { | ||
| label = "image-0"; | ||
| reg = <0x6000 DT_SIZE_K(1784)>; | ||
| }; | ||
|
|
||
| slot1_partition: partition@1c4000 { | ||
| label = "image-1"; | ||
| reg = <0x1c4000 DT_SIZE_K(116)>; | ||
| }; | ||
|
|
||
| storage_partition: partition@1e1000 { | ||
| label = "storage"; | ||
| reg = <0x1e1000 DT_SIZE_K(16)>; | ||
| }; | ||
| }; | ||
| }; | ||
|
|
||
| #include "../app.overlay" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Enable MCUmgr and dependencies. | ||
| CONFIG_NET_BUF=y | ||
| CONFIG_ZCBOR=y | ||
| CONFIG_CRC=y | ||
| CONFIG_MCUMGR=y | ||
| CONFIG_STREAM_FLASH=y | ||
| CONFIG_FLASH_MAP=y | ||
|
|
||
| # Some command handlers require a large stack. | ||
| CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304 | ||
| CONFIG_MAIN_STACK_SIZE=2176 | ||
|
|
||
| # Ensure an MCUboot-compatible binary is generated. | ||
| CONFIG_BOOTLOADER_MCUBOOT=y | ||
|
|
||
| # Enable flash operations. | ||
| CONFIG_FLASH=y | ||
|
|
||
| # Enable most core commands. | ||
| CONFIG_IMG_MANAGER=y | ||
| CONFIG_MCUMGR_GRP_IMG=y | ||
| CONFIG_MCUMGR_GRP_OS=y | ||
| CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y | ||
| CONFIG_MCUMGR_GRP_OS_ECHO=n | ||
| CONFIG_MCUMGR_GRP_OS_INFO=n | ||
|
|
||
| # Enable the Shell mcumgr transport. | ||
| CONFIG_BASE64=y | ||
| CONFIG_CRC=y | ||
|
|
||
| CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=1220 | ||
| CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y | ||
| CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608 | ||
|
|
||
| # Enable the storage erase command. | ||
| CONFIG_MCUMGR_GRP_ZBASIC=y | ||
| CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y | ||
|
|
||
| # Disable shell commands that are not needed | ||
| CONFIG_CLOCK_CONTROL_NRF_SHELL=n | ||
| CONFIG_DEVICE_SHELL=n | ||
| CONFIG_DEVMEM_SHELL=n | ||
| CONFIG_FLASH_SHELL=n | ||
|
|
||
| # Disable unneeded drivers, peripherals and features to optimize for size | ||
| CONFIG_SIZE_OPTIMIZATIONS=y | ||
|
|
||
| # Enable LTO | ||
| CONFIG_LTO=y | ||
| CONFIG_ISR_TABLES_LOCAL_DECLARATION=y | ||
|
|
||
| CONFIG_I2C=n | ||
| CONFIG_WATCHDOG=n | ||
| CONFIG_SPI_NOR=n | ||
| CONFIG_GPIO=n | ||
|
|
||
| CONFIG_FPU=n | ||
|
|
||
| CONFIG_BOOT_BANNER=n | ||
| CONFIG_NCS_BOOT_BANNER=n | ||
| CONFIG_BOOT_DELAY=0 | ||
| CONFIG_PRINTK=n | ||
|
|
||
| CONFIG_ARM_MPU=n | ||
|
|
||
| CONFIG_TIMESLICING=n | ||
| CONFIG_COMMON_LIBC_MALLOC=y | ||
| CONFIG_LOG=n | ||
|
|
||
| CONFIG_UART_CONSOLE=n | ||
| CONFIG_ASSERT=n | ||
|
|
||
| # Enable USB subsystem | ||
| CONFIG_SERIAL=y | ||
| CONFIG_UART_LINE_CTRL=y | ||
| CONFIG_CONSOLE=y | ||
| CONFIG_USB_DEVICE_STACK_NEXT=y | ||
| CONFIG_CDC_ACM_SERIAL_INITIALIZE_AT_BOOT=y | ||
| # USB backend is serial device | ||
| CONFIG_MCUMGR_TRANSPORT_UART=y | ||
|
|
||
|
|
||
| CONFIG_PSA_USE_CRACEN_CIPHER_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_AEAD_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_MAC_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_KEY_AGREEMENT_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_ASYMMETRIC_ENCRYPTION_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_KEY_MANAGEMENT_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_KEY_DERIVATION_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_PAKE_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_ASYMMETRIC_SIGNATURE_DRIVER=n | ||
| CONFIG_PSA_USE_CRACEN_HASH_DRIVER=n |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| sample: | ||
| name: Minimal USB CDC-ACM SMP firmware loader sample | ||
| common: | ||
| sysbuild: true | ||
| build_only: true | ||
| tests: | ||
| sample.fw_loader_usb_mcumgr: | ||
| tags: | ||
| - ci_samples_dfu | ||
| platform_allow: | ||
| - nrf54lm20dk/nrf54lm20a/cpuapp | ||
| integration_platforms: | ||
| - nrf54lm20dk/nrf54lm20a/cpuapp |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Enable MCUboot bootloader support | ||
| SB_CONFIG_BOOTLOADER_MCUBOOT=y | ||
| SB_CONFIG_PARTITION_MANAGER=n |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # | ||
| # Copyright (c) 2026 Nordic Semiconductor ASA | ||
| # | ||
| # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
| # | ||
|
|
||
| SB_CONFIG_BOOTLOADER_MCUBOOT=y | ||
| SB_CONFIG_MCUBOOT_MODE_FIRMWARE_UPDATER=y | ||
| SB_CONFIG_FIRMWARE_LOADER_IMAGE_USB_MCUMGR=y | ||
| SB_CONFIG_BOOT_SIGNATURE_TYPE_PURE=y |
Uh oh!
There was an error while loading. Please reload this page.