Maker Pro
Maker Pro

Uploading an Arduino UNO *.hex file to the chip/board

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
I learned today that the Arduino software can output a *.hex file, as well as the usual *.ino file.
>"Sketch" >"Export Compiled Binary"

Can the hex file be uploaded to a chip without buying a separate programmer, just using the Arduino software?
If so, under >"Tools", >"Programmer", do I select "ArduinoISP" or "Arduino as ISP"? (I'm a bit confused on the difference between these options.)

Will it run without pre-loading the bootloader? (I'm guessing the answer is "Yes", but have to ask.)


Also, I downloaded a little app called XLoader earlier, which claims to be able to upload an Arduino *.hex file to the board/chip.
Has anyone tried it?
And like in the case of my earlier questions, does it need a chip with the bootloader pre-loaded, or a totally blank one?
(I don't have my Arduino yet, so can't test it.)

Some guidance here would be fantastic.

XLoader Screenshot.JPG
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,722
Joined
Nov 17, 2011
Messages
13,722
Sorry, I can't answer your first questions.

And like in the case of my earlier questions, does it need a chip with the bootloader pre-loaded, or a totally blank one?
As far as I know the Arduino comes with a built-in bootloader, that's why you can program it via the serial port (tunneled via USB and a COM port emulation on the PC side) without having to buy a separate programmer.
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Sorry, I can't answer your first questions.

As far as I know the Arduino comes with a built-in bootloader, that's why you can program it via the serial port (tunneled via USB and a COM port emulation on the PC side) without having to buy a separate programmer.
Harald, my plan is to use the programmed chips on my own custom PCBs. I'll be buying completely blank chips, then programming them. If necessary, I'll burn the bootloader in first, (it can be done with the Arduino IDE, without a separate programmer, I've learned), but it would be great if I didn't have to go through that additional step.
For now, though, until I get everything sorted out, I've ordered a couple of chips with the bootloader already programmed in.
At this point, I'm not sure if the compiled hex file includes, or even needs, the bootloader. (If the hex output doesn't need the bootloader, I won't burn the *.ino file in the usual fashion.) I've already laid out a small 'carrier' PCB, with a ZIF socket, 16MHz ceramic resonator, and pin headers for burning the bootloader. Haven't etched the board yet, though. I have to wait for the ZIF sockets to arrive to double-check dimensions.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,722
Joined
Nov 17, 2011
Messages
13,722
Without bootloader you will have to use the ISP programming feature of the AVR. This will require a sort of programmer, as teh AVR wouldn't know how to service the UART port without some initial code (aka bootloader).
If you have a programmer to program the bootloader (this can be your arduino itself), you have no need to program the bootloader anymore as then you can program your code directly - which gives you a few bytes of memory more for your own program (as the bootloader's memory is freed).

As the hex loader tool you want to use shows that it is using a COM port on the PC, it is (at least for me) obvious that a bootloader is required on the AVR's side.
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Without bootloader you will have to use the ISP programming feature of the AVR. This will require a sort of programmer, as teh AVR wouldn't know how to service the UART port without some initial code (aka bootloader).
If you have a programmer to program the bootloader (this can be your arduino itself), you have no need to program the bootloader anymore as then you can program your code directly - which gives you a few bytes of memory more for your own program (as the bootloader's memory is freed).

As the hex loader tool you want to use shows that it is using a COM port on the PC, it is (at least for me) obvious that a bootloader is required on the AVR's side.
Right. I suspected that might be the case. Thanks for that Harald. I've been so busy playing with writing code and testing the limits of using C/C++ that I haven't had time to chase it up further.
In that case, I don't need the hex output and can simply use the Arduino IDE as it was intended - load a programming sketch into the Arduino, burn a bootloader onto a chip in my carrier PCB using "Arduino as ISP", then fit my chip into the Arduino, (or make a separate board for that too), and upload the program itself. It's all coming together.
I'm amazed at the level of C/C++ support, too. Everything I've tried from the C standard lib, stdlib.h, compiles fine.
And I just tried dynamic memory allocation using new and then delete[] to clean up, and it works well, too. No need to struggle along with the Arduino commands. I'm pretty pleased. I hadn't realised that.
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
Also note that "Arduino code" tends to be much slower than code written in C (or Assembler for mx. performance). See this evaluation.
Yep, and the Arduino code uses heaps of program memory compared to C, too, as I'm discovering. (Several times as much to achieve the same thing. C is far more efficient.) I'll use the Arduino language to acces the pins, and other trivial stuff, then C/C++ for everything else.
Ha ha. Just reading the article you linked to. I hate the term 'sketch' too. :D
Edit: As indicated by that article, "PORTB &= 1;" compiles fine in the Arduino IDE.
 
Last edited:

jayanthd

Jul 4, 2015
43
Joined
Jul 4, 2015
Messages
43
MegunoLink Pro is a software made for that purpose. Try it. You can upload .hex file to Arduino without a programmer.
 

Old Steve

Jul 23, 2015
734
Joined
Jul 23, 2015
Messages
734
MegunoLink Pro is a software made for that purpose. Try it. You can upload .hex file to Arduino without a programmer.
Thank you for the tip, jayanthd, but it's unnecessary. I already have XLoader if at some point I want to upload a hex file. And XLoader was free, (that magic word), whereas I'd have to pay for MegunoLink Pro. Only the trial version is free. (I'm a pensioner, and don't work any more, so can't spend much money.) I only do this stuff for a hobby now, not for $$.

And actually, to me there's no real benefit in uploading a hex file anyway. I'll just use the Arduino IDE to burn the bootloader and upload a *.ino file.

As an aside, I only originally bought the Arduino so I could use a 3rd-party library that I need for one project, without having to mess about rewriting the lib for PIC. Usually I use PICs as my weapon-of-choice. For PICs I'm fairly well equipped, with a C compiler, PICBasic Pro compiler as we discussed the other day, and MPLAB, which both run in.
The MegunoLink Pro does look fairly good, though.

N.B. "avrdude" is another free option for uploading hex files to an ATMega chip, too. I have a copy here, that came with WinAVR. (XLoader is actually just a Win GUI wrapper for avrdude, which is a command-line uploader.)
 
Top