miniz library in ROM - usable for application development?

User avatar
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: miniz library in ROM - usable for application development?

Postby kolban » Mon Jul 09, 2018 3:30 am

Thank you sir. I resolved the issue with using the ROM based tinfl_decompress(). I coded something very stupidly. In order to create a buffer to hold the decompressed output I coded:

Code: Select all

void app_main() {
   char outputBuffer[32*1024];
   ... rest of code
Does everyone see my mistake above?

The answer is that I am using default ESP-IDF and the stack size of the main FreeRTOS task is 4K. As coded above, I had allocated 32K on a 4K stack. When I then called tinfl_decompress() passing in the outputBuffer as where I wanted my results to go, I was grossly exceeding stack with all manner of strange and unusual breakage.

When corrected to use a malloc() 32K from the heap, everything fell into place and all is now working. Thanks for the notes on the use of miniz in an ESP8266 environment. I had miserably failed to consider that the stub loader was used in both ESP8266 and ESP32.
Free book on ESP32 available here:

User avatar
Posts: 90
Joined: Wed Jan 30, 2019 12:00 pm
Location: Berlin

Re: miniz library in ROM - usable for application development?

Postby fasani » Mon May 13, 2019 7:08 am

Hello Kolban,

Would please be so kind to share this example with us ?
I've trying to load bytes of a compressed file stored in SPIFFS:

$echo "hello Fibrevillage" | gzip -cf > /data/test.gz

Then uploaded to plataformio using :
pio run --target uploadfs

Code: Select all

 if(SPIFFS.begin()) {
    File cmpFile ="/test.gz", FILE_READ);
    char cmpFileBuf[cmpFile.size()];
int filePtr=0;
  cmpFileBuf[filePtr] =;
 // failing on the decompress part (Just code snippet from while...loop)
 if(remaining_compressed > length) {
   status = tinfl_decompress(&inflator, (const mz_uint8 *)cmpFileBuf, &in_bytes, out_buf, next_out, &out_bytes, flags); // Dies 

But I fail in the part that is using tinfl_decompress. It could be of great help if someone can post a working example of opening a GZ from SPIFFS and successfully uncompressing it using MINIZ
Backend developer-PHP Engineer ESP32 E-Ink Screen manager - Berlin, Germany

Who is online

Users browsing this forum: No registered users and 34 guests