Finding a compiled Hex file for the arduino

Jack W8TEE has provided directions on how find a compiled hex file:

1. Go to your Preferences settings (File –> Preferences) and check “Set verbose output during” and check “compilation”
2. Compile the program. Do not upload as that erases all temporary files, including the hex file. In other words, just click on the
check mark icon that appears below the File menu option.
3. Scroll down the long list of output your compile generated until you see: “Linking everything together…” followed by a series of
lines with path and file names. The hex file for you program will be one of them. Just use that path name to find the hex file.

While you’re there, use a text editor to open the *.lst file. It shows a blending of C and assembler generated by the compiler. It’s an interesting way to find if one way of writing a piece of code is “better” (i.e., faster execution, or perhaps using less memory) than an alternative way.

Reference

See your uBITx sketch in Assembly or Hex

Jack W8TEE notes how easy it is to find where Hex files and Assembly files for a compile of an Arduino sketch are placed on your computer, along with some other compile-time information.

First, go to your Preferences dialog (File –> Preferences) and check the compilation check box for the “Show verbose output during:”

Second, compile your program. Do not click the compile/upload icon, only the check mark for compile only. You will see a lot of stuff scroll by just below the IDE’s Source Code Window.

Third, look towards the end of that list of output for YourProgramName.hex. For example, Jack’s test program was:
C:\Users\econjack\AppData\Local\Temp\arduino_build_160543/TestProgram.ino.hex

Fourth, go to the directory and look at the output files. You will see file types:

elf — executable-linkable file, used for a debugger
hex — the flash output file
eep — th eEEPROM outout file
sym — symbol table information
lst — assembler output

The first file is very interesting to look at, as it shows the C code mixed in with its associated assembler output. (You can load the file into any text editor.) For example, which is more efficient: a cascading series of if statements or a switch/case? Write a short test program using both constructs and then look at the assembler output. You find that the switch/case produces a jump table, which is very efficient in terms of speed, but may be less efficient in terms of memory. Even if you don’t know assembler, you’ll get a feel for the answer. Use whichever fits the situation.

If you want to directly load a hex file into an Arduino, you could use an AVR programmer, or XLoader (http://www.hobbytronics.co.uk/arduino-xloader).