I have searched (pronounced Googliing) the web for information about how (if it is even possible) to upload a hex file USING the Arduino IDE. When I search for that information it gives me lots of kinks to uploading a hex file NOT USING the Arduino IDE. If I only have the hex file and no INO file can I upload it to a chip (ATMega328P) or Uno using the IDE? If so, how do I do that?
I can and do upload hex files using other methods. I am not asking for that information as I do it now. I am asking how to use the Arduino IDE to upload a hex file.
Thank you for your help.
I can't see why not, with a little trickery.
Make a random project. AnalogReadSerial or something. Go into Preferences and turn on "Show Verbose Output During" "Compilation"
Hit the tick.
See the 3rd line of output from the end. Something like this:
/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-size -A /var/folders/9l/dqw_ll688xn06w0059b64w280000gn/T/arduino_build_86696/AnalogReadSerial.ino.elf
Open that folder (/var/folders/9l/dqw_ll688xn06w0059b64w280000gn/T/arduino_build_86696)
Replace the .hex file there with your .hex file.
Touch it so it's newer than the other files.
Hit the upload button in the IDE.
I haven't tried it but I don't see why it wouldn't work.
Of course just running avrdude yourself (here /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude) on your hex file would be a heck of a lot easier. Turn on verbose output while uploading to see what arguments it needs.
Yes.. for the longest time, this is what i do... arduino ide sent the hex through avrdude.exe inside its installation folder... what i did is made a 'middleman' avrdude.exe just to intercept and display what arguments arduino ide commands the avrdude.exe to do the job and then made my little tool to send the same comand along with *.hex i programmed in avr studio 4 to avrdude and then to arduino board.. i did all this simple trick because i suck at arduino the ide for its slow compile time and the childish workflow... if you want my middleman utilities, just ask, i can attach here.. or else, you may find something else in the net, or you can make one youself in no time. I coded my tools in vb.. ymmv.
Edit: err. If what you want is exactly like you asked, ie from exactly arduino the ide to a non arduino board, then no.. the problem is you dont quite understand the flowchain, as some part i already mentioned, and the bootloader... just use avr studio for that is easier if you dont understand the flowchain yet....
ref: youtube.com/watch?v=LO8nnQZCrMU
Touch it so it's newer than the other files.
the Arduino IDE isn't that smart; it'll ALWAYS create a new .hex file.
so all the "No" answers are correct.
Of course, the IDE doesn't actually upload anything; it just "forks" some other tool (avrdude for AVRs) to do the upload for it. That means that somewhere in your Arduino directory structure is a copy of the tool you need to upload a .hex (or .bin or whatever) without the IDE.
I can vaguely visualize a "platform/board" definition that would "compile" .hex files and upload them. Recent platform definitions include pre- and post- build hooks... But I haven't heard of anyone doing that, yet.
That arduino java contraption is not an "IDE".
But for putting a hex file into an ATMEGA, all you need is a simple programmer (such as for example an USBasp) and avrdude.
AVRdude is a command line programmer which supports lots of programmers for the AVR.
If you prefer a GUI check out AVRDUDESS (calls avrdude).
I don't know the answer, but if it is "yes", I would expect that it would be along the lines of what brucehoult said in tricking the IDE.
Are you expecting the bootloader to still be there? If I don't want the bootloader, and I want to use the Arduino IDE to write the code, then I have to use a programmer like USBisp (cheap, works). To do that you can't use the "Upload" button on the IDE, but have to choose Sketch>Upload using programmer. But then all the IDE does is call avrdude. So if I already have a hex file (don't need to go into the IDE to write a program), then there is absolutely no reason to use the IDE. Just type "avrdude -c USBtiny -p m328p -v -e -U flash:w:file.hex"
I don't know if the hex file is different if the bootloader is there. Here my ignorance shows.
I don't know the answer, but if it is "yes", I would expect that it would be along the lines of what brucehoult said in tricking the IDE.
Are you expecting the bootloader to still be there? If I don't want the bootloader, and I want to use the Arduino IDE to write the code, then I have to use a programmer like USBisp (cheap, works). To do that you can't use the "Upload" button on the IDE, but have to choose Sketch>Upload using programmer. But then all the IDE does is call avrdude. So if I already have a hex file (don't need to go into the IDE to write a program), then there is absolutely no reason to use the IDE. Just type "avrdude -c USBtiny -p m328p -v -e -U flash:w:file.hex"
I don't know if the hex file is different if the bootloader is there. Here my ignorance shows.
hex file generated will be the same whether you compile your code in arduino ide or in avr studio, they both probably use the same gcc compiler. the difference will be arduino ide uses different built in library that you will be forced (adviced) to use, in avr studio you have to make your own way of programming (no digitalWrite no pinMode etc, unless you want to emulate the same library yourself in avr studio). the job of arduino bootloader is to watch for serial (uart) comm if any hex code sent during startup, if there is (sent by avrdude) it will write on the next free space on the flash after the bootloader code (i guess, havent look precisely how and where the bootloader do this) if no hex code at startup, it will just jump to hex code it has written to in the past and run whatever code you have programmed whether in arduino ide or avr studio... even if its possible to program an avr ic without a bootloader from avrdude, i dont see the point, since there is more efficient workflow in avr (now microchip) studio for raw metal programming. its like asking how do i go about to office from home using a toy car when i can afford to buy a real car. fwiw.
This sounds similar to burning an Arduino bootloader onto bare chips, which I recall doing using the Arduino desktop app and a second Arduino as a programmer. I thought you could burn any hex that way.
This sounds similar to burning an Arduino bootloader onto bare chips, which I recall doing using the Arduino desktop app and a second Arduino as a programmer. I thought you could burn any hex that way.
That's the thing with the OP's original question. How to get the Arduino IDE to do this with your own hex file. There isn't a button or menu option to burn a hex file. When I want to burn an Arduino bootloader into a bare chip, I use the Arduino IDE because it has that function. I don't have to find the bootloader hex file, it's in the Arduino mess somewhere and I don't have to know where. So I think the answer to the OP's question is that there isn't a button or menu option to do this, and if it is possible then it will involve tricking the IDE interface by replacing a file somewhere with your own.
I suppose if you were really determined to have the "ide" do it for you, you could add add an entry to boards.txt, copying most of the info for the entry for the board you are using, but changing the name of the bootloader hex file in there. You'd probably have to put your hex file in with all the bootloader hex files as I don't think you can specify the full path. Then just select the board you added and Burn Bootloader.
Whatever you do, you could face fuse setting decisions.
even if its possible to program an avr ic without a bootloader from avrdude, i dont see the point, since there is more efficient workflow in avr (now microchip) studio for raw metal programming.
Yes it is possible to program an AVR without a bootloader in AVRDude if you set the correct fuses that the bootloader would set if you were using a bootloader.
This sounds similar to burning an Arduino bootloader onto bare chips, which I recall doing using the Arduino desktop app and a second Arduino as a programmer. I thought you could burn any hex that way.
That's the thing with the OP's original question. How to get the Arduino IDE to do this with your own hex file. There isn't a button or menu option to burn a hex file. When I want to burn an Arduino bootloader into a bare chip, I use the Arduino IDE because it has that function. I don't have to find the bootloader hex file, it's in the Arduino mess somewhere and I don't have to know where. So I think the answer to the OP's question is that there isn't a button or menu option to do this, and if it is possible then it will involve tricking the IDE interface by replacing a file somewhere with your own.
I was trying to find out if the IDE had a feature/function/menu option to upload a previously compile hex file to an AVR. I was hoping there was such an option but I had not found it. I know that I do not have to install a bootloader to program my AVR (ATMega328P in this case) as long as I set the fuses I need (mostly to tell it which clock to use or where to find that clock). What I have read is that the bootloader can get overwritten with later code. That fact bothered me but what I gather is the bootloader overwrite only happens if the code takes up too much space so it commandeers the bootloader space. I was mainly looking for an easy fast way to upload a hex file as many online projects only give a hex file and no INO file. I am surprised that the IDE does not have the ability to do the hex file upload...but then it does not have the ability to read an existing chip (but AVRDude does have that option).
Thank you.