Skip to content

Commit 0df9bb9

Browse files
committed
[nrf fromlist] soc: Move to the app-specific partitions
Use cpuapp_slot_partition instead of slot0_partition, so it is possible to add MCUboot header through --pad-header option. In such cases, the FLASH_LOAD_OFFSET does not point to the begining of the slot, but to the beginning of the executable area, thus the check for the active slot should use ranges instead of exact values. Upstream PR #: 96925 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 208db88 commit 0df9bb9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

soc/nordic/nrf54h/soc.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,21 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
4040
#define HSFLL_NODE DT_NODELABEL(cpurad_hsfll)
4141
#endif
4242

43+
#define FIXED_PARTITION_ADDRESS(label) \
44+
(DT_REG_ADDR(DT_NODELABEL(label)) + \
45+
DT_REG_ADDR(COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \
46+
(DT_GPARENT(DT_PARENT(DT_NODELABEL(label)))), \
47+
(DT_GPARENT(DT_NODELABEL(label))))))
48+
4349
#ifdef CONFIG_USE_DT_CODE_PARTITION
4450
#define FLASH_LOAD_OFFSET DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))
4551
#elif defined(CONFIG_FLASH_LOAD_OFFSET)
4652
#define FLASH_LOAD_OFFSET CONFIG_FLASH_LOAD_OFFSET
4753
#endif
4854

4955
#define PARTITION_IS_RUNNING_APP_PARTITION(label) \
50-
(DT_REG_ADDR(DT_NODELABEL(label)) == FLASH_LOAD_OFFSET)
56+
(DT_REG_ADDR(DT_NODELABEL(label)) <= FLASH_LOAD_OFFSET && \
57+
DT_REG_ADDR(DT_NODELABEL(label)) + DT_REG_SIZE(DT_NODELABEL(label)) > FLASH_LOAD_OFFSET)
5158

5259
sys_snode_t soc_node;
5360

@@ -221,22 +228,16 @@ void soc_late_init_hook(void)
221228
void *radiocore_address = NULL;
222229

223230
#if DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot1_partition))
224-
if (PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
225-
radiocore_address =
226-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot1_partition))) +
227-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot1_partition)) +
228-
CONFIG_ROM_START_OFFSET);
231+
if (PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) {
232+
radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot1_partition) +
233+
CONFIG_ROM_START_OFFSET);
229234
} else {
230-
radiocore_address =
231-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) +
232-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) +
233-
CONFIG_ROM_START_OFFSET);
235+
radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) +
236+
CONFIG_ROM_START_OFFSET);
234237
}
235238
#elif DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot0_partition))
236239
radiocore_address =
237-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) +
238-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) +
239-
CONFIG_ROM_START_OFFSET);
240+
(void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET);
240241
#endif
241242

242243
if (IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR) &&

0 commit comments

Comments
 (0)