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).
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)
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.
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.
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.
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.
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.
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
- Firmware management
- OTA update with Arduino IDE
- OTA update with Web Browser
- Self OTA uptate from HTTP server
- Non standard Firmware update