fbpixel
Tags: ,

When you have a number of Arduino boards to flash with the same program, it can be interesting to flash the HEX compiled file directly. This has two interests. It saves you time on uploading and it allows third parties to upload a program without using the Arduino IDE.

You should not need it every day but I will show you the method to generate the HEX file and upload it to an Arduino microcontroller. This method can be adapted for other microcontrollers like ESP8266 and ESP32 with other tools.

Generate the HEX file with the Arduino IDE

In the Arduino software, go to the File menu then Preferences.

Check the boxes “detailed results during” for compilation and upload (Verbose mode)

arduino-preference-verbose-mode Generating and uploading HEX files to an Arduino

Select the port and type of card to which you want to upload the program.

When you press Compile or Upload, the Arduino IDE creates a build file in the folder AppData\Local\Temp\ in which the HEX file is located. You can find the name of the file in the console of the IDE during the compilation or the upload.

After the compilation:

arduino-preference-verbose-mode-result-arduino Generating and uploading HEX files to an Arduino

After an upload:

arduino-preference-verbose-upload-result-arduino Generating and uploading HEX files to an Arduino

You can copy the generated HEX file somewhere else on your computer.

Upload the HEX file using the Windows command prompt

After launching the upload on the Arduino IDE, you get the upload command.

arduino-preference-verbose-upload-result-arduino Generating and uploading HEX files to an Arduino

You can copy this line to the command prompt to upload the program to the microcontroller. Don’t forget to modify with the new path of the HEX file and to add quotation marks around the paths containing spaces.

terminal-copy-arduino-upload-command Generating and uploading HEX files to an Arduino

Then press the “Enter” key to upload the program. (Tip: once you know the command, you can create a bash file to automate the process).

terminal-run-arduino-upload-command Generating and uploading HEX files to an Arduino

N.B.: If you want to upload the HEX files from another computer (especially if the Arduino IDE is not installed), don’t forget to install the drivers necessary to recognize the microcontrollers.

Upload the HEX file with XLoader

Download the XLoader software.

Run the executable file XLoader.exe

xloader-programmer-interface Generating and uploading HEX files to an Arduino


Select the port of the microcontroller that you can find in the device manager.

device-manager-port-com-arduino Generating and uploading HEX files to an Arduino

Select the right baudrate. In our case, 115200.

Then select the HEX file at the location where you saved it.

xloader-copy-hex-file-path Generating and uploading HEX files to an Arduino

You can then press “Upload” to upload the file.

xloader-file-uploaded Generating and uploading HEX files to an Arduino

Sources