Uploading HEX to Arduino

I am asking myslef is it possible to upload a HEX file using the IDE.
Thats acuali all the IDE does after compiling.

Harry

(deleted)

Yes - well not the IDE itself but what comes with the IDE

You'll need to know what you do :slight_smile:

You’ll need to know how to launch avrdude from the command line (comes with the Arduino IDE)
you'll need to hook up your ISP programmer to the target board - let's say a ATmega328P

To read the flash the command would be:

avrdude -p m328p -P usb -c usbtiny -U flash:r:myflash.bin:r

-P usb = we’re using a usb-connected programmer
m328p the name of the Arduino chip, written exactly as found in the avrdude documentation
usbtiny is the programmer type (list is in the documentation)

-U flash:r:myflash.bin:r tells avrdude to read the contents of the flash (“flash:r”), save it to a file named myflash.bin and specifies the format (“:r”), which is raw binary

To write myflash.bin you would do something like

avrdude -p m328p -P usb -c usbtiny -U flash:w:myflash.bin

for full information there is full documentation available and you can look at 2.3 Example Command Line Invocations

Another method is to use the xloader.

Advantages:

  1. you don't need "command line" commands
  2. you don't need an ISP programmer and can use the normal USB connection

@rpt007 - indeed but

inconvenient: you do need a PC.

[I'm on a mac :)]

@J-M-L

There is a solution - in fact, there are two - for Mac's.
My main Desktop working horse is a Mac :slight_smile:

Solution1: Virtual Machine with windows installed on the Mac
Solution2: Paul Kaplan's "Hex Uploader"

Unfortunately Paul's solution didn't work on my Mac out of the box and I did not invest more time as normally I have my Arduino stuff aside in my office, running on a Laptop with Win10 (as this is closer to the electronics laboratory side of my desk)

Maybe you have more luck on your Mac.

  • Windows-specific *
    You don't need an ISP programmer. You just need to use avrdude from the command-line, to upload via USB.

To get the exact command, upload using the usual method with "Verbose output" enabled. This will show the avrdude command that's needed.

I've used avrdude by having a copy of avrdude.exe and the avrdude.conf file in a folder, (To avoid typing a long path to avrdude and the *.conf file), along with the file to upload, then executed avrdude from a batch file or from a command prompt opened in that folder.

This is my command to upload "MyBlink.hex" to an UNO using COM5:-
avrdude -Cavrdude.conf -v -patmega328p -carduino -PCOM5 -b115200 -D -Uflash:w:MyBlink.hex:i

Effectively, this method uses Arduino as the programmer, so no separate programmer is needed.
Tested with WinXP and Win10.

(I've used 'XLoader' too - it works fine.)

well I'm fine with avrdude command line when I need to - which is not so very often... so resisted the urge to craft something higher level - which probably would have been a shell script anyway

J-M-L:
well I'm fine with avrdude command line when I need to - which is not so very often... so resisted the urge to craft something higher level - which probably would have been a shell script anyway

Yeah. When I said "Windows-specific", I should have been clearer. No doubt the basic method will work with other OS, but I was referring to:- "Tested with WinXP and Win10. (I've used 'XLoader' too - it works fine.)"

I also wanted to clarify that a separate programmer isn't necessary.

I also wanted to clarify that a separate programmer isn't necessary.

Wow, didn't know that. Will give it a try on my Windows machine.
On the other hand - XLoader is really convenient :slight_smile:

rpt007:
Wow, didn't know that. Will give it a try on my Windows machine.
On the other hand - XLoader is really convenient :slight_smile:

It's been a while since I used WinXP, but from memory I also needed "libusb0.dll" in the same folder for the above method to work. (XLoader also has a local copy of "libusb0.dll".)
With Win10, though, it works fine without a local copy of the dll. (I tested it for the first time on Win10 just before posting reply #6.)

Just follow spycatcher's hint, turn on verbose output in File/Prefferences/Show verbose output during upload.

That will show you the avrdude command line IDE is invoking every time you click on Upload sketch. Copy it and replace the .hex file name with yours in a terminal window.

Just to make it easier to read, turn off compiler verbose output, the avrdude command line follows right after
"Global variables use .... " line.