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
?
3 Answers 3
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
-
1Perfect, 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?Eduardo Cardoso– Eduardo Cardoso2018年01月04日 18:41:39 +00:00Commented Jan 4, 2018 at 18:41
-
1Click 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– Gerben2018年01月04日 20:28:15 +00:00Commented Jan 4, 2018 at 20:28
You are asking how to locate the compiled hex file. It's easy! Follow these steps:
- 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 - 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.
-
It only places .bin files in the sketch folder.Maarten Wolzak– Maarten Wolzak2021年05月28日 14:17:50 +00:00Commented May 28, 2021 at 14:17
The easiest way to get the file is:
- Sketch> Export Compiled Binary
- Wait for the compilation process to finish
- 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.
preferences.txt
file and add the linebuild.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.