Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions boot/bootutil/zephyr/src/boot_request_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

#include "bootutil/bootutil_log.h"

#define MAIN_FLASH_DEV FIXED_PARTITION_NODE_DEVICE(DT_CHOSEN(nrf_bootloader_request))
#define MAIN_OFFSET FIXED_PARTITION_NODE_OFFSET(DT_CHOSEN(nrf_bootloader_request))
#define MAIN_SIZE FIXED_PARTITION_NODE_SIZE(DT_CHOSEN(nrf_bootloader_request))
#define MAIN_FLASH_DEV PARTITION_NODE_DEVICE(DT_CHOSEN(nrf_bootloader_request))
#define MAIN_OFFSET PARTITION_NODE_OFFSET(DT_CHOSEN(nrf_bootloader_request))
#define MAIN_SIZE PARTITION_NODE_SIZE(DT_CHOSEN(nrf_bootloader_request))

#ifdef CONFIG_NRF_MCUBOOT_BOOT_REQUEST_PREFERENCE_KEEP
#define BACKUP_FLASH_DEV FIXED_PARTITION_NODE_DEVICE(DT_CHOSEN(nrf_bootloader_request_backup))
#define BACKUP_OFFSET FIXED_PARTITION_NODE_OFFSET(DT_CHOSEN(nrf_bootloader_request_backup))
#define BACKUP_SIZE FIXED_PARTITION_NODE_SIZE(DT_CHOSEN(nrf_bootloader_request_backup))
#define BACKUP_FLASH_DEV PARTITION_NODE_DEVICE(DT_CHOSEN(nrf_bootloader_request_backup))
#define BACKUP_OFFSET PARTITION_NODE_OFFSET(DT_CHOSEN(nrf_bootloader_request_backup))
#define BACKUP_SIZE PARTITION_NODE_SIZE(DT_CHOSEN(nrf_bootloader_request_backup))
#endif /* CONFIG_NRF_MCUBOOT_BOOT_REQUEST_PREFERENCE_KEEP */

#define BOOT_REQUEST_CHECKSUM_SIZE sizeof(uint32_t)
Expand Down
2 changes: 1 addition & 1 deletion boot/zephyr/boot_serial_extension_zephyr_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static int bs_custom_storage_erase(const struct nmgr_hdr *hdr,
return MGMT_ERR_ENOTSUP;
}

rc = flash_area_open(FIXED_PARTITION_ID(storage_partition), &fa);
rc = flash_area_open(PARTITION_ID(storage_partition), &fa);

if (rc < 0) {
BOOT_LOG_ERR("failed to open flash area");
Expand Down
4 changes: 2 additions & 2 deletions boot/zephyr/firmware_loader_bm.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ BOOT_LOG_MODULE_DECLARE(mcuboot);

static struct flash_area fa_app_installer = {
.fa_id = 1,
.fa_off = FIXED_PARTITION_OFFSET(slot0_partition),
.fa_size = FIXED_PARTITION_SIZE(slot0_partition),
.fa_off = PARTITION_OFFSET(slot0_partition),
.fa_size = PARTITION_SIZE(slot0_partition),
.fa_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)),
};

Expand Down
22 changes: 11 additions & 11 deletions boot/zephyr/flash_map_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,26 @@ int flash_area_id_from_direct_image(int image_id)
switch (image_id) {
case 0:
case 1:
return FIXED_PARTITION_ID(slot0_partition);
#if FIXED_PARTITION_EXISTS(slot1_partition)
return PARTITION_ID(slot0_partition);
#if PARTITION_EXISTS(slot1_partition)
case 2:
return FIXED_PARTITION_ID(slot1_partition);
return PARTITION_ID(slot1_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot2_partition)
#if PARTITION_EXISTS(slot2_partition)
case 3:
return FIXED_PARTITION_ID(slot2_partition);
return PARTITION_ID(slot2_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot3_partition)
#if PARTITION_EXISTS(slot3_partition)
case 4:
return FIXED_PARTITION_ID(slot3_partition);
return PARTITION_ID(slot3_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot4_partition)
#if PARTITION_EXISTS(slot4_partition)
case 5:
return FIXED_PARTITION_ID(slot4_partition);
return PARTITION_ID(slot4_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot5_partition)
#if PARTITION_EXISTS(slot5_partition)
case 6:
return FIXED_PARTITION_ID(slot5_partition);
return PARTITION_ID(slot5_partition);
#endif
}
return -EINVAL;
Expand Down
8 changes: 4 additions & 4 deletions boot/zephyr/include/sysflash/sysflash.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
static inline uint32_t __flash_area_ids_for_slot(int img, int slot)
{
static const int all_slots[] = {
FOR_EACH_NONEMPTY_TERM(FIXED_PARTITION_ID, (,), ALL_AVAILABLE_SLOTS)
FOR_EACH_NONEMPTY_TERM(PARTITION_ID, (,), ALL_AVAILABLE_SLOTS)
};
return all_slots[img * 2 + slot];
};
Expand All @@ -61,13 +61,13 @@ static inline uint32_t __flash_area_ids_for_slot(int img, int slot)
#define FLASH_AREA_IMAGE_SECONDARY(x) __flash_area_ids_for_slot(x, 1)

#if !defined(CONFIG_BOOT_SWAP_USING_MOVE) && !defined(CONFIG_BOOT_SWAP_USING_OFFSET)
#define FLASH_AREA_IMAGE_SCRATCH FIXED_PARTITION_ID(scratch_partition)
#define FLASH_AREA_IMAGE_SCRATCH PARTITION_ID(scratch_partition)
#endif

#else /* !CONFIG_SINGLE_APPLICATION_SLOT && !CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP */

#define FLASH_AREA_IMAGE_PRIMARY(x) FIXED_PARTITION_ID(slot0_partition)
#define FLASH_AREA_IMAGE_SECONDARY(x) FIXED_PARTITION_ID(slot0_partition)
#define FLASH_AREA_IMAGE_PRIMARY(x) PARTITION_ID(slot0_partition)
#define FLASH_AREA_IMAGE_SECONDARY(x) PARTITION_ID(slot0_partition)

#endif /* CONFIG_SINGLE_APPLICATION_SLOT */

Expand Down
10 changes: 5 additions & 5 deletions boot/zephyr/include/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
!defined(CONFIG_SOC_FAMILY_ESPRESSIF_ESP32)) || \
(defined(CONFIG_SOC_SERIES_NRF54H) && !DT_HAS_CHOSEN(zephyr_flash)) || \
!defined(FLASH_ALIGN) || \
!(FIXED_PARTITION_EXISTS(slot0_partition)) || \
!(FIXED_PARTITION_EXISTS(slot1_partition) || CONFIG_SINGLE_APPLICATION_SLOT) || \
(defined(CONFIG_BOOT_SWAP_USING_SCRATCH) && !FIXED_PARTITION_EXISTS(scratch_partition))
!(PARTITION_EXISTS(slot0_partition)) || \
!(PARTITION_EXISTS(slot1_partition) || CONFIG_SINGLE_APPLICATION_SLOT) || \
(defined(CONFIG_BOOT_SWAP_USING_SCRATCH) && !PARTITION_EXISTS(scratch_partition))
#error "Target support is incomplete; cannot build mcuboot."
#endif

#if (MCUBOOT_IMAGE_NUMBER == 2) && (!(FIXED_PARTITION_EXISTS(slot2_partition)) || \
!(FIXED_PARTITION_EXISTS(slot3_partition)))
#if (MCUBOOT_IMAGE_NUMBER == 2) && (!(PARTITION_EXISTS(slot2_partition)) || \
!(PARTITION_EXISTS(slot3_partition)))
#error "Target support is incomplete; cannot build mcuboot."
#endif

Expand Down
26 changes: 13 additions & 13 deletions boot/zephyr/load_ironside_se_conf_mpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,49 @@ BUILD_ASSERT(MCUBOOT_IMAGE_NUMBER <= 2,

/* clang-format off */
#define MIN_START_ADDR(_label0, _label1) \
MIN(FIXED_PARTITION_ADDRESS(_label0), \
MIN(PARTITION_ADDRESS(_label0), \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(_label1)), \
(FIXED_PARTITION_ADDRESS(_label1)), \
(PARTITION_ADDRESS(_label1)), \
(UINTPTR_MAX)))

#define MIN_END_ADDR(_label0, _label1) \
MIN((FIXED_PARTITION_ADDRESS(_label0) + FIXED_PARTITION_SIZE(_label0)), \
MIN((PARTITION_ADDRESS(_label0) + PARTITION_SIZE(_label0)), \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(_label1)), \
((FIXED_PARTITION_ADDRESS(_label1) + FIXED_PARTITION_SIZE(_label1))), \
((PARTITION_ADDRESS(_label1) + PARTITION_SIZE(_label1))), \
(UINTPTR_MAX)))

#define MAX_START_ADDR(_label0, _label1) \
MAX(FIXED_PARTITION_ADDRESS(_label0), \
MAX(PARTITION_ADDRESS(_label0), \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(_label1)), \
(FIXED_PARTITION_ADDRESS(_label1)), \
(PARTITION_ADDRESS(_label1)), \
(0)))

#define MAX_END_ADDR(_label0, _label1) \
MAX((FIXED_PARTITION_ADDRESS(_label0) + FIXED_PARTITION_SIZE(_label0)), \
MAX((PARTITION_ADDRESS(_label0) + PARTITION_SIZE(_label0)), \
COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(_label1)), \
((FIXED_PARTITION_ADDRESS(_label1) + FIXED_PARTITION_SIZE(_label1))), \
((PARTITION_ADDRESS(_label1) + PARTITION_SIZE(_label1))), \
(0)))
/* clang-format on */

#define ACCESSIBLE_MRAM_START FIXED_PARTITION_NODE_ADDRESS(DT_CHOSEN(zephyr_code_partition))
#define ACCESSIBLE_MRAM_START PARTITION_NODE_ADDRESS(DT_CHOSEN(zephyr_code_partition))
BUILD_ASSERT((ACCESSIBLE_MRAM_START % OVERRIDE_ALIGNMENT) == 0);

#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(secure_storage_partition))
BUILD_ASSERT((FIXED_PARTITION_ADDRESS(secure_storage_partition) +
FIXED_PARTITION_SIZE(secure_storage_partition)) ==
BUILD_ASSERT((PARTITION_ADDRESS(secure_storage_partition) +
PARTITION_SIZE(secure_storage_partition)) ==
(DT_REG_ADDR(DT_NODELABEL(mram1x)) + DT_REG_SIZE(DT_NODELABEL(mram1x))),
"The MPC override configuration used to provide write protection for the image "
"partitions currently requires that the secure storage partitions are placed at the "
"end of MRAM.");

#define ACCESSIBLE_MRAM_END FIXED_PARTITION_ADDRESS(secure_storage_partition)
#define ACCESSIBLE_MRAM_END PARTITION_ADDRESS(secure_storage_partition)
#else
#define ACCESSIBLE_MRAM_END (DT_REG_ADDR(DT_NODELABEL(mram1x)) + DT_REG_SIZE(DT_NODELABEL(mram1x)))
#endif
BUILD_ASSERT((ACCESSIBLE_MRAM_END % OVERRIDE_ALIGNMENT) == 0);

#define BOOT_PARTITION_END \
(FIXED_PARTITION_NODE_ADDRESS(DT_CHOSEN(zephyr_code_partition)) + \
(PARTITION_NODE_ADDRESS(DT_CHOSEN(zephyr_code_partition)) + \
CONFIG_NCS_MCUBOOT_MPCCONF_STATIC_WRITE_PROTECTION_INITIAL_REGION_SIZE)
BUILD_ASSERT((BOOT_PARTITION_END % OVERRIDE_ALIGNMENT) == 0);

Expand Down
8 changes: 4 additions & 4 deletions boot/zephyr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@
#define SECONDARY_SLOT 1

#define IMAGE0_PRIMARY_START_ADDRESS \
DT_PROP_BY_IDX(DT_NODE_BY_FIXED_PARTITION_LABEL(image_0), reg, 0)
DT_PROP_BY_IDX(DT_NODE_BY_PARTITION_LABEL(image_0), reg, 0)
#define IMAGE0_PRIMARY_SIZE \
DT_PROP_BY_IDX(DT_NODE_BY_FIXED_PARTITION_LABEL(image_0), reg, 1)
DT_PROP_BY_IDX(DT_NODE_BY_PARTITION_LABEL(image_0), reg, 1)

#define IMAGE1_PRIMARY_START_ADDRESS \
DT_PROP_BY_IDX(DT_NODE_BY_FIXED_PARTITION_LABEL(image_1), reg, 0)
DT_PROP_BY_IDX(DT_NODE_BY_PARTITION_LABEL(image_1), reg, 0)
#define IMAGE1_PRIMARY_SIZE \
DT_PROP_BY_IDX(DT_NODE_BY_FIXED_PARTITION_LABEL(image_1), reg, 1)
DT_PROP_BY_IDX(DT_NODE_BY_PARTITION_LABEL(image_1), reg, 1)

#endif /* CONFIG_SOC_FAMILY_ESPRESSIF_ESP32 */

Expand Down
8 changes: 3 additions & 5 deletions boot/zephyr/nrf54h20_custom_s2ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ volatile struct mcuboot_resume_s mcuboot_resume;
#error "mcuboot resume support section not defined in dts"
#endif

#define FIXED_PARTITION_ADDR(node_label) DT_REG_ADDR(DT_NODELABEL(node_label))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomchy You suggested that for some purpose. Is this removal/replacement OK?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look here: nrfconnect/sdk-zephyr#3880
The devicetree.h file now includes the <zephyr/devicetree/mapped-partition.h> which is the newly introduced mechanism to get partition address/offset/size, without the need to enable FLASH_MAP in the build.
Additionally, the PR sets all partitions on all Nordic platform to use the new compatible (zephyr,mapped-partition).

We still may need to give it a thought if those changes are backward compatible (imagine an out of tree sample that still uses fixed-partitions and fixed-subpartitions). The code there should handle it fine, but since all platforms are migrated, there are no tests that verify the old syntax.


#define S2RAM_SLOT_INFO_A 0x37
#define S2RAM_SLOT_INFO_B 0xA4

Expand Down Expand Up @@ -76,17 +74,17 @@ void pm_s2ram_mark_check_and_mediate(void)
#ifdef CONFIG_BOOT_DIRECT_XIP
if (mcuboot_resume.slot_info == S2RAM_SLOT_INFO_A) {
vt = (struct arm_vector_table *)
(FIXED_PARTITION_ADDR(slot0_partition) + APP_EXE_START_OFFSET);
(PARTITION_ADDRESS(slot0_partition) + APP_EXE_START_OFFSET);
} else if (mcuboot_resume.slot_info == S2RAM_SLOT_INFO_B) {
vt = (struct arm_vector_table *)
(FIXED_PARTITION_ADDR(slot1_partition) + APP_EXE_START_OFFSET);
(PARTITION_ADDRESS(slot1_partition) + APP_EXE_START_OFFSET);
} else {
/* invalid slot info */
goto resume_failed;
}
#else
vt = (struct arm_vector_table *)
(FIXED_PARTITION_ADDR(slot0_partition) + APP_EXE_START_OFFSET);
(PARTITION_ADDRESS(slot0_partition) + APP_EXE_START_OFFSET);
#endif

/* Jump to application */
Expand Down
4 changes: 2 additions & 2 deletions samples/runtime-source/zephyr/hooks/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ static struct image_header _hdr;
static uint8_t tmpbuf[BOOT_TMPBUF_SZ];

static uint8_t known_ids[] = {
FIXED_PARTITION_ID(slot0_partition),
FIXED_PARTITION_ID(slot1_partition),
PARTITION_ID(slot0_partition),
PARTITION_ID(slot1_partition),
};

static int current_id;
Expand Down
Loading