fix for PSRAM with new hapOut
Force hapOut to use internal memory only. Tested on ESP32-S2 with/without PSRAM. However, crashes on ESP32-S3 when using PSRAM (?!)
This commit is contained in:
parent
4269eca982
commit
bd474778e5
|
|
@ -73,7 +73,7 @@ void setup() {
|
|||
|
||||
Serial.begin(115200);
|
||||
|
||||
homeSpan.setLogLevel(1);
|
||||
homeSpan.setLogLevel(2);
|
||||
homeSpan.enableWebLog(500);
|
||||
|
||||
homeSpan.begin(Category::Lighting,"HomeSpan Max");
|
||||
|
|
|
|||
18
src/HAP.cpp
18
src/HAP.cpp
|
|
@ -1604,15 +1604,19 @@ void Nonce::inc(){
|
|||
|
||||
HapOut::HapStreamBuffer::HapStreamBuffer(){
|
||||
|
||||
buffer=(char *)HS_MALLOC(bufSize+1); // add 1 for adding null terminator when printing text
|
||||
encBuf=(uint8_t *)HS_MALLOC(bufSize+18); // 2-byte AAD + encrypted data + 16-byte authentication tag
|
||||
// note - must require all memory allocation to be pulled from INTERNAL heap only
|
||||
|
||||
const uint32_t caps=MALLOC_CAP_DEFAULT | MALLOC_CAP_INTERNAL;
|
||||
|
||||
buffer=(char *)heap_caps_malloc(bufSize+1,caps); // add 1 for adding null terminator when printing text
|
||||
encBuf=(uint8_t *)heap_caps_malloc(bufSize+18,caps); // 2-byte AAD + encrypted data + 16-byte authentication tag
|
||||
hash=(uint8_t *)heap_caps_malloc(48,caps); // space for SHA-384 hash output
|
||||
ctx = (mbedtls_sha512_context *)heap_caps_malloc(sizeof(mbedtls_sha512_context),caps); // space for hash context
|
||||
|
||||
hash=(uint8_t *)HS_MALLOC(48); // space for SHA-384 hash output
|
||||
ctx = (mbedtls_sha512_context *)HS_MALLOC(sizeof(mbedtls_sha512_context)); // space for hash context
|
||||
mbedtls_sha512_init(ctx); // initialize context
|
||||
mbedtls_sha512_starts_ret(ctx,1); // start SHA-384 hash (note second argument=1)
|
||||
mbedtls_sha512_init(ctx); // initialize context
|
||||
mbedtls_sha512_starts_ret(ctx,1); // start SHA-384 hash (note second argument=1)
|
||||
|
||||
setp(buffer, buffer+bufSize-1);
|
||||
setp(buffer, buffer+bufSize-1); // assign buffer pointers
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ class HapOut : public std::ostream {
|
|||
|
||||
HapStreamBuffer();
|
||||
~HapStreamBuffer();
|
||||
|
||||
};
|
||||
|
||||
HapStreamBuffer hapBuffer;
|
||||
|
|
@ -214,7 +215,7 @@ class HapOut : public std::ostream {
|
|||
public:
|
||||
|
||||
HapOut() : std::ostream(&hapBuffer){}
|
||||
|
||||
|
||||
HapOut& setHapClient(HAPClient *hapClient){hapBuffer.hapClient=hapClient;return(*this);}
|
||||
HapOut& setLogLevel(int logLevel){hapBuffer.logLevel=logLevel;return(*this);}
|
||||
HapOut& prettyPrint(){hapBuffer.enablePrettyPrint=true;hapBuffer.logLevel=0;return(*this);}
|
||||
|
|
|
|||
|
|
@ -185,10 +185,10 @@ void Span::pollTask() {
|
|||
processSerialCommand("i"); // print homeSpan configuration info
|
||||
|
||||
HAPClient::init(); // read NVS and load HAP settings
|
||||
|
||||
if(heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL)<DEFAULT_LOW_MEM_THRESHOLD)
|
||||
LOG0("\n**** WARNING! Low Internal RAM Watermark of %d bytes is less than Low Threshold of %d bytes. Device *may* run out of memory.\n\n",
|
||||
heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL),DEFAULT_LOW_MEM_THRESHOLD);
|
||||
|
||||
if(heap_caps_get_free_size(MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL)<DEFAULT_LOW_MEM_THRESHOLD)
|
||||
LOG0("\n**** WARNING! Internal Free Heap of %d bytes is less than Low-Memory Threshold of %d bytes. Device *may* run out of Internal memory.\n\n",
|
||||
heap_caps_get_free_size(MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL),DEFAULT_LOW_MEM_THRESHOLD);
|
||||
|
||||
if(!strlen(network.wifiData.ssid)){
|
||||
LOG0("*** WIFI CREDENTIALS DATA NOT FOUND. ");
|
||||
|
|
@ -823,14 +823,24 @@ void Span::processSerialCommand(const char *c){
|
|||
break;
|
||||
|
||||
case 'm': {
|
||||
LOG0("Free Heap Internal RAM : %7d bytes. Low: %7d\n",heap_caps_get_free_size(MALLOC_CAP_INTERNAL),heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
|
||||
#if defined(BOARD_HAS_PSRAM)
|
||||
LOG0("Free Heap SPI (PS) RAM : %7d bytes. Low: %7d\n",heap_caps_get_free_size(MALLOC_CAP_SPIRAM),heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
|
||||
#endif
|
||||
LOG0("Lowest stack level : %7d bytes\n",uxTaskGetStackHighWaterMark(NULL));
|
||||
multi_heap_info_t heapAll;
|
||||
multi_heap_info_t heapInternal;
|
||||
multi_heap_info_t heapPSRAM;
|
||||
|
||||
heap_caps_get_info(&heapAll,MALLOC_CAP_DEFAULT);
|
||||
heap_caps_get_info(&heapInternal,MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
|
||||
heap_caps_get_info(&heapPSRAM,MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM);
|
||||
|
||||
Serial.printf("\n Allocated Free Largest Low\n");
|
||||
Serial.printf(" --------- --------- --------- ---------\n");
|
||||
Serial.printf("Total Heap: %9d %9d %9d %9d\n",heapAll.total_allocated_bytes,heapAll.total_free_bytes,heapAll.largest_free_block,heapAll.minimum_free_bytes);
|
||||
Serial.printf(" Internal: %9d %9d %9d %9d\n",heapInternal.total_allocated_bytes,heapInternal.total_free_bytes,heapInternal.largest_free_block,heapInternal.minimum_free_bytes);
|
||||
Serial.printf(" PSRAM: %9d %9d %9d %9d\n\n",heapPSRAM.total_allocated_bytes,heapPSRAM.total_free_bytes,heapPSRAM.largest_free_block,heapPSRAM.minimum_free_bytes);
|
||||
|
||||
LOG0("Lowest stack level: %d bytes\n",uxTaskGetStackHighWaterMark(NULL));
|
||||
nvs_stats_t nvs_stats;
|
||||
nvs_get_stats(NULL, &nvs_stats);
|
||||
LOG0("NVS Flash Partition : %7d of %d records used\n\n",nvs_stats.used_entries,nvs_stats.total_entries-126);
|
||||
LOG0("NVS Flash Partition: %d of %d records used\n\n",nvs_stats.used_entries,nvs_stats.total_entries-126);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void setup() {
|
|||
Serial.begin(115200);
|
||||
|
||||
homeSpan.setLogLevel(2);
|
||||
homeSpan.enableWebLog(200);
|
||||
homeSpan.enableWebLog(500);
|
||||
|
||||
homeSpan.begin(Category::Lighting,"HomeSpan Max");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue