mirror of https://github.com/arendst/Tasmota.git
Merge pull request #13037 from s-hadinger/fix_psram_uninit
Fixed crash when PSRAM is absent and ``BOARD_HAS_PSRAM`` set
This commit is contained in:
commit
6711d464ed
|
@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## [9.5.0.8]
|
## [9.5.0.8]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed crash when PSRAM is absent and ``BOARD_HAS_PSRAM`` set
|
||||||
|
|
||||||
## [9.5.0.7] 20210901
|
## [9.5.0.7] 20210901
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -60,12 +60,10 @@ extern "C" {
|
||||||
#ifndef BERRY_LOGSZ
|
#ifndef BERRY_LOGSZ
|
||||||
#define BERRY_LOGSZ 700
|
#define BERRY_LOGSZ 700
|
||||||
#endif
|
#endif
|
||||||
extern "C" {
|
|
||||||
extern void *berry_malloc(size_t size);
|
|
||||||
}
|
|
||||||
static char * log_berry_buffer = nullptr;
|
static char * log_berry_buffer = nullptr;
|
||||||
static_block {
|
static_block {
|
||||||
log_berry_buffer = (char*) berry_malloc(BERRY_LOGSZ);
|
log_berry_buffer = (char*) malloc(BERRY_LOGSZ);
|
||||||
if (log_berry_buffer) log_berry_buffer[0] = 0;
|
if (log_berry_buffer) log_berry_buffer[0] = 0;
|
||||||
}
|
}
|
||||||
extern void berry_log(const char * berry_buf);
|
extern void berry_log(const char * berry_buf);
|
||||||
|
|
|
@ -464,10 +464,21 @@ uint8_t* FlashDirectAccess(void) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
bool esp_spiram_is_initialized(void);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this function is a replacement for `psramFound()`.
|
||||||
|
// `psramFound()` can return true even if no PSRAM is actually installed
|
||||||
|
// This new version also checks `esp_spiram_is_initialized` to know if the PSRAM is initialized
|
||||||
|
bool FoundPSRAM(void) {
|
||||||
|
return psramFound() && esp_spiram_is_initialized();
|
||||||
|
}
|
||||||
|
|
||||||
// new function to check whether PSRAM is present and supported (i.e. required pacthes are present)
|
// new function to check whether PSRAM is present and supported (i.e. required pacthes are present)
|
||||||
bool UsePSRAM(void) {
|
bool UsePSRAM(void) {
|
||||||
static bool can_use_psram = CanUsePSRAM();
|
static bool can_use_psram = CanUsePSRAM();
|
||||||
return psramFound() && can_use_psram;
|
return FoundPSRAM() && can_use_psram;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *special_malloc(uint32_t size) {
|
void *special_malloc(uint32_t size) {
|
||||||
|
@ -690,6 +701,7 @@ typedef struct {
|
||||||
* patches are present.
|
* patches are present.
|
||||||
*/
|
*/
|
||||||
bool CanUsePSRAM(void) {
|
bool CanUsePSRAM(void) {
|
||||||
|
if (!FoundPSRAM()) return false;
|
||||||
#ifdef HAS_PSRAM_FIX
|
#ifdef HAS_PSRAM_FIX
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -275,14 +275,17 @@ void setup(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLog(LOG_LEVEL_INFO, PSTR("ADR: Settings %p, Log %p"), Settings, TasmotaGlobal.log_buffer);
|
// AddLog(LOG_LEVEL_INFO, PSTR("ADR: Settings %p, Log %p"), Settings, TasmotaGlobal.log_buffer);
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("HDW: %s"), GetDeviceHardware().c_str());
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("HDW: psramFound=%i CanUsePSRAM=%i"), psramFound(), CanUsePSRAM());
|
AddLog(LOG_LEVEL_INFO, PSTR("HDW: %s %s"), GetDeviceHardware().c_str(),
|
||||||
#endif // ESP32
|
FoundPSRAM() ? (CanUsePSRAM() ? "(PSRAM)" : "(PSRAM disabled)") : "" );
|
||||||
#if defined(ESP32) && !defined(HAS_PSRAM_FIX)
|
AddLog(LOG_LEVEL_DEBUG, PSTR("HDW: FoundPSRAM=%i CanUsePSRAM=%i"), FoundPSRAM(), CanUsePSRAM());
|
||||||
if (psramFound() && !CanUsePSRAM()) {
|
#if !defined(HAS_PSRAM_FIX)
|
||||||
|
if (FoundPSRAM() && !CanUsePSRAM()) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR("HDW: PSRAM is disabled, requires specific compilation on this hardware (see doc)"));
|
AddLog(LOG_LEVEL_INFO, PSTR("HDW: PSRAM is disabled, requires specific compilation on this hardware (see doc)"));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#else // ESP32
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("HDW: %s"), GetDeviceHardware().c_str());
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
#ifdef USE_UFILESYS
|
#ifdef USE_UFILESYS
|
||||||
|
|
Loading…
Reference in New Issue