diff --git a/components/esp_hw_support/esp_memory_utils.c b/components/esp_hw_support/esp_memory_utils.c index 2384db6fe88..8fc74cc5c77 100644 --- a/components/esp_hw_support/esp_memory_utils.c +++ b/components/esp_hw_support/esp_memory_utils.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2010-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,7 +13,7 @@ #include "esp_attr.h" #include "esp_cpu.h" #include "esp_memory_utils.h" -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_extram.h" #endif @@ -23,7 +23,7 @@ bool esp_ptr_dma_ext_capable(const void *p) #if !SOC_PSRAM_DMA_CAPABLE return false; #endif //!SOC_PSRAM_DMA_CAPABLE -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM return esp_psram_check_ptr_addr(p); #else return false; @@ -36,7 +36,7 @@ bool esp_ptr_executable(const void *p) return (ip >= SOC_IROM_LOW && ip < SOC_IROM_HIGH) || (ip >= SOC_IRAM_LOW && ip < SOC_IRAM_HIGH) || (ip >= SOC_IROM_MASK_LOW && ip < SOC_IROM_MASK_HIGH) -#if SOC_SPIRAM_SUPPORTED && CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && SOC_SPIRAM_SUPPORTED && CONFIG_SPIRAM || esp_ptr_external_ram(p) #endif #if defined(SOC_CACHE_APP_LOW) && defined(CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE) @@ -62,7 +62,7 @@ bool esp_ptr_byte_accessible(const void *p) * additional check is required */ r |= (ip >= SOC_RTC_DRAM_LOW && ip < SOC_RTC_DRAM_HIGH); #endif -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM r |= esp_psram_check_ptr_addr(p); #endif #if CONFIG_ESP32S3_DATA_CACHE_16KB @@ -82,14 +82,14 @@ bool esp_ptr_external_ram(const void *p) #if !SOC_SPIRAM_SUPPORTED return false; #endif //!SOC_SPIRAM_SUPPORTED -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM return esp_psram_check_ptr_addr(p); #else return false; #endif //CONFIG_SPIRAM } -#if CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM +#if !BOOTLOADER_BUILD && CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM bool esp_stack_ptr_in_extram(uint32_t sp) { //Check if stack ptr is on PSRAM, and 16 byte aligned. diff --git a/components/esp_hw_support/port/esp32c5/cpu_region_protect.c b/components/esp_hw_support/port/esp32c5/cpu_region_protect.c index 8b8e5e6002c..d8f5bd38473 100644 --- a/components/esp_hw_support/port/esp32c5/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32c5/cpu_region_protect.c @@ -9,9 +9,9 @@ #include "esp_cpu.h" #include "esp_fault.h" #include "esp32c5/rom/rom_layout.h" -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_extram.h" -#endif /* CONFIG_SPIRAM */ +#endif /* !BOOTLOADER_BUILD && CONFIG_SPIRAM */ #ifdef BOOTLOADER_BUILD // Without L bit set diff --git a/components/esp_hw_support/port/esp32c61/cpu_region_protect.c b/components/esp_hw_support/port/esp32c61/cpu_region_protect.c index cc62bade13b..07ad769289e 100644 --- a/components/esp_hw_support/port/esp32c61/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32c61/cpu_region_protect.c @@ -10,9 +10,9 @@ #include "esp_cpu.h" #include "esp_fault.h" #include "esp32c61/rom/rom_layout.h" -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_extram.h" -#endif /* CONFIG_SPIRAM */ +#endif /* !BOOTLOADER_BUILD && CONFIG_SPIRAM */ #ifdef BOOTLOADER_BUILD // Without L bit set diff --git a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c index 54ee7637f5c..ab682877734 100644 --- a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c @@ -11,9 +11,9 @@ #include "esp_fault.h" #include "hal/cache_ll.h" #include "riscv/csr.h" -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_extram.h" -#endif /* CONFIG_SPIRAM */ +#endif /* !BOOTLOADER_BUILD && CONFIG_SPIRAM */ #include "soc/chip_revision.h" #include "hal/config.h" @@ -198,14 +198,14 @@ static void esp_cpu_configure_region_protection_rev_v3(void) PMP_ENTRY_SET_CACHED_AND_UNCACHED(22, 26, page_aligned_drom_resv_end, PMP_TOR | R); #else -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM const uint32_t pmpaddr10 = PMPADDR_NAPOT(SOC_EXTRAM_LOW, SOC_EXTRAM_HIGH); PMP_RESET_AND_ENTRY_SET(10, pmpaddr10, PMP_NAPOT | CONDITIONAL_RWX); const uint32_t pmpaddr11 = PMPADDR_NAPOT(CACHE_LL_L2MEM_NON_CACHE_ADDR(SOC_EXTRAM_LOW), CACHE_LL_L2MEM_NON_CACHE_ADDR(SOC_EXTRAM_HIGH)); PMP_RESET_AND_ENTRY_SET(11, pmpaddr11, PMP_NAPOT | CONDITIONAL_RWX); _Static_assert(SOC_EXTRAM_LOW < SOC_EXTRAM_HIGH, "Invalid I/D_EXTRAM region"); -#endif /* CONFIG_SPIRAM */ +#endif /* !BOOTLOADER_BUILD && CONFIG_SPIRAM */ const uint32_t pmpaddr12 = PMPADDR_NAPOT(SOC_IROM_LOW, SOC_IROM_HIGH); PMP_RESET_AND_ENTRY_SET(12, pmpaddr12, PMP_NAPOT | CONDITIONAL_RX); diff --git a/components/esp_hw_support/port/esp32p4/pmu_sleep.c b/components/esp_hw_support/port/esp32p4/pmu_sleep.c index e8a108d14db..2cb00cd0f4a 100644 --- a/components/esp_hw_support/port/esp32p4/pmu_sleep.c +++ b/components/esp_hw_support/port/esp32p4/pmu_sleep.c @@ -39,6 +39,8 @@ #if CONFIG_SPIRAM #include "hal/ldo_ll.h" #include "hal/mspi_ll.h" +#endif +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_impl.h" #endif @@ -417,7 +419,7 @@ SPM_IRAM_ATTR uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, pmu_sleep_cache_sync_items(SMMU_GID_DEFAULT, CACHE_SYNC_WRITEBACK, CACHE_MAP_L1_DCACHE, 0, 0); // No PSRAM dirty data after this time write back if (!dslp) { -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM psram_ctrlr_ll_wait_all_transaction_done(); #if CONFIG_PM_SLP_SPIRAM_HALFSLEEP_ENABLED esp_psram_impl_enter_halfsleep_mode(); @@ -518,7 +520,7 @@ SPM_IRAM_ATTR bool pmu_sleep_finish(bool dslp) _psram_ctrlr_ll_select_clk_source(PSRAM_CTRLR_LL_MSPI_ID_3, PSRAM_CLK_SRC_MPLL); #endif } -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM mspi_ll_psram_unhold_all_pins(); #if CONFIG_PM_SLP_SPIRAM_HALFSLEEP_ENABLED esp_psram_impl_exit_halfsleep_mode(); diff --git a/components/esp_hw_support/port/esp32s31/cpu_region_protect.c b/components/esp_hw_support/port/esp32s31/cpu_region_protect.c index be4d6b0c9d0..23ff084deb9 100644 --- a/components/esp_hw_support/port/esp32s31/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32s31/cpu_region_protect.c @@ -11,9 +11,9 @@ #include "esp_fault.h" #include "hal/cache_ll.h" #include "riscv/csr.h" -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_extram.h" -#endif /* CONFIG_SPIRAM */ +#endif /* !BOOTLOADER_BUILD && CONFIG_SPIRAM */ /* TODO: [ESP32S31] IDF-15238 */ diff --git a/components/esp_hw_support/port/esp32s31/pmu_sleep.c b/components/esp_hw_support/port/esp32s31/pmu_sleep.c index 3abb86e68c7..632d70027b7 100644 --- a/components/esp_hw_support/port/esp32s31/pmu_sleep.c +++ b/components/esp_hw_support/port/esp32s31/pmu_sleep.c @@ -22,7 +22,7 @@ #include "hal/efuse_hal.h" #include "hal/mspi_ll.h" #include "esp_hw_log.h" -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM #include "esp_private/esp_psram_impl.h" #include "hal/psram_ctrlr_ll.h" #endif @@ -341,7 +341,7 @@ void pmu_sleep_init(const pmu_sleep_config_t *config, bool dslp) IRAM_ATTR uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp) { if (!dslp) { -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM psram_ctrlr_ll_wait_all_transaction_done(); #if CONFIG_PM_SLP_SPIRAM_HALFSLEEP_ENABLED esp_psram_impl_enter_halfsleep_mode(); @@ -390,7 +390,7 @@ IRAM_ATTR bool pmu_sleep_finish(bool dslp) rtc_clk_mpll_enable(); rtc_clk_mpll_configure(clk_hal_xtal_get_freq_mhz(), s_mpll_freq_mhz_before_sleep, false); } -#if CONFIG_SPIRAM +#if !BOOTLOADER_BUILD && CONFIG_SPIRAM mspi_ll_psram_unhold_all_pins(); #if CONFIG_PM_SLP_SPIRAM_HALFSLEEP_ENABLED esp_psram_impl_exit_halfsleep_mode();