Uploading .bin files to ESP32 without Arduino IDE
I recently needed to send new firmware for one of my products to a customer. While he had the neccessary USB-UART converter, he didn’t have any of the software (ie Arduino IDE with ESP32 boards and all the libraries) and I didn’t want to bother him with installing all of that.
Originally, I thought this would be simple – I’ll just generate the .bin file with compiled firmware, send it to him and tell him to download some sort of utility for uploading (that’s at least how it would work with the STM32’s – the utility being their excellent STM32CubeProgrammer). However, the workflow is a little bit more complicated than that, so in this article, I’d like to exaplain what I believe is the simplest method for uploading firmware to an ESP32.
Now, in order to not reinvent the wheel, there’s a pretty good video by Kevin Darrah on uplading compiled binaries to AVRs and ESPs. However, Kevin’s approach still requires the customer (or the end-user) to have Arduino IDE and ESP32 BSP installed (because it invokes the bootloaders etc. from ESP32’s Arduino installation). I wanted my process to be totally IDE-independent, so here’s how it works:
First, you turn on verbose output for uploading in Arduino IDE (File – Preferences) and copy the output. It should look like this:
C:\Users\name\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1/esptool.exe --chip esp32 --port COM12 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users\name\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/partitions/boot_app0.bin 0x1000 C:\Users\name\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4/tools/sdk/bin/bootloader_qio_80m.bin 0x10000 C:\Users\name\AppData\Local\Temp\arduino_build_75007/Sketch-Name.ino.bin 0x8000 C:\Users\name/Sketch-Name.ino.partitions.bin
The five long strings are paths to four *.bin files, which must be uploaded to the ESP32, and one .exe, which is the esptool itself. Now what I did is I copied all those five paths into Windows Explorer and copied the respective files into a single folder. This folder can then be zipped and send to the end user. He unzips it, copies the current path and replaces the <PATH> placeholder. The placeholder <PORT> also needs to be substituted with the relevant COM port name. So the final command looks like this:
<PATH>/esptool.exe --chip esp32 --port <PORT> --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 <PATH>/boot_app0.bin 0x1000 <PATH>/bootloader_qio_80m.bin 0x10000 <PATH>/Sketch-Name.ino.bin 0x8000 <PATH>/Sketch-Name.ino.partitions.bin
This command can then be executed in command line, or in Windows by simply pasting it into the Windows Explorer Address Bar (which is a nice trick for people who are not used to working with CMD).
This simple and relatively primitive approach has two advantages, I’d say – you don’t need to install anything (like some sketchy ESP GUI uploaders) or Python in case of the official ESP tool. And you of course don’t need to install the Arduino IDE or anything similar.