Skip to content

Commit 1d91e5f

Browse files
tomchynordicjm
authored andcommitted
[nrf fromtree] 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]> (cherry picked from commit 14af165)
1 parent 20bb24b commit 1d91e5f

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
@@ -36,14 +36,21 @@ LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
3636
#define HSFLL_NODE DT_NODELABEL(cpurad_hsfll)
3737
#endif
3838

39+
#define FIXED_PARTITION_ADDRESS(label) \
40+
(DT_REG_ADDR(DT_NODELABEL(label)) + \
41+
DT_REG_ADDR(COND_CODE_1(DT_FIXED_SUBPARTITION_EXISTS(DT_NODELABEL(label)), \
42+
(DT_GPARENT(DT_PARENT(DT_NODELABEL(label)))), \
43+
(DT_GPARENT(DT_NODELABEL(label))))))
44+
3945
#ifdef CONFIG_USE_DT_CODE_PARTITION
4046
#define FLASH_LOAD_OFFSET DT_REG_ADDR(DT_CHOSEN(zephyr_code_partition))
4147
#elif defined(CONFIG_FLASH_LOAD_OFFSET)
4248
#define FLASH_LOAD_OFFSET CONFIG_FLASH_LOAD_OFFSET
4349
#endif
4450

4551
#define PARTITION_IS_RUNNING_APP_PARTITION(label) \
46-
(DT_REG_ADDR(DT_NODELABEL(label)) == FLASH_LOAD_OFFSET)
52+
(DT_REG_ADDR(DT_NODELABEL(label)) <= FLASH_LOAD_OFFSET && \
53+
DT_REG_ADDR(DT_NODELABEL(label)) + DT_REG_SIZE(DT_NODELABEL(label)) > FLASH_LOAD_OFFSET)
4754

4855
sys_snode_t soc_node;
4956

@@ -203,22 +210,16 @@ void soc_late_init_hook(void)
203210
void *radiocore_address = NULL;
204211

205212
#if DT_NODE_EXISTS(DT_NODELABEL(cpurad_slot1_partition))
206-
if (PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
207-
radiocore_address =
208-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot1_partition))) +
209-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot1_partition)) +
210-
CONFIG_ROM_START_OFFSET);
213+
if (PARTITION_IS_RUNNING_APP_PARTITION(cpuapp_slot1_partition)) {
214+
radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot1_partition) +
215+
CONFIG_ROM_START_OFFSET);
211216
} else {
212-
radiocore_address =
213-
(void *)(DT_REG_ADDR(DT_GPARENT(DT_NODELABEL(cpurad_slot0_partition))) +
214-
DT_REG_ADDR(DT_NODELABEL(cpurad_slot0_partition)) +
215-
CONFIG_ROM_START_OFFSET);
217+
radiocore_address = (void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) +
218+
CONFIG_ROM_START_OFFSET);
216219
}
217220
#else
218221
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);
222+
(void *)(FIXED_PARTITION_ADDRESS(cpurad_slot0_partition) + CONFIG_ROM_START_OFFSET);
222223
#endif
223224

224225
if (IS_ENABLED(CONFIG_SOC_NRF54H20_CPURAD_ENABLE_CHECK_VTOR) &&

0 commit comments

Comments
 (0)