Freeze web files

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
facuver_26
Posts: 3
Joined: Sun Nov 22, 2020 5:11 pm

Freeze web files

Post by facuver_26 » Wed Jul 07, 2021 12:52 pm

Hello everyone, I have been working on a project that includes a microdot web server on an ESP32.
Is still a work in progress but I would like to start freezing some binaries with all the files in it (.html , .js , .css . json).
I already try with data_to_py.py (https://github.com/peterhinch/micropyth ... a_to_py.py) but the files size go way up. Also try to unpack a .tar file with everything in it but I still need to put the file manually.
For now the best solution that I find is the microfreezer tool (https://github.com/insighio/microfreezer) but I need to modify the microwave.py and the files folder to work in a micropython 1.16.

Anyone knows a better way to put all the files in a single bin image.

Here is my project if you want to read the code.
https://github.com/facuver/iSpindel_Repeater

Thanks in advance.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Freeze web files

Post by jimmo » Thu Jul 08, 2021 1:14 am

=
facuver_26 wrote:
Wed Jul 07, 2021 12:52 pm
Anyone knows a better way to put all the files in a single bin image.
Is your goal to just be able to create a single firmware image for your device that includes everything?

In which case maybe it would be easier to just make a firmware image that instead of just including the MicroPython firmware, also includes the full device filesystem.

For background -- when you flash micropython.bin to your ESP32, it just writes the first section of flash, leaving the rest of the flash untouched (and this is where teh filesystem lives). But nothing stops you making a single .bin file that contains the entire flash.

By far the easiest way to do this is to set up a device exactly how you want it, and then use esptool.py to download the flash back to your PC.

facuver_26
Posts: 3
Joined: Sun Nov 22, 2020 5:11 pm

Re: Freeze web files

Post by facuver_26 » Thu Jul 08, 2021 3:27 pm

Thanks, I will try that.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Freeze web files

Post by pythoncoder » Fri Jul 09, 2021 11:45 am

facuver_26 wrote:
Wed Jul 07, 2021 12:52 pm
...
I already try with data_to_py.py (https://github.com/peterhinch/micropyth ... a_to_py.py) but the files size go way up...
The data_to_py library converts arbitrary data to Python source. This does increase file size. The library's aim is to reduce RAM usage. Converting to Python only makes sense if you freeze the resultant Python code as bytecode. The data can then be accessed directly from flash with minimal RAM usage.

If you need to minimise space in your filesystem I'd look at traditional compression techniques.
Peter Hinch
Index to my micropython libraries.

Post Reply