Browse Source

esp32: add heap status variables

Add status variables to show the state of the heap when dumping config.
H. Peter Anvin 1 year ago
parent
commit
ba66b02d21

+ 4 - 0
common/sysvars.vars

@@ -62,3 +62,7 @@ net.sta.ip4.gw		ip
 net.sta.ip4.mask	ip
 net.sta.mac		mac
 net.sta.ssid		str
+heap.sram.free		uint
+heap.sram.max		uint
+heap.spiram.free	uint
+heap.spiram.max		uint

+ 14 - 3
esp32/max80/max80.ino

@@ -50,7 +50,18 @@ static void heap_info()
     size_t sl = heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM);
     size_t sa = heap_caps_get_free_size(MALLOC_CAP_SPIRAM);
 
-    printf("Heap: sram %zu/%zu, spiram %zu/%zu\n", il, ia, sl, sa);
+    char msg_buffer[128];
+    snprintf(msg_buffer, sizeof msg_buffer,
+	     "Heap: sram %zu/%zu, spiram %zu/%zu\n",
+	     il, ia, sl, sa);
+
+    fputs(msg_buffer, stdout);
+    Serial.print(msg_buffer);
+
+    setvar_uint(status_heap_sram_max, il);
+    setvar_uint(status_heap_sram_free, ia);
+    setvar_uint(status_heap_spiram_max, sl);
+    setvar_uint(status_heap_spiram_free, sa);
 }
 
 #if 0
@@ -104,9 +115,8 @@ void setup() {
     heap_info();
 
     TTY::init();
-    heap_info();
-
     sysvar_init();
+    heap_info();
 
     printf("[FW]   MAX80 firmware compiled on %s\n", fwdate);
     printf("[PCB]  MAX80 board version: %s\n", board_info.version_str);
@@ -174,6 +184,7 @@ void loop() {
 
     if (do_log_config_status) {
 	do_log_config_status = false;
+	heap_info();
 	log_config_status();
     }
 

BIN
esp32/output/max80.ino.bin


+ 2 - 2
fpga/max80.qpf

@@ -19,12 +19,12 @@
 #
 # Quartus Prime
 # Version 22.1std.2 Build 922 07/20/2023 SC Lite Edition
-# Date created = 18:46:49  September 30, 2023
+# Date created = 18:58:57  September 30, 2023
 #
 # -------------------------------------------------------------------------- #
 
 QUARTUS_VERSION = "22.1"
-DATE = "18:46:49  September 30, 2023"
+DATE = "18:58:57  September 30, 2023"
 
 # Revisions
 

BIN
fpga/output/bypass.jic


BIN
fpga/output/max80.fw


BIN
fpga/output/v1.fw


BIN
fpga/output/v1.jic


BIN
fpga/output/v1.sof


BIN
fpga/output/v2.fw


BIN
fpga/output/v2.jic


BIN
fpga/output/v2.sof


+ 1 - 1
rv32/checksum.h

@@ -1,4 +1,4 @@
 #ifndef CHECKSUM_H
 #define CHECKSUM_H
-#define SDRAM_SUM 0x26731e5a
+#define SDRAM_SUM 0x858c32df
 #endif