5

I currently have a .ino firmware file that I use in the Arduino IDE to program an ATmega328 micro-controller. I would like to get the file that the Arduino IDE uses to program the micro-controller.

Probably the IDE uses a hexadecimal (hex) file or something and sends it to the micro-controller through the serial.

How can I get this file being the only file that the IDE generates is the .ino?

4
  • These questions have been answered here before. Jan 4, 2018 at 16:55
  • @ChrisStratton I removed my question (was not aware of what you wrote) ... if the question has already been answered, it should be marked as duplicate question (s). Jan 4, 2018 at 17:06
  • I am getting .BIN file while using the above method in Arduino IDE. Dec 11, 2018 at 15:42
  • I guess this isn't allowing to add another answer. One approach is to use the "Export compiled binary" listed in the answers. You can also have the build go to a more predictable (non-temp) folder/directory. Edit your preferences.txt file and add the line build.path=<folder for build output>, specifying an existing folder to send the build artifacts to. Your hex files will be in there the next check/build you run.
    – RufusVS
    Mar 26, 2020 at 20:38

3 Answers 3

7

In the Preferences 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

2
  • 1
    Perfect, this I needed. Now if I send through the serial this .hex file to the microcontroller it will work as the UPLOAD of the IDE? Jan 4, 2018 at 18:41
  • 1
    Click the checkbox next to it to get verbose output on upload. You can the see the command the IDE uses to upload. Just a hint. It uses the avrdude command line program for that.
    – Gerben
    Jan 4, 2018 at 20:28
9

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.

1
  • It only places .bin files in the sketch folder. May 28, 2021 at 14:17
6

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.