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

Spread the love

An important features that simplify the sharing of firmware (and It is used by the most productor) is to generate pre-compiled binary file with only the sketch part (or filesystem).

esp8266 flash firmware e filesystem binaro compilato con strumenti con interfaccia grafica
esp8266 flash firmware e filesystem binaro compilato con strumenti con interfaccia grafica

Espressif also offers a graphical tool to simplify this process.

I usually use these devices WeMos D1 mini - NodeMCU V2 V2.1 V3 - esp01 - esp01 programmer

Basic tools

First we look that the core component of esp8266 core need python installed, and when install It remember to add to 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 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 path.

Flash firmware binary with Espressif download tool

The same operation (after install python and esptool) can be do with the Espressif Download Tool, that you can download from here.

If you understand the above commands, it is very easy to use.

You must link the bin file, set the correct address and select the specs of your microcontroller.

esp8266 esp32 espressif download tool flash compiled binary
esp8266 esp32 espressif download tool flash compiled binary

click to start, at the end reboot the device.

Generate binary filesystem file

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

Add verbose output to Arduino IDE

To better understand all process we are going to enable verbose output on our Arduino IDE. You can find this options on File -> Preferences and check Show verbose output checks.

Arduino IDE enable show verbose ouput
Arduino IDE enable show verbose ouput

Now we can grab and reuse console commands.

Prerequisite

For the filesystem we can do the same, but first you need to read one of the following guides:

WeMos D1 mini (esp8266), integrated SPIFFS Filesystem (deprecated)

WeMos D1 mini (esp8266), integrated LittleFS Filesystem (reccomended)

Now we are going to add data directory to the sketch folder (with some files), and use the plugin to upload.

esp8266 LittleFS plugin menu on ArduinoIDE
esp8266 LittleFS plugin menu on ArduinoIDE

In the console we find the right command to generate this file.

[LittleFS] data    : D:\tmp\testBlink\Blink\data
[LittleFS] size    : 2024
[LittleFS] page    : 256
[LittleFS] block   : 8192
/bombo.png
[LittleFS] upload  : C:\Users\renzo\AppData\Local\Temp\arduino_build_49036/Blink.mklittlefs.bin
[LittleFS] address : 0x200000
[LittleFS] reset   : --before default_reset --after hard_reset
[LittleFS] port    : COM17
[LittleFS] speed   : 921600
[LittleFS] python   : C:\Users\renzo\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1\python3.exe
[LittleFS] uploader : C:\Users\renzo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\tools\upload.py

esptool.py v2.8
Serial port COM17
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 50:02:91:74:fe:11
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 2072576 bytes to 48389...
Wrote 2072576 bytes (48389 compressed) at 0x00200000 in 4.9 seconds (effective 3416.7 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

We can now see a lot of information, including the location of the file

[LittleFS] upload  : C:\Users\renzo\AppData\Local\Temp\arduino_build_49036/Blink.mklittlefs.bin

and the address

[LittleFS] address : 0x200000

Upload via command prompt

Than we can rebuild the command

:\Users\renzo\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1/python3 C:\Users\renzo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4/tools/upload.py --chip esp8266 --port COM17 --baud 921600 --before default_reset --after hard_reset write_flash 0x200000 C:\Users\renzo\AppData\Local\Temp\arduino_build_49036/Blink.mklittlefs.bin

The most important information is the address, I select 2Mb of FS and the relative address is that in console.

Upload with Espressif Download Tool

With the gui we must simply set the correct file and address.

esp8266 espressif download tool flash filesystem littlefs spiffs binary
esp8266 espressif download tool flash filesystem littlefs spiffs binary

Combine binary files

Espressif Download tool can combine binary file with the button Combine, and generates a single binary file for the compiled and filesystem.

esp8266 espressif download tool combine binary files
esp8266 espressif download tool combine binary files

The size become the intere size of flash, in the case of WeMos D1 mini with 4Mb of flash the target file is 4Mb.

You can upload the new generated file by set the address 0x0.

Thanks

  1. Firmware management
    1. esp8266: flash firmware binary (.bin) compiled and signed
    2. esp8266: flash firmware and filesystem binary (.bin) compiled with GUI tools
  2. OTA update with Arduino IDE
    1. esp8266 OTA update with Arduino IDE: filesystem, signed and password
  3. OTA update with Web Browser
    1. esp8266 OTA update with Web Browser: firmware, filesystem and authentication
    2. esp8266 OTA update with Web Browser: sign the firmware and HTTPS (SSL/TLS)
    3. esp8266 OTA update with Web Browser: custom web interface
  4. Self OTA uptate from HTTP server
    1. esp8266 self OTA update firmware from server
    2. esp8266 self OTA update firmware from server with version check
    3. esp8266 self OTA update in HTTPS (SSL/TLS) with trusted self signed certificate
  5. Non standard Firmware update
    1. esp8266 firmware and filesystem update from SD card
    1. esp8266 firmware and filesystem update with FTP client


Spread the love

Leave a Reply

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