1919#include "esp_heap_caps.h"
2020
2121#include "esp_system.h"
22- #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
22+ #include "esp_psram.h"
23+ #include "esp_private/esp_psram_extram.h"
2324#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
24- #include "esp32/spiram .h"
25+ #include "esp32/rom/cache .h"
2526#elif CONFIG_IDF_TARGET_ESP32S2
26- #include "esp32s2/spiram.h"
2727#include "esp32s2/rom/cache.h"
2828#elif CONFIG_IDF_TARGET_ESP32S3
29- #include "esp32s3/spiram.h"
3029#include "esp32s3/rom/cache.h"
3130#else
3231#error Target CONFIG_IDF_TARGET is not supported
3332#endif
34- #else // ESP32 Before IDF 4.0
35- #include "esp_spiram.h"
36- #endif
3733
3834static volatile bool spiramDetected = false;
3935static volatile bool spiramFailed = false;
4036
4137//allows user to bypass SPI RAM test routine
4238__attribute__((weak )) bool testSPIRAM (void )
4339{
44- return esp_spiram_test ();
40+ return esp_psram_extram_test ();
4541}
4642
4743
@@ -66,7 +62,7 @@ bool psramInit(){
6662 esp_config_data_cache_mode ();
6763 Cache_Enable_DCache (0 );
6864#endif
69- if (esp_spiram_init () != ESP_OK ) {
65+ if (esp_psram_init () != ESP_OK ) {
7066 spiramFailed = true;
7167 log_w ("PSRAM init failed!" );
7268#if CONFIG_IDF_TARGET_ESP32
@@ -77,14 +73,14 @@ bool psramInit(){
7773#endif
7874 return false;
7975 }
80- esp_spiram_init_cache ();
76+
8177 //testSPIRAM() allows user to bypass SPI RAM test routine
8278 if (!testSPIRAM ()) {
8379 spiramFailed = true;
8480 log_e ("PSRAM test failed!" );
8581 return false;
8682 }
87- if (esp_spiram_add_to_heapalloc () != ESP_OK ) {
83+ if (esp_psram_extram_add_to_heap_allocator () != ESP_OK ) {
8884 spiramFailed = true;
8985 log_e ("PSRAM could not be added to the heap!" );
9086 return false;
0 commit comments