How to get miniz working.

mohammedahmed248
Posts: 1
Joined: Wed May 29, 2019 4:14 pm

How to get miniz working.

Postby mohammedahmed248 » Wed May 29, 2019 9:13 pm

Hey guys, I am very new to the ESP32 environment, so bear with me. I am wanting to compress/decompress a file in the ESP32, and I saw that a library called miniz is included in the idf. But I am honestly completely clueless on how to use this library, as there isn't an example for it. If anyone can help guide me in the right direction , I would greatly appreciate it. Thank you for your time!

User avatar
fasani
Posts: 197
Joined: Wed Jan 30, 2019 12:00 pm
Location: Barcelona
Contact:

Re: How to get miniz working.

Postby fasani » Wed Dec 11, 2019 9:13 am

There is an example on the IDF :

https://github.com/espressif/esp-idf/bl ... st_miniz.c

Now keep in mind that #include "esp32/rom/miniz.h" includes only the low level deflate / inflate methods.
I'm sending compressed data (led matrix video) from an Android app and I found Brotli to be a very reliable decompressor for ESP32. Check google's library with my fork to update headers and tests for ESP32 here:

https://github.com/martinberlin/brotli
epdiy collaborator | http://fasani.de Fan of Espressif MCUs and electronic design

flipatoms
Posts: 3
Joined: Mon Sep 23, 2019 8:45 pm

Re: How to get miniz working.

Postby flipatoms » Fri Oct 02, 2020 2:13 pm

I've managed to get miniz working in my project by inluding both .c and .h
Only problem is I don't have enough ram to run compress function.

Is there any plan to include a compression lib in esp-idf that will work out of the box without tweeking? (I think a lot of people will appreciate that)

We are running an IoT startup and need to send log data etc to AWS IOT. Would help a lot if we could compress log files before transfer.

Sprite
Espressif staff
Espressif staff
Posts: 10594
Joined: Thu Nov 26, 2015 4:08 am

Re: How to get miniz working.

Postby Sprite » Fri Oct 02, 2020 2:49 pm

I don't think lack of ram is a problem that is easily solvable... due to the nature of zlib-style compression, the compressor needs to keep large chunks of data in RAM to compare incoming data with, to see if it can be replaced by a backreference.

flipatoms
Posts: 3
Joined: Mon Sep 23, 2019 8:45 pm

Re: How to get miniz working.

Postby flipatoms » Fri Oct 02, 2020 4:46 pm

I see. Though there seems to be a lot of people that got it running....

Anyone who know about other compression lib that is more lightweight?

nopnop2002
Posts: 347
Joined: Thu Oct 03, 2019 10:52 pm
Contact:

Re: How to get miniz working.

Postby nopnop2002 » Tue Jan 23, 2024 10:13 am

>Anyone who know about other compression lib that is more lightweight?

zlib is more lightweight.

Works with ESP32C2 with small RAM.

https://github.com/nopnop2002/esp-idf-zlib

DrMickeyLauer
Posts: 209
Joined: Sun May 22, 2022 2:42 pm

Re: How to get miniz working.

Postby DrMickeyLauer » Tue Jan 23, 2024 2:17 pm

https://github.com/atomicobject/heatshrink claims to work with memory footprints of 50 bytes. I'm not sure how it compares in terms of compression size, but it's on my to-evaluate list.

Sprite
Espressif staff
Espressif staff
Posts: 10594
Joined: Thu Nov 26, 2015 4:08 am

Re: How to get miniz working.

Postby Sprite » Wed Jan 24, 2024 8:52 am

https://github.com/atomicobject/heatshrink claims to work with memory footprints of 50 bytes. I'm not sure how it compares in terms of compression size, but it's on my to-evaluate list.
I used that a long time ago. It's pretty decent, albeit not as efficient as zlib.

xryl669
Posts: 9
Joined: Tue Oct 09, 2018 4:31 pm

Re: How to get miniz working.

Postby xryl669 » Mon Sep 15, 2025 3:26 pm

There's also https://github.com/X-Ryl669/tinytinycompress which implement both a compressor and decompressor with as small as 4 bytes for required RAM (and configurable RAM for compressor, can be as low as 128 bytes). It's probably not as efficient as zlib, but it's darn fast and doesn't have any impact on the other code so it can be dropped in easily.

Who is online

Users browsing this forum: ChatGPT-User, Google [Bot], meta-externalagent and 7 guests