diff --git a/components/esp_hw_support/Kconfig.spiram.common b/components/esp_hw_support/Kconfig.spiram.common index e10d5cf588..92cd10be7e 100644 --- a/components/esp_hw_support/Kconfig.spiram.common +++ b/components/esp_hw_support/Kconfig.spiram.common @@ -2,7 +2,7 @@ # # sourced into the "SPIRAM config" submenu for ESP32 or ESP32S2 -# invisible option selected by ESP32_SPIRAM_SUPPORT || ESP32S2_SPIRAM_SUPPORT +# invisible option selected by ${target}_SPIRAM_SUPPORT config SPIRAM bool diff --git a/components/esp_hw_support/component.mk b/components/esp_hw_support/component.mk index 5876fe64d8..5e75d5e0e3 100644 --- a/components/esp_hw_support/component.mk +++ b/components/esp_hw_support/component.mk @@ -1,5 +1,5 @@ COMPONENT_SRCDIRS := . port/$(IDF_TARGET) -COMPONENT_ADD_INCLUDEDIRS := . include port/$(IDF_TARGET)/ include/soc port/$(IDF_TARGET)/private_include +COMPONENT_ADD_INCLUDEDIRS := . include port/$(IDF_TARGET)/ include/soc include/soc/${IDF_TARGET} port/$(IDF_TARGET)/private_include COMPONENT_ADD_LDFRAGMENTS := linker.lf ifdef IS_BOOTLOADER_BUILD diff --git a/components/esp_hw_support/include/soc/esp32s2/spiram.h b/components/esp_hw_support/include/soc/esp32s2/spiram.h index cc2b4c8549..47871e627f 100644 --- a/components/esp_hw_support/include/soc/esp32s2/spiram.h +++ b/components/esp_hw_support/include/soc/esp32s2/spiram.h @@ -91,6 +91,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/components/esp_hw_support/include/soc/esp32s3/spiram.h b/components/esp_hw_support/include/soc/esp32s3/spiram.h index 105a60543e..863f0c48aa 100644 --- a/components/esp_hw_support/include/soc/esp32s3/spiram.h +++ b/components/esp_hw_support/include/soc/esp32s3/spiram.h @@ -78,7 +78,14 @@ size_t esp_spiram_get_size(void); */ void esp_spiram_writeback_cache(void); - +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); /** * @brief Reserve a pool of internal memory for specific DMA/internal allocations @@ -91,6 +98,15 @@ void esp_spiram_writeback_cache(void); */ esp_err_t esp_spiram_reserve_dma_pool(size_t size); +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return + * - true SPI RAM has been initialized successfully + * - false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void); + #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS extern int _instruction_reserved_start, _instruction_reserved_end; diff --git a/components/esp_hw_support/port/esp32s2/spiram.c b/components/esp_hw_support/port/esp32s2/spiram.c index 242d434263..23cbd137bc 100644 --- a/components/esp_hw_support/port/esp32s2/spiram.c +++ b/components/esp_hw_support/port/esp32s2/spiram.c @@ -375,6 +375,15 @@ void IRAM_ATTR esp_spiram_writeback_cache(void) Cache_WriteBack_All(); } - +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return true SPI RAM has been initialized successfully + * @return false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void) +{ + return spiram_inited; +} #endif diff --git a/components/esp_hw_support/port/esp32s3/spiram.c b/components/esp_hw_support/port/esp32s3/spiram.c index 7d8d63a095..9d60dcedcf 100644 --- a/components/esp_hw_support/port/esp32s3/spiram.c +++ b/components/esp_hw_support/port/esp32s3/spiram.c @@ -329,4 +329,15 @@ void IRAM_ATTR esp_spiram_writeback_cache(void) Cache_WriteBack_All(); } +/** + * @brief If SPI RAM(PSRAM) has been initialized + * + * @return true SPI RAM has been initialized successfully + * @return false SPI RAM hasn't been initialized or initialized failed + */ +bool esp_spiram_is_initialized(void) +{ + return s_spiram_inited; +} + #endif