-
Notifications
You must be signed in to change notification settings - Fork 1.4k
applications: nrf_desktop: align dfu config channel with nRF54H IronSide #24865
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -65,32 +65,55 @@ LOG_MODULE_REGISTER(MODULE, CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_LOG_LEVEL); | |
#error Missing partition definitions. | ||
#endif | ||
#elif CONFIG_BOOTLOADER_MCUBOOT | ||
BUILD_ASSERT(IS_ENABLED(CONFIG_PARTITION_MANAGER_ENABLED), | ||
"MCUBoot bootloader supported only with Partition Manager"); | ||
#include <pm_config.h> | ||
#include <zephyr/dfu/mcuboot.h> | ||
#if CONFIG_DESKTOP_CONFIG_CHANNEL_DFU_MCUBOOT_DIRECT_XIP | ||
#define BOOTLOADER_NAME "MCUBOOT+XIP" | ||
#else | ||
#define BOOTLOADER_NAME "MCUBOOT" | ||
#endif | ||
|
||
#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE | ||
BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE); | ||
#endif | ||
|
||
#if CONFIG_BUILD_WITH_TFM | ||
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE) | ||
#if CONFIG_PARTITION_MANAGER_ENABLED | ||
#include <pm_config.h> | ||
|
||
#ifdef PM_MCUBOOT_SECONDARY_PAD_SIZE | ||
BUILD_ASSERT(PM_MCUBOOT_PAD_SIZE == PM_MCUBOOT_SECONDARY_PAD_SIZE); | ||
#endif | ||
|
||
#if CONFIG_BUILD_WITH_TFM | ||
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE + PM_TFM_SIZE) | ||
#else | ||
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE) | ||
#endif | ||
|
||
#define MCUBOOT_PRIMARY_ID PM_MCUBOOT_PRIMARY_ID | ||
#define MCUBOOT_SECONDARY_ID PM_MCUBOOT_SECONDARY_ID | ||
|
||
#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS | ||
#define DFU_SLOT_ID MCUBOOT_SECONDARY_ID | ||
#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS | ||
#define DFU_SLOT_ID MCUBOOT_PRIMARY_ID | ||
#else | ||
#error Missing partition definitions. | ||
#endif | ||
#elif CONFIG_USE_DT_CODE_PARTITION | ||
#include <zephyr/devicetree.h> | ||
|
||
#define CODE_PARTITION_NODE DT_CHOSEN(zephyr_code_partition) | ||
#define MCUBOOT_PRIMARY_NODE DT_NODELABEL(slot0_partition) | ||
#define MCUBOOT_SECONDARY_NODE DT_NODELABEL(slot1_partition) | ||
Comment on lines
+102
to
+103
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. You could consider checking if both partitions exist ( |
||
|
||
#define MCUBOOT_PRIMARY_ID DT_FIXED_PARTITION_ID(MCUBOOT_PRIMARY_NODE) | ||
#define MCUBOOT_SECONDARY_ID DT_FIXED_PARTITION_ID(MCUBOOT_SECONDARY_NODE) | ||
|
||
#if DT_REG_ADDR(CODE_PARTITION_NODE) == DT_REG_ADDR(MCUBOOT_PRIMARY_NODE) | ||
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. Consider using 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. btw. It would be good to also test IronSide with our |
||
#define DFU_SLOT_ID MCUBOOT_SECONDARY_ID | ||
#elif DT_REG_ADDR(CODE_PARTITION_NODE) == DT_REG_ADDR(MCUBOOT_SECONDARY_NODE) | ||
#define DFU_SLOT_ID MCUBOOT_PRIMARY_ID | ||
#else | ||
#error Missing partition definitions in DTS. | ||
#endif | ||
#else | ||
#define PM_ADDRESS_OFFSET (PM_MCUBOOT_PAD_SIZE) | ||
#endif | ||
|
||
#if (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_PRIMARY_ADDRESS | ||
#define DFU_SLOT_ID PM_MCUBOOT_SECONDARY_ID | ||
#elif (PM_ADDRESS - PM_ADDRESS_OFFSET) == PM_MCUBOOT_SECONDARY_ADDRESS | ||
#define DFU_SLOT_ID PM_MCUBOOT_PRIMARY_ID | ||
#else | ||
#error Missing partition definitions. | ||
#error Unsupported partitioning scheme. | ||
#endif | ||
#else | ||
#error Bootloader not supported. | ||
|
@@ -732,12 +755,12 @@ static void handle_image_info_request(uint8_t *data, size_t *size) | |
uint8_t flash_area_id; | ||
uint8_t bank_header_area_id; | ||
|
||
if (DFU_SLOT_ID == PM_MCUBOOT_SECONDARY_ID) { | ||
if (DFU_SLOT_ID == MCUBOOT_SECONDARY_ID) { | ||
flash_area_id = 0; | ||
bank_header_area_id = PM_MCUBOOT_PRIMARY_ID; | ||
bank_header_area_id = MCUBOOT_PRIMARY_ID; | ||
} else { | ||
flash_area_id = 1; | ||
bank_header_area_id = PM_MCUBOOT_SECONDARY_ID; | ||
bank_header_area_id = MCUBOOT_SECONDARY_ID; | ||
} | ||
|
||
int err = boot_read_bank_header(bank_header_area_id, &header, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MCUBOOT_PRIMARY_PARTITION_ID
? (previouslyPARTITION
word was part of thePM_
prefix)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe
MCUBOOT_PRIMARY_SLOT_ID
(for consistency withDFU_SLOT_ID
)?