GiorgosXou / NeuralNetworks

A resource-conscious neural network implementation for MCUs
MIT License
70 stars 21 forks source link

failed: heap_caps_free heap_caps.c:381 (heap != NULL && "free() target pointer is outside heap areas") #20

Closed GiorgosXou closed 7 months ago

GiorgosXou commented 7 months ago

If you get this error in "serial monitor" when trying to deploy a NN in PROGMEM

failed: heap_caps_free heap_caps.c:381 (heap != NULL && "free() target pointer is outside heap areas")
Core  0 register dump:
MEPC    : 0x40381cdc  RA      : 0x40384d60  SP      : 0x3fc95150  GP      : 0x3fc8ba00  
TP      : 0x3fc8add4  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x3fc952ed  S1      : 0x0000005a  A0      : 0x3fc951b4  A1      : 0x3fc8c98d  
A2      : 0x00000001  A3      : 0x00000029  A4      : 0x00000001  A5      : 0x3fc8f000  
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x3fc951a8  S3      : 0x00000001  
S4      : 0x3fc951a8  S5      : 0x4038215a  S6      : 0x00000000  S7      : 0x00000000  
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
MHARTID : 0x00⸮⸮⸮⸮ ⸮⸮

Then just add && !defined(USE_PROGMEM) and #if !defined(USE_PROGMEM) to the destructor lines:

https://github.com/GiorgosXou/NeuralNetworks/blob/31bb95e4cefcaefb28f6b031a634ded6c7274a7d/src/NeuralNetwork.h#L578-L584

https://github.com/GiorgosXou/NeuralNetworks/blob/31bb95e4cefcaefb28f6b031a634ded6c7274a7d/src/NeuralNetwork.h#L586-L587

https://github.com/GiorgosXou/NeuralNetworks/blob/31bb95e4cefcaefb28f6b031a634ded6c7274a7d/src/NeuralNetwork.h#L602-L605