How to get the firmware (hex) file from a .ino file containing the code

In the setting of the Arduino IDE; after Show verbose output during: check the box next to compilation.

Then when you compile you should get something like this at the bottom of the window:

...
...
"/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-objcopy" -O ihex -R .eeprom  "/var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/arduino_build_635063/Blink.ino.elf" "/var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/arduino_build_635063/Blink.ino.hex"
Sketch uses 928 bytes (3%) of program storage space. Maximum is 30720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

At the end of the third line from the bottom you get the .hex filename. In this case (on OSX) that would be /var/folders/tp/grrlc56j3z7057f12_7f1_0r0000gn/T/arduino_build_635063/Blink.ino.hex


You are asking how to locate the compiled hex file. It's easy! Follow these steps:

  1. In the Arduino IDE select Sketch > Export Compiled Binary. This performs a compile. Once complete, this command places a copy of the compiled .hex file into the directory of your sketch.
    Export Compiled Binary
  2. Then either browse to the sketch folder or in the IDE select Sketch > Show Sketch Folder.
    Show Sketch Folder

This generates two hex files for the target micro-controller; one with the bootloader and one without the bootloader. These hex files can be uploaded to the micro-controller using a programmer such as the Atmel Ice or AVRISPmkII.


The easiest way to get the file is:

  1. Sketch > Export Compiled Binary
  2. Wait for the compilation process to finish
  3. Sketch > Show Sketch Folder

You will find an extra file in the sketch folder, which in this case will have a .hex extension. This is the compiled file which would normally be uploaded to the Arduino board via Sketch > Upload.

Note that the "Export Compiled Binary" feature is only available from Arduino IDE 1.6.5 and newer.

Tags:

Arduino Ide