One .bin contains binary image and web files

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

One .bin contains binary image and web files

Postby snahmad75 » Thu May 31, 2018 2:34 pm

Hi,

I would like to generate one .bin files containing my main application(firmware) binary image and some HTML, JS and css files.

How can I extract it and run OTA for firmware and later extract web files and write to FatFS.

Is there unzip available in esp32 using C/C++


Thanks,
Naeem.

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

Re: One .bin contains binary image and web files

Postby kolban » Thu May 31, 2018 3:00 pm

There are two techniques that I have found useful ... one is to use the ESP-IDF make system and use the "COMPONENT_EMBED_FILES" mechanism (can be found and studied by google). The other is to turn the binary file into a C include file using the "xxd" tool. Both of those will build binary that can be embedded in the flash image that is pushed to the ESP32 during flash.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: One .bin contains binary image and web files

Postby snahmad75 » Thu May 31, 2018 4:09 pm

I am talking about update over the air update. uploading .bin file via http post once transfer over http. extract using C/C++ and update firmware and write list of web files to file system.

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

Re: One .bin contains binary image and web files

Postby kolban » Thu May 31, 2018 5:15 pm

In order to create a firmware image that contains code and data, you must somehow "package" that data into your firmware image. The last post provided two possible recipes for doing that. At this point you have a large firmware image that can be sent via OTA and will cause a boot. Now that your application is running, you can extract the content from the firmware image and write that content as files on the file system.

Whether this is a "good idea" or not, I can't yet say. Having the data in flash twice doesn't feel right. What I mean by this is that if you build a binary image which contains code + data ... and then you copy that data into files also contained in flash, you now have two copies of the data in flash. The one that came with the OTA upload of the original firmware and the one you used to write into the file system. If it were me, I'd look at the puzzle holistically. Maybe you reserve part of your update process for OTA of "just executable code" and a second part of your update process to using FTP or HTTP or MQTT or sockets to source the data you want to write into the files.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: One .bin contains binary image and web files

Postby snahmad75 » Thu May 31, 2018 8:02 pm

Yes it makes senses to have separate files for .bin and data files separate http/ftp get and write to disk.

Who is online

Users browsing this forum: jtroncin21 and 105 guests