ESP32: flash compiled firmware and filesystem (.bin) with GUI tools – 2

Spread the love

The ESP32 boasts a crucial capability that streamlines the sharing of firmware, which most manufacturers widely utilize. This capability involves creating a pre-compiled binary file containing the sketch portion (or filesystem).

ESP32: compiled binary (.hex) with command line and GUI tool
ESP32: compiled binary (.hex) with command line and GUI tool

You can compile and generate source code for your device, but you can generate a binary file for the filesystem, also.

Espressif offers a GUI tool also to simplify the upload process.

Here some common esp32 device I use ESP32 Dev Kit v1 - TTGO T-Display 1.14 ESP32 - NodeMCU V3 V2 ESP8266 Lolin32 - NodeMCU ESP-32S - WeMos Lolin32 - WeMos Lolin32 mini - ESP32-CAM programmer - ESP32-CAM bundle - ESP32-WROOM-32 - ESP32-S

Basic tools

First, we look that the core component of ESP32 core needs python installed, and when installing It remember to add to the path (for windows)

ESP Tools Install Python and add It to path
ESP Tools Install Python and add It to path

upload.py or esptool.py

In your installation of Arduino IDE, you can find upload.py, the file that is the same of esptool.py.

You can install only esptool.py for python with a simple command

pip install esptool

or you can download from here the compiled version; remember to add the executable to the path.

Flash with Espressif download tool

The same operation (after installing python and esptool) can be done with the Espressif Download Tool, which you can download from here.

Export the sketch binary only

To use the exported binary file, you must remember the address 0x10000, which identifies the writing address of the firmware.

You must link the bin file (check to the left), set the correct address and select the specs of your microcontroller.

esp32 espressif download tool sketch binary file only
esp32 espressif download tool sketch binary file only

Compiled and filesystem binary

To learn more about the ESP32 filesystem, It’s important that you read

We are going to do a test. I got a sketch from the tutorial “ESP32: integrated SPIFFS FileSystem“, and I created a data folder with file1.txt and file2.txt.

/*
 *  ESP32
 *  SPIFFS get info, read dir and show all file uploaded
 *  add a data folder to use with ESP32 Sketch data uploader
 *  by Mischianti Renzo <https://mischianti.org>
 *
 *  https://mischianti.org
 *
 */
 
#include "Arduino.h"
#include "SPIFFS.h"
 
void printDirectory(File dir, int numTabs = 3);
 
void setup()
{
    Serial.begin(115200);
 
    delay(500);
 
    Serial.println(F("Inizializing FS..."));
    if (SPIFFS.begin()){
        Serial.println(F("done."));
    }else{
        Serial.println(F("fail."));
    }
 
    // To format all space in SPIFFS
    // SPIFFS.format()
 
    // Get all information of your SPIFFS
 
    unsigned int totalBytes = SPIFFS.totalBytes();
    unsigned int usedBytes = SPIFFS.usedBytes();
 
    Serial.println("File sistem info.");
 
    Serial.print("Total space:      ");
    Serial.print(totalBytes);
    Serial.println("byte");
 
    Serial.print("Total space used: ");
    Serial.print(usedBytes);
    Serial.println("byte");
 
    Serial.println();
 
    // Open dir folder
    File dir = SPIFFS.open("/");
    // Cycle all the content
    printDirectory(dir);
}
 
void loop()
{
 
}
 
void printDirectory(File dir, int numTabs) {
  while (true) {
 
    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}

This sketch gets the list of files and some SPIFFS information; here is the upload command from the console.

C:\Users\renzo\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.0.0/esptool.exe --chip esp32 --port COM26 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\renzo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/partitions/boot_app0.bin 0x1000 C:\Users\renzo\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/bin/bootloader_qio_80m.bin 0x10000 C:\Users\renzo\AppData\Local\Temp\arduino_build_303630/read_dir_spiffs.ino.bin 0x8000 C:\Users\renzo\AppData\Local\Temp\arduino_build_303630/read_dir_spiffs.ino.partitions.bin 

and the uploading of SPIFFS,

[SPIFFS] data   : D:\tmp\testSPIFFS\read_dir_spiffs\data
[SPIFFS] offset : 0
[SPIFFS] start  : 1376256
[SPIFFS] size   : 704
[SPIFFS] page   : 256
[SPIFFS] block  : 4096
->/file1.txt
->/file2.txt
[SPIFFS] upload : C:\Users\renzo\AppData\Local\Temp\arduino_build_303630/read_dir_spiffs.spiffs.bin
[SPIFFS] address: 1376256
[SPIFFS] port   : COM26
[SPIFFS] speed  : 921600
[SPIFFS] mode   : dio
[SPIFFS] freq   : 80m

Pay attention address 1376256 in HEX is 0x150000

the serial output is now

Inizializing FS...
done.
File sistem info.
Total space:      655361byte
Total space used: 1004byte

			/file1.txt		5
			/file2.txt		5

Now we change it a little the sketch:

    Serial.println(F("Inizializing FS 2..."));

and I add file3.txt to spiffs, disconnected the device and regenerated all.

Pay attention LittleFS and SPIFFS have the same partition table, FFat no.

Now upload with Espressif Download Tool

esp32 espressif download tool all binary files with filesystem
esp32 espressif download tool all binary files with a filesystem

We can check that the sketch is updated.

Combine all binary in one file

Now we are going to combine all files. This generates a taget.bin file, erases the microcontroller firmware with the tool, and we are going to upload the combined file.

Pay attention the start address for combined file is 0x0.

esp32 espressif download tool combined binary and filesystem files
esp32 espressif download tool combined binary and filesystem files

Thanks

  1. ESP32: pinout, specs and Arduino IDE configuration
  2. ESP32: integrated SPIFFS Filesystem
  3. ESP32: manage multiple Serial and logging
  4. ESP32 practical power saving
    1. ESP32 practical power saving: manage WiFi and CPU
    2. ESP32 practical power saving: modem and light sleep
    3. ESP32 practical power saving: deep sleep and hibernation
    4. ESP32 practical power saving: preserve data, timer and touch wake up
    5. ESP32 practical power saving: external and ULP wake up
    6. ESP32 practical power saving: UART and GPIO wake up
  5. ESP32: integrated LittleFS FileSystem
  6. ESP32: integrated FFat (Fat/exFAT) FileSystem
  7. ESP32-wroom-32
    1. ESP32-wroom-32: flash, pinout, specs and IDE configuration
  8. ESP32-CAM
    1. ESP32-CAM: pinout, specs and Arduino IDE configuration
    2. ESP32-CAM: upgrade CamerWebServer with flash features
  9. ESP32: use ethernet w5500 with plain (HTTP) and SSL (HTTPS)
  10. ESP32: use ethernet enc28j60 with plain (HTTP) and SSL (HTTPS)
  11. How to use SD card with esp32
  12. esp32 and esp8266: FAT filesystem on external SPI flash memory
  1. Firmware and OTA update management
    1. Firmware management
      1. ESP32: flash compiled firmware (.bin)
      2. ESP32: flash compiled firmware and filesystem (.bin) with GUI tools
    2. OTA update with Arduino IDE
      1. ESP32 OTA update with Arduino IDE: filesystem, firmware, and password
    3. OTA update with Web Browser
      1. ESP32 OTA update with Web Browser: firmware, filesystem, and authentication
      2. ESP32 OTA update with Web Browser: upload in HTTPS (SSL/TLS) with self-signed certificate
      3. ESP32 OTA update with Web Browser: custom web interface
    4. Self OTA uptate from HTTP server
      1. ESP32 self OTA update firmware from the server
      2. ESP32 self OTA update firmware from the server with version check
      3. ESP32 self-OTA update in HTTPS (SSL/TLS) with trusted self-signed certificate
    5. Non-standard Firmware update
      1. ESP32 firmware and filesystem update from SD card
      2. ESP32 firmware and filesystem update with FTP client
  1. Integrating LAN8720 with ESP32 for Ethernet Connectivity with plain (HTTP) and SSL (HTTPS)
  2. Connecting the EByte E70 to ESP32 c3/s3 devices and a simple sketch example
  3. ESP32-C3: pinout, specs and Arduino IDE configuration
  4. Integrating W5500 with ESP32 Using Core 3: Native Ethernet Protocol Support with SSL and Other Features
  5. Integrating LAN8720 with ESP32 Using Core 3: Native Ethernet Protocol Support with SSL and Other Features
  6. Dallas ds18b20:
    • Dallas ds18b20 with esp32 and esp8266: introduction and parasite mode
    • Dallas ds18b20 with esp32 and esp8266: pull-up P-MOSFET gate and alarms
    • Dallas ds18b20 with esp32 and esp8266: all OneWire topologies, long stubs and more devices

Spread the love

3 Responses

  1. Alain Parent says:

    I made many test to create an export apps using your solution to export app.
    It work fine if no file system is used. I implement the LittleFs in my projets.
    The informations about this second phase is not clear for me.
    Do you have a post link to share details about my projets?

  2. Alain Parent says:

    Hi Renzo,
    thk for suggestion.
    I will later
    and nice application .
    My need is exact the same in the forum. I wlll work on my side to do it: include LittelFs in export app.

Leave a Reply

Your email address will not be published. Required fields are marked *