Export compiled program (Arduino)
If a program is uploaded to a microcontroller from the Arduino IDE, the program must first be compiled. The compiler converts the program written in C or C++ into a machine language. This produces either a hex file (.hex file) or a bin file (.bin file) depending on your hardware. This article is about exporting codes to a HEX or BIN file from the Arduino IDE.
When is an export useful?
The hex and bin file contains the finished program including all integrated libraries. An export of this file is therefore useful when:
A program should be archived (backup)
The program code should not be changeable
The program code should not be visible
It happens again and again that libraries are no longer updated by the developers. In contrast, the Arduino IDE and the compiler are updated from time to time. The consequence is that compilation problems can occur. It can also happen that the compilation process was successful and yet the program or a hardware no longer works due to an old library. This can be prevented with a program export, as the compiled exported program is independent of the Arduino IDE version or libraries.
Changes to the code cannot be made after the compilation process. Also, the source code is no longer viewable after compiling.
Attention: There are tools that allow to decompile an already compiled file again. In practice, however, this works only conditionally. In simple terms, this means that you can get a rough overview of a compiled program, but a direct decompile, change and recompile is not possible.
Exporting from the Arduino IDE
Meanwhile the program export with the Arduino IDE is very simple. Under [Sketch] -> [Export compiled Binary] the program will be compiled and a file will be created afterwards. For ESP projects a .BIN file is created, AVR projects are saved as .HEX file. The file is saved directly to the project folder parallel to the .ino file. The following screenshot shows the export function in the Arduino IDE:
Upload without Arduino IDE
For the ESP32 there is an own flash tool, which can upload the previously exported BIN file. This is especially advantageous if the program is given to other people and there is no need to install an Arduino IDE. The Software and the instructions are in this article:
Info: This page was automatically translated and may contain errors