Flashing an ESP32 without compiling from a hex file
@ForrestErickson is already working on this.
Since Apr 11, 2025.
- Dominant language
- C++
- Stars
- 8
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
Is your feature request related to a problem? Please describe.
_A clear and concise description of what the problem is. Ex.
I'm always frustrated when I have to wait a long time for compiling code in the ARDUINO IDE when there have been no changes to flash an ESP32.
In a production environment I am always terrified that code may be corrupted.
Describe the solution you'd like
A clear and concise description of what you want to happen.
Upload a write protected HEX file
From Google AI
AI Overview
Here's a breakdown of how to achieve this: [1, 1] Example Command (using esptool.py): [1, 7]
esptool.py --chip esp32 --port COM3 --baud 921600 --before default_reset --after hard_reset write_flash -z 0x1000 --
- --chip esp32: Specifies the ESP32 chip type.
- --port COM3: Specifies the COM port your ESP32 is connected to.
- --baud 921600: Sets the baud rate for communication.
- --before default_reset --after hard_reset: Performs a default reset before and a hard reset after flashing.
- write_flash: Indicates that you want to write to the flash memory.
- -z: Instructs esptool.py to write only the changed parts of the flash memory.
- 0x1000: The starting address in flash memory where the binary file should be written.
- <path_to_your_bin_file>: The full path to your .bin file. [2, 2, 8, 9, 10]
Generative AI is experimental.[1] https://www.reddit.com/r/esp32/comments/9gvuy7/arduino_question_can_i_save_a_binary_instead_of/[2] https://www.cedarlakeinstruments.com/archives/990[3] https://dev.classmethod.jp/articles/esp32-upload-compiled-sketch-using-esptool-en/[4] https://www.quora.com/How-do-I-create-bin-binary-files-from-Sketch-on-Arduino-IDE[5] https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html[6] https://esp32.com/viewtopic.php?t=16334[7] https://forum.arduino.cc/t/programming-esp8266-without-compiling-every-time/472971[8] https://www.linkedin.com/posts/abdul-majeed-4976bb183_how-to-extract-a-binary-file-from-esp32-activity-7230168583685738498-B_in[9] https://www.espboards.dev/blog/standalone-esptool-basics/[10] https://esp32.com/viewtopic.php?t=9065
You can program an ESP32 without compiling from a hex file by using a binary file (bin) and a tool like esptool.py. Instead of generating a hex file, you can use the Arduino IDE to export a binary file directly, which can then be flashed to the ESP32 using esptool.py. [[1](https://www.reddit.com/r/esp32/comments/9gvuy7/arduino_question_can_i_save_a_binary_instead_of/), [2](https://www.cedarlakeinstruments.com/archives/990)] Here's a breakdown of how to achieve this: [[1](https://www.reddit.com/r/esp32/comments/9gvuy7/arduino_question_can_i_save_a_binary_instead_of/), [1](https://www.reddit.com/r/esp32/comments/9gvuy7/arduino_question_can_i_save_a_binary_instead_of/)]
-
Export a Binary File: [1, 1]
• Open your ESP32 sketch in the Arduino IDE. [1, 1]
• Go to "Sketch" -> "Export Compiled Binary". [1, 1]
• This will generate a .bin file in the same directory as your sketch. [1, 3, 4] -
Install esptool.py: [1, 1, 2, 5]
• You'll need to install esptool.py, a Python script for flashing ESP32 devices. [1, 1, 2, 2]
• You can find esptool.py on the ESPRESSIF GitHub repository. [1, 1] -
Flash the ESP32: [2, 6]
• Use esptool.py to flash the binary file to your ESP32. [2, 2]
• The command will vary slightly depending on your specific setup, but it generally involves specifying the COM port, baud rate, and the binary file to be flashed. [2, 2]
Example Command (using esptool.py): [1, 7]
esptool.py --chip esp32 --port COM3 --baud 921600 --before default_reset --after hard_reset write_flash -z 0x1000 <path_to_your_bin_file>
Explanation of the command: [2, 2]
• --chip esp32: Specifies the ESP32 chip type.
• --port COM3: Specifies the COM port your ESP32 is connected to.
• --baud 921600: Sets the baud rate for communication.
• --before default_reset --after hard_reset: Performs a default reset before and a hard reset after flashing.
• write_flash: Indicates that you want to write to the flash memory.
• -z: Instructs esptool.py to write only the changed parts of the flash memory.
• 0x1000: The starting address in flash memory where the binary file should be written.
• <path_to_your_bin_file>: The full path to your .bin file. [2, 2, 8, 9, 10]
In summary, instead of compiling and then flashing a hex file, you can directly export a .bin file from the Arduino IDE and then use esptool.py to flash it to your ESP32, skipping the need for compilation before flashing. [1, 2]
Generative AI is experimental.
[1] https://www.reddit.com/r/esp32/comments/9gvuy7/arduino_question_can_i_save_a_binary_instead_of/[2] https://www.cedarlakeinstruments.com/archives/990[3] [https://dev.classmethod.jp/articles/esp32-upload-compiled-sketch-using-esptool-en/](https://dev.classmethod.jp/articles/esp32-upload-compiled-sketch-using-esptool-en/#:~:text=Additional%20notes%20When%20you%20execute%20%22Export%20Compiled,a%20physically%20different%20board%20to%20your%20PC/Mac.)[4] https://www.quora.com/How-do-I-create-bin-binary-files-from-Sketch-on-Arduino-IDE[5] [https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html](https://docs.espressif.com/projects/esptool/en/latest/esp32/installation.html#:~:text=You%20can%20install%20it%20by%20a%20package,command%20esptool.py%20or%20python%20%2Dm%20esptool%20.)[6] https://esp32.com/viewtopic.php?t=16334[7] https://forum.arduino.cc/t/programming-esp8266-without-compiling-every-time/472971[8] [https://www.linkedin.com/posts/abdul-majeed-4976bb183_how-to-extract-a-binary-file-from-esp32-activity-7230168583685738498-B_in](https://www.linkedin.com/posts/abdul-majeed-4976bb183_how-to-extract-a-binary-file-from-esp32-activity-7230168583685738498-B_in#:~:text=%F0%9F%93%82%20%F0%9F%94%84%20Step%206:%20Uploading%20to%20Another,correct%20port%20for%20your%20target%20ESP32%20device.)[9] https://www.espboards.dev/blog/standalone-esptool-basics/[10] [https://esp32.com/viewtopic.php?t=9065](https://esp32.com/viewtopic.php?t=9065#:~:text=Can%20esptool.py%20be%20used%20to%20copy%20a,to%20write%20a%20binary%20blob%20to%20flash.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.