Skip to content

Commit 291579f

Browse files
committed
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. Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent c77e5a6 commit 291579f

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
@@ -39,14 +39,21 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
3939
#define HSFLL_NODE DT_NODELABEL(cpurad_hsfll)
4040
#endif
4141

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

4854
#define PARTITION_IS_RUNNING_APP_PARTITION(label) \
49-
(DT_REG_ADDR(DT_NODELABEL(label)) == FLASH_LOAD_OFFSET)
55+
(DT_REG_ADDR(DT_NODELABEL(label)) <= FLASH_LOAD_OFFSET && \
56+
DT_REG_ADDR(DT_NODELABEL(label)) + DT_REG_SIZE(DT_NODELABEL(label)) > FLASH_LOAD_OFFSET)
5057

5158
sys_snode_t soc_node;
5259

@@ -209,22 +216,16 @@ void soc_late_init_hook(void)
209216
void *radiocore_address = NULL;
210217

211218
#if DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot1_partition))
212-
if (PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
213-
radiocore_address =
214-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot1_partition))) +
215-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot1_partition)) +
216-
CONFIG_ROM_START_OFFSET);
219+
if (PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) {
220+
radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot1_partition) +
221+
CONFIG_ROM_START_OFFSET);
217222
} else {
218-
radiocore_address =
219-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) +
220-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) +
221-
CONFIG_ROM_START_OFFSET);
223+
radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) +
224+
CONFIG_ROM_START_OFFSET);
222225
}
223226
#else
224227
radiocore_address =
225-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) +
226-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) +
227-
CONFIG_ROM_START_OFFSET);
228+
(void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET);
228229
#endif
229230

230231
if (IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR) &&

0 commit comments

Comments
 (0)