From e96b1aff81b21a3affd1d3c9434f10a76b1b5141 Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Wed, 1 Oct 2025 16:27:50 +0200 Subject: [PATCH] soc: nordic: nrf54h: Disable code relocation for MCUBOOT MCUBOOT requires LTO to be enabled, while using code relocation forces switching it off. When `__ramfunc` is used, LTO can also be used. Then the `cache_retain_and_sleep` function will work correctly, but slightly slower. Signed-off-by: Adam Kondraciuk --- soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp | 2 +- soc/nordic/nrf54h/power.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp b/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp index f2e0343d6350d..674b5433c1479 100644 --- a/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp +++ b/soc/nordic/nrf54h/Kconfig.defconfig.nrf54h20_cpuapp @@ -15,6 +15,6 @@ config POWER_DOMAIN default y config CODE_DATA_RELOCATION - default y if PM || POWEROFF + default y if (PM || POWEROFF) && !MCUBOOT endif # SOC_NRF54H20_CPUAPP diff --git a/soc/nordic/nrf54h/power.c b/soc/nordic/nrf54h/power.c index 3a23a6050605f..c72cb6e834e59 100644 --- a/soc/nordic/nrf54h/power.c +++ b/soc/nordic/nrf54h/power.c @@ -88,7 +88,12 @@ void nrf_poweroff(void) CODE_UNREACHABLE; } -static __attribute__((__used__, noinline)) void cache_retain_and_sleep(void) +#if CONFIG_MCUBOOT +static __ramfunc +#else +static __attribute__((__used__, noinline)) +#endif +void cache_retain_and_sleep(void) { nrf_cache_task_trigger(NRF_DCACHE, NRF_CACHE_TASK_SAVE); nrf_cache_task_trigger(NRF_ICACHE, NRF_CACHE_TASK_SAVE);