The simplest way to upload a compiled .hex file without the IDE

Hey guys,

anybody know a simple easy way to upload a compiled .hex file to an Arduino board without using the IDE?

Thanks so much,
Rob :slight_smile:

  1. Plug in your Arduino
  2. Select your Arduino board from the Arduino IDE Tools > Board menu
  3. Select your Arduino board's port from the Tools > Port menu
  4. Select File > Preferences from the Arduino IDE menus.
  5. Check the box next to "Show verbose output during: [] upload".
  6. Click the OK button.
  7. Select Sketch > Upload from the Arduino IDE menus.
  8. Wait for the upload to finish.
  9. Scroll up in the black output panel at the bottom of the Arduino IDE window until you see the avrdude command.
    On Windows with Uno selected it looks something like:
    C:\Program Files (x86)\arduino-1.6.10\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\arduino-1.6.10\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM21 -b115200 -D -Uflash:w:C:\Users\per\AppData\Local\Temp\builda0905d717cd3fb20c5f6c59067701315.tmp/serial.ino.hex:i
  10. Select and copy the avrdude command.
  11. Paste the avrdude command to the command line.
  12. Change the file name to the .hex file you want to upload.
    In my case I also had to add quotes around the paths that had spaces in them.
  13. Press Enter

You can use the same system to generate the correct commands for burning a bootloader or to upload using a programmer.

1 Like

Thanks for the great advice :slight_smile:

Presumably if I send somebody the .hex file and they want to upload it, they first need to download AVRDude?

Will this method still work if I tell them to put the .hex file in a certain location and send them the command line?

Thanks so much,

they first need to download AVRDude?

That's correct. You can download it here: Index of /releases/avrdude/

Will this method still work if I tell them to put the .hex file in a certain location and send them the command line?

You will need to know the location of avrdude, avrdude.conf, and the hex file which is no problem but the difficulty is the port will probably be different from one computer to another so they would need to find which port was assigned to their Arduino and update the -P option of the command. I was assuming this was for someone with the Arduino IDE installed. For your purposes it might be more user friendly to find some kind of a GUI wrapper application for avrdude that will allow the port to be selected from a menu as the Arduino IDE does. I'm pretty sure I've seen people refer to something like that here before but I don't remember the name.

Avrdude is free tool, it is part of Arduino SW but it can be downloaded separately. Arduino IDE is just calling the command line. It will work the same way directly from the command line, of course correct paths to the files must be passed.

Incidentally, in the download are also "avrdude.exe", "avrdude.conf" and "libusb0.dll", so it works without needing to include anything apart from the *.hex file.

Edit: I just gave it a spin with an UNO and it works fine.
Edit2: And a Mega2560. No problems. :slight_smile:

Plese try it , it is my small app for bossac.exe and avrdude

Thanks for the good description! I compiled the Blink Sketch, adjusted the output of the IDE for my firmware and copied the firmware to the Temp directory where the binary of Blink is located. All I had to do was add the quotes needed under Windows and the command to upload to the display now looks like this:

"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude" "-CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf" -v -patmega328p -carduino -PCOM13 -b9600 -D -Uflash:w:C:\Users\mike\AppData\Local\Temp\arduino_build_221325/OpenLCD.ino.arduino_standard.hex:i

Windows can't process the spaces before and after files without the quotes. Program Files (x86) Therefore, the command and the reference to the config file must be enclosed in quotation marks.

1 Like

Good info in this thread. Here I am trying it about 15 months later. After adjusting the quotes for the path names I was able to get to the point where the error was "access denied". No doubt due to trying to work within the Program Files folder. Opening the Command Window as administrator didn't help.

Eventually I remembered that I have the WinAVR complier installed from years ago under C:, so no rights issues there. I replaced the path to point there for avrdude.exe and avrdude.conf and then I was able to upload a HEX file to the Arduino.

My problems were more Windows related than Arduino related, and my solution wouldn't work for most folks, but I add it anyway as another viewpoint.

Nick Kennedy