14
14
15
15
#include "esp32-hal.h"
16
16
17
- #if CONFIG_SPIRAM_SUPPORT
17
+ #if CONFIG_SPIRAM_SUPPORT || CONFIG_SPIRAM
18
18
#include "soc/efuse_reg.h"
19
19
#include "esp_heap_caps.h"
20
20
21
21
#include "esp_system.h"
22
22
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
23
23
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
24
24
#include "esp32/spiram.h"
25
+ #elif CONFIG_IDF_TARGET_ESP32S2
26
+ #include "esp32s2/spiram.h"
27
+ #include "esp32s2/rom/cache.h"
25
28
#else
26
29
#error Target CONFIG_IDF_TARGET is not supported
27
30
#endif
@@ -40,6 +43,7 @@ bool psramInit(){
40
43
if (spiramFailed ) {
41
44
return false;
42
45
}
46
+ #if CONFIG_IDF_TARGET_ESP32
43
47
uint32_t chip_ver = REG_GET_FIELD (EFUSE_BLK0_RDATA3_REG , EFUSE_RD_CHIP_VER_PKG );
44
48
uint32_t pkg_ver = chip_ver & 0x7 ;
45
49
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 || pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ) {
@@ -48,13 +52,21 @@ bool psramInit(){
48
52
return false;
49
53
}
50
54
esp_spiram_init_cache ();
55
+ #elif CONFIG_IDF_TARGET_ESP32S2
56
+ extern void esp_config_data_cache_mode (void );
57
+ esp_config_data_cache_mode ();
58
+ Cache_Enable_DCache (0 );
59
+ #endif
51
60
if (esp_spiram_init () != ESP_OK ) {
52
61
spiramFailed = true;
53
62
log_w ("PSRAM init failed!" );
63
+ #if CONFIG_IDF_TARGET_ESP32
54
64
pinMatrixOutDetach (16 , false, false);
55
65
pinMatrixOutDetach (17 , false, false);
66
+ #endif
56
67
return false;
57
68
}
69
+ esp_spiram_init_cache ();
58
70
if (!esp_spiram_test ()) {
59
71
spiramFailed = true;
60
72
log_e ("PSRAM test failed!" );
0 commit comments