Skip to content

Commit 8f63951

Browse files
committed
applications: nrf_desktop: align dfu config channel with nRF54H IronSide
Adapted the DFU module over the Configuration channel in the nRF Desktop application so that it can work with the new nRF54H20 DFU architecture. Enabled support for the DFU module over the Configuration channel in all configurations of the nrf54h20dk/nrf54h20/cpuapp board target. Ref: NCSDK-34151 Signed-off-by: Kamil Piszczek <[email protected]>
1 parent e0e8f74 commit 8f63951

File tree

6 files changed

+82
-39
lines changed

6 files changed

+82
-39
lines changed

applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@ CONFIG_DESKTOP_BLE_LOW_LATENCY_LOCK=y
5656

5757
CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE=y
5858
CONFIG_DESKTOP_CONFIG_CHANNEL_OUT_REPORT=y
59+
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=y
5960

6061
CONFIG_DESKTOP_DFU_MCUMGR_ENABLE=y
6162
CONFIG_CAF_INIT_LOG_BLE_SMP_TRANSFER_EVENTS=n
6263

63-
# Temporarily disable unsupported features.
64-
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=n
65-
6664
################################################################################
6765
# Zephyr Configuration
6866

@@ -124,6 +122,10 @@ CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4096
124122
CONFIG_MCUMGR_GRP_OS=y
125123
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
126124

125+
CONFIG_STREAM_FLASH=y
126+
CONFIG_IMG_MANAGER=y
127+
CONFIG_MCUBOOT_IMG_MANAGER=y
128+
127129
# Configure Zephyr system power management
128130
CONFIG_PM=y
129131
CONFIG_PM_S2RAM=y

applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_dongle.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ CONFIG_DESKTOP_BLE_NEW_PEER_SCAN_ON_BOOT=y
4141
CONFIG_DESKTOP_BLE_PEER_ERASE=y
4242

4343
CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE=y
44-
45-
# Temporarily disable unsupported features.
46-
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=n
44+
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=y
4745

4846
################################################################################
4947
# Zephyr Configuration
@@ -85,6 +83,10 @@ CONFIG_BT_PRIVACY=y
8583

8684
CONFIG_BT_BUF_ACL_TX_SIZE=35
8785

86+
CONFIG_STREAM_FLASH=y
87+
CONFIG_IMG_MANAGER=y
88+
CONFIG_MCUBOOT_IMG_MANAGER=y
89+
8890
# Configure Zephyr system power management
8991
CONFIG_PM=y
9092
CONFIG_PM_S2RAM=y

applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_release.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ CONFIG_DESKTOP_FAILSAFE_ENABLE=y
5252

5353
CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE=y
5454
CONFIG_DESKTOP_CONFIG_CHANNEL_OUT_REPORT=y
55+
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=y
5556

5657
CONFIG_DESKTOP_DFU_MCUMGR_ENABLE=y
5758

58-
# Temporarily disable unsupported features.
59-
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=n
60-
6159
################################################################################
6260
# Zephyr Configuration
6361

@@ -118,6 +116,10 @@ CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4096
118116
CONFIG_MCUMGR_GRP_OS=y
119117
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
120118

119+
CONFIG_STREAM_FLASH=y
120+
CONFIG_IMG_MANAGER=y
121+
CONFIG_MCUBOOT_IMG_MANAGER=y
122+
121123
# Configure Zephyr system power management
122124
CONFIG_PM=y
123125
CONFIG_PM_S2RAM=y

applications/nrf_desktop/configuration/nrf54h20dk_nrf54h20_cpuapp/prj_release_dongle.conf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ CONFIG_DESKTOP_WATCHDOG_ENABLE=y
4040
CONFIG_DESKTOP_FAILSAFE_ENABLE=y
4141

4242
CONFIG_DESKTOP_CONFIG_CHANNEL_ENABLE=y
43-
44-
# Temporarily disable unsupported features.
45-
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=n
43+
CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_ENABLE=y
4644

4745
################################################################################
4846
# Zephyr Configuration
@@ -84,6 +82,10 @@ CONFIG_BT_PRIVACY=y
8482

8583
CONFIG_BT_BUF_ACL_TX_SIZE=35
8684

85+
CONFIG_STREAM_FLASH=y
86+
CONFIG_IMG_MANAGER=y
87+
CONFIG_MCUBOOT_IMG_MANAGER=y
88+
8789
# Configure Zephyr system power management
8890
CONFIG_PM=y
8991
CONFIG_PM_S2RAM=y

applications/nrf_desktop/src/modules/Kconfig.config_channel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ comment "DFU"
5757
config DESKTOP_CONFIG_CHANNEL_DFU_ENABLE
5858
bool "DFU over the config channel"
5959
depends on DESKTOP_CONFIG_CHANNEL_ENABLE
60-
depends on (SSF_SUIT_SERVICE_ENABLED || !SUIT)
6160
help
6261
This option enables DFU over the config channel.
6362

applications/nrf_desktop/src/modules/dfu.c

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -56,41 +56,77 @@ LOG_MODULE_REGISTER(MODULE, CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_LOG_LEVEL);
5656
"B0 bootloader supported only with Partition Manager");
5757
#include <pm_config.h>
5858
#include <fw_info.h>
59-
#define BOOTLOADER_NAME "B0"
59+
#define BOOTLOADER_NAME "B0"
6060
#if PM_ADDRESS == PM_S0_IMAGE_ADDRESS
61-
#define DFU_SLOT_ID PM_S1_IMAGE_ID
61+
#define DFU_SLOT_ID PM_S1_IMAGE_ID
6262
#elif PM_ADDRESS == PM_S1_IMAGE_ADDRESS
63-
#define DFU_SLOT_ID PM_S0_IMAGE_ID
63+
#define DFU_SLOT_ID PM_S0_IMAGE_ID
6464
#else
6565
#error Missing partition definitions.
6666
#endif
6767
#elif CONFIG_BOOTLOADER_MCUBOOT
68-
BUILD_ASSERT(IS_ENABLED(CONFIG_PARTITION_MANAGER_ENABLED),
69-
"MCUBoot bootloader supported only with Partition Manager");
70-
#include <pm_config.h>
7168
#include <zephyr/dfu/mcuboot.h>
7269
#if CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_MCUBOOT_DIRECT_XIP
73-
#define BOOTLOADER_NAME "MCUBOOT+XIP"
74-
#else
75-
#define BOOTLOADER_NAME "MCUBOOT"
76-
#endif
77-
78-
#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE
79-
BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE);
80-
#endif
81-
82-
#if CONFIG_BUILD_WITH_TFM
83-
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE)
70+
#define BOOTLOADER_NAME "MCUBOOT+XIP"
8471
#else
85-
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE)
72+
#define BOOTLOADER_NAME "MCUBOOT"
8673
#endif
8774

88-
#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS
89-
#define DFU_SLOT_ID PM_MCUBOOT_SECONDARY_ID
90-
#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS
91-
#define DFU_SLOT_ID PM_MCUBOOT_PRIMARY_ID
75+
#if CONFIG_PARTITION_MANAGER_ENABLED
76+
#include <pm_config.h>
77+
78+
#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE
79+
BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE);
80+
#endif
81+
82+
#if CONFIG_BUILD_WITH_TFM
83+
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE)
84+
#else
85+
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE)
86+
#endif
87+
88+
#define MCUBOOT_PRIMARY_SLOT_ID PM_MCUBOOT_PRIMARY_ID
89+
#define MCUBOOT_SECONDARY_SLOT_ID PM_MCUBOOT_SECONDARY_ID
90+
91+
#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS
92+
#define DFU_SLOT_ID MCUBOOT_SECONDARY_SLOT_ID
93+
#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS
94+
#define DFU_SLOT_ID MCUBOOT_PRIMARY_SLOT_ID
95+
#else
96+
#error Missing partition definitions.
97+
#endif
98+
#elif CONFIG_USE_DT_CODE_PARTITION
99+
#include <zephyr/devicetree.h>
100+
101+
#define CODE_PARTITION_NODE DT_CHOSEN(zephyr_code_partition)
102+
#define MCUBOOT_PRIMARY_NODE DT_NODELABEL(slot0_partition)
103+
#define MCUBOOT_SECONDARY_NODE DT_NODELABEL(slot1_partition)
104+
105+
BUILD_ASSERT(DT_FIXED_PARTITION_EXISTS(MCUBOOT_PRIMARY_NODE),
106+
"Missing primary partition definition in DTS.");
107+
BUILD_ASSERT(DT_FIXED_PARTITION_EXISTS(MCUBOOT_SECONDARY_NODE),
108+
"Missing secondary partition definition in DTS.");
109+
110+
#define CODE_PARTITION_START_ADDR DT_FIXED_PARTITION_ADDR(CODE_PARTITION_NODE)
111+
#define MCUBOOT_PRIMARY_START_ADDR DT_FIXED_PARTITION_ADDR(MCUBOOT_PRIMARY_NODE)
112+
#define MCUBOOT_SECONDARY_START_ADDR DT_FIXED_PARTITION_ADDR(MCUBOOT_SECONDARY_NODE)
113+
114+
#if MCUBOOT_PRIMARY_START_ADDR == MCUBOOT_SECONDARY_START_ADDR
115+
#error Primary and secondary partitions cannot have the same address.
116+
#endif
117+
118+
#define MCUBOOT_PRIMARY_SLOT_ID DT_FIXED_PARTITION_ID(MCUBOOT_PRIMARY_NODE)
119+
#define MCUBOOT_SECONDARY_SLOT_ID DT_FIXED_PARTITION_ID(MCUBOOT_SECONDARY_NODE)
120+
121+
#if CODE_PARTITION_START_ADDR == MCUBOOT_PRIMARY_START_ADDR
122+
#define DFU_SLOT_ID MCUBOOT_SECONDARY_SLOT_ID
123+
#elif CODE_PARTITION_START_ADDR == MCUBOOT_SECONDARY_START_ADDR
124+
#define DFU_SLOT_ID MCUBOOT_PRIMARY_SLOT_ID
125+
#else
126+
#error Missing partition definitions in DTS.
127+
#endif
92128
#else
93-
#error Missing partition definitions.
129+
#error Unsupported partitioning scheme.
94130
#endif
95131
#else
96132
#error Bootloader not supported.
@@ -732,12 +768,12 @@ static void handle_image_info_request(uint8_t *data, size_t *size)
732768
uint8_t flash_area_id;
733769
uint8_t bank_header_area_id;
734770

735-
if (DFU_SLOT_ID == PM_MCUBOOT_SECONDARY_ID) {
771+
if (DFU_SLOT_ID == MCUBOOT_SECONDARY_SLOT_ID) {
736772
flash_area_id = 0;
737-
bank_header_area_id = PM_MCUBOOT_PRIMARY_ID;
773+
bank_header_area_id = MCUBOOT_PRIMARY_SLOT_ID;
738774
} else {
739775
flash_area_id = 1;
740-
bank_header_area_id = PM_MCUBOOT_SECONDARY_ID;
776+
bank_header_area_id = MCUBOOT_SECONDARY_SLOT_ID;
741777
}
742778

743779
int err = boot_read_bank_header(bank_header_area_id, &header,

0 commit comments

Comments
 (0)